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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
using System;
using System.Collections.Generic;
using System.Text;
using Shared;
using Shared.SimpleControl.R;
using Shared.SimpleControl.Phone.Music;
using Shared.SimpleControl.Phone;
 
namespace SmartHome.UI.SimpleControl.Phone.Music
{
    class A31Rename : FrameLayout
    {
        //当前选择的按键
        Button selecteButton = null;
       public void show (A31MusicModel a31)
        {
            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 RadiolistName = new Button {
                TextID = MyInternationalizationString.radiolistName,
                TextColor = SkinStyle.Current.MusicTextColor,
            };
            topFrameLayout.AddChidren (RadiolistName);
 
            var complete = new Button {
                Width = Application.GetRealWidth (110),
                Height = Application.GetRealHeight (100),
                X = Application.GetRealWidth (530),
                Gravity = Gravity.CenterVertical,
                TextID = MyInternationalizationString.complete,
                TextColor = SkinStyle.Current.MusicTextColor,
            };
            topFrameLayout.AddChidren (complete);
 
            complete.MouseUpEventHandler += (sender, e) => {
                if (selecteButton == null) {
                    return;
                }
                a31.Name = selecteButton.Text;
                System.Threading.Tasks.Task.Run (() => {
                    try {
                        new Shared.Net.MyWebClient ().DownloadData ("http://" + a31.IPAddress + "/httpapi.asp?command=setDeviceName:" + a31.Name);
                    } catch { }
                });
                this.Parent.RemoveAt (Parent.ChildrenCount - 4);
                this.Parent.RemoveAt (Parent.ChildrenCount - 3);
                this.Parent.RemoveAt (Parent.ChildrenCount - 2);
                RemoveFromParent ();
            };
 
            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.MouseUpEventHandler += (sender, e) => {
                RemoveFromParent ();
            };
 
            var middle = new VerticalScrolViewLayout ();
            middle.Y = topFrameLayout.Bottom;
            middle.Height = Application.GetRealHeight (Application.DesignHeight - 136);
            middle.BackgroundColor = SkinStyle.Current.MusicVerticalScrolViewLayout;
            AddChidren (middle);
                      
 
            var customLayout = new RowLayout {
                Height = Application.GetRealHeight (100),
                LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
            };
            middle.AddChidren (customLayout);
 
            var custom = new Button {
                Height = Application.GetRealHeight (100),
                X = Application.GetRealWidth (30),
                TextAlignment = TextAlignment.CenterLeft,
                TextID = MyInternationalizationString.custom,
                TextColor = SkinStyle.Current.MusicTextColor,
            };
            customLayout.AddChidren (custom);
 
            var next = new Button {
                Width = Application.GetRealWidth (87),
                Height = Application.GetRealHeight (100),
                UnSelectedImagePath = "MusicIcon/Next.png",
                SelectedImagePath = "MusicIcon/NextSelecte.png",
                X = Application.GetRealWidth (550),
            };
            customLayout.AddChidren (next);
 
 
            EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
                
                if (selecteButton != null) {
                    selecteButton.Parent.BackgroundColor = 0x00000000;
                }
                selecteButton = sender as Button;
                selecteButton.Parent.BackgroundColor = SkinStyle.Current.MusicselecteButtonColcor;
            };
 
            List<string> deviceName = new List<string> ();
            deviceName.AddRange (new string [] {
                Language.StringByID(MyInternationalizationString.Bedroom),
                Language.StringByID(MyInternationalizationString.Studyroom),
                Language.StringByID(MyInternationalizationString.Office),
                Language.StringByID(MyInternationalizationString.Livingroom),
                Language.StringByID(MyInternationalizationString.Meetingroom),
                Language.StringByID(MyInternationalizationString.Kitchen),
                Language.StringByID(MyInternationalizationString.Bathroom), });
            if (!deviceName.Contains (a31.Name)) {
                deviceName.Add (a31.Name);
            }
 
