wei
2021-06-23 d4973876384be55df64de45db8a511d1e0330872
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
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 class IrFanPage : DeviceFunctionCardCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 图标
        /// </summary>
        private Button btnIcon = null;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 初始化白色区域的内容
        /// </summary>
        public override void InitFrameWhiteContent()
        {
            base.ShowColltionButton = false;
            base.SetTitleText(Language.StringByID(StringId.Electric));
 
            //初始化第一个索引页的内容
            this.InitFrameWhiteContent1();
            ;
        }
 
        /// <summary>
        /// 初始化第一个索引页的内容
        /// </summary>
        private void InitFrameWhiteContent1()
        {
            btnIcon = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(88),
                Width = Application.GetRealWidth(134),
                Height = Application.GetRealHeight(134),
                UnSelectedImagePath = "FunctionIcon/IrFan/FanIcon.png",
            };
            FrameWhiteCentet1.AddChidren(btnIcon);
 
            var patternView = new IrFanControl("FunctionIcon/IrFan/PatternIcon.png",
                                            "FunctionIcon/IrFan/PatternIconOn.png",
                                            Language.StringByID(StringId.Mode),
                                            "");
            patternView.Y = Application.GetRealHeight(263);
            patternView.X = Application.GetRealWidth(57);
            patternView.Width = Application.GetRealWidth(96);
            patternView.Height = Application.GetRealHeight(74);
            FrameWhiteCentet1.AddChidren(patternView);
            EventHandler<MouseEventArgs> mode_EventHandler = (sender, e) =>
            {
                Dictionary<string, string> d = new Dictionary<string, string>();
                d.Add("mode", "");
                Control.Ins.SendWriteCommand(device, d);
            };
            patternView.SetThouchEvent(mode_EventHandler);
 
            var swingView = new IrFanControl("FunctionIcon/IrFan/HeadSwingingIcon.png",
                                            "FunctionIcon/IrFan/HeadSwingingIconOn.png",
                                            Language.StringByID(StringId.HeadSwinging),
                                            "");
            swingView.Y = Application.GetRealHeight(263);
            swingView.X = Application.GetRealWidth(216);
            swingView.Width = Application.GetRealWidth(96);
            swingView.Height = Application.GetRealHeight(74);
            FrameWhiteCentet1.AddChidren(swingView);
            EventHandler<MouseEventArgs> swing_EventHandler = (sender, e) =>
            {
                Dictionary<string, string> d = new Dictionary<string, string>();
                d.Add("swing", "");
                Control.Ins.SendWriteCommand(device, d);
            };
            swingView.SetThouchEvent(swing_EventHandler);
 
 
            var timingView = new IrFanControl("FunctionIcon/IrFan/TimingIcon.png",
                                            "FunctionIcon/IrFan/TimingIconOn.png",
                                            Language.StringByID(StringId.Timing),
                                            "");
            timingView.Y = Application.GetRealHeight(366);
            timingView.X = Application.GetRealWidth(57);
            timingView.Width = Application.GetRealWidth(96);
            timingView.Height = Application.GetRealHeight(74);
            FrameWhiteCentet1.AddChidren(timingView);
            EventHandler<MouseEventArgs> timing_EventHandler = (sender, e) =>
            {
                Dictionary<string, string> d = new Dictionary<string, string>();
                d.Add("timer", "");
                Control.Ins.SendWriteCommand(device, d);
            };
            timingView.SetThouchEvent(timing_EventHandler);
 
 
            var airVolumeView = new IrFanControl("FunctionIcon/IrFan/SpeedIcon.png",
                                            "FunctionIcon/IrFan/SpeedIconOn.png",
                                            Language.StringByID(StringId.AirVolume),
                                            "");
            airVolumeView.Y = Application.GetRealHeight(263);
            airVolumeView.X = Application.GetRealWidth(216);
            airVolumeView.Width = Application.GetRealWidth(96);
            airVolumeView.Height = Application.GetRealHeight(74);
            FrameWhiteCentet1.AddChidren(airVolumeView);
            EventHandler<MouseEventArgs> speed_EventHandler = (sender, e) =>
            {
                Dictionary<string, string> d = new Dictionary<string, string>();
                d.Add("speed", "");
                Control.Ins.SendWriteCommand(device, d);
            };
            airVolumeView.SetThouchEvent(speed_EventHandler);
 
            Button btnPower = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(468),
                Width = Application.GetRealWidth(32),
                Height = Application.GetRealWidth(32),
                UnSelectedImagePath = "FunctionIcon/IrFan/PowerIcon.png",
                SelectedImagePath = "FunctionIcon/IrFan/PowerIconOn.png"
            };
            FrameWhiteCentet1.AddChidren(btnPower);
            btnPower.MouseDownEventHandler = (sender, e) =>
            {
                btnPower.IsSelected = true;
            };
            btnPower.MouseUpEventHandler = (sender, e) => {
                new System.Threading.Thread(() => {
                    Dictionary<string, string> d = new Dictionary<string, string>();
                    d.Add(FunctionAttributeKey.OnOff, "");
                    Control.Ins.SendWriteCommand(device, d);
                    System.Threading.Thread.Sleep(500);
                    Application.RunOnMainThread(() => {
                        btnPower.IsSelected = false;
                    });
                }) { IsBackground = true }.Start();
            };
 
 
        }
        #endregion
 
        #region ■ 设备状态反馈_______________________
 
        /// <summary>
        /// 设备状态反馈
        /// </summary>
        /// <param name="i_LocalDevice"></param>
        public override void DeviceStatuPush(Function i_LocalDevice)
        {
        }
 
        #endregion
    }
 
    public class IrFanControl : FrameLayout
    {
        private Button btnIcon;
        private Button btnTitle;
 
        public bool Lighting = false;
 
 
        public IrFanControl(string unSelectedIconPath, string selectedIconPath, string title, string time)
        {
            btnIcon = new Button()
            {
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(28),
                Height = Application.GetRealWidth(28),
                UnSelectedImagePath = unSelectedIconPath,
                SelectedImagePath = selectedIconPath,
            };
            this.AddChidren(btnIcon);
 
            btnTitle = new Button()
            {
                Gravity = Gravity.Center,
                Text = title,
                Height = Application.GetRealHeight(42),
                TextColor = CSS_Color.TextualColor,
                SelectedTextColor = CSS_Color.MainColor,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
            };
            this.AddChidren(btnTitle);
 
        }
 
        public void SetViewStatus(bool state)
        {
            btnIcon.IsSelected = btnTitle.IsSelected = Lighting = state;
        }
 
        /// <summary>
        /// 设置点击事件
        /// </summary>
        public void SetThouchEvent(EventHandler<MouseEventArgs> eventHandler)
        {
            btnIcon.MouseUpEventHandler = eventHandler;
            btnTitle.MouseUpEventHandler = eventHandler;
            btnIcon.MouseDownEventHandler = (sender, e) => {
                btnIcon.IsSelected = true;
            };
            btnTitle.MouseDownEventHandler = (sender, e) => {
                btnIcon.IsSelected = true;
            };
            btnIcon.MouseUpEventHandler += (sender, e) => {
                new System.Threading.Thread(() => {
                    System.Threading.Thread.Sleep(500);
                    Application.RunOnMainThread(() =>
                    {
                        btnIcon.IsSelected = true;
                    });
                })
                { IsBackground = true }.Start();
            };
            btnTitle.MouseUpEventHandler += (sender, e) => {
                new System.Threading.Thread(() => {
                    System.Threading.Thread.Sleep(500);
                    Application.RunOnMainThread(() =>
                    {
                        btnIcon.IsSelected = true;
                    });
                })
                { IsBackground = true }.Start();
            };
 
        }
    }
}