From 9f326f4000847e6167d8166fa2f6a66f53cb3734 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 17 十二月 2020 09:07:13 +0800
Subject: [PATCH] 新云端Ver1.3

---
 ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs |  415 +++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 302 insertions(+), 113 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs b/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs
index 0a8c985..ee0245f 100755
--- a/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs
@@ -12,184 +12,373 @@
     public class AddScenePage : FrameLayout
     {
 
-        Button roomname;
         public AddScenePage()
         {
             Tag = "Logic";
         }
-        public void Show()
+     
+        ///鎴块棿婊戝姩鎺т欢
+        public HorizontalScrolViewLayout roomhorizontalScrol = new HorizontalScrolViewLayout
         {
-            this.BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor;
+            Width = Application.GetRealWidth(1080 - 58),
+            Height = Application.GetRealHeight(204),
+            Y = Application.GetRealHeight(184),
+            X = Application.GetRealWidth(58),
+        };
+        public VerticalScrolViewLayout middle = new VerticalScrolViewLayout
+        {
+            Width = Application.GetRealWidth(1080),
+            Height = Application.GetRealHeight(Method.H - 260 - 204 - 184),
+            BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
+        };
 
-            var topFrameLayout = new FrameLayout
+        Button roombjButton = new Button();
+        Button roomTextButton = new Button();
+        Button clickbutton = new Button();
+        public string clickTag = "no";
+        public SceneUI tempScene = null;
+        Dictionary<string, object> actionsInfo = new Dictionary<string, object>();
+        public void Show(string sceneType)
+        {
+            #region  涓婇潰鐨勫竷灞�浠g爜
+            UserView.HomePage.Instance.ScrollEnabled = false;
+            this.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor;
+            TopView view = new TopView();
+            this.AddChidren(view.TopRowView(true));
+            view.toptitleNameBtn.TextID =MyInternationalizationString.addscene;
+            view.clickBtn.MouseDownEventHandler += (sender, e) =>
             {
-                Height = Application.GetRealHeight(220),
-                Y = Application.GetRealHeight(80),
-            };
-
-            AddChidren(topFrameLayout);
-
-            var titleName = new Button
-            {
-                //Text = "娣诲姞鍦烘櫙",
-                TextID = MyInternationalizationString.addscene,
-                TextSize = 17,
-                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
-            };
-            topFrameLayout.AddChidren(titleName);
-
-            var back = new Button
-            {
-                Width = Application.GetRealWidth(110),
-                Height = Application.GetRealHeight(110),
-                X = Application.GetRealWidth(20),
-                Gravity = Gravity.CenterVertical,
-                UnSelectedImagePath = "ZigeeLogic/Back.png",
-            };
-            topFrameLayout.AddChidren(back);
-            back.MouseDownEventHandler += (sender, e) =>
-            {
+                UserView.HomePage.Instance.ScrollEnabled = true;
                 RemoveFromParent();
             };
-
-            roomname = new Button
+            view.foolrnameBtn.Text = Config.Instance.Home.GetCurrentFloorName;
+            if (Config.Instance.Home.FloorDics.Count < 2)
             {
-                Width = Application.GetMinRealAverage(300 + 300),
-                Height = Application.GetMinRealAverage(80),
-                X = Application.GetRealWidth(1080 - 300 - 30 - 300),
-                Y = Application.GetRealHeight(120),
-                TextAlignment = TextAlignment.CenterRight,
-                //Text = "鑷畾涔夋埧闂�",
-                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
-                TextID=MyInternationalizationString.customroom,
-            };
-            topFrameLayout.AddChidren(roomname);
+                ///娌℃湁妤煎眰鎴栬�呭彧鏈変竴涓ゼ灞傦紝榛樿涓嶆樉绀哄浘鏍囧拰鏂囨湰;
+                view.foolrnameBtn.Visible = false;
+                view.dropdownBtn.Visible = false;
+                view.foolrclickBtn.Visible = false;
+            }
+            if (Config.Instance.Home.FloorDics.Count == 0)
+            {
+                Config.Instance.Home.CurrentFloorId = "";
+            }
+            #endregion
 
-            var middle = new VerticalScrolViewLayout();
-            middle.Y = topFrameLayout.Bottom;
-            middle.Height = Application.GetRealHeight(1920 - 300);
-            middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
+            ///娌℃湁鎴块棿鐩存帴杩斿洖鍘伙紱
+            var listAllRoom = HdlRoomLogic.Current.GetAllListRooms();
+            if (listAllRoom.Count == 0)
+            {
+                return;
+            }
+         
+            this.AddChidren(roomhorizontalScrol);
+            middle.Y = roomhorizontalScrol.Bottom;
             this.AddChidren(middle);
-
-            roomname.MouseUpEventHandler += (sender, e) =>
+            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)
+                {
+                    var alert = new ShowMsgControl(ShowMsgType.Normal,
+                          Language.StringByID(MyInternationalizationString.scenetip),
+                          Language.StringByID(MyInternationalizationString.confrim));
+                    alert.Show();
+                    return;
+                }
+                if (actionsInfo.ContainsKey("LinkType"))
+                {
+                    actionsInfo.Remove("LinkType");
+                }
+                actionsInfo.Add("LinkType", 2);
+                LogicIfon.AddSceneactions(tempScene, actionsInfo);
+                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(() => { });
+                }
+
+            };
+
+            ///妤煎眰鐐瑰嚮浜嬩欢
+            view.foolrclickBtn.MouseUpEventHandler += (sender, e) =>
+            {
+
                 var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor };
                 this.AddChidren(flMain);
                 flMain.MouseUpEventHandler += (sender2, e2) =>
                 {
                     flMain.RemoveFromParent();
                 };
