From 41f9c8837b0551c68f8fd798c06951fa716b7ab8 Mon Sep 17 00:00:00 2001
From: wei <kaede@kaededeMacBook-Air.local>
Date: 星期一, 11 一月 2021 14:05:29 +0800
Subject: [PATCH] Merge branch 'NewFilePath' of http://172.16.1.23:6688/r/~wxr/HDL_APP_Project into NewFilePath

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/TimeTpye.cs |  254 +++++++++++---------------------------------------
 1 files changed, 55 insertions(+), 199 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/TimeTpye.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/TimeTpye.cs
old mode 100755
new mode 100644
index edf6086..047b701
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/TimeTpye.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/TimeTpye.cs
@@ -90,64 +90,8 @@
         /// <param name="index">缂栬緫鏉′欢鐨勭储寮�</param>
         public void TimePoint(FrameLayout fLayout, bool edit, int index)
         {
-            LogicView.TimeView timePointView = new LogicView.TimeView();
-            timePointView.FLayoutView(fLayout);
-            EventHandler<MouseEventArgs> removefLayout = (sender, e1) =>
-             {
-                 //绉婚櫎fLayout鐣岄潰
-                 fLayout.RemoveFromParent();
-             };
-            //鍙栨秷鐐瑰嚮浜嬩欢
-            timePointView.btnCancel.MouseUpEventHandler += removefLayout;
-
-            //鍔犺浇鏁版嵁鐣岄潰鐨勮缃柟娉�(鍒楄〃浜掍笉鑱斿姩)
-            timePointView.mUIPickerView.setNPicker(timePointView.GethStringList(), timePointView.GetmStringList(), null);
-
-            var systemHour = DateTime.Now.Hour; //鑾峰彇灏忔椂
-            var systeMinute = DateTime.Now.Minute;//鑾峰彇鍒嗛挓
-            int systemHourIndex = 0;
-            int systeMinuteIndex = 0;
-            for (int i = 0; i < timePointView.GethIntList().Count; i++)
-            {
-                var currhour = timePointView.GethIntList()[i];
-                if (systemHour == currhour)
-                {
-                    systemHourIndex = i;
-                    break;
-                }
-            }
-            for (int i = 0; i < timePointView.GetmIntList().Count; i++)
-            {
-                var currminute = timePointView.GetmIntList()[i];
-                if (systeMinute == currminute)
-                {
-                    systeMinuteIndex = i;
-                    break;
-                }
-            }
-
-            //榛樿鍒濆閫変腑鐘舵��
-            timePointView.mUIPickerView.setCurrentItems(systemHourIndex, systeMinuteIndex, 0);
-            string currH = "";
-            string currM = "";
-            if (systemHour < 10)
-            {
-                currH = "0" + systemHour.ToString();
-            }
-            else
-            {
-                currH = systemHour.ToString();
-            }
-            if (systeMinute < 10)
-            {
-                currM = "0" + systeMinute.ToString();
-            }
-            else
-            {
-                currM = systeMinute.ToString();
-            }
-            //瀹氫箟涓�涓眬閮ㄥ彉閲忚褰曢�変腑鏃堕棿
-            string timepoint = currH + ":" + currM;
+            //缂栬緫涔嬪墠鐨勬椂闂寸姸鎬佸��
+            string editTime= "";
             if (edit)
             {
                 Input inputs = Logic.currlogic.input[index];
@@ -157,25 +101,14 @@
                     foreach (var dic in dicList)
                     {
                         string timeValue = dic["value"];
-                        int hIndex = timePointView.GetValueIndex(timeValue, 0, 1, timePointView.GethIntList());
-                        int mIndex = timePointView.GetValueIndex(timeValue, 1, 0, timePointView.GetmIntList());
-                        //鏇存柊鍒濆鐘舵��
-                        timePointView.mUIPickerView.setCurrentItems(hIndex, mIndex, 0);
-                        timepoint = timeValue;
+                        editTime = timeValue;
+                        break;
                     }
                 }
             }
