黄学彪
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
using System;
using System.Collections.Generic;
using System.Text;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.DevicePirSensor
{
    /// <summary>
    /// PIR传感器绑定界面★
    /// </summary>
    public class PirSensorBindTargetForm : EditorCommonForm
    {
        /// <summary>
        /// 列表控件
        /// </summary>
        private VerticalScrolViewLayout listView = null;
        /// <summary>
        /// 编辑按钮
        /// </summary>
        private BottomClickButton btnEditor = null;
        /// <summary>
        /// 传感器设备
        /// </summary>
        private IASZone deviceIASZone = null;
        /// <summary>
        /// 已经存在的绑定设备
        /// </summary>
        private Dictionary<string, CommonDevice> dicEsixtDevice = new Dictionary<string, CommonDevice>();
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_iasZone">传感器设备</param>
        public void ShowForm(IASZone i_iasZone)
        {
            deviceIASZone = i_iasZone;
 
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uBindTargetsSettion));
 
            ////右上添加按钮
            //var btnAddDeviceIcon = new MostRightIconControl(69, 69);
            //btnAddDeviceIcon.UnSelectedImagePath = "Item/Add.png";
            //btnAddDeviceIcon.SelectedImagePath = "Item/AddSelected.png";
            //topFrameLayout.AddChidren(btnAddDeviceIcon);
            //btnAddDeviceIcon.MouseUpEventHandler += (sender, e) =>
            //{
            //    //显示设备选择的界面
            //    this.ShowDeviceSelectForm();
            //};
 
            //初始化中部信息
            //this.InitMiddleFrame();
        }
 
        ///// <summary>
        ///// 初始化中部信息
        ///// </summary>
        //private void InitMiddleFrame()
        //{
        //    //清空bodyFrame
        //    this.ClearBodyFrame();
 
        //    this.listView = new VerticalScrolViewLayout();
        //    this.listView.Height = bodyFrameLayout.Height;
        //    bodyFrameLayout.AddChidren(this.listView);
 
        //    this.dicEsixtDevice.Clear();
 
        //    //开启进度条
        //    this.ShowProgressBar();
 
        //    HdlThreadLogic.Current.Run(async () =>
        //    {
        //        List<CommonDevice> listDevice = await HdlDeviceBindLogic.Current.GetBindTargetDevice(this.deviceIASZone);
        //        if (listDevice == null)
        //        {
        //            //关闭进度条
        //            this.CloseProgressBar(ShowReLoadMode.YES);
        //            return;
        //        }
        //        foreach(CommonDevice device in listDevice)
        //        {
        //            Application.RunOnMainThread(() =>
        //            {
        //                if (this.Parent != null)
        //                {
        //                    this.AddRowlayout(device);
        //                }
        //            });
        //        }
        //        //关闭进度条
        //        this.CloseProgressBar();
        //    });
        //}
 
        ///// <summary>
        ///// 添加行
        ///// </summary>
        ///// <param name="device"></param>
        //private void AddRowlayout(CommonDevice device)
        //{
        //    //初始化编辑按钮
        //    this.InitEditorButton();
 
        //    string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
        //    this.dicEsixtDevice[mainKeys] = device;
 
        //    var row = new DeviceRoomViewRow(this.listView, device);
        //    row.ChangedChidrenBindMode(row.btnIcon, ChidrenBindMode.BindEventOnly);
        //    row.ChangedChidrenBindMode(row.btnRoom, ChidrenBindMode.BindEventOnly);
        //    row.ChangedChidrenBindMode(row.btnDevie, ChidrenBindMode.BindEventOnly);
 
        //    //删除
        //    var btnDelete = new RowDeleteButton();
        //    row.AddRightView(btnDelete);
        //    btnDelete.MouseUpEventHandler += (sender, e) =>
        //    {
        //        //确认要删除吗?
        //        string msg = Language.StringByID(R.MyInternationalizationString.uShowDoDeleteMsg);
        //        this.ShowConfirmMsg(msg, "DeleteTargetDevice", device, row);
        //    };
        //}
 
        ///// <summary>
        ///// 删除绑定目标
        ///// </summary>
        ///// <param name="device"></param>
        ///// <param name="row"></param>
        //public async void DeleteTargetDevice(CommonDevice device, DeviceRoomViewRow row)
        //{
        //    //开启进度条
        //    this.ShowProgressBar();
        //    bool result = await HdlDeviceBindLogic.Current.DeleteDeviceTarget(this.deviceIASZone, device);
        //    //关闭进度条
        //    this.CloseProgressBar();
 
        //    if (result == false)
        //    {
        //        return;
        //    }
        //    Application.RunOnMainThread(() =>
        //    {
        //        string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
        //        this.dicEsixtDevice.Remove(mainKeys);
 
        //        row?.RemoveFromParent();
        //        if (listView != null && listView.ChildrenCount == 0)
        //        {
        //            this.btnEditor?.RemoveFromParent();
        //            this.btnEditor = null;
        //        }
        //    });
        //}
 
        ///// <summary>
        ///// 显示设备选择的界面
        ///// </summary>
        //private void ShowDeviceSelectForm()
        //{
        //    var listShowDevice = new List<CommonDevice>();
        //    var listTempDevice = Common.LocalDevice.Current.listAllDevice;
        //    foreach (var device in listTempDevice)
        //    {
        //        //如果是传感器,或者是没有开关簇的话(这里判断的是输入簇)
        //        if ((device is IASZone) || Common.LocalDevice.Current.InDeviceIsCanOnOff(device) == false)
        //        {
        //            continue;
        //        }
        //        string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
        //        if (this.dicEsixtDevice.ContainsKey(mainKeys) == true)
        //        {
        //            //如果已经添加了,则不再显示
        //            continue;
        //        }
 
        //        listShowDevice.Add(device);
        //    }
        //    var listSelect = new List<string>();
        //    foreach (string mainkeys in this.dicEsixtDevice.Keys)
        //    {
        //        listSelect.Add(mainkeys);
        //    }
 
        //    var form = new SelectDeviceForm();
        //    form.AddForm(listShowDevice, listSelect, false);
        //    //添加绑定目标
        //    form.SetTitleText(Language.StringByID(R.MyInternationalizationString.AddBindTargets));
 
        //    //设备选择确定
        //    form.ActionSelectDevice += (async (listDevice) =>
        //    {
        //        if (listDevice.Count == 0)
        //        {
        //            return;
        //        }
        //        //开启进度条
        //        this.ShowProgressBar();
        //        var listNewDevice = await HdlDeviceBindLogic.Current.BindDeviceTarget(this.deviceIASZone, listDevice);
        //        //关闭进度条
        //        this.CloseProgressBar();
 
        //        if (listNewDevice == null || listNewDevice.Count == 0)
        //        {
        //            return;
        //        }
 
        //        foreach (CommonDevice device in listNewDevice)
        //        {
        //            string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
        //            this.dicEsixtDevice[mainKeys] = device;
 
        //            Application.RunOnMainThread(() =>
        //            {
        //                if (this.listView != null)
        //                {
        //                    this.AddRowlayout(device);
        //                }
        //            });
        //        }
        //        Application.RunOnMainThread(() =>
        //        {
        //            //打开PIR传感器的灯光特效配置界面
        //            var newform = new PirSensorLightSettionForm();
        //            newform.AddForm(this.deviceIASZone);
        //        });
        //    });
        //}
 
        ///// <summary>
        ///// 初始化编辑按钮
        ///// </summary>
        //private void InitEditorButton()
        //{
        //    if (this.btnEditor != null)
        //    {
        //        return;
        //    }
 
        //    Application.RunOnMainThread(() =>
        //    {
        //        if (this.listView == null)
        //        {
        //            return;
        //        }
        //        //编辑
        //        this.btnEditor = new BottomClickButton();
        //        this.btnEditor.MouseUpTime = 0;
        //        this.btnEditor.TextID = R.MyInternationalizationString.uEditor;
        //        bodyFrameLayout.AddChidren(this.btnEditor);
        //        this.btnEditor.MouseUpEvent += (sender, e) =>
        //        {
        //            var form = new PirSensorLightSettionForm();
        //            form.AddForm(deviceIASZone);
        //        };
 
        //        this.listView.Height = this.btnEditor.Y - ControlCommonResourse.BottomButtonAndListViewSpace;
        //    });
        //}
    }
}