From 7df40c4d000b5424bc11d4a6b9c3332dfe661c67 Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期二, 24 三月 2020 10:22:43 +0800
Subject: [PATCH] 2020-03-24-1

---
 ZigbeeApp/Shared/Phone/Device/Category/Category.cs |  356 ++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 292 insertions(+), 64 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
old mode 100644
new mode 100755
index a770748..252f21c
--- a/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Category/Category.cs
@@ -17,6 +17,7 @@
     /// </summary>
     public class Category : FrameLayout, ZigBee.Common.IStatus
     {
+
         #region 鈼� 鍙橀噺____________________________
         /// <summary>
         /// The instance.
@@ -34,14 +35,10 @@
         /// 鍦烘櫙
         /// </summary>
         private ButtonLineForm sceneBtn;
-        ///// <summary>
-        ///// 鑷姩鍖�
-        ///// </summary>
-        //private ButtonLineForm automationBtn;
         /// <summary>
         /// 鑷姩鍖�
         /// </summary>
-        public  static  ButtonLineForm automationBtn;
+        private ButtonLineForm automationBtn;
         /// <summary>
         /// 鍦烘櫙鍔熻兘涓儴鑳屾櫙bodyView
         /// </summary>
@@ -126,7 +123,7 @@
         #endregion
 
         #region 鈼� 鎺ュ彛____________________________
-
+      
         /// <summary>
         /// 璁惧鐘舵�佹洿鏂版帴鍙�
         /// <para>type锛氬鏋滀负 DeviceInComingRespon:璁惧鏂颁笂鎶�</para>
@@ -2054,11 +2051,9 @@
                 X = Application.GetRealWidth(58),
                 //Radius = (uint)Application.GetRealHeight(50),
                 Y = Application.GetRealHeight(30),
-
             };
             functionSceneAutoBodyView.AddChidren(bjFrameLayout);
             bjFrameLayout.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerBottomLeft);
-            //鍥炬爣鎺т欢
             var sigBtn = new Button
             {
                 Width = Application.GetMinRealAverage(84),
@@ -2068,7 +2063,7 @@
                 Gravity = Gravity.CenterVertical,
             };
             bjFrameLayout.AddChidren(sigBtn);
-            //鎺ㄨ崘妯℃澘鏂囨湰鎺т欢
+
             var recommendtextBtn = new Button
             {
                 Width = Application.GetMinRealAverage(300),
@@ -2082,19 +2077,19 @@
                 TextSize = 15,
             };
             bjFrameLayout.AddChidren(recommendtextBtn);
-            //鎺ㄨ崘妯℃澘寮�鍏虫帶浠�
+
             var recommendswitchBtn = new Button
             {
-                Width = Application.GetRealWidth(104),
-                Height = Application.GetRealHeight(63),
+                Width = Application.GetMinRealAverage(104),
+                Height = Application.GetMinRealAverage(63),
                 UnSelectedImagePath = "ZigeeLogic/logicclose.png",
                 SelectedImagePath = "ZigeeLogic/logicopen.png",
                 X = bjFrameLayout.Width - Application.GetRealWidth(104 + 58),
                 Gravity = Gravity.CenterVertical,
             };
             bjFrameLayout.AddChidren(recommendswitchBtn);
-            #endregion
-            //榛樿鎺ㄨ崘妯℃澘宸﹀彸鍙粦鎺т欢
+
+
             var scenehorizontalScrol = new HorizontalScrolViewLayout
             {
                 Width = Application.GetRealWidth(1080 - 58),
@@ -2103,7 +2098,7 @@
                 Height = Application.GetRealHeight(0),
             };
             functionSceneAutoBodyView.AddChidren(scenehorizontalScrol);
-            //鏄剧ず鑷姩鍖栧垪琛ㄤ笂涓嬪彲婊戞帶浠�
+
             var logicScrolView = new VerticalRefreshLayout//VerticalScrolViewLayout
             {
                 Height = functionSceneAutoBodyView.Height - bjFrameLayout.Height - bjFrameLayout.Y - scenehorizontalScrol.Height - Application.GetRealHeight(30),
@@ -2114,7 +2109,6 @@
             functionSceneAutoBodyView.AddChidren(logicScrolView);
             logicScrolView.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft);
             bool no = false;
