From d5b9ff8bf8cc36f5b13c46b66682f5988d3a6f36 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 15 五月 2020 11:36:11 +0800
Subject: [PATCH] 2020-05-15-1

---
 ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs |  248 +++++++++++++++++-------------------------------
 1 files changed, 89 insertions(+), 159 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs b/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs
old mode 100644
new mode 100755
index 2f34fb8..3b5ffb5
--- a/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs
@@ -16,140 +16,69 @@
         {
             Tag = "Logic";
         }
+     
+        ///鎴块棿婊戝姩鎺т欢
+        public HorizontalScrolViewLayout roomhorizontalScrol = new HorizontalScrolViewLayout
+        {
+            Width = Application.GetRealWidth(1080 - 58),
+            Height = Application.GetRealHeight(200),
+            Y = Application.GetRealHeight(184),
+            X = Application.GetRealWidth(58),
+        };
+        public VerticalScrolViewLayout middle = new VerticalScrolViewLayout
+        {
+            Width = Application.GetRealWidth(1080),
+            Height = Application.GetRealHeight(Method.H - 260 - 200 - 184),
+            BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
+        };
+
         Button roombjButton = new Button();
         Button roomTextButton = new Button();
         Button clickbutton = new Button();
-        HorizontalScrolViewLayout roomhorizontalScrol;
-        VerticalScrolViewLayout middle;
         public string clickTag = "no";
         public SceneUI tempScene = null;
         Dictionary<string, object> actionsInfo = new Dictionary<string, object>();
-        public void Show()
+        public void Show(string sceneType)
         {
+            #region  涓婇潰鐨勫竷灞�浠g爜
             UserView.HomePage.Instance.ScrollEnabled = false;
             this.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor;
-            #region  鏈�涓婇潰鐨勫竷灞�浠g爜
-            var topRowLayout = new RowLayout
+            TopView view = new TopView();
+            this.AddChidren(view.TopRowView(true));
+            view.toptitleNameBtn.TextID =MyInternationalizationString.addscene;
+            view.clickBtn.MouseDownEventHandler += (sender, e) =>
             {
-                BackgroundColor = ZigbeeColor.Current.LogicTopBackgroundColor,
-                Height = Application.GetRealHeight(184),
-                LineColor = ZigbeeColor.Current.LogicRowLayoutTopLineColor,
-            };
-            this.AddChidren(topRowLayout);
-
-            var titleName = new Button
-            {
-                TextSize = 17,
-                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
-                TextAlignment = TextAlignment.CenterLeft,
-                X = Application.GetRealWidth(160),
-                Width = Application.GetRealWidth(600),
-                Height = Application.GetRealHeight(69),
-                Y = Application.GetRealHeight(92),
-                TextID = MyInternationalizationString.addscene,
-                IsBold = true,
-            };
-            topRowLayout.AddChidren(titleName);
-
-            var clickBtn = new Button
-            {
-                Width = Application.GetRealWidth(81 + 51),
-                Height = Application.GetRealHeight(58 + 40),
-                Y = Application.GetRealHeight(98 - 40),
-            };
-            topRowLayout.AddChidren(clickBtn);
-            clickBtn.MouseDownEventHandler += (sender, e) =>
-            {
-                RemoveFromParent();
                 UserView.HomePage.Instance.ScrollEnabled = true;
-            };
-
-            var back = new Button
-            {
-                Width = Application.GetRealWidth(30),
-                Height = Application.GetRealHeight(51),
-                X = Application.GetRealWidth(81),
-                Y = Application.GetRealHeight(98),
-                //Gravity = Gravity.CenterVertical;
-                UnSelectedImagePath = "ZigeeLogic/back.png",
-            };
-            topRowLayout.AddChidren(back);
-            back.MouseDownEventHandler += (sender, e) => {
                 RemoveFromParent();
-                UserView.HomePage.Instance.ScrollEnabled = true;
             };
-
-            var foolrname = new Button
+            view.foolrnameBtn.Text = Config.Instance.Home.GetCurrentFloorName;
+            if (Config.Instance.Home.FloorDics.Count < 2)
             {
-                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
-                TextAlignment = TextAlignment.CenterRight,
-                X = Application.GetRealWidth(1080 - 400 - 120),
-                Width = Application.GetRealWidth(400),
-                Height = Application.GetRealHeight(69),
-                Y = Application.GetRealHeight(92),
-                //TextID = MyInternationalizationString.customroom,
-                Text = Config.Instance.Home.GetCurrentFloorName,
-                TextSize = 14,
-            };
-            topRowLayout.AddChidren(foolrname);
-            var dropdown = new Button
+                ///娌℃湁妤煎眰鎴栬�呭彧鏈変竴涓ゼ灞傦紝榛樿涓嶆樉绀哄浘鏍囧拰鏂囨湰;
+                view.foolrnameBtn.Visible = false;
+                view.dropdownBtn.Visible = false;
+                view.foolrclickBtn.Visible = false;
+            }
+            if (Config.Instance.Home.FloorDics.Count == 0)
             {
-                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
-                TextAlignment = TextAlignment.CenterRight,
-                X = foolrname.Right,
-                Width = Application.GetRealWidth(72),
-                Height = Application.GetRealHeight(72),
-                Y = Application.GetRealHeight(92),
-                UnSelectedImagePath = "ZigeeLogic/drop-down.png",
-            };
-            topRowLayout.AddChidren(dropdown);
+                Config.Instance.Home.CurrentFloorId = "";
+            }
             #endregion
