gxc
2019-10-28 1c4904d77f484c075080942d87785481b52b6fb2
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using ZigBee.Device;
 
namespace Shared.Phone.UserCenter.SharedContent
{
    /// <summary>
    /// 配置新共享内容的主界面
    /// </summary>
    public class ConfigureNewSharedMainForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 设备列表控件
        /// </summary>
        private VerticalScrolViewLayout listDeviceView = null;
        /// <summary>
        /// 场景列表控件
        /// </summary>
        private VerticalScrolViewLayout listSceneView = null;
        /// <summary>
        /// 成员信息
        /// </summary>
        private MemberInfoRes memberResult = null;
        /// <summary>
        /// 成员的分享数据
        /// </summary>
        private MemberShardInfoData memberShardInfo = null;
        /// <summary>
        /// 房间对象
        /// </summary>
        private Common.Room room = null;
        /// <summary>
        /// Tab的选择。1:功能Tab  2:场景Tab
        /// </summary>
        private int TabSelectIndex = 1;
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_room">房间对象</param>
        /// <param name="i_memberResult">成员信息</param>
        /// <param name="i_memberShardInfo">成员的分享数据</param>
        public void ShowForm(Common.Room i_room, MemberInfoRes i_memberResult, MemberShardInfoData i_memberShardInfo)
        {
            this.memberResult = i_memberResult;
            this.memberShardInfo = i_memberShardInfo;
            this.room = i_room;
 
            //设置头部信息
            base.SetTitleText(this.room.Name);
 
            //分享
            //var btnShard = new TopLayoutFinshView();
            //btnShard.TextID = R.MyInternationalizationString.uShared;
            //topFrameLayout.AddChidren(btnShard);
            //btnShard.MouseUpEventHandler += (sender, e) =>
            //{
            //    HdlThreadLogic.Current.Run(() =>
            //    {
            //        //确认分享
            //        this.DoSaveSharedContent();
            //    });
            //};
 
            ////初始化中部信息
            //this.InitMiddleFrame();
        }
 
        ///// <summary>
        ///// 初始化中部信息
        ///// </summary>
        //private void InitMiddleFrame()
        //{
        //    //清空bodyFrame
        //    this.ClearBodyFrame();
 
        //    //初始化Tab控件
        //    var frame = this.InitTabControl();
 
        //    this.listDeviceView = new VerticalScrolViewLayout();
        //    listDeviceView.Y = frame.Bottom;
        //    listDeviceView.Height = bodyFrameLayout.Height - frame.Bottom;
        //    listDeviceView.Visible = this.TabSelectIndex == 1;
        //    bodyFrameLayout.AddChidren(listDeviceView);
 
        //    this.listSceneView = new VerticalScrolViewLayout();
        //    listSceneView.Y = frame.Bottom;
        //    listSceneView.Height = bodyFrameLayout.Height - frame.Bottom;
        //    listSceneView.Visible = this.TabSelectIndex == 2;
        //    bodyFrameLayout.AddChidren(listSceneView);
 
        //    HdlThreadLogic.Current.Run(() =>
        //    {
        //        //初始化功能Tab列表
        //        this.InitFunctionTabList();
        //        //初始化场景Tab列表
        //        this.InitSceneTabList();
        //    });
        //}
 
        #endregion
 
        //#region ■ 初始化Tab控件______________________
 
        ///// <summary>
        ///// 初始化Tab控件
        ///// </summary>
        ///// <returns></returns>
        //private FrameLayout InitTabControl()
        //{
        //    //Tab切换控件
        //    var frameSwich = new FrameLayout();
        //    frameSwich.Height = Application.GetRealHeight(150);
        //    frameSwich.BackgroundColor = UserCenterColor.Current.TopFrameLayout;
        //    bodyFrameLayout.AddChidren(frameSwich);
 
