wei
2021-03-19 c7c61c603b16c0bf2582d81561bdfbe48ab9440c
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
using System;
using System.Collections.Generic;
using HDL_ON.DriverLayer;
using HDL_ON.Entity;
using HDL_ON.Stan;
using HDL_ON.UI.CSS;
using Shared;
 
namespace HDL_ON.UI
{
    public partial class ClothesHangerSetTimePage : FrameLayout
    {
        FrameLayout bodyView;
 
        Function device;
 
        public ClothesHangerSetTimePage(Function function)
        {
            device = function;
            bodyView = this;
        }
 
 
        /// <summary>
        /// 加载界面
        /// </summary>
        public void LoadPage()
        {
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
            new TopViewDiv(bodyView, Language.StringByID(StringId.Time)).LoadTopView();
 
            VerticalScrolViewLayout functionListView = new VerticalScrolViewLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(530),
                BackgroundColor = CSS_Color.BackgroundColor,
                ScrollEnabled = false,
            };
            bodyView.AddChidren(functionListView);
 
 
            /// <summary>
            /// 小时取值范围
            /// </summary>
            List<int> hRange = new List<int> { 0, 1, 2, 3, 4 };
            /// <summary>
            /// 分钟取值范围
            /// </summary>
            List<int> mRange = new List<int> { 0, 30 };
 
            var menu = new List<string>() {
                FunctionAttributeKey.HotDryTime,
                FunctionAttributeKey.WindDryTime,
                FunctionAttributeKey.DisinfectTime,
                FunctionAttributeKey.AnionTime
            };
            List<string> attrs = device.GetAttributes();
 
            #region 烘干时间
            ListCellView hotDryTimeCell;
            hotDryTimeCell = new ListCellView()
            {
                Height = Application.GetRealHeight(50),
            };
            hotDryTimeCell.BtnTilte.TextID = StringId.HotDryTime;
 
            if (attrs.Contains(menu[0]))
            {
 
                var hotDryTime = 0;
                int.TryParse(device.GetAttrState(FunctionAttributeKey.HotDryTime), out hotDryTime);
                hotDryTimeCell.BtnSubtitle.Text = hotDryTime / 60 + Language.StringByID(StringId.HourUint) + hotDryTime % 60 + Language.StringByID(StringId.MinuteUint);
 
                functionListView.AddChidren(hotDryTimeCell);
                hotDryTimeCell.GoAction = () =>
                {
                    BottomTimeSelectControl timeControl = new BottomTimeSelectControl(hRange, mRange,3, Language.StringByID(StringId.HotDryTime));
                    timeControl.RowHeight = Application.GetRealHeight(50);
                    timeControl.InitControl(0, 1, 162);
                    timeControl.ChangePickerEvent();
                    timeControl.FinishEvent = (type, hours, min) =>
                    {
                        if (type == 1)//0:取消;1:确定
                        {
                            HdlThreadLogic.Current.RunThread(() =>
                            {
                                var time = hours * 60 + min;
                                var dic = new Dictionary<string, string>();
                                dic.Add(FunctionAttributeKey.HotDryTime, time.ToString());
                                Control.Ins.SendWriteCommand(this.device, dic);
                                HdlThreadLogic.Current.RunMain(() =>
                                {
                                    hotDryTimeCell.BtnSubtitle.Text = time / 60 + Language.StringByID(StringId.HourUint) + time % 60 + Language.StringByID(StringId.MinuteUint);
                                });
                            });
                        }
                    };
                };
            }
 
 
            #endregion
 
            #region 风干时间
            ListCellView windDryCell;
            windDryCell = new ListCellView()
            {
                Height = Application.GetRealHeight(50),
            };
            windDryCell.BtnTilte.TextID = StringId.WindDryTime;
 
            windDryCell.BtnSubtitle.Text = device.GetAttrState(FunctionAttributeKey.WindDryTime);
 
            if (attrs.Contains(menu[1]))
            {
                var windDryTime = 0;
                int.TryParse(device.GetAttrState(FunctionAttributeKey.WindDryTime), out windDryTime);
                windDryCell.BtnSubtitle.Text = windDryTime / 60 + Language.StringByID(StringId.HourUint) + windDryTime % 60 + Language.StringByID(StringId.MinuteUint);
 
                functionListView.AddChidren(windDryCell);
                windDryCell.GoAction = () =>
                {
                    BottomTimeSelectControl timeControl = new BottomTimeSelectControl(hRange, mRange,3,Language.StringByID(StringId.WindDryTime));
                    timeControl.RowHeight = Application.GetRealHeight(50);
                    timeControl.InitControl(0, 1, 162);
                    timeControl.ChangePickerEvent();
                    timeControl.FinishEvent = (type, hours, min) =>
                    {
                        if (type == 1)//0:取消;1:确定
                        {
                            HdlThreadLogic.Current.RunThread(() =>
                            {
                                var time = hours * 60 + min;
                                var dic = new Dictionary<string, string>();
                                dic.Add(FunctionAttributeKey.WindDryTime, time.ToString());
                                Control.Ins.SendWriteCommand(this.device, dic);
                                HdlThreadLogic.Current.RunMain(() =>
                                {
                                    windDryCell.BtnSubtitle.Text = time / 60 + Language.StringByID(StringId.HourUint) + time % 60 + Language.StringByID(StringId.MinuteUint);
                                });
                            });
                        }
                    };
                };
            }
            else
            {
                hotDryTimeCell.LineView.RemoveFromParent();
            }
            #endregion
 
