From 66a9965c44ecc32a6696abca876ab9d1cd091584 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 28 二月 2020 15:25:13 +0800
Subject: [PATCH] 2020.2.28

---
 ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs |  459 +++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 360 insertions(+), 99 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs b/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs
index 5009ebd..2f34fb8 100755
--- a/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs
@@ -12,186 +12,447 @@
     public class AddScenePage : FrameLayout
     {
 
-        Button roomname;
         public AddScenePage()
         {
             Tag = "Logic";
         }
+        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()
         {
-            this.BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor;
-
-            var topFrameLayout = new FrameLayout
+            UserView.HomePage.Instance.ScrollEnabled = false;
+            this.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor;
+            #region  鏈�涓婇潰鐨勫竷灞�浠g爜
+            var topRowLayout = new RowLayout
             {
-                Height = Application.GetRealHeight(220),
-                Y = Application.GetRealHeight(80),
+                BackgroundColor = ZigbeeColor.Current.LogicTopBackgroundColor,
+                Height = Application.GetRealHeight(184),
+                LineColor = ZigbeeColor.Current.LogicRowLayoutTopLineColor,
             };
-
-            AddChidren(topFrameLayout);
+            this.AddChidren(topRowLayout);
 
             var titleName = new Button
             {
-                //Text = "娣诲姞鍦烘櫙",
-                TextID = MyInternationalizationString.addscene,
                 TextSize = 17,
                 TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                 TextAlignment = TextAlignment.CenterLeft,
-                X = Application.GetRealWidth(150),
+                X = Application.GetRealWidth(160),
+                Width = Application.GetRealWidth(600),
+                Height = Application.GetRealHeight(69),
+                Y = Application.GetRealHeight(92),
+                TextID = MyInternationalizationString.addscene,
+                IsBold = true,
             };
-            topFrameLayout.AddChidren(titleName);
+            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(110),
-                Height = Application.GetRealHeight(110),
-                X = Application.GetRealWidth(20),
-                Gravity = Gravity.CenterVertical,
-                UnSelectedImagePath = "ZigeeLogic/Back.png",
+                Width = Application.GetRealWidth(30),
+                Height = Application.GetRealHeight(51),
+                X = Application.GetRealWidth(81),
+                Y = Application.GetRealHeight(98),
+                //Gravity = Gravity.CenterVertical;
+                UnSelectedImagePath = "ZigeeLogic/back.png",
             };
-            topFrameLayout.AddChidren(back);
-            back.MouseDownEventHandler += (sender, e) =>
-            {
+            topRowLayout.AddChidren(back);
+            back.MouseDownEventHandler += (sender, e) => {
                 RemoveFromParent();
+                UserView.HomePage.Instance.ScrollEnabled = true;
             };
 
-            roomname = new Button
+            var foolrname = new Button
             {
-                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,
+                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,
             };
-            topFrameLayout.AddChidren(roomname);
+            topRowLayout.AddChidren(foolrname);
+            var dropdown = new Button
+            {
+                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);
+            #endregion
+        
+            ///娌℃湁鎴块棿鐩存帴杩斿洖鍘伙紱
+            if (Common.Room.Lists.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);
 
-            var middle = new VerticalScrolViewLayout();
-            middle.Y = topFrameLayout.Bottom;
-            middle.Height = Application.GetRealHeight(1920 - 300);
-            middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
+
+
+            middle = new VerticalScrolViewLayout();
+            middle.Y = roomhorizontalScrol.Bottom;
+            middle.Height = Application.GetRealHeight(1920 - 260 - 200 - 184);
+            middle.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor;
             this.AddChidren(middle);
 
-            roomname.MouseUpEventHandler += (sender, e) =>
+            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) =>
+            {
+                if (clickTag == "no" || tempScene == null)
+                {
+                    var alert = new UserCenter.ShowMsgControl(UserCenter.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);
+                var logicCommunalPage = new LogicCommunalPage();
+                UserView.HomePage.Instance.AddChidren(logicCommunalPage);
+                UserView.HomePage.Instance.PageIndex += 1;
+                logicCommunalPage.Show(() => { });
+
+            };
+
+         
+
+            ///妤煎眰鐐瑰嚮浜嬩欢
+            EventHandler<MouseEventArgs> foorlclick = (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.GetRealWidth(81),
+                        Height = Application.GetRealHeight(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 (foolrname.Text == foolr.Value)
                     {
+                        btnfoolricon.UnSelectedImagePath = "Floor/FloorSelected.png";
+                        btnfoolrname.TextColor = ZigbeeColor.Current.LogicTextBlackColor;
+                    }
 
+                    EventHandler<MouseEventArgs> foolrnameclick = (sender13, e13) =>
+                    {
+                        roomhorizontalScrol.RemoveAll();
+                        foolrname.Text = btnfoolrname.Text;
+                        middle.RemoveAll();
                         flMain.RemoveFromParent();
-                        roomname.Text = room.Name;
-                        SceneView(middle, room.SceneUIList);
+                        var list = Send.GetRoomList(btnfoolrname.Tag.ToString());
+                        AllRoomView(list);
 
                     };
-                    rowLayout.MouseUpEventHandler += roomclick;
-                    btnroomname.MouseUpEventHandler += roomclick;
+                    foolrRowLayout.MouseUpEventHandler += foolrnameclick;
+                    btnfoolrname.MouseUpEventHandler += foolrnameclick;
+
 
                 }
-               
-            };
 
-            SceneView(middle,Common.Room.AllRoomSceneUIList);
+            };
+            foolrname.MouseUpEventHandler += foorlclick;
+            dropdown.MouseUpEventHandler += foorlclick;
+
+            ///绗竴娆¤繘鏉�
+            var roomlists = new List<Common.Room>();
+            roomlists.Clear();
+            if (Config.Instance.Home.FloorDics.Count < 2)
+            {
+                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);
+                }
+            }
+            else
+            {
+                roomlists = Send.GetRoomList(Config.Instance.Home.CurrentFloorId);
+
+            }
+
+
+            ///绗竴娆¤繘鏉�
+            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];
+                var fra = new FrameLayout
+                {
+                    Height = Application.GetRealHeight(200),
+                    Width = Application.GetRealWidth(255),
+                };
+                roomhorizontalScrol.AddChidren(fra);
 
