HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2020-12-31 fe3b2466c68b5db70d38e78039703add3b8b1dfe
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
using Shared.Phone.UserCenter;
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
namespace Shared.Phone.Category.Controls
{
  /// <summary>
  /// 分类界面的晾衣架设备行控件
  /// </summary>
  public class DeviceAirerRowControl : DeviceRowCommon
  {
    #region ■ 变量声明___________________________
 
    /// <summary>
    /// 打开控件
    /// </summary>
    private MostRightIconControl btnOpen = null;
    /// <summary>
    /// 停止控件
    /// </summary>
    private MostRightIconControl btnStop = null;
    /// <summary>
    /// 关闭控件
    /// </summary>
    private MostRightIconControl btnClose = null;
    #endregion
 
    #region ■ 初始化_____________________________
 
    /// <summary>
    /// 初始化控件
    /// </summary>
    /// <param name="i_device"></param>
    public override void InitControl(CommonDevice i_device, Common.Room i_nowSelectRoom)
    {
      base.InitControl(i_device, i_nowSelectRoom);
 
      //添加跳转深度卡片信息事件
      this.AddDetailInfoEvent(i_device);
 
      //打开控件
      this.btnOpen = new MostRightIconControl(69, 69);
      btnOpen.btnIcon.UseClickStatu = true;
      this.frameTable.AddChidren(btnOpen, ChidrenBindMode.NotBind);
      btnOpen.InitControl();
      btnOpen.X = Application.GetRealWidth(625) - btnOpen.XOffset;
      btnOpen.ButtonClickEvent += (sender, e) =>
      {
        ((Airer)i_device).AirerUpDownStopControl(0);
        base.RefreshControlInfo(i_device);
        return;
      };
 
      //停止控件
      this.btnStop = new MostRightIconControl(69, 69);
      btnStop.btnIcon.UseClickStatu = true;
      btnStop.UnSelectedImagePath = "Airer/StopOffline.png";
      btnStop.SelectedImagePath = "Airer/Stop.png";
      this.frameTable.AddChidren(btnStop, ChidrenBindMode.NotBind);
      btnStop.InitControl();
      btnStop.X = Application.GetRealWidth(769) - btnOpen.XOffset;
      btnStop.ButtonClickEvent += (sender, e) =>
      {
        //如果住宅为虚拟住宅,此功能无效
        if (Common.Config.Instance.Home.IsVirtually == false)
        {
          ((Airer)i_device).AirerUpDownStopControl(2);
        }
      };
 
      //关闭
      this.btnClose = new MostRightIconControl(69, 69);
      btnClose.btnIcon.UseClickStatu = true;
      this.frameTable.AddChidren(btnClose, ChidrenBindMode.NotBind);
      btnClose.InitControl();
      btnClose.X = Application.GetRealWidth(896) - btnOpen.XOffset;
      btnClose.ButtonClickEvent += (sender, e) =>
      {
        ((Airer)i_device).AirerUpDownStopControl(1);
        base.RefreshControlInfo(i_device);
        return;
      };
 
      //刷新图标控件的图标
      this.RefreshIconControlImage(i_device);
    }
 
    #endregion
 
    #region ■ 深度卡片信息_______________________
 
    /// <summary>
    /// 添加跳转深度卡片信息事件
    /// </summary>
    private void AddDetailInfoEvent(CommonDevice i_device)
    {
      //深度卡片信息
      this.frameTable.ButtonClickEvent += (sender, e) =>
      {
        //晾衣架类型的深度卡片界面
        var form = new MainPage.ControlForm.DeviceAirerDetailCardForm();
        form.RowOrCardControl = this;
        form.AddForm(i_device, this.nowSelectRoom, 965, 1316);
        form.FormCloseEvent += this.CardDetailInfoBackEvent;
      };
    }
 
    #endregion
 
    #region ■ 检测设备打开状态___________________
 
    /// <summary>
    /// 检测设备打开状态
    /// </summary>
    /// <param name="i_device"></param>
    /// <returns></returns>
    public override bool CheckIsOpenStatu(CommonDevice i_device)
    {
      bool isOpen = false;
      var airer = device as Airer;
      if (airer.OnOffStatus == 1 ||
        airer.DryOnOffStatus == 1 ||
        airer.WindOnOffStatus == 1 ||
        airer.DisinfectOnOffStatus == 1)
      {
        isOpen = true;
      }
      return isOpen;
    }
 
    #endregion
 
    #region ■ 发送获取状态命令___________________
 
    /// <summary>
    /// 发送获取状态命令
    /// </summary>
    public override void SendStatuComand()
    {
      //如果住宅为虚拟住宅,此功能无效
      if (Common.Config.Instance.Home.IsVirtually == true)
      {
        return;
      }
 
      //检测能否发送获取状态命令
      if (this.CheckCanSendStatuComand() == true)
      {
        for (int i = 2; i < 6; i++)
        {
          //注意,衣架中的状态由不同端点获取
          //回路2:读取照明开关状态
          //回路3:读取风干开关状态和时间值 
          //回路4:读取烘干开关状态和时间值
          //回路5:读取消毒开关状态和时间值
          HdlDeviceAttributeLogic.Current.SendAirerComand(this.device, i);
        }
      }
    }
 
    #endregion
 
    #region ■ 刷新控件状态_______________________ 
    /// <summary>
    /// 刷新控件状态
    /// </summary>
    /// <param name="i_device"></param>
    public override void RefreshControlInfo(CommonDevice i_device)
    {
      //刷新图标控件的图标
      this.RefreshIconControlImage(i_device);
      base.RefreshControlInfo(i_device);
    }
    #endregion
 
    #region ■ 一般方法___________________________ 
    /// <summary>
    /// 刷新图标控件的图标
    /// </summary>
    /// <param name="i_device"></param>
    private void RefreshIconControlImage(CommonDevice i_device)
    {
      //还没有初始化完成
      if (btnOpen == null) { return; }
      btnOpen.UnSelectedImagePath = "Airer/UpOffline.png";
      btnOpen.SelectedImagePath = "Airer/Up.png";
      btnClose.UnSelectedImagePath = "Airer/DownOffline.png";
      btnClose.SelectedImagePath = "Airer/Down.png";
    }
    #endregion
  }
}