        //    //功能
        //    var btnFunction = new NormalViewControl(frameSwich.Width / 2, Application.GetRealHeight(100));
        //    btnFunction.Gravity = Gravity.CenterVertical;
        //    btnFunction.TextID = R.MyInternationalizationString.uFunction;
        //    btnFunction.TextAlignment = TextAlignment.Center;
        //    btnFunction.TextColor = UserCenterColor.Current.SelectTextColor;
        //    btnFunction.TextAlignment = TextAlignment.Center;
        //    frameSwich.AddChidren(btnFunction);
 
        //    //场景
        //    var btnScene = new NormalViewControl(frameSwich.Width / 2, Application.GetRealHeight(100));
        //    btnScene.Gravity = Gravity.CenterVertical;
        //    btnScene.X = frameSwich.Width / 2;
        //    btnScene.TextID = R.MyInternationalizationString.uScence;
        //    btnScene.TextAlignment = TextAlignment.Center;
        //    frameSwich.AddChidren(btnScene);
 
        //    //线
        //    var btnLine = new ProgressLine();
        //    btnLine.Gravity = Gravity.BottomLeft;
        //    frameSwich.AddChidren(btnLine);
        //    btnLine.SetValue(50, true);
 
        //    if (this.TabSelectIndex == 2)
        //    {
        //        btnScene.TextColor = UserCenterColor.Current.SelectTextColor;
        //        btnFunction.TextColor = Common.ZigbeeColor.Current.TextColor;
        //        btnLine.SetValue(50, false);
        //    }
 
        //    //功能Tab
        //    btnFunction.MouseUpEventHandler += (sender, e) =>
        //    {
        //        if (this.TabSelectIndex == 1)
        //        {
        //            return;
        //        }
        //        btnScene.TextColor = Common.ZigbeeColor.Current.TextColor;
        //        btnFunction.TextColor = UserCenterColor.Current.SelectTextColor;
        //        btnLine.SetValue(50);
        //        this.TabSelectIndex = 1;
 
        //        //隐藏场景列表控件,显示设备列表控件
        //        this.listSceneView.Visible = false;
        //        this.listDeviceView.Visible = true;
        //    };
 
        //    //场景Tab
        //    btnScene.MouseUpEventHandler += (sender, e) =>
        //    {
        //        if (this.TabSelectIndex == 2)
        //        {
        //            return;
        //        }
        //        btnScene.TextColor = UserCenterColor.Current.SelectTextColor;
        //        btnFunction.TextColor = Common.ZigbeeColor.Current.TextColor;
        //        btnLine.SetValue(50, false);
        //        this.TabSelectIndex = 2;
 
        //        //隐藏设备列表控件,显示场景列表控件
        //        this.listDeviceView.Visible = false;
        //        this.listSceneView.Visible = true;
        //    };
 
        //    return frameSwich;
        //}
 
        //#endregion
 
        //#region ■ 显示功能Tab列表____________________
 
        ///// <summary>
        ///// 初始化功能Tab列表
        ///// </summary>
        //private void InitFunctionTabList()
        //{
        //    if (memberShardInfo.dicAllMemberShard.ContainsKey(this.room.FileName) == false)
        //    {
        //        memberShardInfo.dicAllMemberShard[this.room.FileName] = new HashSet<string>();
        //    }
        //    var listCheck = memberShardInfo.dicAllMemberShard[this.room.FileName];
 
        //    foreach (var deviceUi in this.room.DeviceUIList)
        //    {
        //        var device = deviceUi.CommonDevice;
        //        if (device == null || listCheck.Contains(device.FilePath) == true)
        //        {
        //            //异常,或者已经分享了的,不再显示
        //            continue;
        //        }
        //        Application.RunOnMainThread(() =>
        //        {
        //            if (this.listDeviceView != null)
        //            {
        //                //添加设备行
        //                var deviceRow = new DeviceSelectControl(device);
        //                this.listDeviceView.AddChidren(deviceRow);
        //                deviceRow.InitControl();
        //                //不需要房间控件
        //                deviceRow.RemoveRoomControl();
        //            }
        //        });
        //    }
        //}
 
        //#endregion
 
        //#region ■ 显示场景Tab列表____________________
 
