From 263401d40b2d9d2c1b36a24f33d45c5cb7192518 Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期三, 23 十二月 2020 15:51:54 +0800 Subject: [PATCH] 20201223-6 --- HDL_ON/UI/UI2/3-Intelligence/Automation/TimeTpye.cs | 245 ++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 204 insertions(+), 41 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 100644 new mode 100755 index bbfe182..edf6086 --- 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,32 +74,98 @@ }; //娣诲姞涓荤晫闈� 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(); + //绉婚櫎fLayout鐣岄潰 + fLayout.RemoveFromParent(); }; //鍙栨秷鐐瑰嚮浜嬩欢 - timePointView.btnCancel.MouseUpEventHandler += RemovefLayout; + 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(0, 30, 0); + 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 = "01:30"; + string timepoint = currH + ":" + currM; + 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, mIndex, 0); + timepoint = timeValue; + } + } + } + //閫変腑鏃堕棿鍥炶皟鏂规硶,鏃堕棿鍙樺寲涓�娆″洖璋冧竴娆� timePointView.mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) => { @@ -117,9 +185,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 +205,16 @@ }; } - /// <summary> /// 鏃堕棿鑼冨洿鏂规硶 /// </summary> /// <param name="fLayout">鍦ㄥ摢涓晫闈㈡樉绀�</param> - public void TimeHorizon(FrameLayout fLayout,bool edit,int index) + /// <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(); @@ -152,18 +230,18 @@ Button btnStartTimeText = new Button { TextSize = LogicView.TextSize.text12, - Width = Application.GetRealWidth(32 + 3), - Height = Application.GetRealHeight(20), + Width = Application.GetRealWidth(32 + 3+20), + Height = Application.GetRealHeight(17), TextColor = CSS.CSS_Color.textCancelColor, Y = Application.GetRealHeight(17), - X = Application.GetRealWidth(260), + X = Application.GetRealWidth(260-20), Tag = "0", }; startTimeView.frameLayout.AddChidren(btnStartTimeText); //缁撴潫鏃堕棿 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; @@ -175,11 +253,11 @@ Button btnEndTimeText = new Button { TextSize = LogicView.TextSize.text12, - Width = Application.GetRealWidth(32 + 3), - Height = Application.GetRealHeight(20), + Width = Application.GetRealWidth(32 + 3+20), + Height = Application.GetRealHeight(17), TextColor = CSS.CSS_Color.textCancelColor, Y = Application.GetRealHeight(17), - X = Application.GetRealWidth(260), + X = Application.GetRealWidth(260-20), Tag = "0", }; endTimeView.frameLayout.AddChidren(btnEndTimeText); @@ -188,36 +266,52 @@ #region 鐐瑰嚮浜嬩欢 //寮�濮嬫椂闂寸偣鍑讳簨浠� - startTimeView.btnClick.MouseUpEventHandler += (sender, e) => - { + EventHandler<MouseEventArgs> StartTimeClick = (sender,e) => { SelectedTimeHorizon(fLayout, btnStartTimeText); }; + startTimeView.btnClick.MouseUpEventHandler += StartTimeClick; + btnStartTimeText.MouseUpEventHandler += StartTimeClick; //缁撴潫鏃堕棿鐐瑰嚮浜嬩欢 - endTimeView.btnClick.MouseUpEventHandler += (sender, e) => - { + EventHandler<MouseEventArgs> EndTimeClick = (sender, e) => { SelectedTimeHorizon(fLayout, btnEndTimeText); }; + endTimeView.btnClick.MouseUpEventHandler += EndTimeClick; + btnEndTimeText.MouseUpEventHandler += EndTimeClick; + + //纭畾鐐瑰嚮浜嬩欢 timeHorizonView.btnConfirm.MouseUpEventHandler += (sender, e) => { + + if (btnStartTimeText.Tag.ToString() == "0"&& btnEndTimeText.Tag.ToString() == "0") + { + //鎻愮ず锛氭椂闂存湭璁剧疆锛岃璁剧疆鏃堕棿銆� + new LogicView.TipPopView().TipBox(StringId.tip, StringId.timeNoSet); + return; + } + if (btnStartTimeText.Tag.ToString() == "0") { - //鎻愮ず锛氳閫変腑寮�濮嬫椂闂� + //鎻愮ず锛氬紑濮嬫椂闂存湭璁剧疆锛岃璁剧疆寮�濮嬫椂闂淬�� + new LogicView.TipPopView().TipBox(StringId.tip,StringId.setStartTime); return; } if (btnEndTimeText.Tag.ToString() == "0") { - //鎻愮ず锛氳閫変腑缁撴潫鏃堕棿 + //鎻愮ず锛氱粨鏉熸椂闂存湭璁剧疆锛岃璁剧疆缁撴潫鏃堕棿銆� + new LogicView.TipPopView().TipBox(StringId.tip, StringId.setEndTime); return; } if (btnStartTimeText.Tag.ToString() == btnEndTimeText.Tag.ToString()) { - //鎻愮ず锛氭椂闂翠竴鏍风殑 + //鎻愮ず锛氬紑濮嬫椂闂村拰缁撴潫鏃堕棿涓嶈兘涓�鏍枫�� + new LogicView.TipPopView().TipBox(StringId.tip, StringId.unlikeTime); return; } if (int.Parse(btnStartTimeText.Tag.ToString()) > int.Parse(btnEndTimeText.Tag.ToString())) { - //鎻愮ず锛氬紑濮嬫椂闂翠笉鑳藉ぇ浜庣粨鏉熸椂闂� + //鎻愮ず锛氬紑濮嬫椂闂翠笉鑳藉ぇ浜庣粨鏉熸椂闂淬�� + new LogicView.TipPopView().TipBox(StringId.tip, StringId.startTimeLessThanEndTime); return; } @@ -228,7 +322,7 @@ LogicMethod.dictionary(dic, "key", "timesection"); LogicMethod.dictionary(dic, "comparator", "="); LogicMethod.dictionary(dic, "data_type", "string"); - LogicMethod.dictionary(dic, "value", btnStartTimeText.Text+"~"+btnEndTimeText.Text); + LogicMethod.dictionary(dic, "value", btnStartTimeText.Text + "-" + btnEndTimeText.Text); inputTime.condition.Add(dic); if (edit) { @@ -243,7 +337,7 @@ //娣诲姞涓�涓柊鐨勬椂闂寸偣鏉′欢 Logic.currlogic.input.Add(inputTime); } - RemoveViewByTag("Logic"); + LogicMethod.RemoveAllView(); AddLogic addLogic = new AddLogic(); MainPage.BasePageView.AddChidren(addLogic); addLogic.Show(); @@ -262,8 +356,8 @@ foreach (var dic in dicList) { string value = dic["value"]; - string startTime = value.Split('~')[0]; - string endtTime = value.Split('~')[1]; + string startTime = value.Split('-')[0]; + string endtTime = value.Split('-')[1]; btnStartTimeText.Text = startTime; btnStartTimeText.Tag = int.Parse(startTime.Split(':')[0]) * 60 + int.Parse(startTime.Split(':')[1]); btnEndTimeText.Text = endtTime; @@ -291,11 +385,53 @@ 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(0, 30, 0); + 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 = "01:30"; - int sumTime = 90; + string timepoint = currH + ":" + currM; + int sumTime = systemHour*60+ systeMinute; if (btn.Tag.ToString() != "0") { @@ -323,13 +459,13 @@ int hourIndex = timePointView.GetValueIndex(timepoint, 0, 1, timePointView.GethIntList()); int minuteIndex = timePointView.GetValueIndex(timepoint, 1, 0, timePointView.GetmIntList()); //鏇存柊鐘舵�� - timePointView.mUIPickerView.setCurrentItems(hourIndex - 1, minuteIndex, 0); + timePointView.mUIPickerView.setCurrentItems(hourIndex, minuteIndex, 0); } //閫変腑鏃堕棿鍥炶皟鏂规硶,鏃堕棿鍙樺寲涓�娆″洖璋冧竴娆� timePointView.mUIPickerView.OnSelectChangeEvent += (index1, index2, index3) => { - + string hour = timePointView.GethStringList()[index1].Split(' ')[0]; string minuet = timePointView.GetmStringList()[index2].Split(' ')[0]; timepoint = hour + ":" + minuet; @@ -346,5 +482,32 @@ 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