using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone.UserCenter.HideOption { public class AndroidBluetoothTestForm1 : EditorCommonForm { #region ■ 变量声明___________________________ private VerticalListControl ListView = null; private List listBluetoothInfo = new List(); #endregion #region ■ 初始化_____________________________ /// /// 画面显示(底层会固定调用此方法,借以完成画面创建) /// public void ShowForm() { //设置头部信息 base.SetTitleText("蓝牙列表"); //初始化中部信息 this.InitMiddleFrame(); string ssid = HdlWifiLogic.Current.SSID; } /// /// 初始化中部信息 /// private void InitMiddleFrame() { //清空bodyFrame this.ClearBodyFrame(); this.ListView = new VerticalListControl(23); bodyFrameLayout.AddChidren(ListView); var btnSearch = new BottomClickButton(); btnSearch.Text = "搜索蓝牙"; bodyFrameLayout.AddChidren(btnSearch); btnSearch.ButtonClickEvent += (sender, e) => { this.ListView.RemoveAll(); this.listBluetoothInfo.Clear(); HdlAndroidBluetoothLogic.Current.ScanBluetooth(3, (listData) => { foreach (var data in listData) { this.listBluetoothInfo.Add(data); } HdlThreadLogic.Current.RunMain(() => { foreach (var data in listData) { if (data.Name != string.Empty) { this.AddRowControl(data); } } this.ListView.AdjustRealHeightByBottomButton(Application.GetRealHeight(46)); }); }); }; } private void AddRowControl(HdlAndroidBluetoothLogic.BluetoothInfo bluetooth) { var rowControl = new RowLayoutControl(this.ListView.rowSpace / 2); this.ListView.AddChidren(rowControl); rowControl.frameTable.AddTopView(bluetooth.Name == string.Empty ? "它的名字是null" : bluetooth.Name, 700); rowControl.frameTable.AddBottomView(bluetooth.Address, 700); var btnConnet = rowControl.AddEditorControl(); btnConnet.Text = "链接"; btnConnet.ButtonClickEvent += (sender, e) => { this.ShowMassage(ShowMsgType.Confirm, "是否链接?", () => { HdlAndroidBluetoothLogic.Current.ContectBluetooth(bluetooth, (result) => { if (result != 1) { this.ShowMassage(ShowMsgType.Tip, "链接失败"); } else { this.ShowMassage(ShowMsgType.Tip, "链接成功"); HdlThreadLogic.Current.RunMain(() => { var form = new AndroidBluetoothTestForm2(); form.AddForm(); }); } }); }); }; } #endregion #region ■ 一般方法___________________________ #endregion } }