From 09dfbfd9b77ec887c17b10f15799a1d3f56e4e17 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 15 十二月 2020 12:04:42 +0800
Subject: [PATCH] 2020-12-15-1

---
 HDL_ON/UI/UI2/3-Intelligence/Automation/TimeTpye.cs |   99 +++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 83 insertions(+), 16 deletions(-)

diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/TimeTpye.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/TimeTpye.cs
index bbfe182..39e5dae 100644
--- a/HDL_ON/UI/UI2/3-Intelligence/Automation/TimeTpye.cs
+++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/TimeTpye.cs
@@ -12,7 +12,7 @@
 
         public void Show()
         {
-
+            #region  鐣岄潰甯冨眬
             LogicView.TopView topView = new LogicView.TopView();
             this.AddChidren(topView.FLayoutView());
             topView.clickBackBtn.MouseUpEventHandler += (e, sen) =>
@@ -49,17 +49,19 @@
             timeHorizonView.btnText.TextID = StringId.timeHorizon;
             viewLayout.AddChidren(timeHorizonView.FLayoutView());
 
+            #endregion
+
+            #region  鏃堕棿鐐�  鏃堕棿鑼冨洿鐐瑰嚮浜嬩欢
             //鏃堕棿鐐圭偣鍑讳簨浠�
             timepointView.btnClick.MouseUpEventHandler += (sen, e) =>
             {
-
                 //涓荤晫闈㈡帶浠�
                 FrameLayout fLayout = new FrameLayout
                 {
                     BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
                 };
                 this.AddChidren(fLayout);
-                TimePoint(fLayout);
+                TimePoint(fLayout, false, 100);
 
             };
             //鏃堕棿鑼冨洿鐐瑰嚮浜嬩欢
@@ -72,25 +74,31 @@
                 };
                 //娣诲姞涓荤晫闈�
                 this.AddChidren(fLayout);
-                TimeHorizon(fLayout,false,0);
+                //var fLayout = GetFrame(this,"2");
+
+                TimeHorizon(fLayout, false, 0);
             };
+
+            #endregion
         }
 
         /// <summary>
         /// 鏃堕棿鐐规柟娉�
         /// </summary>
         /// <param name="fLayout">鍦ㄥ摢涓晫闈㈡樉绀�</param>
-        public void TimePoint(FrameLayout fLayout)
+        /// <param name="edit">锛坱rue=缂栬緫锛沠alse=鏂板缓锛�</param>
+        /// <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) =>
+            EventHandler<MouseEventArgs> removefLayout = (sender, e1) =>
              {
                 //绉婚櫎fLayout鐣岄潰
                 fLayout.RemoveFromParent();
              };
             //鍙栨秷鐐瑰嚮浜嬩欢
-            timePointView.btnCancel.MouseUpEventHandler += RemovefLayout;
+            timePointView.btnCancel.MouseUpEventHandler += removefLayout;
 
             //鍔犺浇鏁版嵁鐣岄潰鐨勮缃柟娉�(鍒楄〃浜掍笉鑱斿姩)
             timePointView.mUIPickerView.setNPicker(timePointView.GethStringList(), timePointView.GetmStringList(), null);
@@ -98,6 +106,26 @@
             timePointView.mUIPickerView.setCurrentItems(0, 30, 0);
             //瀹氫箟涓�涓眬閮ㄥ彉閲忚褰曢�変腑鏃堕棿
             string timepoint = "01:30";
+
+            if (edit)
+            {
+                Input inputs = Logic.currlogic.input[index];
+                if (inputs.condition_type == "1")
+                {
+                    List<Dictionary<string, string>> dicList = inputs.condition as List<Dictionary<string, string>>;
+                    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 - 1, mIndex, 0);
+                        timepoint = timeValue;
+                    }
+                }
+            }
+
+
             //閫変腑鏃堕棿鍥炶皟鏂规硶,鏃堕棿鍙樺寲涓�娆″洖璋冧竴娆�
             timePointView.mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) =>
             {
@@ -117,9 +145,19 @@
                 LogicMethod.dictionary(dic, "data_type", "string");
                 LogicMethod.dictionary(dic, "value", timepoint);
                 inputTime.condition.Add(dic);
-                //娣诲姞涓�涓柊鐨勬椂闂寸偣鏉′欢
-                Logic.currlogic.input.Add(inputTime);
-                RemoveViewByTag("Logic");
+                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();
@@ -127,16 +165,16 @@
 
             };
         }
