From 8e5ba5665861b29a4b8da0335c81d620aa891862 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期一, 08 三月 2021 09:23:54 +0800 Subject: [PATCH] Merge branch 'WJC' into temp-wxr --- HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs | 397 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 397 insertions(+), 0 deletions(-) diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs new file mode 100644 index 0000000..ec6420f --- /dev/null +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs @@ -0,0 +1,397 @@ +锘縰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 +{ + public class Matching : FrameLayout + { + public Matching() + { + Tag = "PirView"; + } + public void Show(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(); }; + + FrameLayout fLayout = new FrameLayout + { + Y = topView.frameLayout.Bottom, + Height = Application.GetRealHeight(667 - 64), + Width = Application.GetRealWidth(375), + }; + this.AddChidren(fLayout); + //璇风偣鍑讳互涓嬫寜閽� + Button text1Btn = new Button + { + Y = Application.GetRealHeight(60), + X = Application.GetRealWidth(16), + Width = Application.GetRealWidth(375 - 32), + Height = Application.GetRealHeight(20), + TextID = StringId.dianjianniu, + TextSize = TextSize.text14, + TextColor = CSS.CSS_Color.textColor, + TextAlignment = TextAlignment.Center, + + }; + fLayout.AddChidren(text1Btn); + + //纭璁惧鏄惁鏈夊搷搴� + Button text2Btn = new Button + { + Y = Application.GetRealHeight(60 + 24), + X = Application.GetRealWidth(16), + Width = Application.GetRealWidth(375 - 32), + Height = Application.GetRealHeight(20), + TextID = StringId.shifouyouxiangying, + TextSize = TextSize.text14, + TextColor = CSS.CSS_Color.textColor, + TextAlignment = TextAlignment.Center, + }; + fLayout.AddChidren(text2Btn); + //宸� + var leftIconBtn = new Button + { + Y = Application.GetRealHeight(203), + X = Application.GetRealWidth(16), + Width = Application.GetRealWidth(36), + Height = Application.GetRealWidth(36), + UnSelectedImagePath = "PirIcon/left.png", + }; + fLayout.AddChidren(leftIconBtn); + //鍙� + var rightIconBtn = new Button + { + Y = Application.GetRealHeight(203), + X = Application.GetRealWidth(323), + Width = Application.GetRealWidth(36), + Height = Application.GetRealWidth(36), + UnSelectedImagePath = "PirIcon/right.png", + }; + fLayout.AddChidren(rightIconBtn); + //娴嬭瘯鍔熻兘 + var testBtn = new Button + { + Y = Application.GetRealHeight(199), + X = Application.GetRealWidth(136), + Width = Application.GetRealWidth(104), + Height = Application.GetRealHeight(44), + TextID=StringId.dianyuan, + TextSize = TextSize.text16, + TextColor = CSS.CSS_Color.textColor, + TextAlignment = TextAlignment.Center, + Radius = (uint)Application.GetRealHeight(18), + BorderWidth = 1, + BorderColor = CSS.CSS_Color.textCancelColor, + }; + fLayout.AddChidren(testBtn); + + // 5/10 + Button sumBtn = new Button + { + Y = Application.GetRealHeight(267), + X = Application.GetRealWidth(170), + Width = Application.GetRealWidth(36), + Height = Application.GetRealHeight(17), + Text = "(1/20)", + TextSize = TextSize.text12, + TextColor = CSS.CSS_Color.textCancelColor, + }; + fLayout.AddChidren(sumBtn); + + //鎺у埗澶辫触 + var failedBtn = new Button + { + Y = Application.GetRealHeight(521), + X = Application.GetRealWidth(52), + Width = Application.GetRealWidth(124), + Height = Application.GetRealHeight(44), + TextID = StringId.kongzhishibai, + TextSize = TextSize.text16, + TextColor = CSS.CSS_Color.textConfirmColor, + TextAlignment = TextAlignment.Center, + Radius = (uint)Application.GetRealHeight(44), + BorderWidth = 1, + BorderColor = CSS.CSS_Color.textConfirmColor, + }; + fLayout.AddChidren(failedBtn); + //鎺у埗鎴愬姛 + var succeedBtn = new Button + { + Y = Application.GetRealHeight(521), + X = Application.GetRealWidth(196), + Width = Application.GetRealWidth(124), + Height = Application.GetRealHeight(44), + TextID = StringId.kongzhichenggong, + TextSize = TextSize.text16, + TextColor = CSS.CSS_Color.textWhiteColor, + TextAlignment = TextAlignment.Center, + Radius = (uint)Application.GetRealHeight(44), + //BorderWidth = 1, + //BorderColor = CSS.CSS_Color.textConfirmColor, + BackgroundColor = CSS.CSS_Color.textConfirmColor, + }; + fLayout.AddChidren(succeedBtn); + #endregion + #region 鐐瑰嚮浜嬩欢 + //琛ㄧず搴撳垪琛ㄧ储寮曞�� + int index= 1; + //琛ㄧず娴嬭瘯鐮佺储寮曞�� + int code = 1; + //宸� + leftIconBtn.MouseUpEventHandler += (sender, e) => + { + if (index>1) { + index--; + sumBtn.Text = "(" + index.ToString() + "/20)"; + } + code = 1; + GetBtnText(testBtn, code, spk); + }; + //鍙� + rightIconBtn.MouseUpEventHandler += (sender, e) => + { + if (index < 20) + { + index++; + sumBtn.Text = "(" + index.ToString() + "/20)"; + } + code = 1; + GetBtnText(testBtn, code, spk); + }; + //娴嬭瘯Text + testBtn.MouseUpEventHandler += (sender, e) => + { + var library = libraryList[index]; + var control = GetControl(spk, testBtn.TextID, library); + CodeTest(control); + }; + //鎺у埗澶辫触 + failedBtn.MouseUpEventHandler += (sender, e) => + { + if (index < 20) + { + index++; + sumBtn.Text = "(" + index.ToString() + "/20)"; + } + code = 1; + GetBtnText(testBtn, code, spk); + }; + //鎺у埗鎴愬姛 + succeedBtn.MouseUpEventHandler += (sender, e) => + { + if (code < 3) + { + code++; + } + GetBtnText(testBtn, code, spk); + if (code == 3) + { + var library = libraryList[index]; + var control = GetControl(spk, testBtn.TextID, library); + Method method = new Method(); + method.ThreadAddControl(control, this,(control1) => { + MainPage.BasePageView.RemoveViewByTag("PirView"); + AddControlComplete addControlComplete = new AddControlComplete(); + MainPage.BasePageView.AddChidren(addControlComplete); + addControlComplete.Show(control1,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.AcStandard: + { + switch (textInt) + { + case StringId.dianshi: + { + 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.ElectricTV: + { + switch (textInt) + { + case StringId.dianshi: + { + key = "on_off"; + value = "on"; + } + break; + case StringId.yinliangjia: + { + key = "on_off"; + value = "on"; + } + break; + case StringId.jingyin: + { + key = "mute"; + value = "0"; + } + break; + } + } + break; + } + ButtonObj buttonObj = new ButtonObj(); + buttonObj.Key = key; + buttonObj.value = value; + + Control control = new Control(); + control.spk = spk; + control.name = spk; + control.group_id = library.irIndex; + control.type = "library"; + control.status.Add(buttonObj); + string[] strings = library.irCode.Split(','); + for (int array = 0; array < strings.Length; array++) + { + //var intValue = Convert.ToInt32(strings[array],16); + control.library.Add(strings[array]); + } + + return control; + } + + /// <summary> + /// 鍙戦�佸簱鐮佹祴璇曞懡浠� + /// </summary> + /// <param name="control"></param> + private void CodeTest(Control control) + { + + //鍔犺浇log + Loading loading = new Loading(); + this.AddChidren(loading); + HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; + loading.Start(); + new System.Threading.Thread(() => + { + try + { + //鍙戦�佹寜閿垹闄わ紱 + responsePackNew = PirSend.CodeTest(control); + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + loading.Hide(); + if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + { + + } + else + { + Method method = new Method(); + method.ErrorShow(responsePackNew); + } + + }); + } + + }) + { IsBackground = true }.Start(); + } + + /// <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.ElectricTV: + { + 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