HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2021-01-14 d78515ac4ac8cf4a1785d9df18058d6724f12b79
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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<HdlAndroidBluetoothLogic.BluetoothInfo> listBluetoothInfo = new List<HdlAndroidBluetoothLogic.BluetoothInfo>();
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        {
            //设置头部信息
            base.SetTitleText("蓝牙列表");
 
            //初始化中部信息
            this.InitMiddleFrame();
 
            string ssid = HdlWifiLogic.Current.SSID;
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        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
    }
}