-            //鏄剧ず榛樿妯℃澘鐨勭晫闈簨浠�
             recommendswitchBtn.MouseUpEventHandler += (sender, e) =>
             {
                 int Yheight = 0;
@@ -2208,15 +2202,6 @@
                 logicScrolView.Height = functionSceneAutoBodyView.Height - bjFrameLayout.Height - bjFrameLayout.Y - scenehorizontalScrol.Height - Application.GetRealHeight(30) - Yheight;
                 Automationview(logicScrolView, no);
             };
-            //涓嬫媺鍒锋柊鑷姩鍖栧垪琛ㄧ殑浜嬩欢
-            logicScrolView.BeginHeaderRefreshingAction += () =>
-            {
-                //閲嶆柊鍒锋柊logic鍒楄〃
-                Common.Logic.LogicList.Clear();
-                Read(logicScrolView, no);
-                //鍏抽棴鍒锋柊View锛�
-                logicScrolView.EndHeaderRefreshing();
-            };
             logicScrolView.BeginHeaderRefreshingAction += () =>
             {
                 //閲嶆柊鍒锋柊logic鍒楄〃
@@ -2226,8 +2211,6 @@
                 logicScrolView.EndHeaderRefreshing();
             };
 
-            Read(logicScrolView, no);
-
             Read(logicScrolView, no);
 
         }
@@ -2317,27 +2300,21 @@
                     refresview.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
                 }
             }
-
             foreach (var logic in Common.Logic.LogicList)
-            {
-                var fLayout = new FrameLayout
-                {
-                    Height = Application.GetRealHeight(190 + 30),
-                    Width = Application.GetRealWidth(1080 - 58),
-                    BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
-                };
-                refresview.AddChidren(fLayout);
-
+            {
+
+
                 var logicRowlayout = new RowLayout
                 {
                     Height = Application.GetRealHeight(190 + 30),
                     Width = Application.GetRealWidth(1080 - 58),
-                    LineColor = ZigbeeColor.Current.LogicBackgroundColor,
-                    BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
-                    SubViewWidth = Application.GetRealWidth(184),//鏀瑰彉缂栬緫鎺т欢瀹藉害澶氬皯锛�
-
+                    LineColor = ZigbeeColor.Current.LogicBackgroundColor,
+                    BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
+
                 };
-                fLayout.AddChidren(logicRowlayout);
+                refresview.AddChidren(logicRowlayout);
+
+
 
                 var logicnameBtn = new Button
                 {
@@ -2352,6 +2329,7 @@
                 };
                 logicRowlayout.AddChidren(logicnameBtn);
 
+
                 var logicswitchBtn = new Button
                 {
                     Width = Application.GetMinRealAverage(104),
@@ -2360,9 +2338,10 @@
                     SelectedImagePath = "ZigeeLogic/logicopen.png",
                     X = logicRowlayout.Width - Application.GetRealWidth(104 + 58),
                     Y = Application.GetRealHeight(58 + 30 + 9 + 30),
-
                 };
                 logicRowlayout.AddChidren(logicswitchBtn);
+
+
 
                 logicswitchBtn.MouseUpEventHandler += (sender1, e1) =>
                 {
@@ -2406,9 +2385,13 @@
                     var logicCommunalPage = new Logic.LogicCommunalPage();
                     HomePage.Instance.AddChidren(logicCommunalPage);
                     HomePage.Instance.PageIndex += 1;
-                    logicCommunalPage.Show(() => { logicnameBtn.Text = logic.LogicName; Automationview(refresview, no); });
+                    logicCommunalPage.Show(() => {
+                        logicnameBtn.Text = logic.LogicName;
+                        Automationview(refresview, no);
+                    });
 
                 };
+
 
                 ///鍒犻櫎
                 var del = new Button
@@ -2420,28 +2403,27 @@
                 logicRowlayout.AddRightView(del);
                 del.MouseUpEventHandler += (sender, e) =>
                 {
-                    var alert = new Alert(Language.StringByID(MyInternationalizationString.tip), Language.StringByID(MyInternationalizationString.doyouwanttodelete),
-                                             Language.StringByID(MyInternationalizationString.cancel), Language.StringByID(MyInternationalizationString.confrim));
-                    alert.ResultEventHandler += (sender1, e1) =>
-                    {
-                        if (e1)
-                        {
-                            Common.Logic.LogicList.Remove(logic);
-                            Automationview(refresview, no);
-                            Logic.Send.DelLogic(logic.LogicId);
-                        }
+                    var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Confirm,
+                      Language.StringByID(MyInternationalizationString.doyouwanttodelete),
+                      Language.StringByID(MyInternationalizationString.confrim));
+                    alert.Show();
+                    alert.ConfirmClickEvent += () =>
+                    {
+                        Common.Logic.LogicList.Remove(logic);
+                        Automationview(refresview, no);
+                        Logic.Send.DelLogic(logic.LogicId);
                     };
 
                 };
                 var line = new Button
                 {
-                    Y = fLayout.Height-1,
-                    Height =1,
-                    X = Application.GetRealWidth(58),
+                    Y = Application.GetRealHeight(215),
+                    Height = Application.GetRealHeight(5),
                     Width = Application.GetRealWidth(1080 - 58),
                     BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
+                    X = Application.GetRealWidth(58),
                 };
-                fLayout.AddChidren(line);
+                logicRowlayout.AddChidren(line);
             }
 
         }
