From af9c3e0b3b1eb370e966b3ca9db3f62848d4189b Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期六, 21 八月 2021 13:03:12 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/newBranch1' into WJC --- HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/SenesorEnvironment/AddSensorEnvironmentPage.cs | 203 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 203 insertions(+), 0 deletions(-) diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/SenesorEnvironment/AddSensorEnvironmentPage.cs b/HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/SenesorEnvironment/AddSensorEnvironmentPage.cs new file mode 100644 index 0000000..0d1da43 --- /dev/null +++ b/HDL_ON/UI/UI2/4-PersonalCenter/AddDevice/SenesorEnvironment/AddSensorEnvironmentPage.cs @@ -0,0 +1,203 @@ +锘縰sing HDL_ON.DAL.Server; +using HDL_ON.Entity; +using HDL_ON.Stan; +using Shared; +using System; + +namespace HDL_ON.UI +{ + /// <summary> + /// 娣诲姞鐜浼犳劅鍣ㄦ楠�1鐣岄潰 + /// </summary> + public class AddSensorEnvironmentPage : EditorCommonForm + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 娣诲姞璁惧瀹屾垚涔嬪悗鐨勫洖璋冧簨浠� + /// </summary> + public Action<Function> AddDeviceEvent = null; + + IntegratedBrandDevice integratedDevice = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + /// <summary> + /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) + /// </summary> + public void ShowForm(IntegratedBrandDevice device) + { + integratedDevice = device; + if (Language.CurrentLanguage == "Chinese") + { + //璁剧疆澶撮儴淇℃伅 + base.SetTitleText(Language.StringByID(StringId.Add) + device.productName); + } + else + { + base.SetTitleText(Language.StringByID(StringId.Add) + " " + device.productName); + } + //杩欎釜鐣岄潰鐨勮儗鏅渶瑕佺櫧鑹� + bodyFrameLayout.BackgroundColor = UI.CSS.CSS_Color.MainBackgroundColor; + + //鍒濆鍖栦腑閮ㄤ俊鎭� + this.InitMiddleFrame(); + } + + /// <summary> + /// 鍒濆鍖栦腑閮ㄤ俊鎭� + /// </summary> + private void InitMiddleFrame() + { + //鍥剧墖 + var btnPic = new PicViewControl(132, 132); + btnPic.Y = Application.GetRealHeight(69); + btnPic.Gravity = Gravity.CenterHorizontal; + if (integratedDevice.spk == SPK.SensorEnvironment3) + { + btnPic.UnSelectedImagePath = "PersonalCenter/AddDevice/EnvirSensorQingpingLitebg.png"; + } + else if (integratedDevice.spk == SPK.SensorEnvironment2) + { + btnPic.UnSelectedImagePath = "PersonalCenter/AddDevice/EnvirSensorQingpingCGS1bg.png"; + } + else + { + btnPic.UnSelectedImagePath = "PersonalCenter/AddDevice/EnvironmentalSensorbg.png"; + } + bodyFrameLayout.AddChidren(btnPic); + + //璇疯緭鍏ヨ澶囨満涓婄殑sn鐮� + var textView = new FrameLayout() + { + Y = Application.GetRealHeight(309 - 64), + Gravity = Gravity.CenterHorizontal, + Width = Application.GetRealWidth(319), + Height = Application.GetRealHeight(44), + }; + bodyFrameLayout.AddChidren(textView); + textView.AddChidren(new Button() { Y = Application.GetRealHeight(43), Height = 1, BackgroundColor = CSS.CSS_Color.DividingLineColor }); + + EditText editText = new EditText() + { + TextAlignment = TextAlignment.Center, + TextColor = CSS.CSS_Color.FirstLevelTitleColor, + PlaceholderText = Language.StringByID(StringId.PlsEntrySNCode), + PlaceholderTextColor = CSS.CSS_Color.PromptingColor1, + TextSize = CSS.CSS_FontSize.TextFontSize, + }; + textView.AddChidren(editText); + + if (integratedDevice.spk == SPK.SensorEnvironment2 || integratedDevice.spk == SPK.SensorEnvironment3) + { + editText.PlaceholderText = Language.StringByID(StringId.PlsEntryMacCode); + } + if (integratedDevice.spk == SPK.SensorEnvironment) + { + Button btnScan = new Button() + { + Width = Application.GetRealWidth(32), + Height = Application.GetRealWidth(32), + Gravity = Gravity.CenterVertical, + X = Application.GetRealWidth(275), + UnSelectedImagePath = "Public/Scan.png" + }; + textView.AddChidren(btnScan); + btnScan.MouseUpEventHandler = (sender, e) => + { + Scan.OpenScan((scanString) => + { + editText.Text = scanString; + }); + }; + } + //涓嬩竴姝� + var btnNext = this.AddBottomClickButton(Language.StringByID(StringId.Next)); + btnNext.ButtonClickEvent += (sender, e) => + { + var snCode = editText.Text.Trim(); + if (string.IsNullOrEmpty(snCode)) + { + editText.PlaceholderTextColor = CSS.CSS_Color.WarningColor; + } + else + { + + var waitPage = new Loading(); + waitPage.Start(); + new System.Threading.Thread(() => { + try + { + var pm = new HttpServerRequest(); + var pack = pm.IndependentRegister3TyDevcie(integratedDevice.spk, snCode, Language.StringByID(StringId.SensorEnvironment)); + if (pack.Code == StateCode.SUCCESS) + { + //var revData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<IntegratedBrandDevice>>(pack.Data.ToString()); + Application.RunOnMainThread(() => + { + waitPage.Hide(); + var tipDialog = new OperationResultDisPalyPage(); + tipDialog.LoadPage(true, Language.StringByID(StringId.AddSuccess), "", Language.StringByID(StringId.CanStartUsingEnvironmentalSensor), Language.StringByID(StringId.Next)); + tipDialog.Show(); + AddDeviceEvent?.Invoke(new Function()); + this.CloseForm(); + }); + } + else if (pack.Code == "10801" || pack.Code == "9") + { + var mes = ""; + if (Language.CurrentLanguage == "Chinese") + { + mes = "璇ヨ澶囧凡缁忚娣诲姞銆�"; + } + else + { + mes = "This device has been added."; + } + Application.RunOnMainThread(() => + { + var tip = new Tip() + { + Text = mes, + CloseTime = 2, + Direction = AMPopTipDirection.None + }; + tip.Show(MainPage.BaseView); + }); + } + else + { + IMessageCommon.Current.ShowErrorInfoAlter(pack.Code); + } + } + catch (Exception ex) + { + MainPage.Log("2--::" + ex.Message); + } + finally + { + Application.RunOnMainThread(() => { waitPage.Hide(); }); + } + }) + { IsBackground = true }.Start(); + } + }; + } + + #endregion + + #region 鈻� 鍏抽棴鐣岄潰___________________________ + + /// <summary> + /// 鍏抽棴鐣岄潰 + /// </summary> + public override void CloseFormBefore() + { + this.AddDeviceEvent = null; + base.CloseFormBefore(); + } + + #endregion + } +} -- Gitblit v1.8.0