HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2019-10-10 2ed75b8b337048e5d75e6d9ec8307633134f02fd
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
using System;
using System.Collections.Generic;
using Shared;
using Shared.R;
using Shared.Phone;
using Shared.Common;
namespace Shared.Phone.Device.Logic
{
    public class CyclicCycle:FrameLayout
    {
        Action action;
        public CyclicCycle(Action action)
        {
            this.action = action;
        }
        public CyclicCycle()
        {
            Tag = "Logic";
        }
        public int value = 0;
        public void Show()
        {
            var weeklist = new List<string>();
            ///记录之前值
            value = Common.Logic.CurrentLogic.TimeAttribute.WeekDay;
            this.BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor;
            var topFrameLayout = new FrameLayout
            {
                Height = Application.GetRealHeight(140),
                Y = Application.GetRealHeight(80),
            };
            AddChidren(topFrameLayout);
 
            var titleName = new Button
            {
                TextID = MyInternationalizationString.cycle,
                TextSize = 17,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth(150),
            };
            topFrameLayout.AddChidren(titleName);
 
            var back = new Button
            {
                Width = Application.GetRealWidth(110),
                Height = Application.GetRealHeight(110),
                X = Application.GetRealWidth(20),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "ZigeeLogic/Back.png",
            };
            topFrameLayout.AddChidren(back);
            back.MouseDownEventHandler += (sender, e) =>
            {
                RemoveFromParent();
                //if (action != null)
                //action();
            };
 
            var middle = new VerticalScrolViewLayout();
            middle.Y = topFrameLayout.Bottom;
            middle.Height = Application.GetRealHeight(1920 - 220-200);
            middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
            this.AddChidren(middle);
            if (Common.Logic.CurrentLogic.TimeAttribute.Repeat == 5)
            {
                string len = "";
                var maxvalue = Convert.ToString(Common.Logic.CurrentLogic.TimeAttribute.WeekDay, 2);
                var str = maxvalue.Insert(0, new string('0', 8 - maxvalue.Length));
                for (int j = 7; j >= 0; j--)
                {
                    len += str.Substring(j, 1);
                }
 
                for (int j = 0; j < len.Length; j++)
                {
                    var strvalue = len.Substring(j, 1);
                    if (strvalue == "1")
                    {
                        if ((j + 1) == 1)
                        {
                            weeklist.Add(Language.StringByID(MyInternationalizationString.mon));
                        }
                        else if ((j + 1) == 2)
                        {
                            weeklist.Add(Language.StringByID(MyInternationalizationString.tue));
                        }
                        else if ((j + 1) == 3)
                        {
                            weeklist.Add(Language.StringByID(MyInternationalizationString.wed));
                        }
                        else if ((j + 1) == 4)
                        {
                            weeklist.Add(Language.StringByID(MyInternationalizationString.thu));
                        }
                        else if ((j + 1) == 5)
                        {
                            weeklist.Add(Language.StringByID(MyInternationalizationString.frl));
                        }
                        else if ((j + 1) == 6)
                        {
                            weeklist.Add(Language.StringByID(MyInternationalizationString.sat));
                        }
                        else if ((j + 1) == 7)
                        {
                            weeklist.Add(Language.StringByID(MyInternationalizationString.sun));
                        }
 
                    }
                }
            }
            var cyclelist = new List<string>();
            cyclelist.AddRange(new string[] {
                        Language.StringByID(MyInternationalizationString.mon),
                        Language.StringByID(MyInternationalizationString.tue),
                        Language.StringByID(MyInternationalizationString.wed),
                        Language.StringByID(MyInternationalizationString.thu),
                        Language.StringByID(MyInternationalizationString.frl),
                        Language.StringByID(MyInternationalizationString.sat),
                        Language.StringByID(MyInternationalizationString.sun),
            });
            foreach (var name in cyclelist)
            {
                var cyclerwLayout = new RowLayout
                {
                    Height = Application.GetRealHeight(180),
                };
                middle.AddChidren(cyclerwLayout);
 
                var btnname = new Button
                {
                    X = Application.GetRealWidth(40),
                    Width = Application.GetRealWidth(600),
                    Gravity = Gravity.CenterVertical,
                    TextAlignment = TextAlignment.CenterLeft,
                    Text = name,
                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                };
                cyclerwLayout.AddChidren(btnname);
 
                var btnCheck = new Button
                {
                    Width = Application.GetRealWidth(115),
                    Height = Application.GetRealHeight(110),
                    Gravity = Gravity.CenterVertical,
                    X = Application.GetRealWidth(1080 - 140),
                    SelectedImagePath = "ZigeeLogic/CheckOn.png",
                    UnSelectedImagePath = "ZigeeLogic/Check.png",
                };
                cyclerwLayout.AddChidren(btnCheck);
 
                var str = weeklist.Find((o) => { return o == name; });
                if (str != null)
                {
                    btnCheck.IsSelected = true;
                }
                ///选中时间 
                EventHandler<MouseEventArgs> weekclick = (sender, e) =>
                {
                    btnCheck.IsSelected = !btnCheck.IsSelected;
                    if (btnCheck.IsSelected)
                    {
                        var d = weeklist.Find((o) => { return o == name; });
                        if (d == null)
                        {
                            weeklist.Add(name);
                        }
                    }
                    else
                    {
                        weeklist.RemoveAll((o) => {
                            return o == name;
                        });
                    }
                    int weekvalue = 0;
                    foreach (var strname in weeklist)
                    {
                        if (Language.StringByID(MyInternationalizationString.mon) == strname)
                        {
                            weekvalue += 1;
                        }
                        else if (Language.StringByID(MyInternationalizationString.tue) == strname)
                        {
                            weekvalue += 2;
                        }
                        else if (Language.StringByID(MyInternationalizationString.wed) == strname)
                        {
                            weekvalue += 4;
                        }
                        else if (Language.StringByID(MyInternationalizationString.thu) == strname)
                        {
                            weekvalue += 8;
                        }
                        else if (Language.StringByID(MyInternationalizationString.frl) == strname)
                        {
                            weekvalue += 16;
                        }
                        else if (Language.StringByID(MyInternationalizationString.sat) == strname)
                        {
                            weekvalue += 32;
                        }
                        else if (Language.StringByID(MyInternationalizationString.sun) == strname)
                        {
                            weekvalue += 64;
                        }
                    }
                    //Common.Logic.CurrentLogic.TimeAttribute.Repeat = 5;
                    //Common.Logic.CurrentLogic.TimeAttribute.WeekDay = weekvalue;
                    value = weekvalue;
                   
                };
                cyclerwLayout.MouseUpEventHandler += weekclick;
                btnname.MouseUpEventHandler += weekclick;
                btnCheck.MouseUpEventHandler += weekclick;
 
            }
 
            var fra = new FrameLayout
            {
                Y = middle.Bottom,
                Height = Application.GetRealHeight(200),
                BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
            };
            this.AddChidren(fra);
            var btncomplete = new Button
            {
                X = Application.GetRealWidth(290),
                Height = Application.GetRealHeight(150),//194
                Width = Application.GetRealWidth(500),
                Radius = (uint)Application.GetRealHeight(50),
                BackgroundColor = ZigbeeColor.Current.LogicButtonBlueColor,
                TextID = MyInternationalizationString.Save,
            };
            fra.AddChidren(btncomplete);
            EventHandler<MouseEventArgs> completeclick = (sender, e) =>
            {
                RemoveFromParent();
                Common.Logic.CurrentLogic.TimeAttribute.Repeat = 5;
                Common.Logic.CurrentLogic.TimeAttribute.WeekDay =value;
                if (action != null)
                    action();
            };
            fra.MouseUpEventHandler += completeclick;
            btncomplete.MouseUpEventHandler += completeclick;
        }
    }
}