JLChen
2020-06-04 6d55af8792cf8fbef0055e677b900fc352dba9a2
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
using Shared;
using Shared.SimpleControl;
using Shared.SimpleControl.Phone.Music;
using Shared.SimpleControl.R;
 
namespace SmartHome
{
    class WiFiSet : FrameLayout
    {
        public static Action refreshView;
        FrameLayout middle;
       
 
        public void Show ()
        {
           
            AddChidren (new Button {
                Height = Application.GetRealHeight (36),
                BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
            });
 
            var topFrameLayout = new FrameLayout {
                Height = Application.GetRealHeight (100),
                Y = Application.GetRealHeight (36),
                BackgroundColor = SkinStyle.Current.MusicTopFrameLayout,
            };
            AddChidren (topFrameLayout);
 
            var btnset = new Button {
                TextID = MyInternationalizationString.Setting,
                TextColor = SkinStyle.Current.MusicTextColor,
                //Text = "设置",
            };
            topFrameLayout.AddChidren (btnset);
 
            var hdl = new Button {
                Width = Application.GetRealWidth (154),
                Height = Application.GetRealHeight (90),
                X = Application.GetRealWidth (486),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = MainPage.LogoString,
            };
            topFrameLayout.AddChidren (hdl);
            var back = new Button {
                Width = Application.GetRealWidth (82),
                Height = Application.GetRealHeight (89),
                X = Application.GetRealWidth (10),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "MusicIcon/HomepageBack.png",
            };
            topFrameLayout.AddChidren (back);
            back.MouseDownEventHandler += (sender, e) => {
                RemoveFromParent ();
                refreshView = null;
            };
 
            middle = new FrameLayout ();
            middle.Y = topFrameLayout.Bottom;
            middle.Height = Application.GetRealHeight (Application.DesignHeight - 136);
            middle.BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout;
            AddChidren (middle);
 
            refreshView += () => {
                refreshView = null;
                RemoveFromParent ();
                var wifiSet = new WiFiSet ();
                MainPage.MainFrameLayout.AddChidren (wifiSet);
                wifiSet.Show ();
                MainPage.Loading.Start (Language.StringByID (MyInternationalizationString.load));
                System.Threading.Tasks.Task.Run (() => {
                    Application.RunOnMainThread (() => {
                        MainPage.Loading.Hide ();
                        wifiSet.Init ();
                    });
                });
            };
 
        }
 