            #region 消毒时间
            ListCellView disinfectTimeCell;
            disinfectTimeCell = new ListCellView()
            {
                Height = Application.GetRealHeight(50),
            };
            disinfectTimeCell.BtnTilte.TextID = StringId.DisinfectTime;
 
            disinfectTimeCell.BtnSubtitle.Text = device.GetAttrState(FunctionAttributeKey.DisinfectTime);
 
            if (attrs.Contains(menu[2]))
            {
                var disinfectTime = 0;
                int.TryParse(device.GetAttrState(FunctionAttributeKey.DisinfectTime), out disinfectTime);
                disinfectTimeCell.BtnSubtitle.Text = disinfectTime / 60 + Language.StringByID(StringId.HourUint) + disinfectTime % 60 + Language.StringByID(StringId.MinuteUint);
 
                functionListView.AddChidren(disinfectTimeCell);
                disinfectTimeCell.GoAction = () => {
                    BottomTimeSelectControl timeControl = new BottomTimeSelectControl(hRange, mRange,3, Language.StringByID(StringId.DisinfectTime));
                    timeControl.RowHeight = Application.GetRealHeight(50);
                    timeControl.InitControl(0, 1, 162);
                    timeControl.ChangePickerEvent();
                    timeControl.FinishEvent = (type, hours, min) => {
                        if (type == 1)//0:取消;1:确定
                        {
                            HdlThreadLogic.Current.RunThread(() =>
                            {
                                var time = hours * 60 + min;
                                var dic = new Dictionary<string, string>();
                                dic.Add(FunctionAttributeKey.DisinfectTime, time.ToString());
                                Control.Ins.SendWriteCommand(this.device, dic);
                                HdlThreadLogic.Current.RunMain(() =>
                                {
                                    disinfectTimeCell.BtnSubtitle.Text = time / 60 + Language.StringByID(StringId.HourUint) + time % 60 + Language.StringByID(StringId.MinuteUint);
                                });
                            });
                        }
                    };
                };
            }
            else
            {
                windDryCell.LineView.RemoveFromParent();
            }
            #endregion
 
            #region 负离子时间
            ListCellView anionTimeCell;
            anionTimeCell = new ListCellView()
            {
                Height = Application.GetRealHeight(50),
            };
            anionTimeCell.BtnTilte.TextID = StringId.AnionTime;
 
            anionTimeCell.BtnSubtitle.Text = device.GetAttrState(FunctionAttributeKey.AnionTime);
 
            if (attrs.Contains(menu[3]))
            {
                var anionTime = 0;
                int.TryParse(device.GetAttrState(FunctionAttributeKey.HotDryTime), out anionTime);
                anionTimeCell.BtnSubtitle.Text = anionTime / 60 + Language.StringByID(StringId.HourUint) + anionTime % 60 + Language.StringByID(StringId.MinuteUint);
 
                functionListView.AddChidren(anionTimeCell);
                anionTimeCell.LineView.RemoveFromParent();
 
                anionTimeCell.GoAction = () => {
                    BottomTimeSelectControl timeControl = new BottomTimeSelectControl(hRange, mRange,3,Language.StringByID(StringId.AnionTime));
 
 
                    timeControl.RowHeight = Application.GetRealHeight(50);
                    timeControl.InitControl(0, 1, 162);
 
                    timeControl.ChangePickerEvent();
 
                    timeControl.FinishEvent = (type, hours, min) => {
                        if (type == 1)//0:取消;1:确定
                        {
                            HdlThreadLogic.Current.RunThread(() =>
                            {
                                var time = hours * 60 + min;
                                var dic = new Dictionary<string, string>();
                                dic.Add(FunctionAttributeKey.AnionTime, time.ToString());
                                Control.Ins.SendWriteCommand(this.device, dic);
                                HdlThreadLogic.Current.RunMain(() =>
                                {
                                    anionTimeCell.BtnSubtitle.Text = time / 60 + Language.StringByID(StringId.HourUint) + time % 60 + Language.StringByID(StringId.MinuteUint);
                                });
                            });
                        }
                    };
                };
            }
            else
            {
                disinfectTimeCell.LineView.RemoveFromParent();
            }
            #endregion
 
        }
    }
 
    //---------------------------------------
    public partial class ClothesHangerSetTimePage
    {
 
    }
 
    //========================================
 
 
}