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
using System;
using System.Collections.Generic;
using System.Text;
 
namespace Shared.Phone.UserCenter.HideOption
{
    public class AndroidBluetoothTestForm2 : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        {
            //设置头部信息
            base.SetTitleText("自定义发送内容");
 
            //初始化中部信息
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
        {
            //清空bodyFrame
            this.ClearBodyFrame();
 
            var txtInput = new EditTextView();
            txtInput.Width = bodyFrameLayout.Width - ControlCommonResourse.XXLeft * 2;
            txtInput.Height = Application.GetRealHeight(470);
            txtInput.Y = Application.GetRealHeight(32);
            txtInput.TextAlignment = TextAlignment.TopLeft;
            txtInput.Gravity = Gravity.CenterHorizontal;
            txtInput.TextColor = UserCenterColor.Current.TextColor1;
            bodyFrameLayout.AddChidren(txtInput);
 
            var mySendData = new SendData();
            mySendData.ssid = HdlWifiLogic.Current.SSID;
            txtInput.Text = Newtonsoft.Json.JsonConvert.SerializeObject(mySendData);
 
            var btnSend = new BottomClickButton();
            btnSend.Text = "发送";
            bodyFrameLayout.AddChidren(btnSend);
            btnSend.ButtonClickEvent += (sender, e) =>
            {
                btnSend.CanClick = false;
                string sendData = txtInput.Text.Trim();
                HdlThreadLogic.Current.RunThread(() =>
                {
                    if (HdlAndroidBluetoothLogic.Current.SendData(sendData, 1) == true)
                    {
                        this.ShowMassage(ShowMsgType.Tip, "发送成功");
                    }
                    else
                    {
                        this.ShowMassage(ShowMsgType.Tip, "发送失败");
                    }
                    HdlThreadLogic.Current.RunMain(() =>
                    {
                        btnSend.CanClick = true;
                    });
                });
 
            };
        }
 
        #endregion
 
        #region ■ 界面关闭___________________________
 
        public override void CloseFormBefore()
        {
            HdlAndroidBluetoothLogic.Current.DisContectBluetooth();
 
            base.CloseFormBefore();
        }
 
        #endregion
 
        #region ■ 结构体_____________________________
 
        private class SendData
        {
            public string id = "id010203";
            public string ssid = string.Empty;
            public string password = "hdl1985..";
            public string gatewayIp = "172.16.2.209";
            public int port = 8888;
        }
 
        #endregion
    }
}