黄学彪
2020-03-11 06802250b4b9041d39d568c1dbe77684075006b2
ZigbeeApp/Shared/Phone/Device/Logic/TimePage.cs
@@ -3,6 +3,7 @@
using Shared;
using Shared.Common;
using Shared.Phone;
using Shared.Phone.Device.Logic.LogicView;
using Shared.R;
using ZigBee.Device;
@@ -21,252 +22,54 @@
        public void Show()
        {
            #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.addtime,
                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();
            };
            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();
            };
            #region  上面的布局代码
            TopView view = new TopView();
            this.AddChidren(view.TopRowView());
            view.toptitleNameBtn.TextID = MyInternationalizationString.selection;
            view.clickBtn.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); };
            #endregion
            #region  最下面的布局代码
            var middle = new FrameLayout
            {
                Y = topRowLayout.Bottom,
                Y = view.topRowLayout.Bottom,
                Height = Application.GetRealHeight(1920 - 184-260),
                BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
            };
            this.AddChidren(middle);
            var fra = new FrameLayout
            {
                Y = middle.Bottom,
                Height = Application.GetRealHeight(260),
                BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
            };
            this.AddChidren(fra);
            var btnsave = new Button
            {
                X = Application.GetRealWidth(85),
                Height = Application.GetRealHeight(130),//194
                Width = Application.GetRealWidth(910),
                Radius = (uint)Application.GetRealHeight(60),
                BackgroundColor = ZigbeeColor.Current.LogicBtnSaveBackgroundColor,
                TextID = MyInternationalizationString.Save,
                TextColor = ZigbeeColor.Current.LogicBtnSaveTextColor,
                TextSize = 16,
            };
            fra.AddChidren(btnsave);
            //保存
            SaveView saveView = new SaveView();
            saveView.frameLayout.Y = middle.Bottom;
            this.AddChidren(saveView.Show());
            #endregion
            #region   -----时间范围  开始时间  结束时间
            #region   -----时间范围
            var typeFramelayout = new FrameLayout
            {
                Height = Application.GetRealHeight(160),
                BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
            };
            middle.AddChidren(typeFramelayout);
            var typeRowlayout = new RowLayout
            {
                Y = Application.GetRealHeight(30),
                Width = Application.GetRealWidth(965),
                Height = Application.GetRealHeight(130),
                X = Application.GetRealWidth(58),
                LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
            };
            typeFramelayout.AddChidren(typeRowlayout);
            var btnTypeTextTitle = new Button
            {
                Text = Language.StringByID(MyInternationalizationString.type),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                Width = Application.GetRealWidth(265),
                TextSize = 14,
            };
            typeRowlayout.AddChidren(btnTypeTextTitle);
            var btnimmediateexecution = new Button
            {
                X = btnTypeTextTitle.Right,
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth(630),
                TextAlignment = TextAlignment.CenterRight,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextID = MyInternationalizationString.timeframe,
                TextSize = 14,
            };
            typeRowlayout.AddChidren(btnimmediateexecution);
            var btnimmediateexecutionBack = new Button
            {
                Width = Application.GetRealWidth(58),
                Height = Application.GetRealHeight(58),
                UnSelectedImagePath = "ZigeeLogic/next.png",
                X = btnimmediateexecution.Right + Application.GetRealWidth(12),
                Gravity = Gravity.CenterVertical,
            };
            typeRowlayout.AddChidren(btnimmediateexecutionBack);
            TypeView typeView = new TypeView();
            middle.AddChidren(typeView.Show());
            typeView.textBtn.TextID = MyInternationalizationString.type;
            typeView.titleBtn.TextID = MyInternationalizationString.timeframe;
            #endregion
            #region  -----开始时间
            var timestarFramelayout = new FrameLayout
            {
                Height = Application.GetRealHeight(160),
                BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
                Y= typeFramelayout.Bottom,
            };
            middle.AddChidren(timestarFramelayout);
            var timestartrow = new RowLayout
            {
                Y = Application.GetRealHeight(30),
                Width = Application.GetRealWidth(965),
                Height = Application.GetRealHeight(130),
                X = Application.GetRealWidth(58),
                LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
            };
            timestarFramelayout.AddChidren(timestartrow);
            var btnstarttimetext = new Button
            {
                Text = Language.StringByID(MyInternationalizationString.starttime),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                Width = Application.GetRealWidth(265),
                TextSize = 14,
            };
            timestartrow.AddChidren(btnstarttimetext);
            var btnstarttime = new Button
            {
                X = btnstarttimetext.Right,
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth(630),
                TextAlignment = TextAlignment.CenterRight,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                Tag = "0",
                TextSize = 14,
            };
            timestartrow.AddChidren(btnstarttime);
            var btnstartback = new Button
            {
                Width = Application.GetRealWidth(58),
                Height = Application.GetRealHeight(58),
                UnSelectedImagePath = "ZigeeLogic/next.png",
                X = btnstarttime.Right + Application.GetRealWidth(12),
                Gravity = Gravity.CenterVertical,
            };
            timestartrow.AddChidren(btnstartback);
            TypeView startView = new TypeView();
            startView.frameLayout.Y = typeView.frameLayout.Bottom;
            middle.AddChidren(startView.Show());
            startView.textBtn.TextID = MyInternationalizationString.starttime;
            startView.titleBtn.Tag = "0";
            #endregion
            #region  -----结束时间
            var timeendFramelayout = new FrameLayout
            {
                Height = Application.GetRealHeight(160),
                BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
                Y = timestarFramelayout.Bottom,
            };
            middle.AddChidren(timeendFramelayout);
            var timeendrow = new RowLayout
            {
                Y = Application.GetRealHeight(30),
                Width = Application.GetRealWidth(965),
                Height = Application.GetRealHeight(130),
                X = Application.GetRealWidth(58),
                LineColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
            };
            timeendFramelayout.AddChidren(timeendrow);
            var btnendtimetext = new Button
            {
                Text = Language.StringByID(MyInternationalizationString.endtime),
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                Width = Application.GetRealWidth(265),
                TextSize = 14,
            };
            timeendrow.AddChidren(btnendtimetext);
            var btnendtime = new Button
            {
                X = btnendtimetext.Right,
                Gravity = Gravity.CenterVertical,
                Width = Application.GetRealWidth(630),
                TextAlignment = TextAlignment.CenterRight,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                Tag = "0",
                TextSize = 14,
            };
            timeendrow.AddChidren(btnendtime);
            var btnendtimeback = new Button
            {
                Width = Application.GetRealWidth(58),
                Height = Application.GetRealHeight(58),
                UnSelectedImagePath = "ZigeeLogic/next.png",
                X = btnendtime.Right + Application.GetRealWidth(12),
                Gravity = Gravity.CenterVertical,
            };
            timeendrow.AddChidren(btnendtimeback);
            TypeView endView = new TypeView();
            endView.frameLayout.Y = startView.frameLayout.Bottom;
            middle.AddChidren(endView.Show());
            endView.textBtn.TextID = MyInternationalizationString.endtime;
            endView.titleBtn.Tag = "0";
            #endregion
            #endregion
