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

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

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs b/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs
new file mode 100755
index 0000000..3b5ffb5
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs
@@ -0,0 +1,393 @@
+锘縰sing System;
+using System.Collections.Generic;
+using Newtonsoft.Json.Linq;
+using Shared;
+using Shared.Common;
+using Shared.Phone;
+using Shared.R;
+using ZigBee.Device;
+
+namespace Shared.Phone.Device.Logic
+{
+    public class AddScenePage : FrameLayout
+    {
+
+        public AddScenePage()
+        {
+            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();
+        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) =>
+            {
+                UserView.HomePage.Instance.ScrollEnabled = true;
+                RemoveFromParent();
+            };
+            view.foolrnameBtn.Text = Config.Instance.Home.GetCurrentFloorName;
+            if (Config.Instance.Home.FloorDics.Count < 2)
+            {
+                ///娌℃湁妤煎眰鎴栬�呭彧鏈変竴涓ゼ灞傦紝榛樿涓嶆樉绀哄浘鏍囧拰鏂囨湰;
+                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 listAllRoom = UserCenter.HdlRoomLogic.Current.GetAllListRooms();
+            if (listAllRoom.Count == 0)
+            {
+                return;
+            }
+         
+            this.AddChidren(roomhorizontalScrol);
+            middle.Y = roomhorizontalScrol.Bottom;
+            this.AddChidren(middle);
+            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 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);
+                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 foolrbjicon = new FrameLayout
+                {
+
+                    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(foolrbjicon);
+
+                var btnfoolrtext = new Button
+                {
+                    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,
+                    };
+                    foolrbj.AddChidren(foolrRowLayout);
+
+                    var btnfoolricon = new Button
+                    {
+                        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,
+                        TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
+                        Tag = foolr.Key,
+                        X = btnfoolricon.Right + Application.GetRealWidth(12),
+                        TextSize = 14,
+                    };
+                    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();
+                        var list = Method.GetRoomList(sceneType, btnfoolrname.Tag.ToString());
+                        AllRoomView(list);
+
+                    };
+                    foolrRowLayout.MouseUpEventHandler += foolrnameclick;
+                    btnfoolrname.MouseUpEventHandler += foolrnameclick;
+
+
+                }
+
+            };
+            ///鎴块棿鍒楄〃
+            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];
+                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);
+
+                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.ListSceneId);
+
+                }
+
+                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.ListSceneId);
+                };
+                roomnameBtn.MouseUpEventHandler += roomclick;
+                roombjBtn.MouseUpEventHandler += roomclick;
+
+            }
+        }
+        /// <summary>
+        /// 鏄剧ず鎵�鏈夌殑鍦烘櫙鐨勬柟娉�
+        /// </summary>
+        /// <param name="scenelist"></param>
+        void SceneView(List<int>scenelist)
+        {
+            middle.RemoveAll();
+            foreach (var sceneId in scenelist)
+            {
+                var scene = UserCenter.HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId);
+                if (scene == null)
+                {
+                    continue;
+                }
+                var sceneFramelayout = new FrameLayout
+                {
+                    Height = Application.GetRealHeight(160),
+                    BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
+                };
+                middle.AddChidren(sceneFramelayout);
+
+                var sceneIconBtn = new Button
+                {
+                    Width = Application.GetMinRealAverage(81),
+                    Height = Application.GetMinRealAverage(81),
+                    X = Application.GetRealWidth(58),
+                    Y = Application.GetRealHeight(55),
+                    UnSelectedImagePath = "ZigeeLogic/scene.png",
+
+                };
+                sceneFramelayout.AddChidren(sceneIconBtn);
+
+                var sceneRow = new RowLayout
+                {
+                    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,
+                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
+                    SelectedTextColor = ZigbeeColor.Current.LogicAddColor,
+                    TextSize = 14,
+                };
+                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) =>
+                {
+                    tempScene = scene;
+                    clickTag = "yes";
+                    clickbutton.Visible = false;
+                    clickbutton = selectedBtn;
+                    selectedBtn.Visible = true;
+                    if (actionsInfo.ContainsKey("DeviceAddr"))
+                    {
+                        actionsInfo.Remove("DeviceAddr");
+                    }
+                    actionsInfo.Add("DeviceAddr", scene.Id);
+                };
+
+                sceneFramelayout.MouseUpEventHandler += sceneclick;
+                sceneIconBtn.MouseUpEventHandler += sceneclick;
+                sceneRow.MouseUpEventHandler += sceneclick;
+                scenename.MouseUpEventHandler += sceneclick;
+                selectedBtn.MouseUpEventHandler += sceneclick;
+
+            }
+
+        }
+
+
+    }
+}

--
Gitblit v1.8.0