From d72ca686a3e262693f8a6e45e747e8e8da43335b Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期二, 06 七月 2021 09:39:03 +0800 Subject: [PATCH] 2021-07-06 1.更新 --- HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs | 247 +++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 238 insertions(+), 9 deletions(-) diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs index a50b719..1a97eef 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs @@ -1,4 +1,6 @@ 锘縰sing System; +using System.Collections.Generic; +using HDL_ON.Entity; using HDL_ON.UI.UI2.Intelligence.Automation.LogicView; using Shared; namespace HDL_ON.UI.UI2.PersonalCenter.PirDevice @@ -7,15 +9,25 @@ { public Matching() { + Tag = "PirView"; } - public void Show() + + public void Show(List<Brand> brandList, List<Library> libraryList,string spk) { + + #region 鐣岄潰甯冨眬 this.BackgroundColor = CSS.CSS_Color.viewMiddle; PirDevice.View.TopView topView = new View.TopView(); topView.topNameBtn.TextID = StringId.pipeiyaokongqi; this.AddChidren(topView.FLayoutView()); - topView.clickBackBtn.MouseUpEventHandler += (sender, e) => { this.RemoveFromParent(); }; + topView.clickBackBtn.MouseUpEventHandler += (sender, e) => + { + BrandList brandObj = new BrandList(); + brandObj.Show(brandList, spk); + this.RemoveFromParent(); + + }; FrameLayout fLayout = new FrameLayout { @@ -79,7 +91,7 @@ X = Application.GetRealWidth(136), Width = Application.GetRealWidth(104), Height = Application.GetRealHeight(44), - Text = "鐢垫簮", + TextID=StringId.dianyuan, TextSize = TextSize.text16, TextColor = CSS.CSS_Color.textColor, TextAlignment = TextAlignment.Center, @@ -93,10 +105,10 @@ Button sumBtn = new Button { Y = Application.GetRealHeight(267), - X = Application.GetRealWidth(170), - Width = Application.GetRealWidth(36), + X = Application.GetRealWidth(136), + Width = Application.GetRealWidth(104), Height = Application.GetRealHeight(17), - Text = "(" + "1" + "/20)", + Text = $"(1/{libraryList.Count})", TextSize = TextSize.text12, TextColor = CSS.CSS_Color.textCancelColor, }; @@ -113,7 +125,7 @@ TextSize = TextSize.text16, TextColor = CSS.CSS_Color.textConfirmColor, TextAlignment = TextAlignment.Center, - Radius = (uint)Application.GetRealHeight(44), + Radius = (uint)Application.GetRealHeight(22), BorderWidth = 1, BorderColor = CSS.CSS_Color.textConfirmColor, }; @@ -129,7 +141,7 @@ TextSize = TextSize.text16, TextColor = CSS.CSS_Color.textWhiteColor, TextAlignment = TextAlignment.Center, - Radius = (uint)Application.GetRealHeight(44), + Radius = (uint)Application.GetRealHeight(22), //BorderWidth = 1, //BorderColor = CSS.CSS_Color.textConfirmColor, BackgroundColor = CSS.CSS_Color.textConfirmColor, @@ -137,15 +149,232 @@ fLayout.AddChidren(succeedBtn); #endregion #region 鐐瑰嚮浜嬩欢 - int value = 1; + //琛ㄧず搴撳垪琛ㄧ储寮曞��(鐩墠鍙�20涓簱) + int index = 1; + //琛ㄧず娴嬭瘯鐮佺储寮曞��(鐩墠鍙祴璇�3涓爜) + int code = 1; + //琛ㄧず娴嬭瘯鏈�鍚庝竴涓爜锛� + bool if_bool = false; + //宸� leftIconBtn.MouseUpEventHandler += (sender, e) => { + if (index>1) { + index--; + sumBtn.Text = $"({index.ToString()}/{libraryList.Count})"; + } + code = 1; + GetBtnText(testBtn, code, spk); }; + //鍙� rightIconBtn.MouseUpEventHandler += (sender, e) => { + if (index < libraryList.Count) + { + index++; + sumBtn.Text = $"({index.ToString()}/{libraryList.Count})"; + } + code = 1; + GetBtnText(testBtn, code, spk); + }; + + //娴嬭瘯Text + testBtn.MouseUpEventHandler += (sender, e) => + { + var library = libraryList[index - 1]; + var control = GetControl(spk, testBtn.TextID, library); + //鍙戦�佹祴璇曠爜鍛戒护 + Method.ThreadSend(control, (responsePackNew) => { }, "搴撶爜娴嬭瘯", "frame", this, null); + if (code == 3) { + //鏍囪鏈�鍚庨偅涓爜 + if_bool = true; + } + }; + //鎺у埗澶辫触 + failedBtn.MouseUpEventHandler += (sender, e) => + { + if (index < libraryList.Count) + { + //鍏堝姞 + index++; + //鏇存柊鏂囨湰 + sumBtn.Text = $"({index.ToString()}/{libraryList.Count})"; + } + code = 1; + //鏇存柊鐘舵�� + GetBtnText(testBtn, code, spk); + }; + //鎺у埗鎴愬姛 + succeedBtn.MouseUpEventHandler += (sender, e) => + { + if (code < 3) + { + code++; + } + //鏇存柊鐘舵�� + GetBtnText(testBtn, code, spk); + if (if_bool) + { + var library = libraryList[index-1]; + var control = GetControl(spk, testBtn.TextID, library); + Method method = new Method(); + //鍙戦�佸簱娣诲姞閬ユ帶鍣ㄥ懡浠� + method.ThreadAddControl(control, this, (device) => + { + MainPage.BasePageView.RemoveViewByTag("PirView"); + AddControlComplete addControlComplete = new AddControlComplete(); + MainPage.BasePageView.AddChidren(addControlComplete); + addControlComplete.Show(device, true); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }); + } }; #endregion } + + /// <summary> + /// 鑾峰彇Control瀵硅薄锛堝瓨鍌ㄥ彂閫佹暟鎹殑瀵硅薄锛� + /// </summary> + /// <param name="spk"></param> + /// <param name="textInt"></param> + /// <param name="library"></param> + /// <returns></returns> + private Control GetControl(string spk, int textInt, Library library) { + + string key = ""; + string value = ""; + switch (spk) + { + case SPK.AcIr: + { + switch (textInt) + { + case StringId.dianyuan: + { + key = "on_off"; + value = "on"; + } + break; + case StringId.moshizhileng: + { + key = "mode"; + value = "cool"; + } + break; + case StringId.fengsuzhongfeng: + { + key = "fan"; + value = "medium"; + } + break; + } + } + break; + case SPK.TvIr: + { + switch (textInt) + { + case StringId.dianyuan: + { + key = "on_off"; + value = "on"; + } + break; + case StringId.yinliangjia: + { + key = "volume+"; + value = "50"; + } + break; + case StringId.jingyin: + { + key = "mute"; + value = "0"; + } + break; + } + } + break; + } + AttributesStatus buttonObj = new AttributesStatus(); + buttonObj.key = key; + buttonObj.value = value; + + Control control = new Control(); + control.spk = spk; + control.name = spk; + control.groupId = library.irIndex; + control.type = "library"; + control.status.Add(buttonObj); + control.deviceId = Pir.currPir.deviceId; + control.sid = ""; + string[] strings = library.irCode.Split(','); + for (int arrayStr = 0; arrayStr < strings.Length; arrayStr++) + { + //var intValue = Convert.ToInt32(strings[arrayStr],16); + control.library.Add(strings[arrayStr].Replace("0x","")); + } + + return control; + } + + /// <summary> + /// 鏄剧ず娴嬭瘯鏂囨湰 + /// </summary> + /// <param name="testBtn">鏄剧ず鎺т欢</param> + /// <param name="code">娴嬭瘯鐮佹枃鏈储寮曞��</param> + /// <param name="spk">浜戦泙涓婂畾涔塻pk</param> + private void GetBtnText(Button testBtn,int code,string spk) { + + int textValue = 0; + switch (spk) + { + case SPK.AcIr: + { + switch (code) + { + case 1: + { + textValue = StringId.dianyuan; + } + break; + case 2: + { + textValue = StringId.moshizhileng; + } + break; + case 3: + { + textValue = StringId.fengsuzhongfeng; + } + break; + } + } + break; + case SPK.TvIr: + { + switch (code) + { + case 1: + { + textValue = StringId.dianyuan; + } + break; + case 2: + { + textValue = StringId.yinliangjia; + } + break; + case 3: + { + textValue = StringId.jingyin; + } + break; + } + } + break; + } + testBtn.TextID = textValue; + } } } -- Gitblit v1.8.0