-                var roombj = new VerticalScrolViewLayout
+                var foolrbjicon = new FrameLayout
                 {
 
-                    Width = Application.GetRealWidth(400),
-                    Height = Application.GetRealHeight(600),
-                    X = Application.GetRealWidth(1080 - 400 - 60),
-                    Y = Application.GetRealHeight(220 + 30 + 80),
-                    BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
-                    Radius = (uint)Application.GetRealHeight(30),
+                    Width = Application.GetRealWidth(450),
+                    Height = Application.GetRealHeight(780),
+                    X = Application.GetRealWidth(1080 - 468 - 35),
+                    Y = Application.GetRealHeight(184),
+                    BackgroundImagePath = "Item/SelectFloor_Right.png",
                 };
-                flMain.AddChidren(roombj);
-                List<Common.Room> roomlist = new List<Common.Room>();
-                roomlist.Clear();
-                Common.Room customroom = new Common.Room();
-                //铏氭嫙涓�涓埧闂村姞杞芥湰鍦版墍鏈夊満鏅紱
-                customroom.SceneUIList.AddRange(Common.Room.AllRoomSceneUIList);
-                customroom.Name =Language.StringByID(MyInternationalizationString.customroom);
-                roomlist.Add(customroom);
-                roomlist.AddRange(Common.Room.Lists);
-                foreach (var room in roomlist)
+                flMain.AddChidren(foolrbjicon);
+
+                var btnfoolrtext = new Button
                 {
-                    var rowLayout = new RowLayout
+                    Width = Application.GetRealWidth(450),
+                    Height = Application.GetRealHeight(150),
+                    TextAlignment = TextAlignment.CenterLeft,
+                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
+                    X = Application.GetRealWidth(80),
+                    TextID = MyInternationalizationString.selecfoolr,
+                    TextSize = 14,
+                };
+                foolrbjicon.AddChidren(btnfoolrtext);
+
+                var foolrbj = new VerticalScrolViewLayout
+                {
+
+                    Width = Application.GetRealWidth(450),
+                    Height = foolrbjicon.Height - btnfoolrtext.Height,
+                    X = Application.GetRealWidth(80),
+                    Y = btnfoolrtext.Bottom,
+                };
+                foolrbjicon.AddChidren(foolrbj);
+
+                foreach (var foolr in Config.Instance.Home.FloorDics)
+                {
+                    var foolrRowLayout = new RowLayout
                     {
                         Height = Application.GetRealHeight(150),
+                        LineColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
                     };
-                    roombj.AddChidren(rowLayout);
+                    foolrbj.AddChidren(foolrRowLayout);
 
-                    var btnroomname = new Button
+                    var btnfoolricon = new Button
                     {
-                        Width = Application.GetRealWidth(300),
-                        Text = room.Name,
+                        Width = Application.GetMinRealAverage(81),
+                        Height = Application.GetMinRealAverage(81),
+                        UnSelectedImagePath = "Floor/Floor.png",
+                        Gravity = Gravity.CenterVertical,
+                    };
+                    foolrRowLayout.AddChidren(btnfoolricon);
+
+
+                    var btnfoolrname = new Button
+                    {
+                        Width = Application.GetRealWidth(250),
+                        Height = Application.GetRealHeight(150),
+                        Text = foolr.Value,
                         TextAlignment = TextAlignment.CenterLeft,
-                        X = Application.GetRealWidth(30),
-                        TextColor = ZigbeeColor.Current.LogicTextBlackColor,
+                        TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
+                        Tag = foolr.Key,
+                        X = btnfoolricon.Right + Application.GetRealWidth(12),
+                        TextSize = 14,
                     };
-                    rowLayout.AddChidren(btnroomname);
-
-                    EventHandler<MouseEventArgs> roomclick = (sender1, e1) =>
+                    foolrRowLayout.AddChidren(btnfoolrname);
+                    if (view.foolrnameBtn.Text == foolr.Value)
                     {
+                        btnfoolricon.UnSelectedImagePath = "Floor/FloorSelected.png";
+                        btnfoolrname.TextColor = ZigbeeColor.Current.LogicTextBlackColor;
+                    }
 
+                    EventHandler<MouseEventArgs> foolrnameclick = (sender13, e13) =>
+                    {
+                        roomhorizontalScrol.RemoveAll();
+                        view.foolrnameBtn.Text = btnfoolrname.Text;
+                        middle.RemoveAll();
                         flMain.RemoveFromParent();
-                        roomname.Text = room.Name;
-                        SceneView(middle, room.SceneUIList);
+                        var list = Method.GetRoomList(sceneType, btnfoolrname.Tag.ToString());
+                        AllRoomView(list);
 
                     };
-                    rowLayout.MouseUpEventHandler += roomclick;
-                    btnroomname.MouseUpEventHandler += roomclick;
+                    foolrRowLayout.MouseUpEventHandler += foolrnameclick;
+                    btnfoolrname.MouseUpEventHandler += foolrnameclick;
+
 
                 }