        public void Init ()
        {
            var radius = new Button {
                Width = Application.GetRealWidth (50),
                Height = Application.GetRealHeight (50),
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth (30),
                UnSelectedImagePath = "MusicIcon/radius.png",
                Y = Application.GetRealHeight (73),
            };
            middle.AddChidren (radius);
 
 
            var btnnulltxet1 = new Button {
                Height = Application.GetRealHeight (50),
                Width = Application.GetRealWidth (560),
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth (70),
                Y = Application.GetRealHeight (70),
                TextColor = SkinStyle.Current.MusicTextColor,
            };
            middle.AddChidren (btnnulltxet1);
 
            var btnnulltxet2 = new Button {
                Height = Application.GetRealHeight (50),
                Width = Application.GetRealWidth (500),
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth (70),
                Y = Application.GetRealHeight (120),
                TextColor = SkinStyle.Current.MusicTextColor,
            };
            middle.AddChidren (btnnulltxet2);
 
 
            var btntxet1 = new Button {
                Height = Application.GetRealHeight (50),
                Width = Application.GetRealWidth (560),
                TextAlignment = TextAlignment.CenterLeft,
                Y = Application.GetRealHeight (70),
                X = Application.GetRealWidth (70),
                TextColor = SkinStyle.Current.MusicTextColor,
            };
            middle.AddChidren (btntxet1);
 
            var btntxet2 = new Button {
                Height = Application.GetRealHeight (50),
                Width = Application.GetRealWidth (560),
                TextAlignment = TextAlignment.CenterLeft,
                Y = Application.GetRealHeight (120),
                X = Application.GetRealWidth (70),
                TextColor = SkinStyle.Current.MusicTextColor,
            };
            middle.AddChidren (btntxet2);
 
            var btntxet3 = new Button {
                Height = Application.GetRealHeight (50),
                Width = Application.GetRealWidth (560),
                TextAlignment = TextAlignment.CenterLeft,
                Y = Application.GetRealHeight (170),
                X = Application.GetRealWidth (70),//
                TextColor = SkinStyle.Current.MusicTextColor,
                };
            middle.AddChidren (btntxet3);
 
            var btnicon = new Button {
                Height = Application.GetRealHeight (537),
                Width = Application.GetRealWidth (535),
               // TextAlignment = TextAlignment.CenterLeft,
                Y = Application.GetRealHeight (200),
                X = Application.GetRealWidth (45),
                TextColor = SkinStyle.Current.MusicTextColor,
            };
            middle.AddChidren (btnicon);
            ///引导图片的Button
            if (Application.DeviceType == Device.Android) {
                btnicon.UnSelectedImagePath = "MusicIcon/androidwifi.png";
            } else {
                btnicon.UnSelectedImagePath = "MusicIcon/iossetwifi.png";
            }
 
            var btnwifiset = new Button {
                Width = Application.GetRealWidth (580),
                Height = Application.GetRealHeight (80),
                Text = Language.StringByID (MyInternationalizationString.Setting) + "Wi-Fi",
                TextSize = 20,
                X = Application.GetRealWidth (30),
                Y = Application.GetRealHeight (820),
                BackgroundColor = 0xff656565,
                Radius = (uint)Application.GetRealHeight (16),
            };
            middle.AddChidren(btnwifiset);
            ///调用手机设置界面的点击事件
            btnwifiset.MouseUpEventHandler += (sen, e) => {
                //RemoveFromParent ();
                if (Application.DeviceType == Device.Android) {
                    ///打开设置界面
                    //CommonClass.OpenAction ("android.settings.SETTINGS");
                    ///打开WI-IF界面
                    CommonClass.OpenAction ("android.settings.WIFI_SETTINGS");
                } else {
                    CommonClass.OpenAction ("App-Prefs:root=WIFI");
                }
            };
 
            try {
                ///判断手机当前连接WI-IF是以HDL开头
                if (WiimuUPnP.SSID != null && WiimuUPnP.SSID.StartsWith ("HDL")) {
                    refreshView = null;
                    RemoveFromParent ();
                    var a31wifi = new A31Wifi ();
                    MainPage.MainFrameLayout.AddChidren (a31wifi);
                    a31wifi.Show ();
 
                    MainPage.Loading.Start (Language.StringByID (MyInternationalizationString.load));
                    System.Threading.Tasks.Task.Run (() => {
                        Application.RunOnMainThread (() => {
                            MainPage.Loading.Hide ();
                            a31wifi.Init ();
                        });
                    });
                } else if (WiimuUPnP.SSID == null) {
                   if (Language.CurrentLanguage == "English") {
                        btnnulltxet1.Text = "Your cellphone hasn't open the Wi-Fi yet,";
                        btnnulltxet2.Text = "please open it and search again .";
                    }else{
                        btnnulltxet1.TextID = MyInternationalizationString.searchwifi;
                    }
                } else {
                    if (Language.CurrentLanguage == "English") {
                        btntxet1.Text = "Go to the wireless LAN interface of cellphone.";
                        btntxet2.Text = "Select the Wi-Fi which is named HDL*** as";
                        btntxet3.Text = "beginning to connect.";
                    } else {
                        btntxet1.TextID = MyInternationalizationString.WirelessLANinterface;
                        btntxet2.TextID = MyInternationalizationString.Makeconnection;
                    }
 
                }
            } catch { }
 
 
        }
 
    }
}