        ///// <summary>
        ///// 初始化场景Tab列表
        ///// </summary>
        //private void InitSceneTabList()
        //{
        //    if (memberShardInfo.dicAllMemberShard.ContainsKey(this.room.FileName) == false)
        //    {
        //        memberShardInfo.dicAllMemberShard[this.room.FileName] = new HashSet<string>();
        //    }
        //    var listCheck = memberShardInfo.dicAllMemberShard[this.room.FileName];
 
        //    foreach (var sceneUi in this.room.SceneUIList)
        //    {
        //        if (sceneUi == null || listCheck.Contains(sceneUi.FileName) == true)
        //        {
        //            //异常,或者已经分享了的,不再显示
        //            continue;
        //        }
        //        Application.RunOnMainThread(() =>
        //        {
        //            if (this.listSceneView != null)
        //            {
        //                //添加场景行
        //                var sceneRow = new SceneSelectRow(this.listSceneView, sceneUi);
        //            }
        //        });
        //    }
        //}
 
        //#endregion
 
        //#region ■ 获取选择的设备_____________________
 
        ///// <summary>
        ///// 获取选择的设备
        ///// </summary>
        ///// <param name="listCheck">重复检测</param>
        ///// <returns></returns>
        //private List<CommonDevice> GetSelectedDevice(HashSet<string> listCheck)
        //{
        //    var listDevice = new List<CommonDevice>();
        //    for (int i = 0; i < listDeviceView.ChildrenCount; i++)
        //    {
        //        var myView = listDeviceView.GetChildren(i);
        //        var selectRow = (DeviceSelectControl)myView;
        //        if (selectRow.IsSelected == true && listCheck.Contains(selectRow.device.FilePath) == false)
        //        {
        //            listCheck.Add(selectRow.device.FilePath);
        //            listDevice.Add(selectRow.device);
        //        }
        //    }
        //    return listDevice;
        //}
 
        //#endregion
 
        //#region ■ 获取选择的场景_____________________
 
        ///// <summary>
        ///// 获取选择的场景
        ///// </summary>
        ///// <param name="listCheck">重复检测</param>
        ///// <returns></returns>
        //private List<Common.SceneUI> GetSelectedSceneUI(HashSet<string> listCheck)
        //{
        //    var listSceneUI = new List<Common.SceneUI>();
        //    for (int i = 0; i < listSceneView.ChildrenCount; i++)
        //    {
        //        var myView = listSceneView.GetChildren(i);
        //        var selectRow = (SceneSelectRow)myView;
        //        if (selectRow.IsSelected == true && listCheck.Contains(selectRow.sceneUI.Id.ToString()) == false)
        //        {
        //            listCheck.Add(selectRow.sceneUI.Id.ToString());
        //            listSceneUI.Add(selectRow.sceneUI);
        //        }
        //    }
        //    return listSceneUI;
        //}
 
        //#endregion
 
        //#region ■ 确认分享___________________________
 
        ///// <summary>
        ///// 确认分享
        ///// </summary>
        //private async void DoSaveSharedContent()
        //{
        //    var listCheck = new HashSet<string>();
        //    //选择的设备
        //    var listSelectDevice = this.GetSelectedDevice(listCheck);
        //    //选择的场景
        //    var listSelectScene = this.GetSelectedSceneUI(listCheck);
        //    if (listSelectDevice.Count == 0 && listSelectScene.Count == 0)
        //    {
        //        //请选择目标后再执行分享操作
        //        string msg = Language.StringByID(R.MyInternationalizationString.uNotSelectDeviceBeforeSave);
        //        this.ShowErrorMsg(msg);
        //        return;
        //    }
        //    //执行上传分享内容
        //    var result = await HdlShardLogic.Current.DoUploadSharedContent(memberShardInfo, this.room, listSelectDevice, listSelectScene);
        //    if (result == true)
        //    {
        //        Application.RunOnMainThread(() =>
        //        {
        //            //重新刷新界面
        //            this.InitMiddleFrame();
        //            //分享成功
        //            string msg = Language.StringByID(R.MyInternationalizationString.uShardSuccess);
        //            this.ShowMassage(msg);
        //        });
        //    }
        //}
 
        //#endregion
 
    }
}