From 0f5a53c7b36c27a0f2bec12e6119207edb6860f8 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期二, 29 十月 2019 14:29:21 +0800
Subject: [PATCH] 修改主页卡死问题

---
 ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedContentForm.cs |  711 +++++++++++++++-------------------------------------------
 1 files changed, 188 insertions(+), 523 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedContentForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedContentForm.cs
index 5749ce1..03a1c54 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedContentForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedContentForm.cs
@@ -13,341 +13,6 @@
     {
         #region 鈻� 鍙橀噺澹版槑___________________________
 
-        ///// <summary>
-        ///// 璁惧鍒楄〃鎺т欢
-        ///// </summary>
-        //private VerticalScrolViewLayout listDeviceView = null;
-        ///// <summary>
-        ///// 鍦烘櫙鍒楄〃鎺т欢
-        ///// </summary>
-        //private VerticalScrolViewLayout listSceneView = null;
-        ///// <summary>
-        ///// 鎴愬憳淇℃伅
-        ///// </summary>
-        //private MemberInfoRes memberResult = null;
-
-        ///// <summary>
-        ///// 鎴块棿瀵硅薄
-        ///// </summary>
-        //private Common.Room room = null;
-        ///// <summary>
-        ///// Tab鐨勯�夋嫨銆�1锛氬姛鑳絋ab  2锛氬満鏅疶ab
-        ///// </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();
-
-        //    //鍒濆鍖朤ab鎺т欢
-        //    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(() =>
-        //    {
-        //        //鍒濆鍖栧姛鑳絋ab鍒楄〃
-        //        this.InitFunctionTabList();
-        //        //鍒濆鍖栧満鏅疶ab鍒楄〃
-        //        this.InitSceneTabList();
-        //    });
-        //}
-
-        #endregion
-
-        //#region 鈻� 鍒濆鍖朤ab鎺т欢______________________
-
-        ///// <summary>
-        ///// 鍒濆鍖朤ab鎺т欢
-        ///// </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>
-        ///// 鍒濆鍖栧姛鑳絋ab鍒楄〃
-        ///// </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>
-        ///// 鍒濆鍖栧満鏅疶ab鍒楄〃
-        ///// </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
-
-
-        #region 鈻� 鍙橀噺澹版槑___________________________
-
         /// <summary>
         /// 鏌ョ湅鐨勬埧闂村璞�
         /// </summary>
@@ -356,10 +21,6 @@
         /// 鎴愬憳鐨勫垎浜暟鎹�
         /// </summary>
         private MemberShardInfoData memberShardInfo = null;
-        /// <summary>
-        /// 褰撳墠閫夋嫨鐨勫垎鏀紝1锛氬満鏅�  2锛氬姛鑳�
-        /// </summary>
-        private int nowSelectIndex = 1;
         /// <summary>
         /// 璁惧妗屽竷鎺т欢
         /// </summary>
@@ -372,6 +33,22 @@
         /// 鍔熻兘鎸夐挳
         /// </summary>
         private BottomClickButton btnShard = null;
+        /// <summary>
+        /// 閫夋嫨鐨勫満鏅�
+        /// </summary>
+        private Dictionary<int, Common.SceneUI> dicSelectScene = new Dictionary<int, Common.SceneUI>();
+        /// <summary>
+        /// 閫夋嫨鐨勮澶�
+        /// </summary>
+        private Dictionary<string, CommonDevice> dicSelectDevice = new Dictionary<string, CommonDevice>();
+        /// <summary>
+        /// 褰撳墠閫夋嫨鐨勫垎鏀� 1锛氬満鏅�  2锛氬姛鑳�
+        /// </summary>
+        private int nowSwitchIndex = 1;
+        /// <summary>
+        /// 褰撳墠閫夋嫨鐨勮澶囩储寮�
+        /// </summary>
+        private string nowDeviceIndex = string.Empty;
 
         #endregion
 
@@ -400,9 +77,8 @@
         {
             //娓呯┖bodyFrame
             this.ClearBodyFrame();
-
-            //鍒濆鍖栧垎鏀帶浠�
-            this.InitSwitchControl();
+            this.dicSelectDevice = new Dictionary<string, CommonDevice>();
+            this.dicSelectScene = new Dictionary<int, Common.SceneUI>();
 
             //鍒濆鍖栨甯冩帶浠�
             this.frameSceneTable = new FrameLayout();
@@ -416,6 +92,9 @@
             bodyFrameLayout.AddChidren(frameDeviceTable);
             frameDeviceTable.Visible = false;
 
+            //鍒濆鍖栧垎鏀帶浠�
+            this.InitSwitchControl();
+
             //鎴块棿
             var btnRoom = new NormalViewControl(400, 63, true);
             btnRoom.Y = Application.GetRealHeight(40);
@@ -424,12 +103,15 @@
             btnRoom.TextAlignment = TextAlignment.CenterRight;
             bodyFrameLayout.AddChidren(btnRoom);
 
+            //鍒嗕韩鎸夐挳
             this.btnShard = new BottomClickButton();
             btnShard.TextID = R.MyInternationalizationString.uShared2;
             bodyFrameLayout.AddChidren(btnShard);
             btnShard.Visible = false;
             btnShard.ButtonClickEvent += (sender, e) =>
             {
+                //淇濆瓨鍒嗕韩
+                this.SaveShardData();
             };
 
             //鍒濆鍖栧満鏅垪琛�
@@ -443,95 +125,28 @@
         /// </summary>
         private void InitSwitchControl()
         {
-            var btnTemp = new NormalViewControl(10, 10, false);
-            btnTemp.TextID = R.MyInternationalizationString.uScence;
-
-            //鍦烘櫙妗�(鐐瑰嚮鑼冨洿鏈夌偣灏忥紝闇�瑕佹墿澶у畠鐨勭偣鍑昏寖鍥�)
-            var frameScene = new FrameLayoutControl();
-            frameScene.UseClickStatu = false;
-            frameScene.Height = Application.GetRealHeight(90);
-            frameScene.Width = btnTemp.GetRealWidthByText(16);
-            frameScene.X = ControlCommonResourse.XXLeft;
-            frameScene.Y = Application.GetRealHeight(40);
-            bodyFrameLayout.AddChidren(frameScene);
-            //鍦烘櫙
-            var btnScene = new NormalViewControl(frameScene.Width, Application.GetRealHeight(63), false);
-            btnScene.Text = btnTemp.Text;
-            btnScene.TextSize = 16;
-            btnScene.TextColor = UserCenterColor.Current.TextColor2;
-            frameScene.AddChidren(btnScene, ChidrenBindMode.BindEventOnly);
-            //搴曠嚎
-            var btnSceneLine = new NormalViewControl(40, 10, true);
-            btnSceneLine.Y = btnScene.Bottom + Application.GetRealHeight(14);
-            btnSceneLine.X = btnScene.X + btnScene.Width / 2 - Application.GetRealWidth(40) / 2;
-            btnSceneLine.Radius = (uint)Application.GetRealHeight(10) / 2;
-            btnSceneLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor;
-            frameScene.AddChidren(btnSceneLine, ChidrenBindMode.BindEventOnly);
-
-            btnTemp.TextID = R.MyInternationalizationString.uFunction;
-            //鍔熻兘妗�(鐐瑰嚮鑼冨洿鏈夌偣灏忥紝闇�瑕佹墿澶у畠鐨勭偣鍑昏寖鍥�)
-            var frameFunc = new FrameLayoutControl();
-            frameFunc.UseClickStatu = false;
-            frameFunc.Height = Application.GetRealHeight(90);
-            frameFunc.Width = btnTemp.GetRealWidthByText(16);
-            frameFunc.X = frameScene.Right + Application.GetRealWidth(58);
-            frameFunc.Y = Application.GetRealHeight(40);
-            bodyFrameLayout.AddChidren(frameFunc);
-            //鍔熻兘
-            var btnFunc = new NormalViewControl(frameFunc.Width, Application.GetRealHeight(63), false);
-            btnFunc.Text = btnTemp.Text;
-            btnFunc.TextColor = UserCenterColor.Current.TextGrayColor3;
-            frameFunc.AddChidren(btnFunc, ChidrenBindMode.BindEventOnly);
-            //搴曠嚎
-            var btnFuncLine = new NormalViewControl(40, 10, true);
-            btnFuncLine.Y = btnFunc.Bottom + Application.GetRealHeight(14);
-            btnFuncLine.X = btnFunc.X + btnFunc.Width / 2 - Application.GetRealWidth(40) / 2;
-            btnFuncLine.Radius = (uint)Application.GetRealHeight(10) / 2;
-            btnFuncLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor;
-            frameFunc.AddChidren(btnFuncLine, ChidrenBindMode.BindEventOnly);
-            btnFuncLine.Visible = false;
-
-            frameScene.ButtonClickEvent += (sender, e) =>
+            var tabControl = new SceneFunctionSwitchControl();
+            tabControl.Y = Application.GetRealHeight(40);
+            bodyFrameLayout.AddChidren(tabControl);
+            //璁剧疆鍒濆鍖栧��
+            tabControl.SetDefultIndex(nowSwitchIndex);
+            tabControl.SelectTabEvent += (tabIndex) =>
             {
-                //鍦烘櫙鍒嗘敮閫夋嫨
-                if (this.nowSelectIndex == 1)
+                this.nowSwitchIndex = tabIndex;
+                if (tabIndex == 1)
                 {
-                    return;
+                    //鏄剧ず鍦烘櫙鍒楄〃
+                    this.frameSceneTable.Visible = true;
+                    this.frameDeviceTable.Visible = false;
                 }
-                this.nowSelectIndex = 1;
-
-                btnScene.TextSize = 16;
-                btnScene.TextColor = UserCenterColor.Current.TextColor2;
-                btnFunc.TextSize = 14;
-                btnFunc.TextColor = UserCenterColor.Current.TextGrayColor3;
-                btnSceneLine.Visible = true;
-                btnFuncLine.Visible = false;
-
-                //鏄剧ず鍦烘櫙鍒楄〃
-                this.frameSceneTable.Visible = true;
-                this.frameDeviceTable.Visible = false;
-            };
-
-            frameFunc.ButtonClickEvent += (sender, e) =>
-            {
-                //鍔熻兘鍒嗘敮閫夋嫨
-                if (this.nowSelectIndex == 2)
+                else
                 {
-                    return;
+                    //鏄剧ず鍔熻兘鍒楄〃
+                    this.frameSceneTable.Visible = false;
+                    this.frameDeviceTable.Visible = true;
                 }
-                this.nowSelectIndex = 2;
-
-                btnScene.TextSize = 14;
-                btnScene.TextColor = UserCenterColor.Current.TextGrayColor3;
-                btnFunc.TextSize = 16;
-                btnFunc.TextColor = UserCenterColor.Current.TextColor2;
-                btnFuncLine.Visible = true;
-                btnSceneLine.Visible = false;
-
-                //鏄剧ず鍔熻兘鍒楄〃
-                this.frameSceneTable.Visible = false;
-                this.frameDeviceTable.Visible = true;
             };
+            tabControl.InitControl();
         }
 
         #endregion
@@ -546,14 +161,39 @@
             //娓呯┖妗屽竷
             this.frameSceneTable.RemoveAll();
 
-            var listView = new VerticalFrameControl(29);
-            listView.Y = Application.GetRealHeight(53);
-            listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(187);
-            frameSceneTable.AddChidren(listView);
+            //鍦烘櫙鏈夌偣鐗规畩,濡傛灉鍚屼竴涓埧闂村唴,宸茬粡鍒嗕韩浜�,鍒欎笉鍐嶆樉绀� 
+            //濡傛灉杩欎釜鍦烘櫙鏄敱宓屽鑰屽垎浜殑,杩欎釜鏃跺��,瀹冨彲浠ユ樉绀哄嚭鏉�
+            var listScene = new List<Common.SceneUI>();
+            if (memberShardInfo.dicShardRoom.ContainsKey(lookRoom.FileName) == false)
+            {
+                listScene.AddRange(lookRoom.SceneUIList);
+            }
+            else
+            {
+                var tempRoom = memberShardInfo.dicShardRoom[lookRoom.FileName];
+                foreach (var data in lookRoom.SceneUIList)
+                {
+                    if (tempRoom.SceneUIFilePathList.Contains(data.FileName) == false)
+                    {
+                        listScene.Add(data);
+                    }
+                }
+            }
+            if (listScene.Count == 0)
+            {
+                //鏃犲彲鍏变韩鐨勫満鏅�
+                this.ShowNotDataImage(frameSceneTable, Language.StringByID(R.MyInternationalizationString.uNotCanShardSceneMsg), "Item/NotShardPic.png", 383, 279);
+                return;
+            }
 
             HdlThreadLogic.Current.RunMainInThread(() =>
             {
-                foreach (var data in lookRoom.SceneUIList)
+                var listView = new VerticalFrameControl(29);
+                listView.Y = Application.GetRealHeight(53);
+                listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(187);
+                frameSceneTable.AddChidren(listView);
+
+                foreach (var data in listScene)
                 {
                     //鍦烘櫙鍥剧墖
                     var frameContr = new FrameLayoutControl();
@@ -570,9 +210,30 @@
                     btnSelect.X = Application.GetRealWidth(786);
                     btnSelect.Y = Application.GetRealHeight(35);
                     frameContr.AddChidren(btnSelect, ChidrenBindMode.BindEventOnly);
+                    if (dicSelectScene.ContainsKey(data.Id) == true)
+                    {
+                        btnSelect.IsSelected = true;
+                    }
                     frameContr.ButtonClickEvent += (sender, e) =>
                     {
+                        //閫夋嫨
                         btnSelect.IsSelected = !btnSelect.IsSelected;
+                        if (btnSelect.IsSelected == true)
+                        {
+                            dicSelectScene[data.Id] = data;
+                            if (this.btnShard.Visible == false)
+                            {
+                                this.btnShard.Visible = true;
+                            }
+                        }
+                        else
+                        {
+                            dicSelectScene.Remove(data.Id);
+                            if (dicSelectScene.Count == 0 && dicSelectDevice.Count == 0)
+                            {
+                                this.btnShard.Visible = false;
+                            }
+                        }
                     };
                 }
             });
@@ -590,26 +251,33 @@
             //娓呯┖妗屽竷
             this.frameDeviceTable.RemoveAll();
 
-            var frameBack = new FrameLayoutControl(false);
-            frameBack.X = ControlCommonResourse.XXLeft;
-            frameBack.Y = Application.GetRealHeight(178);
-            frameBack.BackgroundColor = UserCenterColor.Current.White;
-            frameBack.Width = bodyFrameLayout.Width;
-            frameBack.Height = Application.GetRealHeight(1650);
-            frameBack.RadiusEx = 20;
-            frameDeviceTable.AddChidren(frameBack);
-
-            var listView = new VerticalListControl(23);
-            listView.Y = Application.GetRealHeight(23);
-            listView.Height = Application.GetRealHeight(1437 - 23);
-            frameBack.AddChidren(listView);
-
             HdlThreadLogic.Current.RunMainInThread(() =>
             {
                 //鑾峰彇鍒嗙粍鍚庣殑璁惧鍒楄〃
                 var dicGroupDevice = this.GetAllGroupDevice();
-                //鍒濆鍖栬澶囩被鍨嬭
-                this.InitDeviceObjectRow(dicGroupDevice, listView);
+                if (dicGroupDevice.Count == 0)
+                {
+                    //鏃犲彲鍏变韩鐨勮澶�
+                    this.ShowNotDataImage(frameDeviceTable, Language.StringByID(R.MyInternationalizationString.uNotCanShardDeviceMsg), "Item/NotShardPic.png", 383, 279);
+                }
+                else
+                {
+                    var frameBack = new FrameLayoutControl(false);
+                    frameBack.X = ControlCommonResourse.XXLeft;
+                    frameBack.Y = Application.GetRealHeight(178);
+                    frameBack.BackgroundColor = UserCenterColor.Current.White;
+                    frameBack.Width = bodyFrameLayout.Width;
+                    frameBack.Height = Application.GetRealHeight(1650);
+                    frameBack.RadiusEx = 20;
+                    frameDeviceTable.AddChidren(frameBack);
+
+                    var listView = new VerticalListControl(23);
+                    listView.Y = Application.GetRealHeight(23);
+                    listView.Height = Application.GetRealHeight(1437 - 23);
+                    frameBack.AddChidren(listView);
+                    //鍒濆鍖栬澶囩被鍨嬭
+                    this.InitDeviceObjectRow(dicGroupDevice, listView);
+                }
             });
         }
 
@@ -624,82 +292,17 @@
         /// <param name="listView"></param>
         private void InitDeviceObjectRow(Dictionary<int, List<CommonDevice>> dicData, VerticalListControl listView)
         {
-            var scrolContr = new HorizontalScrolViewLayout();
-            scrolContr.X = ControlCommonResourse.XXLeft / 2;
-            scrolContr.Width = bodyFrameLayout.Width - ControlCommonResourse.XXLeft / 2;
-            scrolContr.Height = Application.GetRealHeight(160);
+            var scrolContr = new RoomDeviceGroupMenuControl(dicData);
             this.frameDeviceTable.AddChidren(scrolContr);
-
-            int oldTextId = 0;
-            FrameLayout oldFrameBack = null;
-            NormalViewControl oldBtnText = null;
-
-            foreach (int textId in dicData.Keys)
+            //璁剧疆鍒濆鍊�
+            scrolContr.SetDefultIndex(nowDeviceIndex);
+            scrolContr.SelectDeviceEvent += (listdevice) =>
             {
-                var frameMain = new FrameLayout();
-                frameMain.Height = scrolContr.Height;
-                frameMain.Width = Application.GetRealWidth(250) + ControlCommonResourse.XXLeft;
-                scrolContr.AddChidren(frameMain);
-                var frameBack = new FrameLayoutControl();
-                frameBack.UseClickStatu = false;
-                frameBack.Gravity = Gravity.CenterHorizontal;
-                frameBack.Height = frameMain.Height;
-                frameBack.Width = Application.GetRealWidth(187);
-                if (scrolContr.ChildrenCount == 1)
-                {
-                    oldTextId = textId;
-                    frameBack.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png";
-                    oldFrameBack = frameBack;
-                }
-                else
-                {
-                    frameBack.BackgroundImagePath = "Item/RoomIconBackground.png";
-                }
-                frameMain.AddChidren(frameBack);
-                var btnText = new NormalViewControl(frameBack.Width - frameBack.Height, frameBack.Height, false);
-                btnText.Gravity = Gravity.CenterHorizontal;
-                btnText.TextID = textId;
-                btnText.TextSize = 12;
-                btnText.TextAlignment = TextAlignment.Center;
-                if (scrolContr.ChildrenCount == 1)
-                {
-                    btnText.TextColor = UserCenterColor.Current.White;
-                    oldBtnText = btnText;
-                }
-                else
-                {
-                    btnText.TextColor = UserCenterColor.Current.TextGrayColor1;
-                }
-                frameBack.AddChidren(btnText, ChidrenBindMode.BindEventOnly);
-
-                frameBack.ButtonClickEvent += (sender, e) =>
-                {
-                    if (oldTextId == textId)
-                    {
-                        //鍚屼竴涓笢瑗�
-                        return;
-                    }
-                    oldTextId = textId;
-
-                    //鐘舵�佸彉鏇�
-                    frameBack.BackgroundImagePath = "Room/RoomIconBackgroundSelected.png";
-                    btnText.TextColor = UserCenterColor.Current.White;
-
-                    oldFrameBack.BackgroundImagePath = "Room/RoomIconBackground.png";
-                    oldBtnText.TextColor = UserCenterColor.Current.TextGrayColor1;
-                    oldFrameBack = frameBack;
-                    oldBtnText = btnText;
-                    //娣诲姞璁惧琛�
-                    this.AddDeviceRow(dicData[textId], listView);
-                };
-            }
-
-            //娣诲姞璁惧琛�
-            foreach (int textId in dicData.Keys)
-            {
-                this.AddDeviceRow(dicData[textId], listView);
-                break;
-            }
+                this.nowDeviceIndex = scrolContr.nowSelectKeys;
+                //娣诲姞璁惧琛�
+                this.AddDeviceRow(listdevice, listView);
+            };
+            scrolContr.InitControl();
         }
 
         #endregion