-        
+
             ///娌℃湁鎴块棿鐩存帴杩斿洖鍘伙紱
-            if (Common.Room.Lists.Count == 0)
+            var listAllRoom = UserCenter.HdlRoomLogic.Current.GetAllListRooms();
+            if (listAllRoom.Count == 0)
             {
                 return;
             }
-            ///鎴块棿婊戝姩鎺т欢
-             roomhorizontalScrol = new HorizontalScrolViewLayout()
-            {
-                Width = Application.GetRealWidth(1080 - 58),
-                Height = Application.GetRealHeight(200),
-                Y = topRowLayout.Bottom,
-                X = Application.GetRealWidth(58),
-            };
+         
             this.AddChidren(roomhorizontalScrol);
-
-
-
-            middle = new VerticalScrolViewLayout();
             middle.Y = roomhorizontalScrol.Bottom;
-            middle.Height = Application.GetRealHeight(1920 - 260 - 200 - 184);
-            middle.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor;
             this.AddChidren(middle);
-
-            var saveframeLayout = new FrameLayout
-            {
-                Y = middle.Bottom,
-                Height = Application.GetRealHeight(260),
-                BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
-            };
-            this.AddChidren(saveframeLayout);
-
-            var btnsave = new Button
-            {
-                X = Application.GetRealWidth(85),
-                Height = Application.GetRealHeight(130),
-                Width = Application.GetRealWidth(910),
-                Radius = (uint)Application.GetRealHeight(60),
-                BackgroundColor = ZigbeeColor.Current.LogicBtnSaveBackgroundColor,
-                TextID = MyInternationalizationString.Save,
-                TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor,
-                TextSize = 16,
-            };
-            saveframeLayout.AddChidren(btnsave);
-
-            btnsave.MouseUpEventHandler += (sender2, e2) =>
+            LogicView.SaveView saveView = new LogicView.SaveView();
+            saveView.frameLayout.Y = middle.Bottom;
+            this.AddChidren(saveView.Show());
+            saveView.clickviewBtn.MouseUpEventHandler += (sender2, e2) =>
             {
                 if (clickTag == "no" || tempScene == null)
                 {
@@ -165,17 +94,26 @@
                 }
                 actionsInfo.Add("LinkType", 2);
                 LogicIfon.AddSceneactions(tempScene, actionsInfo);
-                var logicCommunalPage = new LogicCommunalPage();
-                UserView.HomePage.Instance.AddChidren(logicCommunalPage);
-                UserView.HomePage.Instance.PageIndex += 1;
-                logicCommunalPage.Show(() => { });
+                if (sceneType ==LogicView.IfString.Action_LogicScene)
+                {
+                    //鑷姩鍖栧満鏅�
+                    var logicCommunalPage = new LogicCommunalPage();
+                    UserView.HomePage.Instance.AddChidren(logicCommunalPage);
+                    UserView.HomePage.Instance.PageIndex += 1;
+                    logicCommunalPage.Show(() => { });
+                }
+                else {
+                    //闂ㄩ攣鍦烘櫙
+                    var lockLogicCommunalPage = new DoorLockLogic.LockLogicCommunalPage();
+                    UserView.HomePage.Instance.AddChidren(lockLogicCommunalPage);
+                    UserView.HomePage.Instance.PageIndex += 1;
+                    lockLogicCommunalPage.Show(() => { });
+                }
 
             };
 
-         
-
             ///妤煎眰鐐瑰嚮浜嬩欢
-            EventHandler<MouseEventArgs> foorlclick = (sender, e) =>
+            view.foolrclickBtn.MouseUpEventHandler += (sender, e) =>
             {
 
                 var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor };
@@ -228,8 +166,8 @@
 
                     var btnfoolricon = new Button
                     {
-                        Width = Application.GetRealWidth(81),
-                        Height = Application.GetRealHeight(81),
+                        Width = Application.GetMinRealAverage(81),
+                        Height = Application.GetMinRealAverage(81),
                         UnSelectedImagePath = "Floor/Floor.png",
                         Gravity = Gravity.CenterVertical,
                     };
@@ -248,7 +186,7 @@
                         TextSize = 14,
                     };
                     foolrRowLayout.AddChidren(btnfoolrname);