@@ -296,8 +99,8 @@
                    {
                        s2 = endtime[1];
                    }
                    btnstarttime.Text = starttime[0] + ":" + s1;
                    btnendtime.Text =endtime[0] + ":" + s2;
                    startView.titleBtn.Text = starttime[0] + ":" + s1;
                    endView.titleBtn.Text =endtime[0] + ":" + s2;
                    //btnstarttime.Text = timestr[0];
                    //btnendtime.Text = timestr[1];
@@ -321,12 +124,13 @@
                    timeBucketConditionsInfo.Add("StartMin", starttime[1]);
                    timeBucketConditionsInfo.Add("StopHour", endtime[0]);
                    timeBucketConditionsInfo.Add("StopMin", endtime[1]);
                    btnstarttime.Tag = int.Parse(starttime[0]) * 60 + int.Parse(starttime[1]);
                    btnendtime.Tag = int.Parse(endtime[0]) * 60 + int.Parse(endtime[1]);
                    startView.titleBtn.Tag = int.Parse(starttime[0]) * 60 + int.Parse(starttime[1]);
                    endView.titleBtn.Tag = int.Parse(endtime[0]) * 60 + int.Parse(endtime[1]);
                }
            }
            EventHandler<MouseEventArgs> stattimeclick = (sender, e) =>
            startView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
            {
                var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicTranslucentColor };
