HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2020-12-14 e90209beae6a4e822cecb18e6889f8bda23f630e
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
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter
{
  /// <summary>
  /// 晾衣架时间设置的控件
  /// </summary>
  public class AiererTimeControl : AirerTimeBaseLayout
  {
    #region ■ 变量声明___________________________
 
    /// <summary>
    /// 选择时间的事件
    ///  int总秒 int类型
    /// </summary>
    public Action<int, int> SelectTimeEvent = null;
    /// <summary>
    /// 选择时间的事件
    ///  int时间 int类型【1:烘干,2:风干;3:消毒】
    /// </summary>
    public Action<int, int> DetailCardActionTimeEvent = null;
    /// <summary>
    /// 显示文本
    /// </summary>
    private NormalViewControl btnTextView = null;
 
    #endregion
 
    #region ■ 初始化_____________________________
 
    /// <summary>
    /// 晾衣架时间设置的控件
    /// </summary>
    /// <param name="i_ChidrenYaxis">子控件Y轴偏移量(【列表控件的rowSpace/2】即可,不懂默认为0即可)</param>
    public AiererTimeControl(int i_ChidrenYaxis = 0) : base(i_ChidrenYaxis)
    {
    }
 
    /// <summary>
    /// 初始化控件
    /// </summary>
    /// <param name="i_caption">标题文本</param>
    /// <param name="i_text">文本显示</param>
    /// <param name="type">晾衣架时间 :1烘干,2:风干;3消毒</param>
    public void InitControl(Airer airer, NormalFrameLayout bodyFrameLayout, string i_caption, string i_text, int type)
    {
      //标题
      var btnCaption = new NormalViewControl(270, 58, true);
      btnCaption.X = ControlCommonResourse.XXLeft;
      btnCaption.Gravity = Gravity.CenterVertical;
      btnCaption.Text = i_caption + ":";
      this.AddChidren(btnCaption, ChidrenBindMode.BindEvent);
 
      //显示框
      this.btnTextView = new NormalViewControl(700, true);
      btnTextView.X = Application.GetRealWidth(294);
      btnTextView.Gravity = Gravity.CenterVertical;
      btnTextView.TextColor = UserCenterColor.Current.TextGrayColor1;
      btnTextView.Text = i_text;
      this.AddChidren(btnTextView, ChidrenBindMode.BindEvent);
 
      if (chidrenYaxis != 0)
      {
        btnCaption.Y += chidrenYaxis;
        btnTextView.Y += chidrenYaxis;
      }
 
      //右箭头  {烘干、风干和消毒的设置默认时间暂时取去掉,且倒计时也去掉,因为第三方设备不支持」
      //默认最大3小时,所以下次要处理时为3,分钟不能操作大情况
      //this.AddRightArrow();
 
      //如果当前不是展示模板,则需要处理
      //if (Common.Config.Instance.Home.IsShowTemplate == false)
      //{
      //  this.ButtonClickEvent += (sender, e) =>
      //  {
      //区域选择
      //SelectTimeEvent = (min, curType) =>
      //{
      //  switch (curType)
      //  {
      //    case 1:
      //    case 2:
      //      double result = min / 60.0;
      //      var hour = Math.Round(result, 2);
      //      var text = hour + Language.StringByID(R.MyInternationalizationString.AirerHour);
 
      //      if (min == 0)
      //      {
      //        text = Language.StringByID(R.MyInternationalizationString.AirerDefault) + 3 + Language.StringByID(R.MyInternationalizationString.AirerHour);
      //      }
      //      btnTextView.Text = text;
 
      //      break;
      //    case 3:
      //      int result2 = min;
      //      var text2 = result2 + Language.StringByID(R.MyInternationalizationString.AirerMin);
 
      //      if (min == 0)
      //      {
      //        text2 = Language.StringByID(R.MyInternationalizationString.AirerDefault) + 30 + Language.StringByID(R.MyInternationalizationString.AirerMin);
      //      }
      //      btnTextView.Text = text2;
      //      break;
      //  }
      //};
      //this.ShowSelectTime(airer, bodyFrameLayout, btnTextView, i_caption, type);
      // };
      //}
    }
 
    #endregion
 
    #region ■ 时间选择___________________________
 
    /// <summary>
    /// 区域选择
    /// </summary>
    /// <param name="txtView"></param>
    /// <param name="i_caption"></param>
    /// <param name="type">晾衣架时间 :1烘干,2:风干;3消毒</param>
    private void ShowSelectTime(Airer airer, NormalFrameLayout bodyFrameLayout, NormalViewControl txtView, string i_caption, int type)
    {
      bodyFrameLayout.AddChidren(this.shadowRadiusFrameLayout);
      this.bottomRadiusFrameLayout.RemoveAll();
      this.BottomRadiusFrameLayout(this);
      this.btnBottomTitle.Text = i_caption;
      var mUIPickerView = new UIPickerView()
      {
        X = Application.GetRealWidth(0),
        Height = Application.GetRealHeight(440 - 140),
      };
      this.bottomRadiusFrameLayout.AddChidren(mUIPickerView);
      mUIPickerView.Y = Application.GetRealWidth(207);
      //小时列表名字
      var listHourName = new List<string>();
      //分钟名字 
      var listMinName = new List<string>();
      int curH = 0;
      int curM = 0;
      if (type == 3)
      {
        curM = 1;
        //名字和键收集
        for (int i = 1; i < 31; i++)
        {
          listMinName.Add(i.ToString() + Language.StringByID(R.MyInternationalizationString.AirerMin));
        }
        mUIPickerView.setNPicker(listMinName, null, null);
        mUIPickerView.setCurrentItems(curH, 0, 0);
        mUIPickerView.OnSelectChangeEvent += (v1, v2, v3) =>
        {
          curM = v1 + 1;
        };
      }
      else
      {
        //名字和键收集
        for (int i = 0; i < 4; i++)
        {
          listHourName.Add(i.ToString() + Language.StringByID(R.MyInternationalizationString.AirerHour));
        }
        for (int i = 0; i < 60; i++)
        {
          listMinName.Add(i.ToString() + Language.StringByID(R.MyInternationalizationString.AirerMin));
        }
        mUIPickerView.setNPicker(listHourName, listMinName, null);
        mUIPickerView.setCurrentItems(curH, curM, 0);
        mUIPickerView.OnSelectChangeEvent += (h, m, s) =>
        {
          curH = h;
          curM = m;
        };
      }
      this.btnCancel.MouseUpEventHandler = (sender1, e1) =>
      {
        this.shadowRadiusFrameLayout.RemoveFromParent();
      };
      this.btnFinish.MouseUpEventHandler = async (sender1, e1) =>
       {
         int totalMin = 0;
         switch (type)
         {
           case 1:
             airer.DryTime = curH * 60 + curM;
             airer.DryRemainTime = airer.DryTime * 60;
             totalMin = airer.DryTime;
             airer.SetAirerFunTimeDevice(airer.DryTime, 4);
             this.DetailCardActionTimeEvent?.Invoke(airer.DryRemainTime, type);
             break;
           case 2:
             airer.WindTime = curH * 60 + curM;
             airer.WindRemainTime = airer.WindTime * 60;
             totalMin = airer.WindTime;
             airer.SetAirerFunTimeDevice(airer.WindTime, 3);
             this.DetailCardActionTimeEvent?.Invoke(airer.WindRemainTime, type);
             break;
           case 3:
             airer.DisinfectTime = curM;
             airer.DisinfectRemainTime = airer.DisinfectTime * 60;
             totalMin = airer.DisinfectTime;
             airer.SetAirerFunTimeDevice(airer.DisinfectTime, 5);
             this.DetailCardActionTimeEvent?.Invoke(airer.DisinfectRemainTime, type);
             break;
         }
         //成功后更新外面文本
         this.SelectTimeEvent?.Invoke(totalMin, type);
         this.SelectTimeEvent = null;
 
         this.shadowRadiusFrameLayout.RemoveFromParent();
       };
      this.shadowRadiusFrameLayout.MouseUpEventHandler += (sender1, e1) =>
      {
        this.shadowRadiusFrameLayout.RemoveFromParent();
      };
    }
    #endregion
    #region ■ 控件摧毁___________________________
 
    /// <summary>
    /// 控件摧毁
    /// </summary>
    public override void RemoveFromParent()
    {
      this.SelectTimeEvent = null;
 
      base.RemoveFromParent();
    }
 
    #endregion 
  }
}