-                    if (foolrname.Text == foolr.Value)
+                    if (view.foolrnameBtn.Text == foolr.Value)
                     {
                         btnfoolricon.UnSelectedImagePath = "Floor/FloorSelected.png";
                         btnfoolrname.TextColor = ZigbeeColor.Current.LogicTextBlackColor;
@@ -257,10 +195,10 @@
                     EventHandler<MouseEventArgs> foolrnameclick = (sender13, e13) =>
                     {
                         roomhorizontalScrol.RemoveAll();
-                        foolrname.Text = btnfoolrname.Text;
+                        view.foolrnameBtn.Text = btnfoolrname.Text;
                         middle.RemoveAll();
                         flMain.RemoveFromParent();
-                        var list = Send.GetRoomList(btnfoolrname.Tag.ToString());
+                        var list = Method.GetRoomList(sceneType, btnfoolrname.Tag.ToString());
                         AllRoomView(list);
 
                     };
@@ -271,32 +209,13 @@
                 }
 
             };
-            foolrname.MouseUpEventHandler += foorlclick;
-            dropdown.MouseUpEventHandler += foorlclick;
-
-            ///绗竴娆¤繘鏉�
-            var roomlists = new List<Common.Room>();
-            roomlists.Clear();
-            if (Config.Instance.Home.FloorDics.Count < 2)
+            ///鎴块棿鍒楄〃
+            var roomlists = Method.GetRoomList(sceneType, Config.Instance.Home.CurrentFloorId);
+            if (roomlists.Count == 0)
             {
-                foolrname.Visible = false;
-                dropdown.Visible = false;
-                if (Config.Instance.Home.FloorDics.Count == 0)
-                {
-                    roomlists.AddRange(Common.Room.Lists);
-                }
-                else
-                {
-                    roomlists = Send.GetRoomList(Config.Instance.Home.CurrentFloorId);
-                }
+                ///娌℃湁鎴块棿鐩存帴杩斿洖鍘伙紱
+                return;
             }
-            else
-            {
-                roomlists = Send.GetRoomList(Config.Instance.Home.CurrentFloorId);
-
-            }
-
-
             ///绗竴娆¤繘鏉�
             AllRoomView(roomlists);
 
@@ -349,7 +268,7 @@
                     roomTextButton.IsSelected = false;
                     roomTextButton = roomnameBtn;
                     roomnameBtn.IsSelected = true;
-                    SceneView(room.SceneUIList);
+                    SceneView(room.ListSceneId);
 
                 }
 
@@ -367,7 +286,7 @@
                     roomTextButton.IsSelected = false;
                     roomTextButton = roomnameBtn;
                     roomnameBtn.IsSelected = true;
-                    SceneView(room.SceneUIList);
+                    SceneView(room.ListSceneId);
                 };
                 roomnameBtn.MouseUpEventHandler += roomclick;
                 roombjBtn.MouseUpEventHandler += roomclick;
@@ -378,11 +297,16 @@
         /// 鏄剧ず鎵�鏈夌殑鍦烘櫙鐨勬柟娉�
         /// </summary>
         /// <param name="scenelist"></param>
-        void SceneView(List<SceneUI>scenelist)
+        void SceneView(List<int>scenelist)
         {
             middle.RemoveAll();
-            foreach (var scene in scenelist)
+            foreach (var sceneId in scenelist)
             {
+                var scene = UserCenter.HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId);
+                if (scene == null)
+                {
+                    continue;
+                }
                 var sceneFramelayout = new FrameLayout
                 {
                     Height = Application.GetRealHeight(160),
@@ -390,11 +314,10 @@
                 };
                 middle.AddChidren(sceneFramelayout);
 
-
                 var sceneIconBtn = new Button
                 {
-                    Width = Application.GetRealWidth(81),
-                    Height = Application.GetRealHeight(81),
+                    Width = Application.GetMinRealAverage(81),
+                    Height = Application.GetMinRealAverage(81),
                     X = Application.GetRealWidth(58),
                     Y = Application.GetRealHeight(55),
                     UnSelectedImagePath = "ZigeeLogic/scene.png",
@@ -408,8 +331,7 @@
                     Width = Application.GetRealWidth(850),
                     Height = Application.GetRealHeight(130),
                     X = Application.GetRealWidth(176 + 10),
-                    LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
-
+                    LineColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
                 };
                 sceneFramelayout.AddChidren(sceneRow);
 
@@ -425,15 +347,23 @@
 
                 var selectedBtn = new Button
                 {
-                    Width = Application.GetRealWidth(58),
-                    Height = Application.GetRealHeight(58),
+                    Width = Application.GetMinRealAverage(60),
+                    Height = Application.GetMinRealAverage(60),
                     X = Application.GetRealWidth(789),
                     UnSelectedImagePath = "ZigeeLogic/selected.png",
                     Visible = false,
                     Gravity = Gravity.CenterVertical,
                 };
                 sceneRow.AddChidren(selectedBtn);
-
+                var lineBtn = new Button
+                {
+                    Y = sceneFramelayout.Height - 1,
+                    Width = Application.GetRealWidth(850),
+                    Height = 1,
+                    X = Application.GetRealWidth(176 + 10),
+                    BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
+                };
+                sceneFramelayout.AddChidren(lineBtn);
                 EventHandler<MouseEventArgs> sceneclick = (sender, e) =>
                 {
                     tempScene = scene;

--
Gitblit v1.8.0