HDL Home App 第二版本 旧平台金堂用 正在使用
hxb
2022-08-30 25429f085093d89d543a0b90e30d0d62d1b7dac9
ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs
@@ -16,143 +16,75 @@
        {
            Tag = "Logic";
        }
        ///房间滑动控件
        public HorizontalScrolViewLayout roomhorizontalScrol = new HorizontalScrolViewLayout
        {
            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,
        };
        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  上面的布局代码
            UserView.HomePage.Instance.ScrollEnabled = false;
            this.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor;
            #region  最上面的布局代码
            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 = 16,
                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,
            };
            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,
            };
            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,
            };
            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)
                {
                    var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
                                              Language.StringByID(MyInternationalizationString.selectdevicestatuscondition),
                                              Language.StringByID(MyInternationalizationString.complete));
                    var alert = new UserCenter.ShowMsgControl(ShowMsgType.Normal,
                          Language.StringByID(MyInternationalizationString.scenetip),
                          Language.StringByID(MyInternationalizationString.confrim));
                    alert.Show();
                    return;
                }
@@ -162,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 };
@@ -185,7 +126,7 @@
                {
                    Width = Application.GetRealWidth(450),
                    Height = Application.GetRealHeight(780),
                    Height = Application.GetRealWidth(780),
                    X = Application.GetRealWidth(1080 - 468 - 35),
                    Y = Application.GetRealHeight(184),
                    BackgroundImagePath = "Item/SelectFloor_Right.png",
@@ -200,6 +141,7 @@
                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                    X = Application.GetRealWidth(80),
                    TextID = MyInternationalizationString.selecfoolr,
                    TextSize = 14,
                };
                foolrbjicon.AddChidren(btnfoolrtext);
@@ -225,7 +167,7 @@
                    var btnfoolricon = new Button
                    {
                        Width = Application.GetRealWidth(81),
                        Height = Application.GetRealHeight(81),
                        Height = Application.GetRealWidth(81),
                        UnSelectedImagePath = "Floor/Floor.png",
                        Gravity = Gravity.CenterVertical,
                    };
@@ -241,9 +183,10 @@
                        TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
                        Tag = foolr.Key,
                        X = btnfoolricon.Right + Application.GetRealWidth(12),
                        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;
@@ -252,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);
                    };
@@ -266,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);
@@ -304,63 +228,64 @@
            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);
                LogicView.RoomClickView roomClickView = new LogicView.RoomClickView();
                roomClickView.Show(roomhorizontalScrol);
                roomClickView.roomnameBtn.Text =room.Name;
                if (i == 0)
                {
                    roombjButton.IsSelected = false;
                    roombjButton = roombjBtn;
                    roombjBtn.IsSelected = true;
                    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;
                    roomTextButton = roomnameBtn;
                    roomnameBtn.IsSelected = true;
                    SceneView(room.SceneUIList);
                    roomClickView.roomnameBtn.Width = Application.GetRealWidth(245 - 60 * 2);
                    roomClickView.roomnameBtn.X = Application.GetRealWidth(60);
                    roomTextButton = roomClickView.roomnameBtn;
                    roomClickView.roomnameBtn.IsSelected = true;
                    SceneView(room.ListSceneId);
                }
                EventHandler<MouseEventArgs> roomclick = (sender, e) =>
                {
                    roombjButton.IsSelected = false;
                    roombjButton = roombjBtn;
                    roombjBtn.IsSelected = true;
                    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;
                    roomTextButton = roomnameBtn;
                    roomnameBtn.IsSelected = true;
                    SceneView(room.SceneUIList);
                    roomClickView.roomnameBtn.Width = Application.GetRealWidth(245 - 60 * 2);
                    roomClickView.roomnameBtn.X = Application.GetRealWidth(60);
                    roomTextButton = roomClickView.roomnameBtn;
                    roomClickView.roomnameBtn.IsSelected = true;
                    SceneView(room.ListSceneId);
                };
                roomnameBtn.MouseUpEventHandler += roomclick;
                roombjBtn.MouseUpEventHandler += roomclick;
                roomClickView.roomnameBtn.MouseUpEventHandler += roomclick;
                roomClickView.roombjBtn.MouseUpEventHandler += roomclick;
            }
        }
@@ -368,11 +293,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),
@@ -380,11 +310,10 @@
                };
                middle.AddChidren(sceneFramelayout);
                var sceneIconBtn = new Button
                {
                    Width = Application.GetRealWidth(81),
                    Height = Application.GetRealHeight(81),
                    Height = Application.GetRealWidth(81),
                    X = Application.GetRealWidth(58),
                    Y = Application.GetRealHeight(55),
                    UnSelectedImagePath = "ZigeeLogic/scene.png",
@@ -398,8 +327,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);
@@ -409,20 +337,29 @@
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                    SelectedTextColor = ZigbeeColor.Current.LogicAddColor,
                    TextSize = 14,
                };
                sceneRow.AddChidren(scenename);
                var selectedBtn = new Button
                {
                    Width = Application.GetRealWidth(58),
                    Height = Application.GetRealHeight(58),
                    Width = Application.GetRealWidth(60),
                    Height = Application.GetRealWidth(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;