            foreach (string s in deviceName) {
                var toiletyout = new RowLayout {
                    Height = Application.GetRealHeight (100),
                    LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
                };
                middle.AddChidren (toiletyout);
 
                var button = new Button {
                    Height = Application.GetRealHeight (100),
                    X = Application.GetRealWidth (30),
                    TextAlignment = TextAlignment.CenterLeft,
                    Text = s,
                    TextColor = SkinStyle.Current.MusicTextColor,
                };
                toiletyout.AddChidren (button);
 
                button.MouseUpEventHandler += eventHandler;
                if (s == a31.Name) {
                    //选择
                    eventHandler (button, new MouseEventArgs { });
                }
            }
 
 
            custom.MouseUpEventHandler += (sender, e) => {
                Dialog window = new Dialog ();
                window.Show ();
 
                var frameLayout = new FrameLayout {
                    Width = Application.GetRealWidth (580),
                    Height = Application.GetRealHeight (300),
                    X = Application.GetRealWidth (30),
                    Y = Application.GetRealHeight (330),
                    BackgroundColor = 0xffffffff,
                };
                window.AddChidren (frameLayout);
 
                var Modifyname = new Button {
                    Width = Application.GetRealWidth (580),
                    Height = Application.GetRealHeight (80),
                    TextID = MyInternationalizationString.Modifyname,
                    Y = Application.GetRealHeight (10),
                    //TextColor = 0xff000000,
                    TextColor=SkinStyle.Current.MusicTipTextColor,
                    TextSize = 20,
                };
                frameLayout.AddChidren (Modifyname);
 
                var devicename = new EditText {
                    Width = Application.GetRealWidth (540),
                    Height = Application.GetRealHeight (80),
                    Y = Application.GetRealHeight (80),
                    X = Application.GetRealWidth (20),
                    Gravity = Gravity.CenterVertical,
                    BackgroundColor =SkinStyle.Current.MusicTipBackgroundColor,
                    Radius=1,
                    BorderWidth=1,
                    BorderColor=SkinStyle.Current.MusicEditBorderColor,
                    //TextColor = 0xff000000,
                    TextColor = SkinStyle.Current.MusicTipTextColor,
                };
                frameLayout.AddChidren (devicename);
 
                var ther1 = new Button {
                    Height = Application.GetRealHeight (2),
                    Y = Application.GetRealHeight (218),
                    BackgroundColor = 0xff666666,
                };
                frameLayout.AddChidren (ther1);
 
                var cancelrow = new RowLayout {
                    Y = Application.GetRealHeight (220),
                    Height = Application.GetRealHeight (80),
                    Width = Application.GetRealWidth (289),
                    BackgroundColor = 0xffcccccc,
                };
                frameLayout.AddChidren (cancelrow);
 
                var cancel = new Button {
                    TextID = MyInternationalizationString.cancel,
                    //TextColor = 0xff000000,
                    TextSize = 18,
                    TextColor = SkinStyle.Current.MusicTipTextColor,
                };
                cancelrow.AddChidren (cancel);
                cancel.MouseUpEventHandler += (sender1, e1) => {
                    window.Close ();
                };
 
                var ther = new Button {
                    Y = Application.GetRealHeight (220),
                    Height = Application.GetRealHeight (80),
                    Width = Application.GetRealWidth (2),
                    X = Application.GetRealHeight (289),
                    BackgroundColor = 0xff666666,
                };
                frameLayout.AddChidren (ther);
 
                var confirmrow = new RowLayout {
                    Y = Application.GetRealHeight (220),
                    X = Application.GetRealWidth (291),
                    Height = Application.GetRealHeight (80),
                    Width = Application.GetRealWidth (289),
                    BackgroundColor = 0xffcccccc,
                };
                frameLayout.AddChidren (confirmrow);
 
                var confirm = new Button {
                    TextID = MyInternationalizationString.confirm,
                   //TextColor = 0xff000000,
                    TextSize = 18,
                    TextColor = SkinStyle.Current.MusicTipTextColor,
                };
                confirmrow.AddChidren (confirm);
 
                confirm.MouseUpEventHandler += (sender1, e1) => {
                    //如果不存在就添加
                    if (devicename.Text != "" && !deviceName.Contains (devicename.Text)) {
                        deviceName.Add (devicename.Text);
                        var toiletyout = new RowLayout {
                            Height = Application.GetRealHeight (100),
                            LineColor = SkinStyle.Current.MusicRowLayoutLineColor,
                        };
                        middle.AddChidren (toiletyout);
 
                        var button = new Button {
                            Height = Application.GetRealHeight (100),
                            X = Application.GetRealWidth (30),
                            TextAlignment = TextAlignment.CenterLeft,
                            Text = devicename.Text,
                        };
                        toiletyout.AddChidren (button);
                        button.MouseUpEventHandler += eventHandler;
 
                        //选择当前添加的按键
                        eventHandler (button, new MouseEventArgs { });
                        window.Close ();
                    }
                };
 
            };
        }
    }
}