-
-            //閫変腑鏃堕棿鍥炶皟鏂规硶,鏃堕棿鍙樺寲涓�娆″洖璋冧竴娆�
-            timePointView.mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) =>
-            {
-                string hour = timePointView.GethStringList()[index1].Split(' ')[0];
-                string minuet = timePointView.GetmStringList()[index2].Split(' ')[0];
-                timepoint = hour + ":" + minuet;
-            };
-            //纭畾鐐瑰嚮浜嬩欢
-            timePointView.btnConfirm.MouseUpEventHandler += (sender, e3) =>
-            {
+            LogicView.TimeView timePointView = new LogicView.TimeView();
+            timePointView.FLayoutView(fLayout);
+            timePointView.TimePoint(fLayout, editTime, (timeValue)=>{
                 Input inputTime = new Input();
                 inputTime.sid = LogicMethod.NewSid();
                 inputTime.condition_type = "1";
@@ -183,27 +116,11 @@
                 LogicMethod.dictionary(dic, "key", "timepoint");
                 LogicMethod.dictionary(dic, "comparator", "=");
                 LogicMethod.dictionary(dic, "data_type", "string");
-                LogicMethod.dictionary(dic, "value", timepoint);
+                LogicMethod.dictionary(dic, "value", timeValue);
                 inputTime.condition.Add(dic);
-                if (edit)
-                {
-                    //绉婚櫎鏃ф暟鎹�
-                    Logic.currlogic.input.RemoveAt(index);
-                    //鏂版暟鎹彃鍏ユ棫鏁版嵁鐨勪綅缃�;
-                    Logic.currlogic.input.Insert(index, inputTime);
-                }
-                else
-                {
-                    //娣诲姞涓�涓柊鐨勬椂闂寸偣鏉′欢
-                    Logic.currlogic.input.Add(inputTime);
-                }
-                LogicMethod.RemoveAllView();
-                AddLogic addLogic = new AddLogic();
-                MainPage.BasePageView.AddChidren(addLogic);
-                addLogic.Show();
-                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
-
-            };
+                AddCondition(inputTime, edit, index);
+            });
+            
         }
         /// <summary>
         /// 鏃堕棿鑼冨洿鏂规硶
@@ -324,24 +241,7 @@
                 LogicMethod.dictionary(dic, "data_type", "string");
                 LogicMethod.dictionary(dic, "value", btnStartTimeText.Text + "-" + btnEndTimeText.Text);
                 inputTime.condition.Add(dic);
-                if (edit)
-                {
-                    //绉婚櫎鏃ф暟鎹�
-                    Logic.currlogic.input.RemoveAt(index);
-                    //鏂版暟鎹彃鍏ユ棫鏁版嵁鐨勪綅缃�
-                    Logic.currlogic.input.Insert(index, inputTime);
-                    fLayout.RemoveFromParent();
-                }
-                else
-                {
-                    //娣诲姞涓�涓柊鐨勬椂闂寸偣鏉′欢
-                    Logic.currlogic.input.Add(inputTime);
-                }
-                LogicMethod.RemoveAllView();
-                AddLogic addLogic = new AddLogic();
-                MainPage.BasePageView.AddChidren(addLogic);
-                addLogic.Show();
-                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                AddCondition(inputTime, edit, index);
 
 
             };
@@ -367,76 +267,18 @@
             }
         }
         /// <summary>
