黄学彪
2020-03-11 06802250b4b9041d39d568c1dbe77684075006b2
ZigbeeApp/Shared/Phone/Device/Logic/AddScenePage.cs
@@ -16,125 +16,70 @@
        {
            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(1920 - 260 - 200 - 184),
            BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
        };
        public FrameLayout saveframeLayout = new FrameLayout {
            Height = Application.GetRealHeight(260),
            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 = 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
            ///没有房间直接返回去;
            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,
            };
            saveframeLayout.Y = middle.Bottom;
            this.AddChidren(saveframeLayout);
            var btnsave = new Button
@@ -166,17 +111,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 };
@@ -249,7 +203,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;
@@ -258,10 +212,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);
                    };
@@ -272,32 +226,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(listAllRoom);
                }
                else
                {
                    roomlists = Send.GetRoomList(Config.Instance.Home.CurrentFloorId);
                }
                ///没有房间直接返回去;
                return;
            }
            else
            {
                roomlists = Send.GetRoomList(Config.Instance.Home.CurrentFloorId);
            }
            ///第一次进来
            AllRoomView(roomlists);