From 08a8afe782cd499550f94f3da0ba5788e1e12971 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期二, 02 三月 2021 17:45:45 +0800 Subject: [PATCH] 2021-3-2-1 --- HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Matching.cs | 248 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 244 insertions(+), 4 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..b6bdd3b 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,8 +9,9 @@ { public Matching() { + Tag = "PirView"; } - public void Show() + public void Show(List<Library> libraryList,string spk) { #region 鐣岄潰甯冨眬 this.BackgroundColor = CSS.CSS_Color.viewMiddle; @@ -79,7 +82,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, @@ -96,7 +99,7 @@ X = Application.GetRealWidth(170), Width = Application.GetRealWidth(36), Height = Application.GetRealHeight(17), - Text = "(" + "1" + "/20)", + Text = "(1/20)", TextSize = TextSize.text12, TextColor = CSS.CSS_Color.textCancelColor, }; @@ -137,15 +140,252 @@ fLayout.AddChidren(succeedBtn); #endregion #region 鐐瑰嚮浜嬩欢 - int value = 1; + //琛ㄧず搴撳垪琛ㄧ储寮曞�� + 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, true); + } }; #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.AcStandard: + { + 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