-               
-            };
 
-            SceneView(middle,Common.Room.AllRoomSceneUIList);
+            };
+            ///鎴块棿鍒楄〃
+            var roomlists = Method.GetRoomList(sceneType, Config.Instance.Home.CurrentFloorId);
+            if (roomlists.Count == 0)
+            {
+                ///娌℃湁鎴块棿鐩存帴杩斿洖鍘伙紱
+                return;
+            }
+            ///绗竴娆¤繘鏉�
+            AllRoomView(roomlists);
 
         }
+        /// <summary>
+        /// 鏄剧ず鎵�鏈夋埧闂寸殑鏂规硶
+        /// </summary>
+        /// <param name="RoomList"></param>
+        void AllRoomView(List<Common.Room> RoomList ) {
+            for (int i = 0; i < RoomList.Count; i++)
+            {
+                var room = RoomList[i];
+
+                LogicView.RoomClickView roomClickView = new LogicView.RoomClickView();
+                roomClickView.Show(roomhorizontalScrol);
+                roomClickView.roomnameBtn.Text =room.Name;
+
+                if (i == 0)
+                {
+
+                    roombjButton.IsSelected = false;
+                    roomClickView.roombjBtn.Height = Application.GetRealHeight(135);
+                    roomClickView.roombjBtn.Width = Application.GetRealWidth(245);
+                    roomClickView.roombjBtn.Y = Application.GetRealHeight(40);
+                    roomClickView.roombjBtn.X = Application.GetRealWidth(0);
+                    roombjButton = roomClickView.roombjBtn;
+                    roomClickView.roombjBtn.IsSelected = true;
+                    roomTextButton.IsSelected = false;
+                    roomClickView.roomnameBtn.Width = Application.GetRealWidth(245 - 60 * 2);
+                    roomClickView.roomnameBtn.X = Application.GetRealWidth(60);
+                    roomTextButton = roomClickView.roomnameBtn;
+                    roomClickView.roomnameBtn.IsSelected = true;
+
+                    SceneView(room.ListSceneId);
+
+                }
 
 
-        void SceneView(VerticalScrolViewLayout middle,List<SceneUI>scenelist)
+                EventHandler<MouseEventArgs> roomclick = (sender, e) =>
+                {
+                    clickTag = "no";
+                    tempScene = null;
+                    clickbutton = null;
+                    clickbutton = new Button();
+
+                    roombjButton.Height = Application.GetRealHeight(72);
+                    roombjButton.Width = Application.GetRealWidth(170);
+                    roombjButton.Y = Application.GetRealHeight(60);
+                    roombjButton.X = Application.GetRealWidth(26);
+                    roombjButton.IsSelected = false;
+
+                    roomClickView.roombjBtn.Height = Application.GetRealHeight(135);
+                    roomClickView.roombjBtn.Width = Application.GetRealWidth(245);
+                    roomClickView.roombjBtn.Y = Application.GetRealHeight(40);
+                    roomClickView.roombjBtn.X = Application.GetRealWidth(0);
+                    roombjButton = roomClickView.roombjBtn;
+                    roomClickView.roombjBtn.IsSelected = true;
+
+                    roomTextButton.Width = Application.GetRealWidth(125);
+                    roomTextButton.X = Application.GetRealWidth(26 + 22);
+                    roomTextButton.IsSelected = false;
+                    roomClickView.roomnameBtn.Width = Application.GetRealWidth(245 - 60 * 2);
+                    roomClickView.roomnameBtn.X = Application.GetRealWidth(60);
+                    roomTextButton = roomClickView.roomnameBtn;
+                    roomClickView.roomnameBtn.IsSelected = true;
+
+                    SceneView(room.ListSceneId);
+                };
+                roomClickView.roomnameBtn.MouseUpEventHandler += roomclick;
+                roomClickView.roombjBtn.MouseUpEventHandler += roomclick;
+
+            }
+        }
+        /// <summary>
+        /// 鏄剧ず鎵�鏈夌殑鍦烘櫙鐨勬柟娉�
+        /// </summary>
+        /// <param name="scenelist"></param>
+        void SceneView(List<int>scenelist)
         {
             middle.RemoveAll();
-            foreach (var tempScene in scenelist)
+            foreach (var sceneId in scenelist)
             {
-                var deviceRowLayout = new RowLayout
+                var scene = HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId);
+                if (scene == null)
                 {
-                    Height = Application.GetRealHeight(180),
+                    continue;
+                }
+                var sceneFramelayout = new FrameLayout
+                {
+                    Height = Application.GetRealHeight(160),
+                    BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                 };
-                middle.AddChidren(deviceRowLayout);
+                middle.AddChidren(sceneFramelayout);
 
-                var btn = new Button
+                var sceneIconBtn = new Button
                 {
-                    Height = Application.GetRealHeight(180),
-                    Width = LayoutParams.MatchParent,
+                    Width = Application.GetMinRealAverage(81),
+                    Height = Application.GetMinRealAverage(81),
+                    X = Application.GetRealWidth(58),
+                    Y = Application.GetRealHeight(55),
+                    UnSelectedImagePath = "ZigeeLogic/scene.png",
 
                 };
-                deviceRowLayout.AddChidren(btn);
+                sceneFramelayout.AddChidren(sceneIconBtn);
 
-                var devicetypename = new Button
+                var sceneRow = new RowLayout
                 {
-                    Width = Application.GetRealWidth(600),
-                    Text = tempScene.Name,
+                    Y = Application.GetRealHeight(30),
+                    Width = Application.GetRealWidth(850),
+                    Height = Application.GetRealHeight(130),
+                    X = Application.GetRealWidth(176 + 10),
+                    LineColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
+                };
+                sceneFramelayout.AddChidren(sceneRow);
+
+                var scenename = new Button
+                {
+                    Text = scene.Name,
                     TextAlignment = TextAlignment.CenterLeft,
-                    X = Application.GetRealWidth(40),
-                    //SelectedBackgroundColor = 0xfffe5e00,
                     TextColor = ZigbeeColor.Current.LogicTextBlackColor,
+                    SelectedTextColor = ZigbeeColor.Current.LogicAddColor,
+                    TextSize = 14,
                 };
-                deviceRowLayout.AddChidren(devicetypename);
+                sceneRow.AddChidren(scenename);
 
+                var selectedBtn = new Button
+                {
+                    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) =>
                 {
-                    Dictionary<string, object> actionsInfo = new Dictionary<string, object>();
-                    if (actionsInfo.ContainsKey("LinkType"))
-                    {
-                        actionsInfo.Remove("LinkType");
-                    }
+                    tempScene = scene;
+                    clickTag = "yes";
+                    clickbutton.Visible = false;
+                    clickbutton = selectedBtn;
+                    selectedBtn.Visible = true;
                     if (actionsInfo.ContainsKey("DeviceAddr"))
                     {
                         actionsInfo.Remove("DeviceAddr");
                     }
-                    actionsInfo.Add("LinkType", 2);
-                    actionsInfo.Add("DeviceAddr", tempScene.Id);
-
-                    LogicIfon.AddSceneactions(tempScene,actionsInfo);
-                    var logicCommunalPage = new LogicCommunalPage();
-                    UserView.HomePage.Instance.AddChidren(logicCommunalPage);
-                    UserView.HomePage.Instance.PageIndex += 1;
-                    logicCommunalPage.Show(() => { });
+                    actionsInfo.Add("DeviceAddr", scene.Id);
                 };
 
-                deviceRowLayout.MouseUpEventHandler += sceneclick;
-                btn.MouseUpEventHandler += sceneclick;
-                devicetypename.MouseUpEventHandler += sceneclick;
+                sceneFramelayout.MouseUpEventHandler += sceneclick;
+                sceneIconBtn.MouseUpEventHandler += sceneclick;
+                sceneRow.MouseUpEventHandler += sceneclick;
+                scenename.MouseUpEventHandler += sceneclick;
+                selectedBtn.MouseUpEventHandler += sceneclick;
 
             }
 

--
Gitblit v1.8.0