+                var roombjBtn = new Button
+                {
+                    Height = Application.GetRealHeight(158),
+                    Width = Application.GetRealWidth(255),
+                    UnSelectedImagePath = "ZigeeLogic/iconBackgroundColor.png",
+                    SelectedImagePath = "ZigeeLogic/iconSelectedBackgroundColor.png",
+                    Y = Application.GetRealHeight(21),
+                };
+                fra.AddChidren(roombjBtn);
 
-        void SceneView(VerticalScrolViewLayout middle,List<SceneUI>scenelist)
+                var roomnameBtn = new Button
+                {
+
+                    Height = Application.GetRealHeight(152 - 26 - 20),
+                    Width = Application.GetRealWidth(255 - 20 - 50),
+                    Text = room.Name,
+                    TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
+                    SelectedTextColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
+                    Y = Application.GetRealHeight(21 + 13 + 10),
+                    X = Application.GetRealWidth(10 + 25),
+
+                };
+                fra.AddChidren(roomnameBtn);
+
+                if (i == 0)
+                {
+                    roombjButton.IsSelected = false;
+                    roombjButton = roombjBtn;
+                    roombjBtn.IsSelected = true;
+
+                    roomTextButton.IsSelected = false;
+                    roomTextButton = roomnameBtn;
+                    roomnameBtn.IsSelected = true;
+                    SceneView(room.SceneUIList);
+
+                }
+
+                EventHandler<MouseEventArgs> roomclick = (sender, e) =>
+                {
+                    clickTag = "no";
+                    tempScene = null;
+                    clickbutton = null;
+                    clickbutton = new Button();
+
+                    roombjButton.IsSelected = false;
+                    roombjButton = roombjBtn;
+                    roombjBtn.IsSelected = true;
+
+                    roomTextButton.IsSelected = false;
+                    roomTextButton = roomnameBtn;
+                    roomnameBtn.IsSelected = true;
+                    SceneView(room.SceneUIList);
+                };
+                roomnameBtn.MouseUpEventHandler += roomclick;
+                roombjBtn.MouseUpEventHandler += roomclick;
+
+            }
+        }
+        /// <summary>
+        /// 鏄剧ず鎵�鏈夌殑鍦烘櫙鐨勬柟娉�
+        /// </summary>
+        /// <param name="scenelist"></param>
+        void SceneView(List<SceneUI>scenelist)
         {
             middle.RemoveAll();
-            foreach (var tempScene in scenelist)
+            foreach (var scene in scenelist)
             {
-                var deviceRowLayout = new RowLayout
+                var sceneFramelayout = new FrameLayout
                 {
-                    Height = Application.GetRealHeight(180),
+                    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.GetRealWidth(81),
+                    Height = Application.GetRealHeight(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.LogicRowLayoutLineColor,
+
+                };
+                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.GetRealWidth(58),
+                    Height = Application.GetRealHeight(58),
+                    X = Application.GetRealWidth(789),
+                    UnSelectedImagePath = "ZigeeLogic/selected.png",
+                    Visible = false,
+                    Gravity = Gravity.CenterVertical,
+                };
+                sceneRow.AddChidren(selectedBtn);
 
                 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