-        /// 璁剧疆鏃堕棿娈垫椂闂寸殑鏂规硶
+        /// 璁剧疆鏃堕棿娈靛��
         /// </summary>
         /// <param name="fLayout"></param>
         /// <param name="btn"></param>
         public void SelectedTimeHorizon(FrameLayout fLayout, Button btn)
         {
-
-            LogicView.TimeView timePointView = new LogicView.TimeView();
-            timePointView.FLayoutView(fLayout);
-            EventHandler<MouseEventArgs> RemovefLayout = (sender, e1) =>
-            {
-                //鍙Щ闄ゆ椂闂村脊绐楃晫闈�
-                timePointView.frameLayout.RemoveFromParent();
-            };
-            //鍙栨秷鐐瑰嚮浜嬩欢
-            timePointView.btnCancel.MouseUpEventHandler += RemovefLayout;
-            //鍔犺浇鏁版嵁鐣岄潰鐨勮缃柟娉�(鍒楄〃浜掍笉鑱斿姩)
-            timePointView.mUIPickerView.setNPicker(timePointView.GethStringList(), timePointView.GetmStringList(), null);
-
-            var systemHour = DateTime.Now.Hour; //鑾峰彇灏忔椂
-            var systeMinute = DateTime.Now.Minute;//鑾峰彇鍒嗛挓
-            int systemHourIndex = 0;
-            int systeMinuteIndex = 0;
-            for (int i = 0; i < timePointView.GethIntList().Count; i++)
-            {
-                var currhour = timePointView.GethIntList()[i];
-                if (systemHour == currhour)
-                {
-                    systemHourIndex = i;
-                    break;
-                }
-            }
-            for (int i = 0; i < timePointView.GetmIntList().Count; i++)
-            {
-                var currminute = timePointView.GetmIntList()[i];
-                if (systeMinute == currminute)
-                {
-                    systeMinuteIndex = i;
-                    break;
-                }
-            }
-
-            //榛樿鍒濆閫変腑鐘舵��
-            timePointView.mUIPickerView.setCurrentItems(systemHourIndex, systeMinuteIndex, 0);
-            string currH = "";
-            string currM = "";
-            if (systemHour < 10)
-            {
-                currH = "0" + systemHour.ToString();
-            }
-            else
-            {
-                currH = systemHour.ToString();
-            }
-            if (systeMinute < 10)
-            {
-                currM = "0" + systeMinute.ToString();
-            }
-            else
-            {
-                currM = systeMinute.ToString();
-            }
-            //瀹氫箟涓�涓眬閮ㄥ彉閲忚褰曢�変腑鏃堕棿
-            string timepoint = currH + ":" + currM;
-            int sumTime = systemHour*60+ systeMinute;
-
+            //缂栬緫涔嬪墠鐨勬椂闂寸姸鎬佸��
+            string editTime = "";
             if (btn.Tag.ToString() != "0")
             {
                 string h = "", m = "";
-                sumTime = int.Parse(btn.Tag.ToString());
+               int  sumTime = int.Parse(btn.Tag.ToString());
                 if ((sumTime / 60) < 10)
                 {
                     h = "0" + (sumTime / 60).ToString();
@@ -454,34 +296,48 @@
                 {
                     m = (sumTime % 60).ToString();
                 }
-                timepoint = h + ":" + m;
-
-                int hourIndex = timePointView.GetValueIndex(timepoint, 0, 1, timePointView.GethIntList());
-                int minuteIndex = timePointView.GetValueIndex(timepoint, 1, 0, timePointView.GetmIntList());
-                //鏇存柊鐘舵��
-                timePointView.mUIPickerView.setCurrentItems(hourIndex, minuteIndex, 0);
+                editTime = h + ":" + m;
             }
-
-            //閫変腑鏃堕棿鍥炶皟鏂规硶,鏃堕棿鍙樺寲涓�娆″洖璋冧竴娆�
-            timePointView.mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) =>
+            LogicView.TimeView timePointView = new LogicView.TimeView();
+            timePointView.FLayoutView(fLayout);
+            timePointView.TimePoint(timePointView.frameLayout, editTime, (timeValue) =>
             {
-
-                string hour = timePointView.GethStringList()[index1].Split(' ')[0];
-                string minuet = timePointView.GetmStringList()[index2].Split(' ')[0];
-                timepoint = hour + ":" + minuet;
-                sumTime = int.Parse(hour) * 60 + int.Parse(minuet);
-
-
-            };
-            //纭畾鐐瑰嚮浜嬩欢
-            timePointView.btnConfirm.MouseUpEventHandler += (sender1, e3) =>
-            {
-                btn.Tag = sumTime;
-                btn.Text = timepoint;
-                //鍙Щ闄ゆ椂闂村脊绐楃晫闈�
-                timePointView.frameLayout.RemoveFromParent();
-            };
+                int hour = int.Parse(timeValue.Split(':')[0]);
+                int minuet = int.Parse(timeValue.Split(':')[1]);
+                int intValueTag = hour * 60 + minuet;
+                //鏍囪鍊�,鐢ㄤ簬姣旇緝寮�濮嬫椂闂村拰缁撴潫鏃堕棿澶у皬;
+                btn.Tag = intValueTag;
+                //鏄剧ず鏃堕棿鏂囨湰
+                btn.Text = timeValue;
+            });
         }
+    
+        /// <summary>
+        /// 娣诲姞鏉′欢
+        /// </summary>
+        /// <param name="input"></param>
+        private void AddCondition(Input input,bool edit,int index)
+        {
+            if (edit)
+            {
+                //绉婚櫎鏃ф暟鎹�
+                Logic.currlogic.input.RemoveAt(index);
+                //鏂版暟鎹彃鍏ユ棫鏁版嵁鐨勪綅缃�
+                Logic.currlogic.input.Insert(index, input);
+            }
+            else
+            {
+                //娣诲姞涓�涓柊鐨勬椂闂存潯浠�
+                Logic.currlogic.input.Add(input);
+            }
+            LogicMethod.RemoveAllView();
+            AddLogic addLogic = new AddLogic();
+            MainPage.BasePageView.AddChidren(addLogic);
+            addLogic.Show();
+            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+
+        }
+
         /// <summary>
         /// 鐏拌壊寮规鐖舵帶浠�
         /// </summary>

--
Gitblit v1.8.0