From 7e863a33397f317ffc3ffd9288496d0e4f16aa66 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 12 十二月 2019 14:58:20 +0800 Subject: [PATCH] 合并了新代码 --- ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs | 256 ++++++++++++++++++++++++++------------------------- 1 files changed, 130 insertions(+), 126 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs index 1819ec7..e1f47a1 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs @@ -25,32 +25,32 @@ { this.currentKey = key; this.currentModeID = key.panelMode; - this.oldModeID = key.panelMode; this.curDeviceBindType = deviceBindType; this.targetList = targetSelectList; } #region 鈼� 鍙橀噺鐢虫槑__________________________ - ZigBee.Device.Panel currentKey; + ZigBee.Device.Panel currentKey;//褰撳墠鎸夐敭 //鏄剧ず琚粦瀹氳澶囨垨鍦烘櫙鐨剉iew - VerticalScrolViewLayout midVerticalScrolViewLayout; - HorizontalScrolViewLayout btnHorizontalScrolViewLayout; + VerticalScrolViewLayout midVerticalScrolViewLayout;//涓儴鍒锋柊鍒楄〃 + HorizontalScrolViewLayout btnHorizontalScrolViewLayout;//鎴块棿鍒楄〃宸﹀彸婊戝姩甯冨眬 /// <summary> /// 鎸夐敭閰嶇疆鐨勭洰鏍囧垪琛� /// </summary> - List<CommonDevice> targetList = new List<CommonDevice>(); + List<CommonDevice> targetList = new List<CommonDevice>();//鏈湴涓存椂閫変腑鍒楄〃 /// <summary> /// 鏂扮殑鎸夐敭閰嶇疆鐩爣鍒楄〃涓紝鐩爣瀹為檯瀛樺湪鎸夐敭涓紝姝ゆ椂瑕佸垹鎺夌殑鏁版嵁 /// </summary> - List<CommonDevice> oldTargetList = new List<CommonDevice>(); - List<Room> roomList = new List<Room>(); - int currentClusterID = 6; - public Action<List<BindListResponseObj>> action; - int currentModeID = 0; - int oldModeID = 0; - string curDeviceBindType = ""; + List<CommonDevice> oldTargetList = new List<CommonDevice>();//鏈湴鏃х殑閫変腑鍒楄〃 + int currentClusterID = 6;//褰撳墠绨嘔D + public Action<List<BindListResponseObj>> action;//鍥炶皟缁戝畾鐩爣椤甸潰鍒锋柊 + int currentModeID = 0;//褰撳墠妯″紡ID + string curDeviceBindType = "";//褰撳墠璁惧缁戝畾绫诲瀷 #endregion + /// <summary> + /// 鏄剧ず鎸夐敭妯″紡椤� + /// </summary> public void Show() { this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.ChooseKeyMode)); @@ -66,6 +66,9 @@ MidFrameLayoutContent(); } + /// <summary> + /// 涓儴甯冨眬 + /// </summary> async void MidFrameLayoutContent() { #region UI @@ -97,11 +100,7 @@ #endregion #region 鏁版嵁澶勭悊 - roomList = Shared.Common.Room.Lists; - Shared.Common.Room curRoom = roomList[0]; - int index = 0; - KeyModeList(roomList[index]); - + KeyModeList(); btnFinifh.MouseUpEventHandler += async (sender, e) => { oldTargetList.Clear(); @@ -115,17 +114,15 @@ if (currentKey.bindList != null) { var bindResult = await currentKey.ClearBindInfoAsync(); - if (bindResult != null && bindResult.clearBindInfoResponseData != null) { if (bindResult.clearBindInfoResponseData.Result != 0) { Application.RunOnMainThread(() => { + CommonPage.Loading.Hide(); new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); }); - CommonPage.Loading.Hide(); - this.RemoveFromParent(); btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; return; @@ -139,9 +136,9 @@ { Application.RunOnMainThread(() => { + CommonPage.Loading.Hide(); new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); }); - CommonPage.Loading.Hide(); btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; return; @@ -214,105 +211,97 @@ } } + //鏄寒搴﹀啀娆″彂6鍛戒护 + if (currentClusterID == 8) + { + foreach (var de in targetList) + { + if (de.DeviceAddr != null) + { + var addBindInfo = new AddBindListObj(); + addBindInfo.BindType = 0; + addBindInfo.BindCluster = 6; + addBindInfo.BindMacAddr = de.DeviceAddr; + addBindInfo.BindEpoint = de.DeviceEpoint; + addBindeDev.BindList.Add(addBindInfo); + } + } + } + var dev = new AddedDeviceBindResponseAllData(); dev = await currentKey.AddDeviceBindAsync(addBindeDev); if (dev.addedDeviceBindResponseData == null) { Application.RunOnMainThread(() => { + CommonPage.Loading.Hide(); new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); }); btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; + return; } else { - foreach (var ab in dev.addedDeviceBindResponseData?.BindList) + if (dev.addedDeviceBindResponseData.Result == 0) { - switch (ab.Result) + if (currentClusterID == 8) { - case 0: - currentKey.bindList.Add((BindListResponseObj)ab); - - for (int i = 0; i < targetList.Count; i++) + foreach (var de in dev.addedDeviceBindResponseData.BindList) + { + if (de.BindCluster == 8) { - var de = targetList[i]; - var sc1 = new SceneUI(); - if (de.DeviceAddr == null) - { - sc1 = (SceneUI)de; - - if (sc1.Id == ab.BindScenesId) - { - targetList.RemoveAt(i); - i--; - } - } + currentKey.bindList.Add(de); } - //isFinish = true; - break; - case 1: - Application.RunOnMainThread(() => - { - new Tip() - { - MaxWidth = 150, - Text = Language.StringByID(R.MyInternationalizationString.BindErrorAbsence), - Direction = AMPopTipDirection.Up, - CloseTime = 1 - }.Show(btnFinifh); - }); - break; - case 2: - var abr = dev.addBindResultResponseData?.Result; - switch (dev.addBindResultResponseData?.Result) - { - case 0: - currentKey.bindList.Add((BindListResponseObj)ab); - for (int i = 0; i < targetList.Count; i++) - { - var de = targetList[i]; - if (de.DeviceAddr == ab.BindMacAddr && de.DeviceEpoint == ab.BindEpoint) - { - targetList.RemoveAt(i); - i--; - } - } - //isFinish = true; - break; - case 140: - Application.RunOnMainThread(() => - { - new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFull), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); - }); - break; - default: - Application.RunOnMainThread(() => - { - new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindUnknownError), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); - }); - break; - } - break; - case 3: - Application.RunOnMainThread(() => - { - new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindErrorExisted), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); - }); - break; - case 4: - Application.RunOnMainThread(() => - { - new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); - }); - break; - default: - Application.RunOnMainThread(() => - { - new Tip() { MaxWidth = 150, Text = ab.ESName + Language.StringByID(R.MyInternationalizationString.BindUnknownError), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh); - }); - break; + } } + else + { + currentKey.bindList = dev.addedDeviceBindResponseData.BindList; + } + if (action != null) + { + action(currentKey.bindList); + } + this.RemoveFromParent(); + targetList.Clear(); + CommonPage.Loading.Hide(); + btnFinifh.Enable = true; + btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; + } + else if (dev.addedDeviceBindResponseData.Result == 1) + { + Application.RunOnMainThread(() => + { + CommonPage.Loading.Hide(); + new Tip() + { + MaxWidth = 150, + Text = Language.StringByID(R.MyInternationalizationString.BindFailed), + Direction = AMPopTipDirection.Up, + CloseTime = 1 + }.Show(btnFinifh); + }); + btnFinifh.Enable = true; + btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; + return; + } + else + { + Application.RunOnMainThread(() => + { + CommonPage.Loading.Hide(); + new Tip() + { + MaxWidth = 150, + Text = Language.StringByID(R.MyInternationalizationString.BindUnknownError), + Direction = AMPopTipDirection.Up, + CloseTime = 1 + }.Show(btnFinifh); + }); + btnFinifh.Enable = true; + btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; + return; } } } @@ -320,6 +309,7 @@ { Application.RunOnMainThread(() => { + CommonPage.Loading.Hide(); new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ChangeBindMode), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnFinifh); }); btnFinifh.Enable = true; @@ -331,6 +321,7 @@ { Application.RunOnMainThread(() => { + CommonPage.Loading.Hide(); new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnFinifh); }); btnFinifh.Enable = true; @@ -338,26 +329,8 @@ return; } } - catch { } - finally + catch { - //if (isFinish) - //{ - // if (action != null) - // { - // action(currentKey.bindList); - // } - // this.RemoveFromParent(); - //} - //else - //{ - // this.RemoveFromParent(); - //} - if (action != null) - { - action(currentKey.bindList); - } - this.RemoveFromParent(); CommonPage.Loading.Hide(); btnFinifh.Enable = true; btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack; @@ -371,10 +344,9 @@ /// </summary> /// <param name="gateway">Gateway.</param> /// <param name="key">Key.</param> - void KeyModeList(Shared.Common.Room curRoom) + private void KeyModeList() { midVerticalScrolViewLayout.RemoveAll(); - switch (curDeviceBindType) { case "AddSwitch": @@ -392,7 +364,7 @@ } } - public void AddSwitchMode() + private void AddSwitchMode() { Button oldMode = null; for (int i = 0; i < 3; i++) @@ -470,6 +442,15 @@ btnChoose.Visible = true; oldMode = btnChoose; } + else if ((currentKey.panelMode == 65535) && i == 0) + { + //榛樿绗竴涓� + btnChoose.IsSelected = true; + btnChoose.Visible = true; + oldMode = btnChoose; + currentModeID = 100; + currentKey.panelMode = currentModeID; + } EventHandler<MouseEventArgs> hander = async (sender, e) => { @@ -508,7 +489,7 @@ } } - public void AddDimmerMode() + private void AddDimmerMode() { Button oldMode = null; for (int i = 0; i < 5; i++) @@ -606,6 +587,15 @@ btnChoose.Visible = true; oldMode = btnChoose; } + else if ((currentKey.panelMode == 65535) && i == 0) + { + //榛樿绗竴涓� + btnChoose.IsSelected = true; + btnChoose.Visible = true; + oldMode = btnChoose; + currentModeID = 200; + currentKey.panelMode = currentModeID; + } EventHandler<MouseEventArgs> hander = (sender, e) => { @@ -654,7 +644,7 @@ } } - public void AddCurtainMode() + private void AddCurtainMode() { Button oldMode = null; for (int i = 0; i < 5; i++) @@ -752,6 +742,15 @@ btnChoose.Visible = true; oldMode = btnChoose; } + else if ((currentKey.panelMode == 65535) && i == 0) + { + //榛樿绗竴涓� + btnChoose.IsSelected = true; + btnChoose.Visible = true; + oldMode = btnChoose; + currentModeID = 300; + currentKey.panelMode = currentModeID; + } EventHandler<MouseEventArgs> hander = (sender, e) => { @@ -799,6 +798,11 @@ } } + private void FinisfhEventHandler(object sender, MouseEventArgs e) + { + + } + public void DeviceInfoChange(CommonDevice common, string typeTag) { } -- Gitblit v1.8.0