黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/Device/Logic/DeviceTarget.cs
@@ -15,367 +15,110 @@
        {
            Tag = "Logic";
        }
        public void Show ()
        /// <summary>
        /// 添加目标功能类
        /// </summary>
        /// <param name="str1">设备界面识别字符串</param>
        /// <param name="str2">场景界面识别字符串</param>
        public void Show (string str1,string str2)
        {
            #region  最上面的布局代码
            var topRowLayout = new RowLayout
            {
                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(176),
                Width = Application.GetRealWidth(600),
                Height = Application.GetRealHeight(69),
                Y = Application.GetRealHeight(92),
                TextID = MyInternationalizationString.addaction,
            };
            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();
            };
            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();
            };
            TopView view = new TopView();
            this.AddChidren(view.TopRowView());
            view.toptitleNameBtn.TextID = MyInternationalizationString.addaction;
            view.clickBtn.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); };
            #endregion
            var middle = new FrameLayout
            {
                Y = topRowLayout.Bottom,
                Height = Application.GetRealHeight(1920 - 184),
                Y = view.topRowLayout.Bottom,
                Height = Application.GetRealHeight(Method.H - 184),
                BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
            };
            this.AddChidren(middle);
            #region ----- 设备------
            var deviceframelayout = new FrameLayout
            #region ----- 设备------
            FunView deviceview= new FunView();
            deviceview.iconBtn.UnSelectedImagePath = "ZigeeLogic/function.png";
            deviceview.funnameBtn.TextID = MyInternationalizationString.device;
            middle.AddChidren(deviceview.FunFrameView());
            deviceview.clickviewBtn.MouseUpEventHandler += (sender, e) =>
            {
                Height = Application.GetRealHeight(160),
                BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
            };
            middle.AddChidren(deviceframelayout);
            var deviceiconBtn = new Button
            {
                Width = Application.GetRealWidth(81),
                Height = Application.GetRealHeight(81),
                X = Application.GetRealWidth(58),
                Y = Application.GetRealHeight(55),
                UnSelectedImagePath = "ZigeeLogic/function.png",
            };
            deviceframelayout.AddChidren(deviceiconBtn);
            var devicerow = new RowLayout
            {
                Y = Application.GetRealHeight(30),
                Width = Application.GetRealWidth(850),
                Height = Application.GetRealHeight(130),
                X = Application.GetRealWidth(176),
                LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
            };
            deviceframelayout.AddChidren(devicerow);
            var btndevice = new Button
            {
                TextID = MyInternationalizationString.device,
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
               TextSize=15,
            };
            devicerow.AddChidren(btndevice);
            var btndeviceback = new Button
            {
                Width = Application.GetRealWidth(58),
                Height = Application.GetRealHeight(58),
                X = Application.GetRealWidth(789),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "ZigeeLogic/next.png",
            };
            devicerow.AddChidren(btndeviceback);
            EventHandler<MouseEventArgs> devicestateclick = (sender, e) =>
            {
                var logicDevicePage = new LogicDevicePage();
                UserView.HomePage.Instance.AddChidren(logicDevicePage);
                var roomAndDeviceView = new RoomAndDeviceView();
                UserView.HomePage.Instance.AddChidren(roomAndDeviceView);
                UserView.HomePage.Instance.PageIndex += 1;
                logicDevicePage.Show();
                roomAndDeviceView.IfType = str1;
                roomAndDeviceView.Show(Language.StringByID(MyInternationalizationString.addaction));
            };
            deviceframelayout.MouseUpEventHandler += devicestateclick;
            btndevice.MouseUpEventHandler += devicestateclick;
            btndeviceback.MouseUpEventHandler += devicestateclick;
            deviceiconBtn.MouseUpEventHandler += devicestateclick;
            devicerow.MouseUpEventHandler += devicestateclick;
            #endregion
            #region ----- 场景------
            var sceneframelayout = new FrameLayout
            {
                Height = Application.GetRealHeight(160),
                BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
                Y= deviceframelayout.Bottom,
            };
            middle.AddChidren(sceneframelayout);
            var sceneiconBtn = new Button
            {
                Width = Application.GetRealWidth(81),
                Height = Application.GetRealHeight(81),
                X = Application.GetRealWidth(58),
                Y = Application.GetRealHeight(55),
                UnSelectedImagePath = "ZigeeLogic/scene.png",
            };
            sceneframelayout.AddChidren(sceneiconBtn);
            var sceneRowLayout = new RowLayout {
                Y = Application.GetRealHeight(30),
                Width = Application.GetRealWidth(850),
                Height = Application.GetRealHeight(130),
                X = Application.GetRealWidth(176),
                LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
            };
            sceneframelayout.AddChidren (sceneRowLayout);
            var scene = new Button {
                TextID = MyInternationalizationString.scene,
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextSize = 15,
            };
            sceneRowLayout.AddChidren (scene);
            var btnsceneback = new Button {
                Width = Application.GetRealWidth(58),
                Height = Application.GetRealHeight(58),
                X = Application.GetRealWidth(789),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "ZigeeLogic/next.png",
            };
            sceneRowLayout.AddChidren (btnsceneback);
            EventHandler<MouseEventArgs> sceneclick = (sender, e) =>
            FunView sceneview= new FunView();
            sceneview.iconBtn.UnSelectedImagePath = "ZigeeLogic/scene.png";
            sceneview.funnameBtn.TextID = MyInternationalizationString.scene;
            sceneview.funFrameLayout.Y = deviceview.funFrameLayout.Bottom;
            middle.AddChidren(sceneview.FunFrameView());
            sceneview.clickviewBtn.MouseUpEventHandler += (sender, e) =>
            {
                var addScenePage = new AddScenePage();
                UserView.HomePage.Instance.AddChidren(addScenePage);
                UserView.HomePage.Instance.PageIndex += 1;
                addScenePage.Show();
                addScenePage.Show(str2);
            };
             sceneRowLayout.MouseUpEventHandler += sceneclick;
             scene.MouseUpEventHandler += sceneclick;
             btnsceneback.MouseUpEventHandler += sceneclick;
            sceneframelayout.MouseUpEventHandler += sceneclick;
            sceneiconBtn.MouseUpEventHandler += sceneclick;
            #endregion
            #region ----- 安防模式------
            var securityframelayout = new FrameLayout
            #region ----- 安防模式------
            FunView securityview= new FunView();
            securityview.iconBtn.UnSelectedImagePath = "ZigeeLogic/security.png";
            securityview.funnameBtn.TextID = MyInternationalizationString.securitymode;
            securityview.funFrameLayout.Y = sceneview.funFrameLayout.Bottom;
            if (str1 == LogicView.IfString.Action_Logic)
            {   ///联动事件输出-不支持安防模式
                ///自动化输出-支持安防模式
                middle.AddChidren(securityview.FunFrameView());
            }
            else
            {
                Height = Application.GetRealHeight(160),
                Y = sceneframelayout.Bottom,
                BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
            };
            middle.AddChidren(securityframelayout);
            var securityiconBtn = new Button
                ///改变最后功能快线条颜色
                sceneview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor;
            }
            securityview.clickviewBtn.MouseUpEventHandler += (sender, e) =>
            {
                Width = Application.GetRealWidth(81),
                Height = Application.GetRealHeight(81),
                UnSelectedImagePath = "ZigeeLogic/security.png",
                X = Application.GetRealWidth(58),
                Y = Application.GetRealHeight(55),
            };
            securityframelayout.AddChidren(securityiconBtn);
            var securityrow = new RowLayout
            {
                Y = Application.GetRealHeight(30),
                Width = Application.GetRealWidth(850),
                Height = Application.GetRealHeight(130),
                X = Application.GetRealWidth(176),
                LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
            };
            securityframelayout.AddChidren(securityrow);
            var btnsecurity = new Button
            {
                TextAlignment = TextAlignment.CenterLeft,
                TextID = MyInternationalizationString.securitymode,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextSize = 15,
            };
            securityrow.AddChidren(btnsecurity);
            var btnsecurityback = new Button
            {
                Width = Application.GetRealWidth(58),
                Height = Application.GetRealHeight(58),
                UnSelectedImagePath = "ZigeeLogic/next.png",
                X = Application.GetRealWidth(789),
                Gravity = Gravity.CenterVertical,
            };
            securityrow.AddChidren(btnsecurityback);
            EventHandler<MouseEventArgs> securityclick = (sender, e) => {
                var securityMode = new SecurityMode();
                UserView.HomePage.Instance.AddChidren(securityMode);
                UserView.HomePage.Instance.PageIndex += 1;
                securityMode.Show();
            };
            securityframelayout.MouseUpEventHandler += securityclick;
            btnsecurity.MouseUpEventHandler += securityclick;
            btnsecurityback.MouseUpEventHandler += securityclick;
            securityiconBtn.MouseUpEventHandler += securityclick;
            securityrow.MouseUpEventHandler += securityclick;
            #endregion
            #region ----- 已有自动化------
            ///已有自动化
            var existenceRowLayout = new RowLayout
            {
                Height = Application.GetRealHeight(180),
                //BackgroundColor = 0xff323232,
                Y = securityframelayout.Bottom,
            };
            //middle.AddChidren(existenceRowLayout);
            var existence = new Button
            {
                Width = Application.GetRealWidth(400),
                TextID = MyInternationalizationString.Alreadyautomated,
                //Text = "已有自动化",
                TextSize = 15,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth(40),
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
            };
            existenceRowLayout.AddChidren(existence);
            var btnexistenceback = new Button
            {
                Width = Application.GetRealWidth(110),
                Height = Application.GetRealHeight(110),
                UnSelectedImagePath = "ZigeeLogic/next.png",
                SelectedImagePath = "ZigeeLogic/NextSelecte.png",
                X = Application.GetRealWidth(1080 - 140),//550
                Gravity = Gravity.CenterVertical,
            };
            existenceRowLayout.AddChidren(btnexistenceback);
            EventHandler<MouseEventArgs> existenceclick = (sender, e) => {
                var logicListPage = new LogicListPage();
                UserView.HomePage.Instance.AddChidren(logicListPage);
                UserView.HomePage.Instance.PageIndex += 1;
                logicListPage.Show();
            };
            existenceRowLayout.MouseUpEventHandler += existenceclick;
            existence.MouseUpEventHandler += existenceclick;
            btnexistenceback.MouseUpEventHandler += existenceclick;
            #endregion
            #region ----- 延时------
            var delayedframelayout = new FrameLayout
            FunView delayedview = new FunView();
            delayedview.iconBtn.UnSelectedImagePath = "ZigeeLogic/delay.png";
            delayedview.funnameBtn.TextID = MyInternationalizationString.delayed;
            delayedview.funFrameLayout.Y = securityview.funFrameLayout.Bottom;
            delayedview.funFrameLayout.Height = Application.GetRealHeight(160 + 20);//最后一行增加20高度;
            delayedview.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor; ///改变最后功能快线条颜色
            if (str1 == LogicView.IfString.Action_Logic)
            {
                Height = Application.GetRealHeight(160),
                BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
                Y = securityframelayout.Bottom,
            };
            middle.AddChidren(delayedframelayout);
            var delayediconBtn = new Button
            {
                Width = Application.GetRealWidth(81),
                Height = Application.GetRealHeight(81),
                X = Application.GetRealWidth(58),
                Y = Application.GetRealHeight(55),
                UnSelectedImagePath = "ZigeeLogic/delay.png",
            };
            delayedframelayout.AddChidren(delayediconBtn);
            var delayedRowLayout = new RowLayout
            {
                Y = Application.GetRealHeight(30),
                Width = Application.GetRealWidth(850),
                Height = Application.GetRealHeight(130),
                X = Application.GetRealWidth(176),
                LineColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
            };
            delayedframelayout.AddChidren(delayedRowLayout);
            var delayed = new Button
            {
                TextAlignment = TextAlignment.CenterLeft,
                TextID = MyInternationalizationString.delayed,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextSize = 15,
            };
            delayedRowLayout.AddChidren(delayed);
            var btndelayedback = new Button
            {
                Width = Application.GetRealWidth(58),
                Height = Application.GetRealHeight(58),
                UnSelectedImagePath = "ZigeeLogic/next.png",
                X = Application.GetRealWidth(789),
                Gravity = Gravity.CenterVertical,
            };
            delayedRowLayout.AddChidren(btndelayedback);
            EventHandler<MouseEventArgs> delayedclick = (sender, e) =>
                ///联动事件输出-不支持延时
                ///自动化输出-支持延时
                middle.AddChidren(delayedview.FunFrameView());
            }
            delayedview.clickviewBtn.MouseUpEventHandler += (sender, e) =>
            {
                var delayTime = new DelayTime();
                UserView.HomePage.Instance.AddChidren(delayTime);
                UserView.HomePage.Instance.PageIndex += 1;
                delayTime.Show();
            };
            delayedRowLayout.MouseUpEventHandler += delayedclick;
            delayed.MouseUpEventHandler += delayedclick;
            btndelayedback.MouseUpEventHandler += delayedclick;
            delayedframelayout.MouseUpEventHandler += delayedclick;
            delayediconBtn.MouseUpEventHandler += delayedclick;
            #endregion
        }