@@ -2466,8 +2448,254 @@
             logicRowlayout.AddChidren(logictimeBtn);
 
             ///鏄剧ず鎵ц鍛ㄦ湡
-            Logic.Method.UpdateWeek(logictimeBtn, logic);
+            switch (logic.TimeAttribute.Repeat)
+            {
+                ///0:鍙墽琛屼竴娆★紝鎵ц鍚嶪sEnable鍊肩疆;1,浠婂勾鍐呮墽琛�;2锛氭瘡澶╂墽琛�;3锛氭瘡鏈堟墽琛�;4锛氭瘡骞存墽琛�;5锛氬懆閲嶅銆�
+                case 0:
+                    {
+                        logictimeBtn.Text = Language.StringByID(MyInternationalizationString.executeonce);
+                    }; break;
+                case 1: { }; break;
+                case 2:
+                    {
+                        logictimeBtn.Text = Language.StringByID(MyInternationalizationString.everyday);
+                    }; break;
+                case 3:
+                    {
 
+                        string len = "", value = "";
+                        var stringvalue = Convert.ToString(logic.TimeAttribute.MonthDate, 2);
+                        var str = stringvalue.Insert(0, new string('0', 32 - stringvalue.Length));
+                        for (int j = 31; j >= 0; j--)
+                        {
+                            len += str.Substring(j, 1);
+                        }
+                        for (int j = 0; j < len.Length; j++)
+                        {
+                            var strvalue = len.Substring(j, 1);
+                            if (strvalue == "1")
+                            {
+                                value += (j + 1).ToString() + ",";
+                            }
+                        }
+                        logictimeBtn.Text = Language.StringByID(MyInternationalizationString.monthly) + value.TrimEnd(',') + Language.StringByID(MyInternationalizationString.day);
+
+                    }; break;
+                case 4:
+                    {
+
+                        Dictionary<int, int> dictionary = new Dictionary<int, int>();
+                        ///鎵惧嚭鎵ц鐨勬湀浠藉拰澶╂暟
+                        if (logic.TimeAttribute.SelectMonDate.Count != 0)
+                        {
+                            for (int i = 0; i < logic.TimeAttribute.SelectMonDate.Count; i++)
+                            {
+                                var dayvalue = logic.TimeAttribute.SelectMonDate[i];
+                                if (dayvalue != 0)
+                                {
+                                    dictionary.Add(i + 1, dayvalue);
+                                }
+                            }
+                        }
+                        if (dictionary.Count != 0 && dictionary.Count == 1)
+                        {
+                            string len = "", leng = "";
+                            int minvalue = 0, Maximum = 0;
+                            foreach (var value in dictionary)
+                            {
+                                ///鍙栧嚭鏈堜唤
+                                var month = value.Key;
+                                ///鍙栧嚭鏃ユ暟
+                                var day = value.Value;
+                                var maxvalue = Convert.ToString(day, 2);
+                                var str = maxvalue.Insert(0, new string('0', 32 - maxvalue.Length));
+                                for (int j = 31; j >= 0; j--)
+                                {
+                                    len += str.Substring(j, 1);
+                                }
+
+                                for (int j = 0; j < len.Length; j++)
+                                {
+                                    var strvalue = len.Substring(j, 1);
+                                    if (strvalue == "1")
+                                    {
+                                        minvalue = j + 1;
+                                        break;
+                                    }
+                                }
+                                for (int j = 0; j < len.Length; j++)
+                                {
+                                    var strvalue = len.Substring(j, 1);
+                                    if (strvalue == "1")
+                                    {
+                                        Maximum = j + 1;
+                                    }
+                                }
+
+                                if (month.ToString().Length < 2)
+                                {
+                                    leng = "0" + month.ToString();
+                                }
+                                else
+                                {
+                                    leng = month.ToString();
+                                }
+                                if (minvalue == Maximum)
+                                {
+                                    logictimeBtn.Text = Language.StringByID(MyInternationalizationString.everyyear) + leng + "/" + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString());
+                                }
+                                else
+                                {
+                                    logictimeBtn.Text = Language.StringByID(MyInternationalizationString.everyyear) + leng + "/" + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString()) + "-" + leng + "/" + (Maximum.ToString().Length < 2 ? "0" + Maximum.ToString() : Maximum.ToString());
+                                }
+                            }
+
+                        }
+                        else
+                        {
+                            int b = 0;
+                            string stringtext = "";
+                            foreach (var value in dictionary)
+                            {
+                                string len = "", leng = "";
+                                int minvalue = 0, Maximum = 0;
+                                ///鍙栧嚭鏈堜唤
+                                var month = value.Key;
+                                ///鍙栧嚭鏃ユ暟
+                                var day = value.Value;
+                                var maxvalue = Convert.ToString(day, 2);
+                                var str = maxvalue.Insert(0, new string('0', 32 - maxvalue.Length));
+                                for (int j = 31; j >= 0; j--)
+                                {
+                                    len += str.Substring(j, 1);
+                                }
+
+
+                                if (month.ToString().Length < 2)
+                                {
+                                    leng = "0" + month.ToString();
+                                }
+                                else
+                                {
+                                    leng = month.ToString();
+                                }
+
+
+
+                                if (b == 0)
+                                {
+                                    for (int j = 0; j < len.Length; j++)
+                                    {
+                                        var strvalue = len.Substring(j, 1);
+                                        if (strvalue == "1")
+                                        {
+                                            minvalue = j + 1;
+                                            break;
+                                        }
+                                    }
+                                    stringtext += leng + "/" + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString()) + "-";
+
+                                }
+
+                                if (b == dictionary.Count - 1)
+                                {
+                                    for (int j = 0; j < len.Length; j++)
+                                    {
+                                        var strvalue = len.Substring(j, 1);
+                                        if (strvalue == "1")
+                                        {
+                                            Maximum = j + 1;
+                                        }
+                                    }
+                                    stringtext += leng + "/" + (Maximum.ToString().Length < 2 ? "0" + Maximum.ToString() : Maximum.ToString());
+
+                                }
+                                b++;
+                            }
+                            logictimeBtn.Text = Language.StringByID(MyInternationalizationString.everyyear) + stringtext;
+                        }
+
+                    }; break;
+                case 5:
+                    {
+                        string len = "", text = "";
+                        List<int> listvalueInt = new List<int>();
+                        listvalueInt.Clear();
+                        var maxvalue = Convert.ToString(logic.TimeAttribute.WeekDay, 2);
+                        var str = maxvalue.Insert(0, new string('0', 8 - maxvalue.Length));
+                        for (int j = 7; j >= 0; j--)
+                        {
+                            len += str.Substring(j, 1);
+                        }
+
+                        for (int j = 0; j < len.Length; j++)
+                        {
+                            var strvalue = len.Substring(j, 1);
+                            if (strvalue == "1")
+                            {
+                                listvalueInt.Add(j + 1);
+
+
+                                if ((j + 1) == 1)
+                                {
+                                    text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.mon1) + ",";
+                                    //text += Language.StringByID(MyInternationalizationString.mon) + ",";
+                                }
+                                else if ((j + 1) == 2)
+                                {
+                                    text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.tue1) + ",";
+                                    //text += Language.StringByID(MyInternationalizationString.tue) + ",";
+                                }
+                                else if ((j + 1) == 3)
+                                {
+                                    text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.wed1) + ",";
+                                    //text += Language.StringByID(MyInternationalizationString.wed) + ",";
+                                }
+                                else if ((j + 1) == 4)
+                                {
+                                    text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.thu1) + ",";
+                                    //text += Language.StringByID(MyInternationalizationString.thu) + ",";
+                                }
+                                else if ((j + 1) == 5)
+                                {
+                                    text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.frl1) + ",";
+                                    //text += Language.StringByID(MyInternationalizationString.frl) + ",";
+                                }
+                                else if ((j + 1) == 6)
+                                {
+                                    text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.sat1) + ",";
+                                    //text += Language.StringByID(MyInternationalizationString.sat) + ",";
+                                }
+                                else if ((j + 1) == 7)
+                                {
+                                    text += Language.StringByID(MyInternationalizationString.week1) + Language.StringByID(MyInternationalizationString.sun1) + ",";
+                                    //text += Language.StringByID(MyInternationalizationString.sun) + ",";
+                                }
+
+
+                            }
+                        }
+                        //鏆傛椂闅愯棌鎺夛紝闇�瑕佹樉绀哄懆鏈拰宸ヤ綔鏃ュ啀鏀惧紑锛�
+                        //if (listvalueInt.Count == 5 && !listvalueInt.Contains(6) && !listvalueInt.Contains(7))
+                        //{
+                        //    btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.workingday);
+                        //}
+                        //else if (listvalueInt.Count == 2 && listvalueInt.Contains(6) && listvalueInt.Contains(7))
+                        //{
+                        //    btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.weekend);
+                        //}
+                        //else if (listvalueInt.Count == 7)
+                        //{
+                        //    btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.everyday);
+                        //}
+                        //else
+                        //{
+                        //    btndisplaycycle.Text = Language.StringByID(MyInternationalizationString.week1) + text.Replace(Language.StringByID(MyInternationalizationString.week1), "").TrimEnd(',');
+                        //}
+                        logictimeBtn.Text = Language.StringByID(MyInternationalizationString.week1) + text.Replace(Language.StringByID(MyInternationalizationString.week1), "").TrimEnd(',');
+                        //btndisplaycycle.Text = text.TrimEnd(',');
+                    }; break;
+            }
 
             List<string> indexlist = new List<string>();
             List<string> iconIndexlist = new List<string>();
@@ -2501,19 +2729,19 @@
                 var iconindex = iconIndexlist[i];
                 var typebjBtn = new FrameLayout
                 {
-                    Width = Application.GetMinRealAverage(82),
-                    Height = Application.GetMinRealAverage(82),
+                    Width = Application.GetRealWidth(82),
+                    Height = Application.GetRealHeight(82),
                     X = Application.GetRealWidth(58) + Application.GetRealWidth(12 + (12 + 82 + 45 + 12) * i),
                     Y = Application.GetRealHeight(58 + 30 + 30),
-                    Radius = (uint)Application.GetMinRealAverage(41),
+                    Radius = (uint)Application.GetRealHeight(41),
                     BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
                 };
                 logicRowlayout.AddChidren(typebjBtn);
 
                 var typeIconBtn = new Button
                 {
-                    Width = Application.GetMinRealAverage(58),
-                    Height = Application.GetMinRealAverage(58),
+                    Width = Application.GetRealWidth(58),
+                    Height = Application.GetRealHeight(58),
                     Gravity = Gravity.Center,
 
                 };

--
Gitblit v1.8.0