From 6fa9d69da922c8049f5acfcbb9ce9fd26811024c Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期四, 16 四月 2020 17:10:57 +0800
Subject: [PATCH] 请合并代码

---
 ZigbeeApp/Shared/Phone/Device/Logic/TimePage.cs |  347 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 347 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/TimePage.cs b/ZigbeeApp/Shared/Phone/Device/Logic/TimePage.cs
new file mode 100755
index 0000000..63e792d
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/TimePage.cs
@@ -0,0 +1,347 @@
+锘縰sing System;
+using System.Collections.Generic;
+using Shared;
+using Shared.Common;
+using Shared.Phone;
+using Shared.Phone.Device.Logic.LogicView;
+using Shared.R;
+using ZigBee.Device;
+
+namespace Shared.Phone.Device.Logic
+{
+    public class TimePage : FrameLayout
+    {
+        public TimePage()
+        {
+            Tag = "Logic";
+        }
+        public bool IsEditor;
+        public string str1;
+
+        Dictionary<string, string> timeBucketConditionsInfo = new Dictionary<string, string>();
+        public void Show()
+        {
+
+            #region  涓婇潰鐨勫竷灞�浠g爜
+            TopView view = new TopView();
+            this.AddChidren(view.TopRowView());
+            view.toptitleNameBtn.TextID = MyInternationalizationString.selection;
+            view.clickBtn.MouseDownEventHandler += (sender, e) => { RemoveFromParent(); };
+            #endregion
+
+            #region  鏈�涓嬮潰鐨勫竷灞�浠g爜
+            var middle = new FrameLayout
+            {
+                Y = view.topRowLayout.Bottom,
+                Height = Application.GetRealHeight(Method.H - 184 - 260),
+                BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
+            };
+            this.AddChidren(middle);
+            //淇濆瓨
+            SaveView saveView = new SaveView();
+            saveView.frameLayout.Y = middle.Bottom;
+            this.AddChidren(saveView.Show());
+            #endregion
+
+            #region   -----鏃堕棿鑼冨洿  寮�濮嬫椂闂�  缁撴潫鏃堕棿
+            #region   -----鏃堕棿鑼冨洿
+
+            TypeView typeView = new TypeView();
+            middle.AddChidren(typeView.Show());
+            typeView.textBtn.TextID = MyInternationalizationString.type;
+            typeView.titleBtn.Width = Application.GetRealWidth(630 + 70);
+            typeView.titleBtn.TextID = MyInternationalizationString.timeframe;
+            typeView.backBtn.Visible = false;
+
+            #endregion
+
+            #region  -----寮�濮嬫椂闂�
+
+            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  -----缁撴潫鏃堕棿
+
+            TypeView endView = new TypeView();
+            endView.frameLayout.Y = startView.frameLayout.Bottom;
+            endView.frameLayout.Height = Application.GetRealHeight(160 + 20);//鏈�鍚庝竴琛屽鍔�20楂樺害;
+            middle.AddChidren(endView.Show());
+            endView.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor;//鏀瑰彉鏈�鍚庝竴琛岀嚎棰滆壊;
+            endView.textBtn.TextID = MyInternationalizationString.endtime;
+            endView.titleBtn.Tag = "0";
+
+            #endregion
+            #endregion
+
+            if (IsEditor)
+            {
+                if (str1 != null)
+                {
+
+                    string[] timestr = str1.Split('-');
+                    string[] starttime = timestr[0].Split(':');
+                    string[] endtime = timestr[1].Split(':');
+                    string s1 = "", s2 = "";
+                    if (starttime[1].Length < 2)
+                    {
+                        s1 = "0" + starttime[1];
+                    }
+                    else
+                    {
+                        s1 = starttime[1];
+                    }
+                    if (endtime[1].Length < 2)
+                    {
+                        s2 = "0" + endtime[1];
+                    }
+                    else
+                    {
+                        s2 = endtime[1];
+                    }
+                    startView.titleBtn.Text = starttime[0] + ":" + s1;
+                    endView.titleBtn.Text = endtime[0] + ":" + s2;
+
+                    //btnstarttime.Text = timestr[0];
+                    //btnendtime.Text = timestr[1];
+                    if (timeBucketConditionsInfo.ContainsKey("StartHour"))
+                    {
+                        timeBucketConditionsInfo.Remove("StartHour");
+                    }
+                    if (timeBucketConditionsInfo.ContainsKey("StartMin"))
+                    {
+                        timeBucketConditionsInfo.Remove("StartMin");
+                    }
+                    if (timeBucketConditionsInfo.ContainsKey("StopHour"))
+                    {
+                        timeBucketConditionsInfo.Remove("StopHour");
+                    }
+                    if (timeBucketConditionsInfo.ContainsKey("StopMin"))
+                    {
+                        timeBucketConditionsInfo.Remove("StopMin");
+                    }
+                    timeBucketConditionsInfo.Add("StartHour", starttime[0]);
+                    timeBucketConditionsInfo.Add("StartMin", starttime[1]);
+                    timeBucketConditionsInfo.Add("StopHour", endtime[0]);
+                    timeBucketConditionsInfo.Add("StopMin", 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]);
+                }
+
+            }
+
+            startView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
+            {
+
+                var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicTranslucentColor };
+                AddChidren(flMain);
+                flMain.MouseUpEventHandler += (sender11, e11) =>
+                {
+                    flMain.RemoveFromParent();
+                };
+
+                var timeview = new TimeView
+                {
+                    Y = Application.GetRealHeight(1920 - 600),
+                    Height = Application.GetRealHeight(600),
+                    BackgroundColor = ZigbeeColor.Current.LogicTimeViewColor,
+                    Width = Application.GetRealWidth(1080),
+                };
+                flMain.AddChidren(timeview);
+
+
+                var btnSave = new Button
+                {
+                    Y = Application.GetRealHeight(1920 - 600),
+                    Width = Application.GetRealWidth(200),
+                    Height = Application.GetRealHeight(150),
+                    Text = Language.StringByID(MyInternationalizationString.complete),
+                    // TextColor = 0xFF121212,
+                    TextColor = ZigbeeColor.Current.LogicTimeViewSaveButton,
+                    //TextAlignment = TextAlignment.CenterRight
+                    X = Application.GetRealWidth(1080 - 200),
+                };
+                flMain.AddChidren(btnSave);
+
+                btnSave.MouseUpEventHandler += (sender2, e2) =>
+                {
+                    flMain.RemoveFromParent();
+
+                    var startval = timeview.Hour * 60 + timeview.Minute;
+
+                    if (endView.titleBtn.Tag.ToString() != "0" && startval.ToString() == endView.titleBtn.Tag.ToString())
+                    {
+
+                        var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
+                                        Language.StringByID(MyInternationalizationString.nottime),
+                                       Language.StringByID(MyInternationalizationString.confrim));
+                        alert.Show();
+                        return;
+                    }
+                    if (endView.titleBtn.Tag.ToString() != "0" && startval > int.Parse(endView.titleBtn.Tag.ToString()))
+                    {
+
+                        var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
+                                        Language.StringByID(MyInternationalizationString.timesetting),
+                                       Language.StringByID(MyInternationalizationString.confrim));
+                        alert.Show();
+                        return;
+                    }
+                    if (timeBucketConditionsInfo.ContainsKey("StartHour"))
+                    {
+                        timeBucketConditionsInfo.Remove("StartHour");
+                    }
+                    if (timeBucketConditionsInfo.ContainsKey("StartMin"))
+                    {
+                        timeBucketConditionsInfo.Remove("StartMin");
+                    }
+                    startView.titleBtn.Tag = timeview.Hour * 60 + timeview.Minute;
+                    timeBucketConditionsInfo.Add("StartHour", timeview.Hour.ToString());
+                    timeBucketConditionsInfo.Add("StartMin", timeview.Minute.ToString());
+                    startView.titleBtn.Text = timeview.Hour.ToString() + ":" + (timeview.Minute.ToString().Length < 2 ? "0" + timeview.Minute.ToString() : timeview.Minute.ToString());
+                };
+            };
+
+            endView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
+             {
+
+                 var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicTranslucentColor };
+                 AddChidren(flMain);
+                 flMain.MouseUpEventHandler += (sender11, e11) =>
+                 {
+                     flMain.RemoveFromParent();
+                 };
+
+                 var timeview = new TimeView
+                 {
+                     Y = Application.GetRealHeight(1920 - 600),
+                     Height = Application.GetRealHeight(600),
+                     BackgroundColor = ZigbeeColor.Current.LogicTimeViewColor,
+                     Width = Application.GetRealWidth(1080),
+                 };
+                 flMain.AddChidren(timeview);
+
+
+                 var btnSave = new Button
+                 {
+                     Y = Application.GetRealHeight(1920 - 600),
+                     Width = Application.GetRealWidth(200),
+                     Height = Application.GetRealHeight(150),
+                     Text = Language.StringByID(MyInternationalizationString.complete),
+                    //TextColor = 0xFF121212,
+                    TextColor = ZigbeeColor.Current.LogicTimeViewSaveButton,
+                    //TextAlignment = TextAlignment.CenterRight
+                    X = Application.GetRealWidth(1080 - 200),
+                 };
+                 flMain.AddChidren(btnSave);
+
+                 btnSave.MouseUpEventHandler += (sender2, e2) =>
+                 {
+                     flMain.RemoveFromParent();
+
+                     var endval = timeview.Hour * 60 + timeview.Minute;
+
+                     if (startView.titleBtn.Tag.ToString() != "0" && endval.ToString() == startView.titleBtn.Tag.ToString())
+                     {
+
+                         var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
+                                         Language.StringByID(MyInternationalizationString.nottime),
+                                        Language.StringByID(MyInternationalizationString.confrim));
+                         alert.Show();
+                         return;
+                     }
+                     if (startView.titleBtn.Tag.ToString() != "0" && endval < int.Parse(startView.titleBtn.Tag.ToString()))
+                     {
+
+                         var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
+                                         Language.StringByID(MyInternationalizationString.timesetting),
+                                        Language.StringByID(MyInternationalizationString.confrim));
+                         alert.Show();
+                         return;
+                     }
+
+                     if (timeBucketConditionsInfo.ContainsKey("StopHour"))
+                     {
+                         timeBucketConditionsInfo.Remove("StopHour");
+                     }
+                     if (timeBucketConditionsInfo.ContainsKey("StopMin"))
+                     {
+                         timeBucketConditionsInfo.Remove("StopMin");
+                     }
+                     endView.titleBtn.Tag = timeview.Hour * 60 + timeview.Minute;
+                     timeBucketConditionsInfo.Add("StopHour", timeview.Hour.ToString());
+                     timeBucketConditionsInfo.Add("StopMin", timeview.Minute.ToString());
+                     endView.titleBtn.Text = timeview.Hour.ToString() + ":" + (timeview.Minute.ToString().Length < 2 ? "0" + timeview.Minute.ToString() : timeview.Minute.ToString());
+                 };
+             };
+
+
+            ///瀹屾垚鐐瑰嚮浜嬩欢
+            saveView.clickviewBtn.MouseUpEventHandler += (sender, e) =>
+             {
+                 if (timeBucketConditionsInfo.ContainsKey("Type"))
+                 {
+                     timeBucketConditionsInfo.Remove("Type");
+                 }
+                 if (timeBucketConditionsInfo.ContainsKey("IsValid"))
+                 {
+                     timeBucketConditionsInfo.Remove("IsValid");
+                 }
+                 timeBucketConditionsInfo.Add("Type", "5");
+                 timeBucketConditionsInfo.Add("IsValid", "1");
+
+                 if (string.IsNullOrEmpty(startView.titleBtn.Text) || string.IsNullOrEmpty(endView.titleBtn.Text))
+                 {
+                     var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
+                                            Language.StringByID(MyInternationalizationString.completeNext),
+                                           Language.StringByID(MyInternationalizationString.confrim));
+                     alert.Show();
+                     return;
+                 }
+                 if (startView.titleBtn.Text == endView.titleBtn.Text)
+                 {
+                     var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
+                                            Language.StringByID(MyInternationalizationString.sametime),
+                                           Language.StringByID(MyInternationalizationString.confrim));
+                     alert.Show();
+                     return;
+                 }
+
+                 if (IsEditor)
+                 {
+                     for (int i = 0; i < Common.Logic.CurrentLogic.Conditions.Count; i++)
+                     {
+                         if (Common.Logic.CurrentLogic.Conditions[i]["Type"] == "5")
+                         {
+
+                             var timeBucketInfo = Common.Logic.CurrentLogic.Conditions[i];
+                             var s = timeBucketInfo["StartHour"] + ":" + timeBucketInfo["StartMin"] + "-" + timeBucketInfo["StopHour"] + ":" + timeBucketInfo["StopMin"];
+                             if (str1 == s)
+                             {
+                                 Common.Logic.CurrentLogic.Conditions.RemoveAt(i);
+                                 Common.Logic.CurrentLogic.Conditions.Insert(i, timeBucketConditionsInfo);
+                             }
+
+                         }
+                     }
+                 }
+                 else
+                 {
+                     Common.Logic.CurrentLogic.Conditions.Add(timeBucketConditionsInfo);
+                 }
+
+                //LogicIfon.logicIfon.Addconditions(timeBucketConditionsInfo,timeBucketConditionsInfo.Type);
+
+                var logicCommunalPage = new LogicCommunalPage { };
+                 UserView.HomePage.Instance.AddChidren(logicCommunalPage);
+                 UserView.HomePage.Instance.PageIndex += 1;
+                 logicCommunalPage.Show(() => { });
+
+             };
+        }
+
+    }
+}

--
Gitblit v1.8.0