From 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期二, 21 七月 2020 09:46:53 +0800
Subject: [PATCH] 请合并最新多功能面板代码

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs | 1136 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1,136 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs
new file mode 100644
index 0000000..f36a132
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/Bind/ChooseKeyModePage.cs
@@ -0,0 +1,1136 @@
+锘縰sing System;
+using System.Collections.Generic;
+using Shared.Common;
+using ZigBee.Device;
+using static ZigBee.Device.BindObj;
+namespace Shared.Phone.UserCenter.DeviceBind
+{
+    public class ChooseKeyModePage : BindCommonLayout
+    {
+        /// 鏋勯�犲嚱鏁�
+        /// </summary>
+        /// <param name="doorLock"></param>
+        public ChooseKeyModePage(ZigBee.Device.Panel key, string deviceBindType, List<CommonDevice> targetSelectList)
+        {
+            this.currentKey = key;
+            this.currentModeID = key.panelMode;
+            this.curDeviceBindType = deviceBindType;
+            this.targetList = targetSelectList;
+        }
+
+        #region 鍙橀噺鐢虫槑
+        /// <summary>
+        /// 褰撳墠鎸夐敭
+        /// </summary>
+        ZigBee.Device.Panel currentKey;
+        /// <summary>
+        /// 涓儴鍒锋柊鍒楄〃
+        /// </summary>
+        VerticalScrolViewLayout midVerticalScrolViewLayout;
+        /// <summary>
+        /// 鎴块棿鍒楄〃宸﹀彸婊戝姩甯冨眬
+        /// </summary>
+        HorizontalScrolViewLayout btnHorizontalScrolViewLayout;
+        /// <summary>
+        /// 鎸夐敭閰嶇疆鐨勭洰鏍囧垪琛�
+        /// </summary>
+        List<CommonDevice> targetList = new List<CommonDevice>();
+        /// <summary>
+        /// 鏈湴鏃х殑閫変腑鍒楄〃
+        /// </summary>
+        List<CommonDevice> oldTargetList = new List<CommonDevice>();
+        /// <summary>
+        /// 褰撳墠绨嘔D
+        /// </summary>
+        int currentClusterID = 6;
+        /// <summary>
+        /// 鍥炶皟缁戝畾鐩爣椤甸潰鍒锋柊
+        /// </summary>
+        public Action<List<BindListResponseObj>> action;
+        /// <summary>
+        /// 褰撳墠妯″紡ID
+        /// </summary>
+        int currentModeID = 0;
+        /// <summary>
+        /// 褰撳墠璁惧缁戝畾绫诲瀷
+        /// </summary>
+        string curDeviceBindType = "";
+        /// <summary>
+        /// 绫诲瀷鐨勫叿浣撴ā寮忓垪琛�
+        /// </summary>
+        List<int> typeDetailModeList = new List<int> { };
+        #endregion
+
+        /// <summary>
+        /// 鏄剧ず鎸夐敭妯″紡椤�
+        /// </summary>
+        public void Show()
+        {
+            this.TopFrameLayout(this, Language.StringByID(R.MyInternationalizationString.ChooseKeyMode));
+
+            EventHandler<MouseEventArgs> eHandlerBack = (sender, e) =>
+            {
+                RemoveFromParent();
+            };
+            this.btnBack.MouseUpEventHandler += eHandlerBack;
+            this.btnBackFrameLayout.MouseUpEventHandler += eHandlerBack;
+            this.MidFrameLayout(this);
+
+            MidFrameLayoutContent();
+        }
+
+        /// <summary>
+        /// 涓儴甯冨眬
+        /// </summary>
+        async void MidFrameLayoutContent()
+        {
+            #region UI
+            midVerticalScrolViewLayout = new VerticalScrolViewLayout()
+            {
+            };
+            this.midFrameLayout.AddChidren(midVerticalScrolViewLayout);
+
+            var bottomFrameLayout = new FrameLayout()
+            {
+                Width = LayoutParams.MatchParent,
+                Height = Application.GetRealHeight(1737 - 1472),
+                Y = Application.GetRealHeight(1472),
+            };
+            this.midFrameLayout.AddChidren(bottomFrameLayout);
+
+            var btnFinifh = new Button()
+            {
+                Width = Application.GetRealWidth(907),
+                Height = Application.GetRealHeight(127),
+                Gravity = Gravity.CenterHorizontal,
+                Radius = (uint)Application.GetRealHeight(120) / 2,
+                TextID = R.MyInternationalizationString.Save,
+                BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack,
+                TextColor = Shared.Common.ZigbeeColor.Current.XMWhite,
+                TextSize = 16,
+                IsBold = true,
+            };
+            bottomFrameLayout.AddChidren(btnFinifh);
+            #endregion
+
+            #region 鏁版嵁澶勭悊
+            KeyModeList();
+            btnFinifh.MouseUpEventHandler += (sender, e) =>
+           {
+               oldTargetList.Clear();
+               btnFinifh.Enable = false;
+               btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMUnSelect;
+               System.Threading.Tasks.Task.Run(() =>
+               {
+                   try
+                   {
+                       Application.RunOnMainThread(() =>
+                       {
+                           CommonPage.Loading.Start("");
+                       });
+                       //1銆佹竻绌烘墍鏈夌洰鏍�
+                       if (currentKey.bindList != null)
+                       {
+                           var bindResult = HdlDeviceBindLogic.Current.ClearBindInfoAsync(currentKey);
+                           if (bindResult != null && bindResult.clearBindInfoResponseData != null)
+                           {
+                               if (bindResult.clearBindInfoResponseData.Result != 0)
+                               {
+                                   Application.RunOnMainThread(() =>
+                                   {
+                                       btnFinifh.Enable = true;
+                                       btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                       CommonPage.Loading.Hide();
+                                       new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.BindFailed), Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+                                   });
+                                   return;
+                               }
+                               else
+                               {
+                                   currentKey.bindList.Clear();
+                               }
+                           }
+                           else
+                           {
+                               Application.RunOnMainThread(() =>
+                               {
+                                   btnFinifh.Enable = true;
+                                   btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                   CommonPage.Loading.Hide();
+                                   new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "5006" + ")", Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+                               });
+                               return;
+                           }
+                       }
+
+                       //2銆侀厤缃ā寮�
+                       Panel.SetWritableValueResponAllData temp = null;
+                       switch (currentModeID)
+                       {
+                           case 100:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.OnOff_On);
+                               break;
+                           case 101:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.OnOff_oFF);
+                               break;
+                           case 102:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.OnOff_OnOff);
+                               break;
+                           case 200:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Step_Up);
+                               break;
+                           case 201:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Step_Down);
+                               break;
+                           case 203:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Up);
+                               break;
+                           case 204:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Down);
+                               break;
+                           case 205:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Level_Up_Down);
+                               break;
+                           case 300:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Up);
+                               break;
+                           case 301:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Down);
+                               break;
+                           case 302:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Stop);
+                               break;
+                           case 303:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Up_Stop);
+                               break;
+                           case 304:
+                               temp = HdlDeviceBindLogic.Current.ConfigureHdlKeyValueAsync(currentKey, Panel.KeyMode.Wcd_Down_Stop);
+                               break;
+                       }
+                       if (temp != null && temp.setWritableValueResponData != null)
+                       {
+                           if (temp.setWritableValueResponData.Status == 0)
+                           {
+                               //3銆佺粦瀹氭柊鐨勬暟鎹�
+                               var addBindeDev = new AddBindData();
+                               addBindeDev.DeviceAddr = currentKey.DeviceAddr;
+                               addBindeDev.Epoint = currentKey.DeviceEpoint;
+
+                               foreach (var de in targetList)
+                               {
+                                   if (de.DeviceAddr != null)
+                                   {
+                                       var addBindInfo = new AddBindListObj();
+                                       addBindInfo.BindType = 0;
+                                       addBindInfo.BindCluster = currentClusterID;
+                                       addBindInfo.BindMacAddr = de.DeviceAddr;
+                                       addBindInfo.BindEpoint = de.DeviceEpoint;
+                                       addBindeDev.BindList.Add(addBindInfo);
+                                   }
+                               }
+
+                               //鏄寒搴﹀啀娆″彂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 = HdlDeviceBindLogic.Current.AddDeviceBindAsync(addBindeDev);
+                               if (dev != null && dev.addedDeviceBindResponseData != null)
+                               {
+                                   if (dev.addedDeviceBindResponseData.Result == 0)
+                                   {
+                                       if (currentClusterID == 8)
+                                       {
+                                           foreach (var de in dev.addedDeviceBindResponseData.BindList)
+                                           {
+                                               if (de.BindCluster == 8)
+                                               {
+                                                   currentKey.bindList.Add(de);
+                                               }
+                                           }
+                                       }
+                                       else
+                                       {
+                                           currentKey.bindList = dev.addedDeviceBindResponseData.BindList;
+                                       }
+
+                                       Application.RunOnMainThread(() =>
+                                       {
+                                           if (action != null)
+                                           {
+                                               action(currentKey.bindList);
+                                           }
+                                           targetList.Clear();
+                                           this.RemoveFromParent();
+                                           btnFinifh.Enable = true;
+                                           btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                           CommonPage.Loading.Hide();
+                                       });
+
+                                   }
+                                   else if (dev.addedDeviceBindResponseData.Result == 1)
+                                   {
+                                       Application.RunOnMainThread(() =>
+                                       {
+                                           btnFinifh.Enable = true;
+                                           btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                           CommonPage.Loading.Hide();
+                                           new Tip()
+                                           {
+                                               MaxWidth = 150,
+                                               Text = Language.StringByID(R.MyInternationalizationString.BindFailed),
+                                               Direction = AMPopTipDirection.Up,
+                                               CloseTime = 1
+                                           }.Show(btnFinifh);
+                                       });
+                                       return;
+                                   }
+                                   else
+                                   {
+                                       Application.RunOnMainThread(() =>
+                                       {
+                                           btnFinifh.Enable = true;
+                                           btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                           CommonPage.Loading.Hide();
+                                           new Tip()
+                                           {
+                                               MaxWidth = 150,
+                                               Text = Language.StringByID(R.MyInternationalizationString.BindUnknownError),
+                                               Direction = AMPopTipDirection.Up,
+                                               CloseTime = 1
+                                           }.Show(btnFinifh);
+                                       });
+
+                                       return;
+                                   }
+                               }
+                               else
+                               {
+                                   Application.RunOnMainThread(() =>
+                                   {
+                                       btnFinifh.Enable = true;
+                                       btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                       CommonPage.Loading.Hide();
+                                       new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "5001" + ")", Direction = AMPopTipDirection.Up, CloseTime = 1 }.Show(btnFinifh);
+                                   });
+                                   return;
+                               }
+                           }
+                           else
+                           {
+                               Application.RunOnMainThread(() =>
+                               {
+                                   btnFinifh.Enable = true;
+                                   btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                                   CommonPage.Loading.Hide();
+                                   new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.ChangeBindMode), Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnFinifh);
+                               });
+                               return;
+                           }
+                       }
+                       else
+                       {
+                           Application.RunOnMainThread(() =>
+                           {
+                               btnFinifh.Enable = true;
+                               btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                               CommonPage.Loading.Hide();
+                               new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "120_ 6533" + ")", Direction = AMPopTipDirection.Up, CloseTime = 2 }.Show(btnFinifh);
+                           });
+                           return;
+                       }
+                   }
+                   catch
+                   {
+                       Application.RunOnMainThread(() =>
+                       {
+                           btnFinifh.Enable = true;
+                           btnFinifh.BackgroundColor = Shared.Common.ZigbeeColor.Current.XMBlack;
+                           CommonPage.Loading.Hide();
+                       });
+                   }
+               });
+           };
+            #endregion 
+        }
+
+        /// <summary>
+        /// 鎸夐敭妯″紡鏄剧ず
+        /// </summary>
+        /// <param name="gateway">Gateway.</param>
+        /// <param name="key">Key.</param>
+        async private void KeyModeList()
+        {
+            midVerticalScrolViewLayout.RemoveAll();
+            switch (curDeviceBindType)
+            {
+                case "AddSwitch":
+                    currentClusterID = 6;
+                    typeDetailModeList = await GetAddSwitchMode();
+                    if (typeDetailModeList == null)
+                    {
+                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "0003_switch" + ")", Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                    }
+                    else
+                    {
+                        AddSwitchMode();
+                    }
+                    break;
+                case "AddDimmer":
+                    currentClusterID = 8;
+                    typeDetailModeList = await GetAddDimmerMode();
+                    if (typeDetailModeList == null)
+                    {
+                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "0003_dimmer" + ")", Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                    }
+                    else
+                    {
+                        AddDimmerMode();
+                    }
+                    break;
+                case "AddCurtain":
+                    currentClusterID = 258;
+                    typeDetailModeList = await GetAddCurtainMode();
+                    if (typeDetailModeList == null)
+                    {
+                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "0003_curtain" + ")", Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                    }
+                    else
+                    {
+                        AddCurtainMode();
+                    }
+                    break;
+            }
+        }
+
+        /// <summary>
+        /// 鑾峰彇寮�鍏冲叿浣撶被鍨�
+        /// </summary>
+        /// <returns></returns>
+        System.Threading.Tasks.Task<List<int>> GetAddSwitchMode()
+        {
+            return System.Threading.Tasks.Task.Run(async () =>
+             {
+                 //濡傛灉褰撳墠鏄櫄鎷熶綇瀹�
+                 if (Common.Config.Instance.Home.IsVirtually == true)
+                 {
+                     typeDetailModeList.Clear();
+                     return new List<int>() { 100, 101, 102 };
+                 }
+
+                 Application.RunOnMainThread(() =>
+                 {
+                     CommonPage.Loading.Start();
+                 });
+                 typeDetailModeList.Clear();
+                 List<int> result3 = new List<int> { };
+                 try
+                 {
+                     //鑾峰彇绗笁绾у姛鑳�
+                     if (currentKey.privateFuncThirdLevelList.Count == 0 || currentKey.privateFuncThirdLevelList.Contains(100) == false || currentKey.privateFuncThirdLevelList.Contains(101) == false || currentKey.privateFuncThirdLevelList.Contains(102) == false)
+                     {
+                         result3 = await currentKey.GetPanelDeviceFunctionLevel3(256, 100);
+                         foreach (var l3 in result3)
+                         {
+                             currentKey.privateFuncThirdLevelList.Add(l3);
+                         }
+                     }
+                     else
+                     {
+                         if (currentKey.privateFuncThirdLevelList.Contains(100) == true)
+                         {
+                             result3.Add(100);
+                         }
+                         if (currentKey.privateFuncThirdLevelList.Contains(101) == true)
+                         {
+                             result3.Add(101);
+                         }
+                         if (currentKey.privateFuncThirdLevelList.Contains(102) == true)
+                         {
+                             result3.Add(102);
+                         }
+                     }
+                 }
+                 catch (Exception ex)
+                 {
+                     var aa = ex.Message;
+                 }
+                 finally
+                 {
+                     Application.RunOnMainThread(() =>
+                     {
+                         CommonPage.Loading.Hide();
+                     });
+                 }
+                 return result3;
+             });
+        }
+
+        /// <summary>
+        /// 鑾峰彇璋冨厜鍏蜂綋绫诲瀷
+        /// </summary>
+        /// <returns></returns>
+        System.Threading.Tasks.Task<List<int>> GetAddDimmerMode()
+        {
+            return System.Threading.Tasks.Task.Run(async () =>
+            {
+                //濡傛灉褰撳墠鏄櫄鎷熶綇瀹�
+                if (Common.Config.Instance.Home.IsVirtually == true)
+                {
+                    typeDetailModeList.Clear();
+                    return new List<int>() { 200, 201, 203, 204, 205 };
+                }
+
+                Application.RunOnMainThread(() =>
+                {
+                    CommonPage.Loading.Start();
+                });
+                typeDetailModeList.Clear();
+                List<int> result3 = new List<int> { };
+                try
+                {
+                    //鑾峰彇绗笁绾у姛鑳�
+                    if (currentKey.privateFuncThirdLevelList.Count == 0
+                        || currentKey.privateFuncThirdLevelList.Contains(200) == false
+                        || currentKey.privateFuncThirdLevelList.Contains(201) == false
+                        || currentKey.privateFuncThirdLevelList.Contains(203) == false
+                        || currentKey.privateFuncThirdLevelList.Contains(204) == false
+                        || currentKey.privateFuncThirdLevelList.Contains(205) == false)
+                    {
+                        result3 = await currentKey.GetPanelDeviceFunctionLevel3(256, 200);
+                        foreach (var l3 in result3)
+                        {
+                            currentKey.privateFuncThirdLevelList.Add(l3);
+                        }
+                    }
+                    else
+                    {
+                        if (currentKey.privateFuncThirdLevelList.Contains(200) == true)
+                        {
+                            result3.Add(200);
+                        }
+                        if (currentKey.privateFuncThirdLevelList.Contains(201) == true)
+                        {
+                            result3.Add(201);
+                        }
+                        if (currentKey.privateFuncThirdLevelList.Contains(203) == true)
+                        {
+                            result3.Add(203);
+                        }
+                        if (currentKey.privateFuncThirdLevelList.Contains(204) == true)
+                        {
+                            result3.Add(204);
+                        }
+                        if (currentKey.privateFuncThirdLevelList.Contains(205) == true)
+                        {
+                            result3.Add(205);
+                        }
+                    }
+                }
+                catch { }
+                finally
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        CommonPage.Loading.Hide();
+                    });
+                }
+                return result3;
+            });
+        }
+
+        /// <summary>
+        /// 鑾峰彇绐楀笜鍏蜂綋绫诲瀷
+        /// </summary>
+        /// <returns></returns>
+        System.Threading.Tasks.Task<List<int>> GetAddCurtainMode()
+        {
+            Application.RunOnMainThread(() =>
+            {
+                CommonPage.Loading.Start();
+            });
+            return System.Threading.Tasks.Task.Run(async () =>
+            {
+                typeDetailModeList.Clear();
+                //濡傛灉褰撳墠鏄櫄鎷熶綇瀹�
+                if (Common.Config.Instance.Home.IsVirtually == true)
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        CommonPage.Loading.Hide();
+                    });
+                    typeDetailModeList.Clear();
+                    return new List<int>() { 300, 301, 302, 303, 304 };
+                }
+
+                List<int> result3 = new List<int> { };
+                try
+                {
+                    //鑾峰彇绗笁绾у姛鑳�
+                    if (currentKey.privateFuncThirdLevelList.Count == 0
+                        || currentKey.privateFuncThirdLevelList.Contains(300) == false
+                        || currentKey.privateFuncThirdLevelList.Contains(301) == false
+                        || currentKey.privateFuncThirdLevelList.Contains(302) == false
+                        || currentKey.privateFuncThirdLevelList.Contains(303) == false
+                        || currentKey.privateFuncThirdLevelList.Contains(304) == false)
+                    {
+                        result3 = await currentKey.GetPanelDeviceFunctionLevel3(256, 300);
+                        foreach (var l3 in result3)
+                        {
+                            currentKey.privateFuncThirdLevelList.Add(l3);
+                        }
+                    }
+                    else
+                    {
+                        if (currentKey.privateFuncThirdLevelList.Contains(300) == true)
+                        {
+                            result3.Add(300);
+                        }
+                        if (currentKey.privateFuncThirdLevelList.Contains(301) == true)
+                        {
+                            result3.Add(301);
+                        }
+                        if (currentKey.privateFuncThirdLevelList.Contains(302) == true)
+                        {
+                            result3.Add(302);
+                        }
+                        if (currentKey.privateFuncThirdLevelList.Contains(303) == true)
+                        {
+                            result3.Add(303);
+                        }
+                        if (currentKey.privateFuncThirdLevelList.Contains(304) == true)
+                        {
+                            result3.Add(304);
+                        }
+                    }
+                }
+                catch { }
+                finally
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        CommonPage.Loading.Hide();
+                    });
+                }
+                return result3;
+            });
+        }
+
+        /// <summary>
+        /// 娣诲姞寮�鍏虫ā寮�
+        /// </summary>
+        async private void AddSwitchMode()
+        {
+            if (typeDetailModeList == null)
+            {
+                //鍐嶆鍔ㄦ�佽幏鍙栨寜閿敮鎸佺殑绫�
+                typeDetailModeList = await GetAddSwitchMode();
+                if (typeDetailModeList == null)
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "0003_switch" + ")", Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                    });
+                    return;
+                }
+            }
+            Button oldMode = null;
+            int i = 0;
+            foreach (var modeSwitchValue in typeDetailModeList)
+            {
+                #region 缁戝畾琛║I鏄撅紙鏃犳暟鎹鐞嗭級
+                var rowLayout = new FrameLayout()
+                {
+                    Height = Application.GetRealHeight(23 + 127),
+                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
+                };
+                midVerticalScrolViewLayout.AddChidren(rowLayout);
+
+                var btnModeText = new Button()
+                {
+                    Width = Application.GetRealWidth(821),
+                    Height = Application.GetRealHeight(60),
+                    X = Application.GetRealWidth(58),
+                    Y = Application.GetRealHeight(58),
+                    TextColor = Shared.Common.ZigbeeColor.Current.TextBlack,
+                    TextAlignment = TextAlignment.CenterLeft,
+                    TextSize = 14,
+                };
+                rowLayout.AddChidren(btnModeText);
+
+                var btnChoose = new Button()
+                {
+                    Width = Application.GetMinReal(60),
+                    Height = Application.GetMinReal(60),
+                    X = Application.GetRealWidth(861 + 81),
+                    Y = Application.GetRealHeight(35),
+                    SelectedImagePath = "DoorLock/SelectedIcon.png",
+                    Visible = false,
+                };
+                rowLayout.AddChidren(btnChoose);
+
+                var line2 = new Button()
+                {
+                    Y = rowLayout.Height - 1,
+                    X = Application.GetRealWidth(58),
+                    Width = Application.GetRealWidth(965),
+                    Height = 1,
+                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
+                };
+                rowLayout.AddChidren(line2);
+                #endregion
+
+                switch (modeSwitchValue)
+                {
+                    case 100:
+                        btnModeText.Text = Language.StringByID(R.MyInternationalizationString.OnOffOn);
+                        break;
+                    case 101:
+                        btnModeText.Text = Language.StringByID(R.MyInternationalizationString.OnOffoFF);
+                        break;
+                    case 102:
+                        btnModeText.Text = Language.StringByID(R.MyInternationalizationString.OnOffOnOff);
+                        break;
+                }
+
+                if (i == typeDetailModeList.Count - 1)
+                {
+                    line2.Visible = false;
+                }
+
+                if ((currentKey.panelMode == 100) && i == 0)
+                {
+                    btnChoose.IsSelected = true;
+                    btnChoose.Visible = true;
+                    oldMode = btnChoose;
+                }
+                else if ((currentKey.panelMode == 101) && i == 1)
+                {
+                    btnChoose.IsSelected = true;
+                    btnChoose.Visible = true;
+                    oldMode = btnChoose;
+                }
+                else if ((currentKey.panelMode == 102) && i == 2)
+                {
+                    btnChoose.IsSelected = true;
+                    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) =>
+                 {
+                     if (!btnChoose.IsSelected)
+                     {
+                         if (oldMode != null)
+                         {
+                             oldMode.IsSelected = false;
+                             oldMode.Visible = false;
+                         }
+                         oldMode = btnChoose;
+                         oldMode.IsSelected = true;
+                         oldMode.Visible = true;
+                         if (btnModeText.Text == Language.StringByID(R.MyInternationalizationString.OnOffOn))
+                         {
+                             currentModeID = 100;
+                             currentKey.panelMode = currentModeID;
+                         }
+                         else if (btnModeText.Text == Language.StringByID(R.MyInternationalizationString.OnOffoFF))
+                         {
+                             currentModeID = 101;
+                             currentKey.panelMode = currentModeID;
+                         }
+                         else if (btnModeText.Text == Language.StringByID(R.MyInternationalizationString.OnOffOnOff))
+                         {
+                             currentModeID = 102;
+                             currentKey.panelMode = currentModeID;
+                         }
+                     }
+                 };
+
+                rowLayout.MouseUpEventHandler += hander;
+                btnModeText.MouseUpEventHandler += hander;
+                btnChoose.MouseUpEventHandler += hander;
+                i++;
+            }
+        }
+
+        /// <summary>
+        /// 娣诲姞璋冨厜妯″紡
+        /// </summary>
+        async private void AddDimmerMode()
+        {
+            if (typeDetailModeList == null)
+            {
+                //鍐嶆鍔ㄦ�佽幏鍙栨寜閿敮鎸佺殑绫�
+                typeDetailModeList = await GetAddDimmerMode();
+                if (typeDetailModeList == null)
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "0003_dimmer" + ")", Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                    });
+                    return;
+                }
+            }
+            Button oldMode = null;
+            int i = 0;
+
+            List<int> typeDetailModeListTemp = new List<int> { };
+            foreach (var modeSwitchValue in typeDetailModeList)
+            {
+                if (modeSwitchValue == 202)
+                {
+                    continue;
+                }
+                typeDetailModeListTemp.Add(modeSwitchValue);
+            }
+
+            foreach (var modeSwitchValue in typeDetailModeListTemp)
+            {
+                #region 缁戝畾琛║I鏄撅紙鏃犳暟鎹鐞嗭級
+                var rowLayout = new FrameLayout()
+                {
+                    Height = Application.GetRealHeight(23 + 127),
+                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
+                };
+                midVerticalScrolViewLayout.AddChidren(rowLayout);
+
+                var btnModeText = new Button()
+                {
+                    Width = Application.GetRealWidth(821),
+                    Height = Application.GetRealHeight(60),
+                    X = Application.GetRealWidth(58),
+                    Y = Application.GetRealHeight(58),
+                    TextColor = Shared.Common.ZigbeeColor.Current.TextBlack,
+                    TextAlignment = TextAlignment.CenterLeft,
+                    TextSize = 14,
+                };
+                rowLayout.AddChidren(btnModeText);
+
+                var btnChoose = new Button()
+                {
+                    Width = Application.GetMinReal(60),
+                    Height = Application.GetMinReal(60),
+                    X = Application.GetRealWidth(861 + 81),
+                    Y = Application.GetRealHeight(35),
+                    SelectedImagePath = "DoorLock/SelectedIcon.png",
+                    Visible = false,
+                };
+                rowLayout.AddChidren(btnChoose);
+
+                var line2 = new Button()
+                {
+                    Y = rowLayout.Height - 1,
+                    X = Application.GetRealWidth(58),
+                    Width = Application.GetRealWidth(965),
+                    Height = 1,
+                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
+                };
+                rowLayout.AddChidren(line2);
+                #endregion
+                switch (modeSwitchValue)
+                {
+                    case 200:
+                        btnModeText.Text = Language.StringByID(R.MyInternationalizationString.DimmerMode1);
+                        break;
+                    case 201:
+                        btnModeText.Text = Language.StringByID(R.MyInternationalizationString.DimmerMode2);
+                        break;
+                    case 203:
+                        btnModeText.Text = Language.StringByID(R.MyInternationalizationString.DimmerMode3);
+                        break;
+                    case 204:
+                        btnModeText.Text = Language.StringByID(R.MyInternationalizationString.DimmerMode4);
+                        break;
+                    case 205:
+                        btnModeText.Text = Language.StringByID(R.MyInternationalizationString.DimmerMode5);
+                        break;
+                }
+
+                if (i == typeDetailModeListTemp.Count - 1)
+                {
+                    line2.Visible = false;
+                }
+
+                if ((currentKey.panelMode == 200) && i == 0)
+                {
+                    btnChoose.IsSelected = true;
+                    btnChoose.Visible = true;
+                    oldMode = btnChoose;
+                }
+                else if ((currentKey.panelMode == 201) && i == 1)
+                {
+                    btnChoose.IsSelected = true;
+                    btnChoose.Visible = true;
+                    oldMode = btnChoose;
+                }
+                else if ((currentKey.panelMode == 203) && i == 2)
+                {
+                    btnChoose.IsSelected = true;
+                    btnChoose.Visible = true;
+                    oldMode = btnChoose;
+                }
+                else if ((currentKey.panelMode == 204) && i == 3)
+                {
+                    btnChoose.IsSelected = true;
+                    btnChoose.Visible = true;
+                    oldMode = btnChoose;
+                }
+                else if ((currentKey.panelMode == 205) && i == 4)
+                {
+                    btnChoose.IsSelected = true;
+                    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) =>
+                {
+                    if (!btnChoose.IsSelected)
+                    {
+                        if (oldMode != null)
+                        {
+                            oldMode.IsSelected = false;
+                            oldMode.Visible = false;
+                        }
+                        oldMode = btnChoose;
+                        oldMode.IsSelected = true;
+                        oldMode.Visible = true;
+                        if (btnModeText.Text == Language.StringByID(R.MyInternationalizationString.DimmerMode1))
+                        {
+                            currentModeID = 200;
+                            currentKey.panelMode = currentModeID;
+                        }
+                        else if (btnModeText.Text == Language.StringByID(R.MyInternationalizationString.DimmerMode2))
+                        {
+                            currentModeID = 201;
+                            currentKey.panelMode = currentModeID;
+                        }
+                        else if (btnModeText.Text == Language.StringByID(R.MyInternationalizationString.DimmerMode3))
+                        {
+                            currentModeID = 203;
+                            currentKey.panelMode = currentModeID;
+                        }
+                        else if (btnModeText.Text == Language.StringByID(R.MyInternationalizationString.DimmerMode4))
+                        {
+                            currentModeID = 204;
+                            currentKey.panelMode = currentModeID;
+                        }
+                        else if (btnModeText.Text == Language.StringByID(R.MyInternationalizationString.DimmerMode5))
+                        {
+                            currentModeID = 205;
+                            currentKey.panelMode = currentModeID;
+                        }
+                    }
+                };
+                rowLayout.MouseUpEventHandler += hander;
+                btnModeText.MouseUpEventHandler += hander;
+                btnChoose.MouseUpEventHandler += hander;
+                i++;
+            }
+        }
+
+        /// <summary>
+        /// 娣诲姞绐楀笜妯″紡
+        /// </summary>
+        async private void AddCurtainMode()
+        {
+            if (typeDetailModeList == null)
+            {
+                //鍐嶆鍔ㄦ�佽幏鍙栨寜閿敮鎸佺殑绫�
+                typeDetailModeList = await GetAddCurtainMode();
+                if (typeDetailModeList == null)
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        new Tip() { MaxWidth = 150, Text = Language.StringByID(R.MyInternationalizationString.GwResponseOvertime) + "(" + "0003_curtain" + ")", Direction = AMPopTipDirection.None, CloseTime = 1 }.Show(Common.CommonPage.Instance);
+                    });
+                    return;
+                }
+            }
+            Button oldMode = null;
+            int i = 0;
+            foreach (var modeSwitchValue in typeDetailModeList)
+            {
+                #region 缁戝畾琛║I鏄撅紙鏃犳暟鎹鐞嗭級
+                var rowLayout = new FrameLayout()
+                {
+                    Height = Application.GetRealHeight(23 + 127),
+                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMWhite,
+                };
+                midVerticalScrolViewLayout.AddChidren(rowLayout);
+
+                var btnModeText = new Button()
+                {
+                    Width = Application.GetRealWidth(821),
+                    Height = Application.GetRealHeight(60),
+                    X = Application.GetRealWidth(58),
+                    Y = Application.GetRealHeight(58),
+                    TextColor = Shared.Common.ZigbeeColor.Current.TextBlack,
+                    TextAlignment = TextAlignment.CenterLeft,
+                    TextSize = 14,
+                };
+                rowLayout.AddChidren(btnModeText);
+
+                var btnChoose = new Button()
+                {
+                    Width = Application.GetMinReal(60),
+                    Height = Application.GetMinReal(60),
+                    X = Application.GetRealWidth(861 + 81),
+                    Y = Application.GetRealHeight(35),
+                    SelectedImagePath = "DoorLock/SelectedIcon.png",
+                    Visible = false,
+                };
+                rowLayout.AddChidren(btnChoose);
+
+                var line2 = new Button()
+                {
+                    Y = rowLayout.Height - 1,
+                    X = Application.GetRealWidth(58),
+                    Width = Application.GetRealWidth(965),
+                    Height = 1,
+                    BackgroundColor = Shared.Common.ZigbeeColor.Current.XMRowLine,
+                };
+                rowLayout.AddChidren(line2);
+                #endregion
+                switch (modeSwitchValue)
+                {
+                    case 300:
+                        btnModeText.Text = Language.StringByID(R.MyInternationalizationString.WcdUp);
+                        break;
+                    case 301:
+                        btnModeText.Text = Language.StringByID(R.MyInternationalizationString.WcdDown);
+                        break;
+                    case 302:
+                        btnModeText.Text = Language.StringByID(R.MyInternationalizationString.WcdStop);
+                        break;
+                    case 303:
+                        btnModeText.Text = Language.StringByID(R.MyInternationalizationString.WcdUpStop);
+                        break;
+                    case 304:
+                        btnModeText.Text = Language.StringByID(R.MyInternationalizationString.WcdDownStop);
+                        break;
+                }
+
+                if (i == typeDetailModeList.Count - 1)
+                {
+                    line2.Visible = false;
+                }
+
+                if ((currentKey.panelMode == 300) && i == 0)
+                {
+                    btnChoose.IsSelected = true;
+                    btnChoose.Visible = true;
+                    oldMode = btnChoose;
+                }
+                else if ((currentKey.panelMode == 301) && i == 1)
+                {
+                    btnChoose.IsSelected = true;
+                    btnChoose.Visible = true;
+                    oldMode = btnChoose;
+                }
+                else if ((currentKey.panelMode == 302) && i == 2)
+                {
+                    btnChoose.IsSelected = true;
+                    btnChoose.Visible = true;
+                    oldMode = btnChoose;
+                }
+                else if ((currentKey.panelMode == 303) && i == 3)
+                {
+                    btnChoose.IsSelected = true;
+                    btnChoose.Visible = true;
+                    oldMode = btnChoose;
+                }
+                else if ((currentKey.panelMode == 304) && i == 4)
+                {
+                    btnChoose.IsSelected = true;
+                    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) =>
+                {
+                    if (!btnChoose.IsSelected)
+                    {
+                        if (oldMode != null)
+                        {
+                            oldMode.IsSelected = false;
+                            oldMode.Visible = false;
+                        }
+                        oldMode = btnChoose;
+                        oldMode.IsSelected = true;
+                        oldMode.Visible = true;
+                        if (btnModeText.Text == Language.StringByID(R.MyInternationalizationString.WcdUp))
+                        {
+                            currentModeID = 300;
+                            currentKey.panelMode = currentModeID;
+                        }
+                        else if (btnModeText.Text == Language.StringByID(R.MyInternationalizationString.WcdDown))
+                        {
+                            currentModeID = 301;
+                            currentKey.panelMode = currentModeID;
+                        }
+                        else if (btnModeText.Text == Language.StringByID(R.MyInternationalizationString.WcdStop))
+                        {
+                            currentModeID = 302;
+                            currentKey.panelMode = currentModeID;
+                        }
+                        else if (btnModeText.Text == Language.StringByID(R.MyInternationalizationString.WcdUpStop))
+                        {
+                            currentModeID = 303;
+                            currentKey.panelMode = currentModeID;
+                        }
+                        else if (btnModeText.Text == Language.StringByID(R.MyInternationalizationString.WcdDownStop))
+                        {
+                            currentModeID = 304;
+                            currentKey.panelMode = currentModeID;
+                        }
+                    }
+                };
+                rowLayout.MouseUpEventHandler += hander;
+                btnModeText.MouseUpEventHandler += hander;
+                btnChoose.MouseUpEventHandler += hander;
+                i++;
+            }
+        }
+    }
+}

--
Gitblit v1.8.0