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/EveryyearPage.cs |  677 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 677 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/EveryyearPage.cs b/ZigbeeApp/Shared/Phone/Device/Logic/EveryyearPage.cs
new file mode 100755
index 0000000..9debcc0
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/EveryyearPage.cs
@@ -0,0 +1,677 @@
+锘縰sing System;
+using System.Collections.Generic;
+using Shared;
+using Shared.Phone;
+using Shared.R;
+using Shared.Common;
+namespace Shared.Phone.Device.Logic
+{
+    public class EveryyearPage : FrameLayout
+    {
+
+
+        public void Show()
+        {
+
+            this.BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor;
+            var topFrameLayout = new FrameLayout
+            {
+                Height = Application.GetRealHeight(140),
+                Y = Application.GetRealHeight(80),
+               // BackgroundColor = 0xFF1F1F1F,
+            };
+            AddChidren(topFrameLayout);
+
+            var titleName = new Button
+            {
+                TextID = MyInternationalizationString.cycle,
+                TextSize = 16,
+                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
+                IsBold = true,
+            };
+            topFrameLayout.AddChidren(titleName);
+
+            var hdl = new Button
+            {
+                Width = Application.GetRealWidth(154),
+                Height = Application.GetRealHeight(90),
+                X = Application.GetRealWidth(1080 - 160),
+                Gravity = Gravity.CenterVertical,
+                UnSelectedImagePath = "Logo/Logo.png",
+            };
+            //topFrameLayout.AddChidren(hdl);
+
+            var back = new Button
+            {
+                Width = Application.GetRealWidth(110),
+                Height = Application.GetRealHeight(110),
+                X = Application.GetRealWidth(20),
+                Gravity = Gravity.CenterVertical,
+                UnSelectedImagePath = "ZigeeLogic/Back.png",
+            };
+            topFrameLayout.AddChidren(back);
+            back.MouseDownEventHandler += (sender, e) =>
+            {
+                RemoveFromParent();
+            };
+
+            var titlerl = new RowLayout
+            {
+                Height = Application.GetRealHeight(180),
+                //BackgroundColor = 0xff0f0f0f,
+                Y = Application.GetRealHeight(220),
+            };
+            AddChidren(titlerl);
+
+            titlerl.AddChidren(
+              new Button
+              {
+                  X = Application.GetRealWidth(40),
+                  //Text = "璇烽�夋嫨閲嶅鎵ц鍛ㄦ湡",
+                  TextID = MyInternationalizationString.repeat,
+                  TextSize = 17,
+                  TextAlignment = TextAlignment.CenterLeft,
+                  TextColor = ZigbeeColor.Current.LogicTextBlackColor,
+              }
+            );
+
+            var middle = new VerticalScrolViewLayout();
+            middle.Y = titlerl.Bottom;
+            middle.Height = Application.GetRealHeight(Method.H - 220 - 180);
+            middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
+            this.AddChidren(middle);
+
+
+            var startdateRowLayout = new RowLayout
+            {
+                Height = Application.GetRealHeight(180),
+            };
+            middle.AddChidren(startdateRowLayout);
+
+            var startdatetext = new Button
+            {
+                X = Application.GetRealWidth(40),
+                TextAlignment = TextAlignment.CenterLeft,
+                Gravity = Gravity.CenterVertical,
+                //Text = "璧峰鏃ユ湡",
+                Width = Application.GetRealWidth(400),
+                TextID = MyInternationalizationString.startdate,
+                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
+            };
+            startdateRowLayout.AddChidren(startdatetext);
+
+            ///鏄剧ず璧峰鏃ユ湡鎺т欢
+            var btnStartdate = new Button
+            {
+                Width = Application.GetRealWidth(400),
+                Height = Application.GetRealHeight(180),
+                X = Application.GetRealWidth(440),
+                Gravity = Gravity.CenterVertical,
+                Tag = 0,
+                TextAlignment = TextAlignment.CenterLeft,
+                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
+
+            };
+            startdateRowLayout.AddChidren(btnStartdate);
+
+            var btnStartdateback = new Button
+            {
+                Width = Application.GetRealWidth(110),
+                Height = Application.GetRealHeight(110),
+                UnSelectedImagePath = "ZigeeLogic/next.png",
+                X = Application.GetRealWidth(1080 - 140),
+                Gravity = Gravity.CenterVertical,
+            };
+            startdateRowLayout.AddChidren(btnStartdateback);
+
+            var enddateRowLayout = new RowLayout
+            {
+                Height = Application.GetRealHeight(180),
+            };
+            middle.AddChidren(enddateRowLayout);
+
+            var enddtaetext = new Button
+            {
+                X = Application.GetRealWidth(40),
+                TextAlignment = TextAlignment.CenterLeft,
+                Gravity = Gravity.CenterVertical,
+                TextID = MyInternationalizationString.enddate,
+                Width = Application.GetRealWidth(400),
+                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
+                //Text = "缁撴潫鏃ユ湡",
+            };
+            enddateRowLayout.AddChidren(enddtaetext);
+
+            ///鏄剧ず缁撴潫鏃ユ湡鎺т欢
+            var btndateEnddate = new Button
+            {
+                Width = Application.GetRealWidth(400),
+                Height = Application.GetRealHeight(180),
+                X = Application.GetRealWidth(440),
+                Gravity = Gravity.CenterVertical,
+                Tag = 0,
+                TextAlignment = TextAlignment.CenterLeft,
+                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
+
+            };
+            enddateRowLayout.AddChidren(btndateEnddate);
+
+
+            var btnenddateback = new Button
+            {
+                Width = Application.GetRealWidth(110),
+                Height = Application.GetRealHeight(110),
+                UnSelectedImagePath = "ZigeeLogic/next.png",
+                X = Application.GetRealWidth(1080 - 140),
+                Gravity = Gravity.CenterVertical,
+            };
+            enddateRowLayout.AddChidren(btnenddateback);
+
+
+            ///璧峰鏃ユ湡鐐瑰嚮浜嬩欢
+            EventHandler<MouseEventArgs> startdateclick = (sender33, e33) =>
+            {
+                var list = new List<KeyValuePair<string, string[]>> { };
+                for (int month = 1; month <= 12; month++)
+                {
+                    int days = DateTime.DaysInMonth(DateTime.Now.Year, month);
+                    var listValues = new List<string> { };
+                    for (int day = 1; day <= days; day++)
+                    {
+                        listValues.Add(day.ToString() + " " + Language.StringByID(MyInternationalizationString.day));
+                    }
+                    list.Add(new KeyValuePair<string, string[]>(month.ToString() + " " + Language.StringByID(MyInternationalizationString.month), listValues.ToArray()));
+                }
+                /*
+                PickerView.Show(list, (obj) =>
+                 {
+
+                    var month = obj.Split(',')[0].Split(' ')[0];
+                    var day = obj.Split(',')[1].Split(' ')[0];
+
+                    if (month.Length < 2)
+                    {
+                        month = "0" + month;
+                    }
+                    if (day.Length < 2)
+                    {
+                        day = "0" + day;
+                    }
+                    var leng = month + day;
+
+                    if (btndateEnddate.Tag.ToString() != "0" && int.Parse(btndateEnddate.Tag.ToString()) < int.Parse(leng))
+                    {
+                        var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
+                                               Language.StringByID(MyInternationalizationString.monthday),
+                                               Language.StringByID(MyInternationalizationString.OK));
+                        alert.Show();
+                    }
+                    else
+                    {
+                        btnStartdate.Text = month + "/" + day;
+                        btnStartdate.Tag = leng;
+
+                        if (string.IsNullOrEmpty(btndateEnddate.Text))
+                        {
+                            btndateEnddate.Text = month + "/" + day;
+                            btndateEnddate.Tag = leng;
+                        }
+                        time(btnStartdate, btndateEnddate);
+                    }
+
+                }, Language.StringByID(MyInternationalizationString.complete), "");
+           */
+            };
+            startdateRowLayout.MouseUpEventHandler += startdateclick;
+            btnStartdate.MouseUpEventHandler += startdateclick;
+            startdatetext.MouseUpEventHandler += startdateclick;
+            btnStartdateback.MouseUpEventHandler += startdateclick;
+
+
+
+            ///缁撴潫鏃ユ湡鐐瑰嚮浜嬩欢
+            EventHandler<MouseEventArgs> enddateclick = (sender1, e1) =>
+            {
+
+                var list1 = new List<KeyValuePair<string, string[]>> { };
+                for (int month = 1; month <= 12; month++)
+                {
+                    int days = DateTime.DaysInMonth(DateTime.Now.Year, month);
+                    var listValues = new List<string> { };
+                    for (int day = 1; day <= days; day++)
+                    {
+                        listValues.Add(day.ToString() + " " + Language.StringByID(MyInternationalizationString.day));
+                    }
+                    list1.Add(new KeyValuePair<string, string[]>(month.ToString() + " " + Language.StringByID(MyInternationalizationString.month), listValues.ToArray()));
+                }
+                /*
+                PickerView.Show(list1, (obj) =>
+                {
+                    var month = obj.Split(',')[0].Split(' ')[0];
+                    var day = obj.Split(',')[1].Split(' ')[0];
+                    if (month.Length < 2)
+                    {
+                        month = "0" + month;
+                    }
+                    if (day.Length < 2)
+                    {
+                        day = "0" + day;
+                    }
+                    var leng = month + day;
+
+                    if (btnStartdate.Tag.ToString() != "0" && int.Parse(btnStartdate.Tag.ToString()) > int.Parse(leng))
+                    {
+                        var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
+                                               Language.StringByID(MyInternationalizationString.monthday),
+                                               Language.StringByID(MyInternationalizationString.OK));
+                        alert.Show();
+                    }
+                    else
+                    {
+                        btndateEnddate.Text = month + "/" + day;
+                        btndateEnddate.Tag = leng;
+
+                        if (string.IsNullOrEmpty(btnStartdate.Text))
+                        {
+                            btnStartdate.Text = month + "/" + day;
+                            btnStartdate.Tag = leng;
+                        }
+
+                        time(btnStartdate, btndateEnddate);
+                    }
+
+                }, Language.StringByID(MyInternationalizationString.complete), "");
+
+                */
+            };
+            enddateRowLayout.MouseUpEventHandler += enddateclick;
+            enddtaetext.MouseUpEventHandler += enddateclick;
+            btndateEnddate.MouseUpEventHandler += enddateclick;
+            btnenddateback.MouseUpEventHandler += enddateclick;
+
+            if (Common.Logic.CurrentLogic.TimeAttribute.Repeat == 4)
+            {
+
+                Dictionary<int, int> dictionary = new Dictionary<int, int>();
+                ///鎵惧嚭鎵ц鐨勬湀浠藉拰澶╂暟
+                if (Common.Logic.CurrentLogic.TimeAttribute.SelectMonDate.Count != 0)
+                {
+                    for (int i = 0; i < Common.Logic.CurrentLogic.TimeAttribute.SelectMonDate.Count; i++)
+                    {
+                        var dayvalue = Common.Logic.CurrentLogic.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;
+                        ///杞崲鎴愪簩杩涘埗bit
+                        var maxvalue = Convert.ToString(day, 2);
+                        ///杞崲鎴�32浣峴tring锛�
+                        var str = maxvalue.Insert(0, new string('0', 32 - maxvalue.Length));
+                        ///閲嶆柊鎺掑垪32浣峴tring椤哄簭锛�
+                        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();
+                        }
+
+                        btnStartdate.Text = leng + "/" + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString());
+                        btndateEnddate.Text = leng + "/" + (Maximum.ToString().Length < 2 ? "0" + Maximum.ToString() :Maximum.ToString());
+                        btnStartdate.Tag = leng + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString());
+                        btndateEnddate.Tag = leng + (Maximum.ToString().Length < 2 ? "0" + Maximum.ToString() : Maximum.ToString());
+
+                    }
+
+                }
+                else
+                {
+                    int b = 0;
+                    foreach (var value in dictionary)
+                    {
+                        string len = "", leng = "";
+                        int minvalue = 0,Maximum=0;
+                        ///鍙栧嚭鏈堜唤
+                        var month = value.Key;
+                        ///鍙栧嚭鏃ユ暟
+                        var day = value.Value;
+                        ///杞崲鎴愪簩杩涘埗bit
+                        var maxvalue = Convert.ToString(day, 2);
+                        ///杞崲鎴�32浣峴tring锛�
+                        var str = maxvalue.Insert(0, new string('0', 32 - maxvalue.Length));
+                        ///閲嶆柊鎺掑垪32浣峴tring椤哄簭锛�
+                        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();
+                        }
+                        ///绗竴涓猟ictionary鍏冪礌
+                        if (b == 0)
+                        {
+                            ///鎵惧嚭寮�濮嬫棩
+                            for (int j = 0; j < len.Length; j++)
+                            {
+                                var strvalue = len.Substring(j, 1);
+                                if (strvalue == "1")
+                                {
+                                    minvalue = j + 1;
+                                    break;
+                                }
+                            }
+                            btnStartdate.Text = leng + "/" + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString());
+                            btnStartdate.Tag = leng + (minvalue.ToString().Length < 2 ? "0" + minvalue.ToString() : minvalue.ToString());
+
+                        }
+                        ///绗簩涓猟ictionary鍏冪礌
+                        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;
+                                }
+                            }
+                            btndateEnddate.Text = leng + "/" + (Maximum.ToString().Length < 2 ? "0" + Maximum.ToString() : Maximum.ToString());
+                            btndateEnddate.Tag = leng + (Maximum.ToString().Length < 2 ? "0" + Maximum.ToString() : Maximum.ToString());
+
+                        }
+                        b++;
+                    }
+
+                }
+
+            }
+
+        }
+        /// <summary>
+        /// 鏃ユ湡澶勭悊鐨勬柟娉�
+        /// </summary>
+        void time(Button btnStartdate, Button btndateEnddate)
+        {
+
+            DateTime dtNow = DateTime.Now;
+            Common.Logic.CurrentLogic.TimeAttribute.Repeat = 4;
+            int a1 = int.Parse(btnStartdate.Tag.ToString());
+            int a2 = int.Parse(btndateEnddate.Tag.ToString());
+            int b1 = int.Parse(btnStartdate.Tag.ToString().Substring(0, 2));
+            int b2 = int.Parse(btndateEnddate.Tag.ToString().Substring(0, 2));
+            int c1 = int.Parse(btnStartdate.Tag.ToString().Substring(2, 2));
+            int c2 = int.Parse(btndateEnddate.Tag.ToString().Substring(2, 2));
+            int[] intlist = new int[12];
+            int oXvalue = 0, monthvalue = 0;
+            ///1锛屽厛鍒ゆ柇澶勭悊鐩稿悓鐨勬湀浠斤紱2锛屽啀澶勭悊涓嶇浉鍚岀殑鏈堜唤锛�
+            if (b1 == b2)
+            {
+                for (int i = 1; i < 13; i++)
+                {
+                    if (b1 == b2 && i == b1)
+                    {
+                        switch (i)
+                        {
+                            case 1:
+                                {
+                                    oXvalue = 1;
+                                }
+                                break;
+                            case 2:
+                                {
+                                    oXvalue = 2;
+                                }
+                                break;
+                            case 3:
+                                {
+                                    oXvalue = 4;
+                                }
+                                break;
+                            case 4:
+                                {
+                                    oXvalue = 8;
+                                }
+                                break;
+                            case 5:
+                                {
+                                    oXvalue = 16;
+                                }
+                                break;
+                            case 6:
+                                {
+                                    oXvalue = 32;
+                                }
+                                break;
+                            case 7:
+                                {
+                                    oXvalue = 64;
+                                }
+                                break;
+                            case 8:
+                                {
+                                    oXvalue = 96;
+                                }
+                                break;
+                            case 9:
+                                {
+                                    oXvalue = 128;
+                                }
+                                break;
+                            case 10:
+                                {
+                                    oXvalue = 256;
+                                }
+                                break;
+                            case 11:
+                                {
+                                    oXvalue = 512;
+                                }
+                                break;
+                            case 12:
+                                {
+                                    oXvalue = 1024;
+                                }
+                                break;
+                        }
+
+                        string s = "";
+
+                        for (int j = 32; j > 0; j--)
+                        {
+                            if (j >= c1 && j <= c2)
+                            {
+                                s += "1";
+                            }
+                            else
+                            {
+                                s += "0";
+                            }
+
+                        }
+                        var intvalue = Convert.ToInt32(s, 2);
+                        monthvalue = oXvalue;
+                        intlist[i - 1] = intvalue;
+                    }
+                }
+            }
+            else
+            {
+
+                for (int i = 1; i < 13; i++)
+                {
+
+                    if (i >= b1 && i <= b2)
+                    {
+                        switch (i)
+                        {
+                            case 1:
+                                {
+                                    oXvalue = 1;
+                                }
+                                break;
+                            case 2:
+                                {
+                                    oXvalue = 2;
+                                }
+                                break;
+                            case 3:
+                                {
+                                    oXvalue = 4;
+                                }
+                                break;
+                            case 4:
+                                {
+                                    oXvalue = 8;
+                                }
+                                break;
+                            case 5:
+                                {
+                                    oXvalue = 16;
+                                }
+                                break;
+                            case 6:
+                                {
+                                    oXvalue = 32;
+                                }
+                                break;
+                            case 7:
+                                {
+                                    oXvalue = 64;
+                                }
+                                break;
+                            case 8:
+                                {
+                                    oXvalue = 96;
+                                }
+                                break;
+                            case 9:
+                                {
+                                    oXvalue = 128;
+                                }
+                                break;
+                            case 10:
+                                {
+                                    oXvalue = 256;
+                                }
+                                break;
+                            case 11:
+                                {
+                                    oXvalue = 512;
+                                }
+                                break;
+                            case 12:
+                                {
+                                    oXvalue = 1024;
+                                }
+                                break;
+
+                        }
+                        string s = "";
+                        int days = DateTime.DaysInMonth(dtNow.Year, i);
+
+                        if (i == b1)
+                        {
+                            for (int j = 32; j > 0; j--)
+                            {
+                                if (j >= c1 && j <= days)
+                                {
+                                    s += "1";
+                                }
+                                else
+                                {
+                                    s += "0";
+                                }
+
+                            }
+                        }
+                        else if (i == b2)
+                        {
+                            for (int j = 32; j > 0; j--)
+                            {
+                                if (j >= 0 && j <= c2)
+                                {
+                                    s += "1";
+                                }
+                                else
+                                {
+                                    s += "0";
+                                }
+
+                            }
+
+                        }
+                        else
+                        {
+
+                            for (int j = 32; j > 0; j--)
+                            {
+                                if (j >= 0 && j <= days)
+                                {
+                                    s += "1";
+                                }
+                                else
+                                {
+                                    s += "0";
+                                }
+
+                            }
+                        }
+                        var intvalue = Convert.ToInt32(s, 2);
+                        intlist[i - 1] = intvalue;
+                        monthvalue += oXvalue;
+
+                    }
+                }
+            }
+
+            Common.Logic.CurrentLogic.TimeAttribute.SelectMonth = monthvalue;
+            Common.Logic.CurrentLogic.TimeAttribute.SelectMonDate = new List<int>(intlist);
+        }
+    }
+}

--
Gitblit v1.8.0