@@ -365,7 +169,7 @@
                    var startval = timeview.Hour * 60 + timeview.Minute;
                    if (btnendtime.Tag.ToString() != "0" &&  startval.ToString()==btnendtime.Tag.ToString())
                    if (endView.titleBtn.Tag.ToString() != "0" &&  startval.ToString()== endView.titleBtn.Tag.ToString())
                    {
                       
                        var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
@@ -374,7 +178,7 @@
                        alert.Show();
                        return;
                    }
                    if (btnendtime.Tag.ToString() != "0" && startval > int.Parse(btnendtime.Tag.ToString()))
                    if (endView.titleBtn.Tag.ToString() != "0" && startval > int.Parse(endView.titleBtn.Tag.ToString()))
                    {
             
                        var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
@@ -391,18 +195,14 @@
                    {
                        timeBucketConditionsInfo.Remove("StartMin");
                    }
                    btnstarttime.Tag = timeview.Hour * 60 + timeview.Minute;
                    startView.titleBtn.Tag = timeview.Hour * 60 + timeview.Minute;
                    timeBucketConditionsInfo.Add("StartHour", timeview.Hour.ToString());
                    timeBucketConditionsInfo.Add("StartMin", timeview.Minute.ToString());
                    btnstarttime.Text = timeview.Hour.ToString() + ":" + (timeview.Minute.ToString().Length < 2?"0"+timeview.Minute.ToString():timeview.Minute.ToString());
                    startView.titleBtn.Text = timeview.Hour.ToString() + ":" + (timeview.Minute.ToString().Length < 2?"0"+timeview.Minute.ToString():timeview.Minute.ToString());
                };
            };
            timestartrow.MouseUpEventHandler += stattimeclick;
            btnstarttimetext.MouseUpEventHandler += stattimeclick;
            btnstarttime.MouseUpEventHandler += stattimeclick;
            btnstartback.MouseUpEventHandler += stattimeclick;
            timestarFramelayout.MouseUpEventHandler += stattimeclick;
            EventHandler<MouseEventArgs> endtimeclick = (sender, e) =>
            endView.clickviewBtn.MouseUpEventHandler+= (sender, e) =>
            {
                var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicTranslucentColor };
@@ -441,7 +241,7 @@
                    var endval = timeview.Hour * 60 + timeview.Minute;
                    if (btnstarttime.Tag.ToString() != "0" && endval.ToString() == btnstarttime.Tag.ToString())
                    if (startView.titleBtn.Tag.ToString() != "0" && endval.ToString() == startView.titleBtn.Tag.ToString())
                    {
                       
                        var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
@@ -450,7 +250,7 @@
                        alert.Show();
                        return;
                    }
                    if (btnstarttime.Tag.ToString() != "0" && endval < int.Parse(btnstarttime.Tag.ToString()))
                    if (startView.titleBtn.Tag.ToString() != "0" && endval < int.Parse(startView.titleBtn.Tag.ToString()))
                    {
                       
                        var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
@@ -468,20 +268,16 @@
                    {
                        timeBucketConditionsInfo.Remove("StopMin");
                    }
                    btnendtime.Tag = timeview.Hour * 60 + timeview.Minute;
                    endView.titleBtn.Tag = timeview.Hour * 60 + timeview.Minute;
                    timeBucketConditionsInfo.Add("StopHour",timeview.Hour.ToString());
                    timeBucketConditionsInfo.Add("StopMin", timeview.Minute.ToString());
                    btnendtime.Text = timeview.Hour.ToString() + ":" + (timeview.Minute.ToString().Length < 2?"0"+timeview.Minute.ToString():timeview.Minute.ToString());
                    endView.titleBtn.Text = timeview.Hour.ToString() + ":" + (timeview.Minute.ToString().Length < 2?"0"+timeview.Minute.ToString():timeview.Minute.ToString());
                };
            };
            timeendrow.MouseUpEventHandler += endtimeclick;
            btnendtimetext.MouseUpEventHandler += endtimeclick;
            btnendtime.MouseUpEventHandler += endtimeclick;
            btnendtimeback.MouseUpEventHandler += endtimeclick;
            timeendFramelayout.MouseUpEventHandler += endtimeclick;
            ///完成点击事件
            EventHandler<MouseEventArgs>completeclick=(sender, e) =>
            saveView.clickviewBtn.MouseUpEventHandler+= (sender, e) =>
            {
                if (timeBucketConditionsInfo.ContainsKey("Type"))
                {
@@ -494,7 +290,7 @@
                timeBucketConditionsInfo.Add("Type", "5");
                timeBucketConditionsInfo.Add("IsValid", "1");
                if (string.IsNullOrEmpty(btnstarttime.Text) || string.IsNullOrEmpty(btnendtime.Text))
                if (string.IsNullOrEmpty(startView.titleBtn.Text) || string.IsNullOrEmpty(endView.titleBtn.Text))
                {
                    var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
                                           Language.StringByID(MyInternationalizationString.completeNext),
@@ -502,7 +298,7 @@
                    alert.Show();
                    return;
                }
                if (btnstarttime.Text == btnendtime.Text)
                if (startView.titleBtn.Text == endView.titleBtn.Text)
                {
                    var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
                                           Language.StringByID(MyInternationalizationString.sametime),
@@ -541,8 +337,6 @@
                UserView.HomePage.Instance.PageIndex += 1;
                logicCommunalPage.Show(() => { });
            };
            fra.MouseUpEventHandler += completeclick;
            btnsave.MouseUpEventHandler += completeclick;
        }
    }