gxc
2019-10-29 081ea8d273048fd03756718ac6fb48a3c09218e9
ZigbeeApp/Shared/Phone/Device/Logic/DeviceTarget.cs
@@ -17,75 +17,116 @@
        }
        public void Show ()
        {
            this.BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor;
            var topFrameLayout = new FrameLayout
            #region  最上面的布局代码
            var topRowLayout = new RowLayout
            {
                Height = Application.GetRealHeight(140),
                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 {
                TextID = MyInternationalizationString.addaction,
                TextSize = 17,
            var titleName = new Button
            {
                TextSize = 16,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth(150),
                X = Application.GetRealWidth(176),
                Width = Application.GetRealWidth(400),
                Height = Application.GetRealHeight(69),
                Y = Application.GetRealHeight(92),
                TextID = MyInternationalizationString.addaction,
            };
            topFrameLayout.AddChidren (titleName);
            topRowLayout.AddChidren(titleName);
            var back = new Button {
                Width = Application.GetRealWidth (110),
                Height = Application.GetRealHeight (110),
                X = Application.GetRealWidth (20),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "ZigeeLogic/Back.png",
            var clickBtn = new Button
            {
                Width = Application.GetRealWidth(81 + 51),
                Height = Application.GetRealHeight(58 + 40),
                Y = Application.GetRealHeight(98 - 40),
            };
            topFrameLayout.AddChidren (back);
            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 ();
                RemoveFromParent();
            };
            #endregion
            var middle = new VerticalScrolViewLayout ();
            middle.Y = topFrameLayout.Bottom;
            middle.Height = Application.GetRealHeight(1920 - 220);
            middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
            var middle = new FrameLayout
            {
                Y = topRowLayout.Bottom,
                Height = Application.GetRealHeight(1920 - 184),
                BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
            };
            this.AddChidren(middle);
            #region ----- 设备------    
            var deviceRowLayout = new RowLayout
            var deviceframelayout = new FrameLayout
            {
                Height = Application.GetRealHeight(180),
                //BackgroundColor = 0xff323232,
                Height = Application.GetRealHeight(160),
                BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
            };
            middle.AddChidren (deviceRowLayout);
            middle.AddChidren(deviceframelayout);
            var device = new Button {
                Width = Application.GetRealWidth (400),
            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,
                //Text = "设备",
                TextSize = 16,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth (40),
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
            };
            deviceRowLayout.AddChidren (device);
            devicerow.AddChidren(btndevice);
            var btndeviceback = new Button {
                Width = Application.GetRealWidth (110),
                Height = Application.GetRealHeight (110),
                UnSelectedImagePath = "ZigeeLogic/next.png",
                SelectedImagePath = "ZigeeLogic/NextSelecte.png",
                X = Application.GetRealWidth (1080-140),//550
            var btndeviceback = new Button
            {
                Width = Application.GetRealWidth(58),
                Height = Application.GetRealHeight(58),
                X = Application.GetRealWidth(789),
                Gravity = Gravity.CenterVertical,
            };
            deviceRowLayout.AddChidren (btndeviceback);
                UnSelectedImagePath = "ZigeeLogic/next.png",
            EventHandler<MouseEventArgs> deviceclick = (sender, e) => {
            };
            devicerow.AddChidren(btndeviceback);
            EventHandler<MouseEventArgs> devicestateclick = (sender, e) =>
            {
                Common.Logic.LogicDviceList.Clear();
                if (Common.Logic.LogicDviceList.Count == 0)
                {
@@ -97,90 +138,122 @@
                logicDevicePage.Show();
            };
             deviceRowLayout.MouseUpEventHandler += deviceclick;
             device.MouseUpEventHandler += deviceclick;
             btndeviceback.MouseUpEventHandler += deviceclick;
#endregion
            deviceframelayout.MouseUpEventHandler += devicestateclick;
            btndevice.MouseUpEventHandler += devicestateclick;
            btndeviceback.MouseUpEventHandler += devicestateclick;
            deviceiconBtn.MouseUpEventHandler += devicestateclick;
            devicerow.MouseUpEventHandler += devicestateclick;
            #endregion
            #region ----- 场景------
            var sceneRowLayout = new RowLayout {
                Height = Application.GetRealHeight (180),
                //BackgroundColor = 0xff323232,
                Y=deviceRowLayout.Bottom,
            #region ----- 场景------
            var sceneframelayout = new FrameLayout
            {
                Height = Application.GetRealHeight(160),
                BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
                Y= deviceframelayout.Bottom,
            };
            middle.AddChidren (sceneRowLayout);
            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 {
                Width = Application.GetRealWidth (400),
                TextID = MyInternationalizationString.scene,
                //Text = "场景",
                TextSize = 16,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth (40),
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
            };
            sceneRowLayout.AddChidren (scene);
            var btnsceneback = new Button {
                Width = Application.GetRealWidth (110),
                Height = Application.GetRealHeight (110),
                UnSelectedImagePath = "ZigeeLogic/next.png",
                SelectedImagePath = "ZigeeLogic/NextSelecte.png",
                X = Application.GetRealWidth (1080-140),//550
                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) => {
                CommonPage.Loading.Start ();
                System.Threading.Tasks.Task.Run (() => {
                    Application.RunOnMainThread (() => {
                        CommonPage.Loading.Hide ();
                        var addScenePage = new AddScenePage ();
                        UserView.HomePage.Instance.AddChidren (addScenePage);
                        UserView.HomePage.Instance.PageIndex += 1;
                        addScenePage.Show ();
                    });
                });
            EventHandler<MouseEventArgs> sceneclick = (sender, e) =>
            {
                var addScenePage = new AddScenePage();
                UserView.HomePage.Instance.AddChidren(addScenePage);
                UserView.HomePage.Instance.PageIndex += 1;
                addScenePage.Show();
            };
             sceneRowLayout.MouseUpEventHandler += sceneclick;
             scene.MouseUpEventHandler += sceneclick;
             btnsceneback.MouseUpEventHandler += sceneclick;
#endregion
            sceneframelayout.MouseUpEventHandler += sceneclick;
            sceneiconBtn.MouseUpEventHandler += sceneclick;
            #endregion
            #region ----- 安防模式------        
            ///安防模式
            var securityRowLayout = new RowLayout
            var securityframelayout = new FrameLayout
            {
                Height = Application.GetRealHeight(180),
                //BackgroundColor = 0xff323232,
                Y = sceneRowLayout.Bottom,
                Height = Application.GetRealHeight(160),
                Y = sceneframelayout.Bottom,
                BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
            };
            middle.AddChidren(securityRowLayout);
            middle.AddChidren(securityframelayout);
            var security = new Button
            var securityiconBtn = new Button
            {
                Width = Application.GetRealWidth(400),
                TextID = MyInternationalizationString.securitymode,
                //Text = "安防模式",
                TextSize = 16,
                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,
                X = Application.GetRealWidth(40),
                TextID = MyInternationalizationString.securitymode,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
            };
            securityRowLayout.AddChidren(security);
            securityrow.AddChidren(btnsecurity);
            var btnsecurityback = new Button
            {
                Width = Application.GetRealWidth(110),
                Height = Application.GetRealHeight(110),
                Width = Application.GetRealWidth(58),
                Height = Application.GetRealHeight(58),
                UnSelectedImagePath = "ZigeeLogic/next.png",
                SelectedImagePath = "ZigeeLogic/NextSelecte.png",
                X = Application.GetRealWidth(1080 - 140),//550
                X = Application.GetRealWidth(789),
                Gravity = Gravity.CenterVertical,
            };
            securityRowLayout.AddChidren(btnsecurityback);
            securityrow.AddChidren(btnsecurityback);
            EventHandler<MouseEventArgs> securityclick = (sender, e) => {
                var securityMode = new SecurityMode();
@@ -189,9 +262,11 @@
                securityMode.Show();
            };
            securityRowLayout.MouseUpEventHandler += securityclick;
            security.MouseUpEventHandler += securityclick;
            securityframelayout.MouseUpEventHandler += securityclick;
            btnsecurity.MouseUpEventHandler += securityclick;
            btnsecurityback.MouseUpEventHandler += securityclick;
            securityiconBtn.MouseUpEventHandler += securityclick;
            securityrow.MouseUpEventHandler += securityclick;
            #endregion
            #region ----- 已有自动化------      
@@ -201,7 +276,7 @@
            {
                Height = Application.GetRealHeight(180),
                //BackgroundColor = 0xff323232,
                Y = securityRowLayout.Bottom,
                Y = securityframelayout.Bottom,
            };
            //middle.AddChidren(existenceRowLayout);
@@ -240,101 +315,71 @@
            btnexistenceback.MouseUpEventHandler += existenceclick;
            #endregion
            #region ----- 延时------
            #region ----- 延时------
            var delayedframelayout = new FrameLayout
            {
                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
            {
                Height = Application.GetRealHeight(180),
                //BackgroundColor = 0xff323232,
                Y=securityRowLayout.Bottom,
                Y = Application.GetRealHeight(30),
                Width = Application.GetRealWidth(850),
                Height = Application.GetRealHeight(130),
                X = Application.GetRealWidth(176),
                LineColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
            };
           //middle.AddChidren(delayedRowLayout);
            delayedframelayout.AddChidren(delayedRowLayout);
            var delayed = new Button
            {
                Width = Application.GetRealWidth(400),
                TextID = MyInternationalizationString.delayed,
                //Text = "延时",
                TextSize = 16,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth(40),
                TextID = MyInternationalizationString.delayed,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
            };
            delayedRowLayout.AddChidren(delayed);
            var btndelayedback = new Button
            {
                Width = Application.GetRealWidth(110),
                Height = Application.GetRealHeight(110),
                Width = Application.GetRealWidth(58),
                Height = Application.GetRealHeight(58),
                UnSelectedImagePath = "ZigeeLogic/next.png",
                SelectedImagePath = "ZigeeLogic/NextSelecte.png",
                X = Application.GetRealWidth(1080 - 140),//550
                X = Application.GetRealWidth(789),
                Gravity = Gravity.CenterVertical,
            };
            delayedRowLayout.AddChidren(btndelayedback);
            EventHandler<MouseEventArgs> delayedclick = (sender, e) =>
            {
                //var delayTime = new DelayTime();
                //UserView.HomePage.Instance.AddChidren(delayTime);
                //UserView.HomePage.Instance.PageIndex += 1;
                //delayTime.Show();
                DelayTimeView();
                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;
#endregion
            delayedframelayout.MouseUpEventHandler += delayedclick;
            delayediconBtn.MouseUpEventHandler += delayedclick;
            #endregion
        }
        public static  void DelayTimeView(Dictionary<string, object> delayactionsInfo=null)
        {
            var listValues = new List<string>();
            for (int i = 0; i < 60; i++)
            {
                listValues.Add(i.ToString() + " " + Language.StringByID(MyInternationalizationString.second));
            }
            var list = new List<KeyValuePair<string, string[]>> { };
            for (int i = 0; i <= 60; i++)
            {
                list.Add(new KeyValuePair<string, string[]>(i.ToString() + " " + Language.StringByID(MyInternationalizationString.minute), listValues.ToArray()));
            }
            /*
            PickerView.Show(list, (obj) =>
            {
                var minute = obj.Split(',')[0].Split(' ')[0];
                var second = obj.Split(',')[1].Split(' ')[0];
                int value = int.Parse(minute) * 60 + int.Parse(second);
                if (value == 0)
                {
                    var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
                                                   "时间不能为0",
                                                  Language.StringByID(MyInternationalizationString.complete));
                    alert.Show();
                    return;
                }
                if (delayactionsInfo == null)
                {
                    Dictionary<string, object> actionsInfo = new Dictionary<string, object>();
                    actionsInfo.Add("LinkType", 10);
                    actionsInfo.Add("DelayTime", value);
                    Common.Logic.CurrentLogic.Actions.Add(actionsInfo);
                }
                else
                {
                    if (delayactionsInfo.ContainsKey("DelayTime"))
                    {
                        delayactionsInfo.Remove("DelayTime");
                    }
                    delayactionsInfo.Add("DelayTime", value);
                }
                var logicCommunalPage = new LogicCommunalPage { };
                UserView.HomePage.Instance.AddChidren(logicCommunalPage);
                UserView.HomePage.Instance.PageIndex += 1;
                logicCommunalPage.Show(() => { });
            }, Language.StringByID(MyInternationalizationString.complete), "");
            */
        }
    }
}