-
         /// <summary>
         /// 鏃堕棿鑼冨洿鏂规硶
         /// </summary>
         /// <param name="fLayout">鍦ㄥ摢涓晫闈㈡樉绀�</param>
+        /// <param name="edit">锛坱rue=缂栬緫锛沠alse=鏂板缓锛�</param>
+        /// <param name="index">缂栬緫鏉′欢鐨勭储寮�</param>
         public void TimeHorizon(FrameLayout fLayout,bool edit,int index)
         {
             #region 鐣岄潰甯冨眬
             LogicView.TimeHorizonView timeHorizonView = new LogicView.TimeHorizonView();
-            timeHorizonView.frameLayout.SetCornerWithSameRadius(12, HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight | HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight);
             timeHorizonView.FLayoutView(fLayout);
             //寮�濮嬫椂闂�
             LogicView.SelectTypeView startTimeView = new LogicView.SelectTypeView();
@@ -153,7 +191,7 @@
             {
                 TextSize = LogicView.TextSize.text12,
                 Width = Application.GetRealWidth(32 + 3),
-                Height = Application.GetRealHeight(20),
+                Height = Application.GetRealHeight(17),
                 TextColor = CSS.CSS_Color.textCancelColor,
                 Y = Application.GetRealHeight(17),
                 X = Application.GetRealWidth(260),
@@ -163,7 +201,7 @@
 
             //缁撴潫鏃堕棿
             LogicView.SelectTypeView endTimeView = new LogicView.SelectTypeView();
-            endTimeView.frameLayout.SetCornerWithSameRadius(12, HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight);
+            endTimeView.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight);
             endTimeView.frameLayout.Y = startTimeView.frameLayout.Bottom;
             endTimeView.btnIcon.Visible = false;
             endTimeView.btnLine.Visible = false;
@@ -176,7 +214,7 @@
             {
                 TextSize = LogicView.TextSize.text12,
                 Width = Application.GetRealWidth(32 + 3),
-                Height = Application.GetRealHeight(20),
+                Height = Application.GetRealHeight(17),
                 TextColor = CSS.CSS_Color.textCancelColor,
                 Y = Application.GetRealHeight(17),
                 X = Application.GetRealWidth(260),
@@ -243,7 +281,7 @@
                     //娣诲姞涓�涓柊鐨勬椂闂寸偣鏉′欢
                     Logic.currlogic.input.Add(inputTime);
                 }
-                RemoveViewByTag("Logic");
+                LogicMethod.RemoveAllView();
                 AddLogic addLogic = new AddLogic();
                 MainPage.BasePageView.AddChidren(addLogic);
                 addLogic.Show();
@@ -346,5 +384,34 @@
                 timePointView.frameLayout.RemoveFromParent();
             };
         }
+
+
+        /// <summary>
+        /// 鐏拌壊寮规鐖舵帶浠�
+        /// </summary>
+        /// <param name="frame">鏄剧ず鍦ㄥ摢涓晫闈�</param>
+        /// <returns></returns>
+        public FrameLayout GetFrame(FrameLayout frame, string tagKey)
+        {
+            for (int i = 0; i < frame.ChildrenCount; i++)
+            {
+                var fra = frame.GetChildren(i);
+                if (fra != null)
+                {
+                    fra.RemoveFromParent();
+                }
+            }
+           
+           
+            FrameLayout fLayout = new FrameLayout()
+            {
+                BackgroundColor = CSS.CSS_Color.viewTrans60lucence,
+                
+            };
+            frame.AddChidren(fLayout);
+
+          
+            return fLayout;
+        }
     }
 }

--
Gitblit v1.8.0