@@ -718,7 +321,6 @@
             foreach (var device in listDevice)
             {
                 var frameRow = new FrameRowControl(listView.rowSpace / 2);
-                frameRow.UseClickStatu = false;
                 frameRow.LeftOffset = Application.GetRealWidth(46) - ControlCommonResourse.XXLeft;
                 frameRow.RightOffset = -ControlCommonResourse.XXLeft;
                 listView.AddChidren(frameRow);
@@ -735,10 +337,32 @@
                 var btnSelect = frameRow.AddMostRightEmptyIcon(69, 69);
                 btnSelect.UnSelectedImagePath = "Item/ItemUnSelected.png";
                 btnSelect.SelectedImagePath = "Item/ItemSelected.png";
-                frameRow.ChangedChidrenBindMode(btnSelect, ChidrenBindMode.NotBind);
-                btnSelect.ButtonClickEvent += (sender, e) =>
+
+                string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
+                if (dicSelectDevice.ContainsKey(mainKeys) == true)
                 {
+                    btnSelect.IsSelected = true;
+                }
+                frameRow.ButtonClickEvent += (sender, e) =>
+                {
+                    //閫夋嫨
                     btnSelect.IsSelected = !btnSelect.IsSelected;
+                    if (btnSelect.IsSelected == true)
+                    {
+                        dicSelectDevice[mainKeys] = device;
+                        if (this.btnShard.Visible == false)
+                        {
+                            this.btnShard.Visible = true;
+                        }
+                    }
+                    else
+                    {
+                        dicSelectDevice.Remove(mainKeys);
+                        if (dicSelectScene.Count == 0 && dicSelectDevice.Count == 0)
+                        {
+                            this.btnShard.Visible = false;
+                        }
+                    }
                 };
             }
         }
