From abf4a98837e43e542701c60b7ec6a088cd5236da Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期一, 22 二月 2021 09:10:35 +0800 Subject: [PATCH] 20210222 --- HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWaterValvePage.cs | 150 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 144 insertions(+), 6 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWaterValvePage.cs b/HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWaterValvePage.cs index f2e04a4..3f81d26 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWaterValvePage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Electrical/TuyaWaterValvePage.cs @@ -16,6 +16,20 @@ /// </summary> private PicViewControl btnPictrue = null; /// <summary> + /// 鎺у埗鍣ㄦ帶鍒剁姸鎬佹彁绀烘枃鏈寜閽� + /// </summary> + NormalViewControl btnControlTip = null; + /// <summary> + /// 鎺у埗鍣ㄦ帶鍒舵椂闂存彁绀烘枃鏈寜閽� + /// </summary> + NormalViewControl btnControlTimeTip = null; + + /// <summary> + /// + /// </summary> + private IconViewControl btnTimeSet = null; + + /// <summary> /// 寮�鍏虫帶浠� /// </summary> private IconViewControl btnSwitch = null; @@ -30,8 +44,8 @@ { base.SetTitleText(Language.StringByID(StringId.AirCleaner)); - //娣诲姞绗簩绱㈠紩椤� - this.AddSecondPage(); + ////娣诲姞绗簩绱㈠紩椤� + //this.AddSecondPage(); //鍒濆鍖栫涓�涓储寮曢〉鐨勫唴瀹� this.InitFrameWhiteContent1(); //鍒锋柊鐣岄潰鐘舵�� @@ -56,6 +70,43 @@ this.SendSwitchComand(); }; + btnControlTip = new NormalViewControl(300,30, true) + { + Y = Application.GetRealHeight(231), + TextAlignment = TextAlignment.Center, + Gravity = Gravity.CenterHorizontal, + TextSize = CSS_FontSize.TextFontSize, + SelectedTextColor = CSS_Color.MainColor, + TextColor = CSS_Color.TextualColor, + TextID = StringId.ControllerNotOn, + }; + FrameWhiteCentet1.AddChidren(btnControlTip); + + btnControlTimeTip = new NormalViewControl(300, 30, true) + { + Y = Application.GetRealHeight(252), + Gravity = Gravity.CenterHorizontal, + TextAlignment = TextAlignment.Center, + TextSize = CSS_FontSize.TextFontSize, + //TextColor = 0x00000000, + SelectedTextColor = CSS_Color.TextualColor, + TextColor = CSS_Color.TextualColor, + Text = "00:00:00" + }; + FrameWhiteCentet1.AddChidren(btnControlTimeTip); + + btnTimeSet = new IconViewControl(50) + { + Y = Application.GetRealHeight(365), + Gravity = Gravity.CenterHorizontal, + UnSelectedImagePath = "FunctionIcon/Electrical/WaterValve/SetTimeIcon.png", + SelectedImagePath = "FunctionIcon/Electrical/WaterValve/SetTimeIcon.png", + }; + FrameWhiteCentet1.AddChidren(btnTimeSet); + btnTimeSet.ButtonClickEvent = (sender, e) => { + SetControlTime(); + }; + //寮�鍏冲浘鏍� this.btnSwitch = new IconViewControl(40); btnSwitch.Gravity = Gravity.CenterHorizontal; @@ -68,6 +119,8 @@ //鍙戦�佸紑鍏冲懡浠� this.SendSwitchComand(); }; + + var pack = new DAL.Server.HttpServerRequest().GetDeviceInfoList(new List<string>() { base.device.deviceId }); } #endregion @@ -99,7 +152,6 @@ this.btnSwitch.CanClick = false; string statu = this.btnSwitch.IsSelected == true ? "off" : "on"; - //btnSwitch.IsSelected = !btnSwitch.IsSelected; HdlThreadLogic.Current.RunThread(() => { var dic = new Dictionary<string, string>(); @@ -124,16 +176,102 @@ { Application.RunOnMainThread(() => { - foreach (var data in this.device.attributes) + var onoffStatu = device.status.Find((obj) => obj.key == FunctionAttributeKey.OnOff); + var timeStatu = device.status.Find((obj) => obj.key == FunctionAttributeKey.TuyaWaterTime); + + if (onoffStatu != null) { - if (data.key == FunctionAttributeKey.OnOff) + if (onoffStatu.value.ToString() == "on") { - this.btnSwitch.IsSelected = this.btnPictrue.IsSelected = data.curValue.ToString() == "on"; + btnControlTip.TextID = StringId.ControllerOn; } + else + { + btnControlTip.TextID = StringId.ControllerNotOn; + } + this.btnSwitch.IsSelected = this.btnPictrue.IsSelected = onoffStatu.value.ToString() == "on"; } + if (timeStatu != null) + { + int.TryParse(timeStatu.value, out waterRunningTime); + } + RefreshTimeButton(); }); } + + System.Threading.Thread refreshTimeThread; + int waterRunningTime = 0; + /// <summary> + /// 鍒锋柊姘撮榾鏃堕棿鏂囨湰 + /// </summary> + private void RefreshTimeButton() + { + if (refreshTimeThread == null || refreshTimeThread.ThreadState == System.Threading.ThreadState.Stopped) + { + refreshTimeThread = new System.Threading.Thread(() => + { + while (waterRunningTime >= 0) + { + if (waterRunningTime > 0) + { + waterRunningTime--; + } + var sce = waterRunningTime % 60; + var min = 0; + if(waterRunningTime > 60) + { + min = (waterRunningTime - sce) / 60 %60; + } + var hour = 0; + if(waterRunningTime > 360) + { + hour = (waterRunningTime - sce - (min * 60)) / 3600; + } + Application.RunOnMainThread(() => + { + btnControlTimeTip.Text = $"{hour.ToString().PadLeft(2,'0')}:{min.ToString().PadLeft(2, '0')}:{sce.ToString().PadLeft(2, '0')}"; + }); + System.Threading.Thread.Sleep(1000); + } + }) + { IsBackground = true }; + } + refreshTimeThread.Start(); + } + + public override void RemoveFromParent() + { + if (refreshTimeThread != null) + { + refreshTimeThread.Abort(); + } + base.RemoveFromParent(); + } + #endregion + + private void SetControlTime() + { + var timeControl = new BottomTimeSelectControl(); + timeControl.InitControl(0,0); + timeControl.FinishEvent = (type,hours,min) => { + if (type == 1)//0:鍙栨秷锛�1:纭畾 + { + HdlThreadLogic.Current.RunThread(() => + { + var time = hours * 60 * 60 + min * 60; + var dic = new Dictionary<string, string>(); + dic.Add(FunctionAttributeKey.TuyaWaterTime, time.ToString()); + Control.Ins.SendWriteCommand(this.device, dic, true); + HdlThreadLogic.Current.RunMain(() => + { + waterRunningTime = time; + this.btnControlTimeTip.Text = $"{hours.ToString().PadLeft(2, '0')}:{min.ToString().PadLeft(2, '0')}:00"; + }); + }); + } + }; + } } } -- Gitblit v1.8.0