From 9acd3887f1f8db40d59f991b1726a61aa7c7637c Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期三, 12 五月 2021 15:13:56 +0800 Subject: [PATCH] Merge branch 'CJL' into wxr4 --- HDL_ON/UI/UI2/3-Intelligence/Automation/OnePortAutomation.cs | 344 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 344 insertions(+), 0 deletions(-) diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/OnePortAutomation.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/OnePortAutomation.cs new file mode 100644 index 0000000..4610303 --- /dev/null +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/OnePortAutomation.cs @@ -0,0 +1,344 @@ +锘縰sing System; +using Shared; +using System.Collections.Generic; + + +namespace HDL_ON.UI.UI2.Intelligence.Automation +{ + public class OnePortAutomation : FrameLayout + { + public OnePortAutomation() + { + Tag = "Logic"; + } + + public void Show() + { + #region 鐣岄潰甯冨眬 + this.BackgroundColor = CSS.CSS_Color.viewMiddle; + LogicView.TopView topView = new LogicView.TopView(); + topView.setBtn.Visible = true; + this.AddChidren(topView.FLayoutView()); + topView.clickBackBtn.MouseUpEventHandler += (e, sen) => + { + RemoveFromParent(); + }; + if (string.IsNullOrEmpty(Logic.currlogic.userLogicId)) + { + topView.topNameBtn.TextID = StringId.newAutomation; + topView.setBtn.Visible = false; + topView.clickSetBtn.Visible = false; + } + else + { + topView.topNameBtn.TextID = StringId.editAutomation; + topView.setBtn.Visible = true; + topView.clickSetBtn.Visible = true; + } + + + VerticalScrolViewLayout viewLayout = new VerticalScrolViewLayout + { + Y = Application.GetRealHeight(64), + Width = Application.GetRealWidth(LogicView.TextSize.view375), + Height = Application.GetRealHeight(LogicView.TextSize.view667 - 64 - 76), + BackgroundColor = CSS.CSS_Color.viewMiddle, + }; + this.AddChidren(viewLayout); + #region 鏉′欢 + ///濡傛灉鐨刅iew + LogicView.AddOutputInputTextView addInputTextView = new LogicView.AddOutputInputTextView(); + addInputTextView.btnIf.TextID = StringId.ifCondition; + viewLayout.AddChidren(addInputTextView.FLayoutView(46, 12)); + ///婊¤冻浠ヤ笅鏉′欢鐨刅iew + LogicView.LogicTypeTitleView titleCondition = new LogicView.LogicTypeTitleView(); + titleCondition.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight); + titleCondition.btnText.TextID = StringId.andCondition; + viewLayout.AddChidren(titleCondition.FLayoutView()); + + if (Logic.currlogic.relation == "and") + { + titleCondition.btnText.Text = Language.StringByID(StringId.andCondition); + } + else + { + titleCondition.btnText.Text = Language.StringByID(StringId.orCondition); + + } + + // 鏉′欢澶勭悊鏂规硶 + InpOrOutLogicMethod.InputCondition(this, viewLayout); + ///娣诲姞鍥炬爣鐨刅iew + LogicView.LogicAddView addInputIcon = new LogicView.LogicAddView(); + addInputIcon.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight); + viewLayout.AddChidren(addInputIcon.FLayoutView()); + #endregion + + #region 鐩爣 + ///灏辨墽琛孷iew + LogicView.AddOutputInputTextView addOutpuTextView = new LogicView.AddOutputInputTextView(); + addOutpuTextView.btnIf.TextID = StringId.isExecuted; + viewLayout.AddChidren(addOutpuTextView.FLayoutView(54, 20)); + + + #region 鎵ц鎺ㄩ�� 鍙戦�侀�氱煡 + ///涓婁笅闂撮殧12鍍忕礌 + viewLayout.AddChidren(new FrameLayout { Height = Application.GetRealHeight(12) }); + ///鎵ц鎺ㄩ�乮ew + LogicView.LogicTypeTitleView push = new LogicView.LogicTypeTitleView(); + push.frameLayout.Height = Application.GetRealHeight(50); + push.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight); + push.btnText.TextID = StringId.push; + push.btnNextIcon.Width = Application.GetRealWidth(36); + push.btnNextIcon.Height = Application.GetRealWidth(36); + push.btnNextIcon.X = Application.GetRealWidth(305); + push.btnNextIcon.UnSelectedImagePath = "LogicIcon/off.png"; + push.btnNextIcon.SelectedImagePath = "LogicIcon/on.png"; + push.btnClick.Width = Application.GetRealWidth(305); + viewLayout.AddChidren(push.FLayoutView()); + ///鍙戦�侀�氱煡View + LogicView.LogicTypeTitleView notification = new LogicView.LogicTypeTitleView(); + notification.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(12), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight); + notification.btnText.TextID = StringId.notification; + notification.btnLine.BackgroundColor = CSS.CSS_Color.textWhiteColor; + viewLayout.AddChidren(notification.FLayoutView()); + //鏄剧ず涔嬪墠鎺ㄩ�佸紑鍏崇姸鎬� + if (Logic.currlogic.noticeConfig.enable) + { + push.btnNextIcon.IsSelected = true; + } + else + { + push.btnNextIcon.IsSelected = false; + } + ///涓婁笅闂撮殧62鍍忕礌 + viewLayout.AddChidren(new FrameLayout { Height = Application.GetRealHeight(40) }); + #endregion + + #region 淇濆瓨 + ///淇濆瓨View + LogicView.SaveView saveView = new LogicView.SaveView(); + saveView.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(24), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight); + this.AddChidren(saveView.FLayoutView()); + + #endregion + #endregion + #endregion + #region 鐣岄潰鍚勭鐐瑰嚮浜嬩欢 + ///璁剧疆鍥炬爣鐐瑰嚮浜嬩欢 + topView.clickSetBtn.MouseUpEventHandler += (sender, e) => + { + Set set = new Set(); + MainPage.BasePageView.AddChidren(set); + set.Show(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + + }; + ///鎴栧拰涓庣偣鍑讳簨浠� + titleCondition.btnClick.MouseUpEventHandler += (sender, e) => + { + AndOrMethod(titleCondition.btnText); + }; + ///鏉′欢娣诲姞鐐瑰嚮浜嬩欢 + addInputIcon.btnClick.MouseUpEventHandler += (sen, e) => + { + var addInputType = new AddInputType(); + MainPage.BasePageView.AddChidren(addInputType); + addInputType.Show(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + ///鏄惁瑕佹帹閫佺偣鍑讳簨浠� + push.btnNextIcon.MouseUpEventHandler += (sender, e) => + { + //璐﹀彿鍒楄〃涓虹┖榛樿鎺ㄩ�佸綋鍓嶈处鍙� + if (Logic.currlogic.pushConfigs.Count == 0) + { + //鍒濆鍖栧璞� + PushConfigs pushConfigs = new PushConfigs(); + //榛樿娣诲姞鎺ㄩ�佸綋鍓嶈处鍙� + pushConfigs.pushTarget.Add(UserInfo.Current.ID); + Logic.currlogic.pushConfigs.Add(pushConfigs); + } + push.btnNextIcon.IsSelected = !push.btnNextIcon.IsSelected; + if (push.btnNextIcon.IsSelected) + { + Logic.currlogic.noticeConfig.enable = true; + } + else + { + Logic.currlogic.noticeConfig.enable = false; + } + }; + ///杈撳叆鎺ㄩ�佹枃鏈� + notification.btnClick.MouseUpEventHandler += (sender, e) => + { + InputPushText inputPushText = new InputPushText(); + MainPage.BasePageView.AddChidren(inputPushText); + inputPushText.Show(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + ///淇濆瓨鐐瑰嚮浜嬩欢 + saveView.btnClick.MouseUpEventHandler += (sender, e) => + { + if (Logic.currlogic.input.Count == 0) + { + new LogicView.TipPopView().TipBox(StringId.tip, StringId.conditioncNull); + return; + } + Loading loading = new Loading(); + this.AddChidren(loading); + HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; + if (string.IsNullOrEmpty(Logic.currlogic.userLogicId)) + { + List<string> list = new List<string>(); + foreach (var logic in Logic.LogicList) + { + list.Add(logic.name); + } + new LogicView.TipPopView().InputBox(StringId.editName, InpOrOutLogicMethod.GetLogicName(Logic.currlogic), StringId.nameNull, StringId.NameAlreadyExists, list, (logicName, view + ) => + { + Logic.currlogic.name = logicName; + Logic.currlogic.sid = LogicMethod.NewSid(); + loading.Start(); + new System.Threading.Thread(() => + { + + try + { + //鍙戦�佹柊鍔犻�昏緫鍛戒护锛� + responsePackNew = Send.AddLogic(Logic.currlogic); + + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + loading.Hide(); + if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + { + + + //鑾峰彇閫昏緫璇︾粏杩斿洖鏄竴涓暟缁�(object绫诲瀷杞崲涓烘暟缁�); + var jArray = Newtonsoft.Json.Linq.JArray.Parse(responsePackNew.Data.ToString()); + for (int a = 0; a < jArray.Count; a++) + { + var jay = jArray[a]; + //鏁版嵁杩斿簭鍒楀寲涓篖ogic瀵硅薄 + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay); + var logic = Newtonsoft.Json.JsonConvert.DeserializeObject<Logic>(str); + if (logic.userLogicId != "") + { + //鏇存柊浜戠鍞竴鑷姩鍖杋d; + Logic.currlogic.userLogicId = logic.userLogicId; + } + else + { + //鑷繁鐪嬬殑鎵�浠ヤ笉闇�瑕佹敮鎸佷腑鑻辨枃 + new LogicView.TipPopView().FlashingBox("娌℃湁杩斿洖浜戠鍞竴鑷姩鍖杋d"); + } + + } + + Logic.LogicList.Add(Logic.currlogic); + LogicMethod.RemoveAllView(); + MainView.MainShow(); + } + else if (responsePackNew != null && responsePackNew.Code == "14005") + { + new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline)); + } + else + { + new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail)); + } + }); + } + + }) + { IsBackground = true }.Start(); + + }, () => { }); + + } + else + { + loading.Start(); + new System.Threading.Thread(() => + { + + try + { + //鍙戦�佷慨鏀归�昏緫鍛戒护锛� + responsePackNew = Send.UpdateLogic(Logic.currlogic); + + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + loading.Hide(); + if (responsePackNew != null && responsePackNew.Code == "0") + { + LogicMethod.RemoveAllView(); + MainView.MainShow(); + } + else if (responsePackNew != null && responsePackNew.Code == "14005") + { + new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline)); + } + else + { + new LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail)); + } + }); + } + + + + }) + { IsBackground = true }.Start(); + + } + + }; + #endregion + } + + + /// <summary> + /// 婊¤冻鏉′欢 + /// </summary> + /// <param name="button">鏄剧ず鏂囨湰</param> + public void AndOrMethod(Button button) + { + + ///涔嬪墠鐨勭姸鎬佹枃鏈� + string currCondition = button.Text; + PublicInterface conditionView = new PublicInterface(); + var strList = conditionView.GetViewList("andor"); + conditionView.SingleSelectionShow(this, strList, Language.StringByID(StringId.meetTheCondition), currCondition + , (stateValue) => + { + //鐣岄潰鏄剧ず閫変腑鍊� + button.Text = stateValue; + //灏佽鏁版嵁 + if (stateValue == Language.StringByID(StringId.orCondition)) + { + Logic.currlogic.relation = "or"; + } + else + { + Logic.currlogic.relation = "and"; + } + + }); + + + } + + + } +} \ No newline at end of file -- Gitblit v1.8.0