@@ -758,6 +382,11 @@
             var dic = new Dictionary<int, List<CommonDevice>>();
             foreach (var device in listDevice)
             {
+                if (memberShardInfo.dicAllShardKeys.ContainsKey(device.FilePath) == true)
+                {
+                    //濡傛灉宸茬粡鍒嗕韩浜�,鍒欎笉鏄剧ず
+                    continue;
+                }
                 var typeInfo = Common.LocalDevice.Current.GetNotHdlMyDeviceEnumInfo(new List<ZigBee.Device.CommonDevice>() { device });
                 if (device.Type == DeviceType.IASZone)
                 {
@@ -803,5 +432,41 @@
         }
 
         #endregion
+
+        #region 鈻� 淇濆瓨鍒嗕韩___________________________
+
+        /// <summary>
+        /// 淇濆瓨鍒嗕韩
+        /// </summary>
+        private void SaveShardData()
+        {
+            //閫夋嫨鐨勮澶�
+            var listDevice = new List<CommonDevice>();
+            foreach (var device in dicSelectDevice.Values)
+            {
+                listDevice.Add(device);
+            }
+            //閫夋嫨鐨勫満鏅�
+            var listScene = new List<Common.SceneUI>();
+            foreach (var scene in dicSelectScene.Values)
+            {
+                listScene.Add(scene);
+            }
+            HdlThreadLogic.Current.RunThread(async () =>
+            {
+                //涓婁紶鏂囦欢
+                var result = await HdlShardLogic.Current.DoUploadSharedContent(memberShardInfo, this.lookRoom, listDevice, listScene);
+                if (result == true)
+                {
+                    HdlThreadLogic.Current.RunMain(() =>
+                    {
+                        //閲嶆柊鍒濆鍖栫晫闈�
+                        this.InitMiddleFrame();
+                    });
+                }
+            });
+        }
+
+        #endregion
     }
 }

--
Gitblit v1.8.0