From 592974441a4df95fffd9167c90192da1a390b1c2 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期二, 06 六月 2023 11:51:12 +0800
Subject: [PATCH] Merge branch 'Dev-Branch'

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/TimeView.cs |  137 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 135 insertions(+), 2 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/TimeView.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/TimeView.cs
index a79324c..b45c5ae 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/TimeView.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicView/TimeView.cs
@@ -81,7 +81,7 @@
             frameLayout.AddChidren(btnLine);
         }
         /// <summary>
-        /// 閫変腑鏃堕棿鐨勬柟娉�
+        /// 閫変腑鏃堕棿鐨勬柟娉�(鏃讹紝鍒�)
         /// </summary>
         /// <param name="fLayout">鐖舵帶浠�</param>
         /// <param name="currState">涔嬪墠鐘舵�佸��</param>
@@ -156,6 +156,120 @@
                 string hour = GethStringList()[index1].Split(' ')[0];
                 string minuet = GetmStringList()[index2].Split(' ')[0];
                 timepoint = hour + ":" + minuet;
+            };
+            //纭畾鐐瑰嚮浜嬩欢
+            btnConfirm.MouseUpEventHandler += (sender, e3) =>
+            {
+                action(timepoint);
+                //绉婚櫎fLayout鐣岄潰
+                fLayout.RemoveFromParent();
+
+            };
+        }
+        /// <summary>
+        /// 閫変腑鏃堕棿鐨勬柟娉�(鏃讹紝鍒嗭紝绉�)
+        /// </summary>
+        /// <param name="fLayout">鐖舵帶浠�</param>
+        /// <param name="currState">涔嬪墠鐘舵�佸��</param>
+        /// <param name="action">杩斿洖鏃堕棿鍊�</param>
+        public void Time(FrameLayout fLayout, string currState, Action<string> action)
+        {
+            //鍙栨秷鐐瑰嚮浜嬩欢
+            btnCancel.MouseUpEventHandler += (sender, e1) =>
+            {
+                //绉婚櫎fLayout鐣岄潰
+                fLayout.RemoveFromParent();
+            };
+            //鍔犺浇鏁版嵁鐣岄潰鐨勮缃柟娉�(鍒楄〃浜掍笉鑱斿姩)
+            mUIPickerView.setNPicker(GethStringList(), GetmStringList(), GetsStringList());
+            var systemHour = DateTime.Now.Hour; //鑾峰彇灏忔椂
+            var systeMinute = DateTime.Now.Minute;//鑾峰彇鍒嗛挓
+            var systeSecond = DateTime.Now.Second;//鑾峰彇绉�
+
+            int systemHourIndex = 0;
+            int systeMinuteIndex = 0;
+            int systeSecondIndex = 0;
+            for (int i = 0; i < GethIntList().Count; i++)
+            {
+                var currhour = GethIntList()[i];
+                if (systemHour == currhour)
+                {
+                    systemHourIndex = i;
+                    break;
+                }
+            }
+            for (int i = 0; i < GetmIntList().Count; i++)
+            {
+                var currminute = GetmIntList()[i];
+                if (systeMinute == currminute)
+                {
+                    systeMinuteIndex = i;
+                    break;
+                }
+            }
+            for (int i = 0; i < GetsIntList().Count; i++)
+            {
+                var currsecond= GetsIntList()[i];
+                if (systeSecond == currsecond)
+                {
+                    systeSecondIndex = i;
+                    break;
+                }
+            }
+
+            //榛樿鍒濆閫変腑鐘舵��
+            mUIPickerView.setCurrentItems(systemHourIndex, systeMinuteIndex, systeSecondIndex);
+            string currH = "";
+            string currM = "";
+            string currS = "";
+            if (systemHour < 10)
+            {
+                currH = "0" + systemHour.ToString();
+            }
+            else
+            {
+                currH = systemHour.ToString();
+            }
+            if (systeMinute < 10)
+            {
+                currM = "0" + systeMinute.ToString();
+            }
+            else
+            {
+                currM = systeMinute.ToString();
+            }
+            if (systeSecond < 10)
+            {
+                currS = "0" + systeMinute.ToString();
+            }
+            else
+            {
+                currS = systeMinute.ToString();
+            }
+            //瀹氫箟涓�涓眬閮ㄥ彉閲忚褰曢�変腑鏃堕棿
+            string timepoint = currH + ":" + currM + ":" + currS;
+            if (!string.IsNullOrEmpty(currState))
+            {
+                int hIndex = GetValueIndex(currState, 0, 1, GethIntList());
+                int mIndex = GetValueIndex(currState, 1, 0, GetmIntList());
+                int sIndex = GetValueIndex(currState, 2, 0, GetsIntList());
+                //鏇存柊鍒濆鐘舵��
+                mUIPickerView.setCurrentItems(hIndex, mIndex, sIndex);
+                timepoint = currState;
+            }
+
+
+            //閫変腑鏃堕棿鍥炶皟鏂规硶,鏃堕棿鍙樺寲涓�娆″洖璋冧竴娆�
+            mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) =>
+            {
+                try
+                {
+                    string hour = GethStringList()[index1].Split(' ')[0];
+                    string minuet = GetmStringList()[index2].Split(' ')[0];
+                    string second = GetmStringList()[index3].Split(' ')[0];
+                    timepoint = hour + ":" + minuet + ":" + second;
+                }
+                catch { }
             };
             //纭畾鐐瑰嚮浜嬩欢
             btnConfirm.MouseUpEventHandler += (sender, e3) =>
@@ -306,7 +420,22 @@
             }
             return mList;
         }
-       
+        /// <summary>
+        /// 鑾峰彇60绉掑垪琛�
+        /// </summary>
+        /// <returns></returns>
+        public List<int> GetsIntList()
+        {
+            //鍒濆鍖栧垪琛�
+            var mList = new List<int>();
+            for (int i = 0; i < 60; i++)
+            {
+                //娣诲姞鏁版嵁
+                mList.Add(i);
+            }
+            return mList;
+        }
+
         /// <summary>
         /// 鑾峰彇鏃堕棿鍊�
         /// </summary>
@@ -317,6 +446,10 @@
         /// <returns></returns>
         public int GetValueIndex(string str, int digit, int startIndex, List<int> list)
         {
+            if (string.IsNullOrEmpty(str))
+            {
+                return 0;
+            }
             int index = 0;
             int value = 0;
             if (str.Contains(":"))

--
Gitblit v1.8.0