From 5266531a3a1552a11a29473974481d60100812c6 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期四, 04 三月 2021 19:24:44 +0800 Subject: [PATCH] Merge branch 'temp-wxr' into NewFilePath --- HDL_ON/UI/UI2/FuntionControlView/Electrical/ClothesHangerPage.cs | 155 ++++++++++++++++++++++++++++++++------------------- 1 files changed, 98 insertions(+), 57 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Electrical/ClothesHangerPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Electrical/ClothesHangerPage.cs index fa00457..3255433 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Electrical/ClothesHangerPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Electrical/ClothesHangerPage.cs @@ -64,8 +64,6 @@ //鍒濆鍖栫涓�涓储寮曢〉鐨勫唴瀹� this.InitFrameWhiteContent1(); - //鍒锋柊褰撳墠璁惧鐨勭姸鎬佺紦瀛� - this.RefreshNowDeviceStatuMemory(this.device); //鍒锋柊鐣岄潰鐘舵�� this.RefreshFormStatu(); //璇诲彇鐘舵�� @@ -126,6 +124,62 @@ }; FrameWhiteCentet1.AddChidren(btnDown); + #region 鎺у埗 + btnUp.MouseDownEventHandler = (sender, e) => { + btnUp.IsSelected = true; + }; + btnUp.MouseUpEventHandler = (sender, e) => { + new System.Threading.Thread(() => + { + System.Threading.Thread.Sleep(2000); + Application.RunOnMainThread(() => + { + btnUp.IsSelected = false; + }); + }) + { IsBackground = true }.Start(); + Dictionary<string, string> d = new Dictionary<string, string>(); + d.Add(FunctionAttributeKey.Position, "up"); + Control.Ins.SendWriteCommand(device, d); + }; + //---- + btnStop.MouseDownEventHandler = (sender, e) => { + btnStop.IsSelected = true; + }; + btnStop.MouseUpEventHandler = (sender, e) => { + new System.Threading.Thread(() => + { + System.Threading.Thread.Sleep(2000); + Application.RunOnMainThread(() => + { + btnStop.IsSelected = false; + }); + }) + { IsBackground = true }.Start(); + Dictionary<string, string> d = new Dictionary<string, string>(); + d.Add(FunctionAttributeKey.Position, "stop"); + Control.Ins.SendWriteCommand(device, d); + }; + //----- + btnDown.MouseDownEventHandler = (sender, e) => { + btnDown.IsSelected = true; + }; + btnDown.MouseUpEventHandler = (sender, e) => { + new System.Threading.Thread(() => + { + System.Threading.Thread.Sleep(2000); + Application.RunOnMainThread(() => + { + btnDown.IsSelected = false; + }); + }) + { IsBackground = true }.Start(); + Dictionary<string, string> d = new Dictionary<string, string>(); + d.Add(FunctionAttributeKey.Position, "down"); + Control.Ins.SendWriteCommand(device, d); + }; + #endregion + #endregion #region 鑿滃崟 @@ -152,7 +206,8 @@ { FrameWhiteCentet1.AddChidren(hotDryView); - EventHandler<MouseEventArgs> eventHandler = (sender, e) => { + EventHandler<MouseEventArgs> eventHandler = (sender, e) => + { string onoff = hotDryView.Lighting ? "false" : "true"; device.SetAttrState(FunctionAttributeKey.HotDry, onoff); Dictionary<string, string> d = new Dictionary<string, string>(); @@ -174,13 +229,14 @@ windDryView.Height = Application.GetRealHeight(74); if (attrs.Contains(menu[1])) { - if(index == 1) + if (index == 1) { windDryView.Gravity = Gravity.CenterHorizontal; } FrameWhiteCentet1.AddChidren(windDryView); - EventHandler<MouseEventArgs> eventHandler = (sender, e) => { + EventHandler<MouseEventArgs> eventHandler = (sender, e) => + { string onoff = windDryView.Lighting ? "false" : "true"; device.SetAttrState(FunctionAttributeKey.WindDry, onoff); Dictionary<string, string> d = new Dictionary<string, string>(); @@ -192,7 +248,7 @@ index++; } - + disinfectView = new ClothesHangerControl( "FunctionIcon/Electrical/ClothesHanger/ClothesHangerDisinfectIcon.png", @@ -204,7 +260,7 @@ disinfectView.Height = Application.GetRealHeight(74); if (attrs.Contains(menu[2])) { - if(index == 1) + if (index == 1) { disinfectView.Gravity = Gravity.CenterHorizontal; } @@ -214,7 +270,8 @@ } FrameWhiteCentet1.AddChidren(disinfectView); - EventHandler<MouseEventArgs> eventHandler = (sender, e) => { + EventHandler<MouseEventArgs> eventHandler = (sender, e) => + { string onoff = disinfectView.Lighting ? "false" : "true"; device.SetAttrState(FunctionAttributeKey.Disinfect, onoff); Dictionary<string, string> d = new Dictionary<string, string>(); @@ -235,10 +292,11 @@ lightingView.Height = Application.GetRealHeight(74); if (attrs.Contains(menu[3])) { - if(index >2) + if (index > 2) { lightingView.Y = Application.GetRealHeight(409); - }else + } + else { lightingView.Y = Application.GetRealHeight(304); if (index == 1) @@ -252,7 +310,8 @@ } FrameWhiteCentet1.AddChidren(lightingView); - EventHandler<MouseEventArgs> eventHandler = (sender, e) => { + EventHandler<MouseEventArgs> eventHandler = (sender, e) => + { string onoff = lightingView.Lighting ? "off" : "on"; device.SetAttrState(FunctionAttributeKey.OnOff, onoff); Dictionary<string, string> d = new Dictionary<string, string>(); @@ -305,8 +364,6 @@ //涓嶆槸鍚屼竴涓笢瑗� if (this.device.sid != i_LocalDevice.sid) { return; } - //鍒锋柊褰撳墠璁惧鐨勭姸鎬佺紦瀛� - this.RefreshNowDeviceStatuMemory(i_LocalDevice); //鍒锋柊鐣岄潰鐘舵�� this.RefreshFormStatu(); } @@ -324,49 +381,47 @@ /// </summary> private void RefreshFormStatu() { - Application.RunOnMainThread(() => { + Application.RunOnMainThread(() => + { btnIcon.IsSelected = true; #region 鐐逛寒鏂囨湰 - var hotDryTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.HotDry); + var hotDryTemp = device.attributes.Find((sta) => sta.key == FunctionAttributeKey.HotDry); if (hotDryTemp != null) { - hotDryView.SetViewStatus(hotDryTemp.value == "true"); + hotDryView.SetViewStatus(hotDryTemp.state == "true"); } - var windDryTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.WindDry); + var windDryTemp = device.attributes.Find((sta) => sta.key == FunctionAttributeKey.WindDry); if (windDryTemp != null) { - windDryView.SetViewStatus(windDryTemp.value == "true"); + windDryView.SetViewStatus(windDryTemp.state == "true"); } - var disinfectTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.Disinfect); + var disinfectTemp = device.attributes.Find((sta) => sta.key == FunctionAttributeKey.Disinfect); if (disinfectTemp != null) { - disinfectView.SetViewStatus(disinfectTemp.value == "true"); + disinfectView.SetViewStatus(disinfectTemp.state == "true"); } - var lightTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.OnOff); + var lightTemp = device.attributes.Find((sta) => sta.key == FunctionAttributeKey.OnOff); if (lightTemp != null) { - lightingView.SetViewStatus(lightTemp.value == "on"); + lightingView.SetViewStatus(lightTemp.state == "on"); } #endregion #region 淇敼鏃堕棿 - var hotDryTimeLeftTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.HotDryTimeLeft); + var hotDryTimeLeftTemp = device.attributes.Find((sta) => sta.key == FunctionAttributeKey.HotDryTimeLeft); if (hotDryTimeLeftTemp != null) { - hotDryView.ChangeTime(hotDryTimeLeftTemp.value); - MainPage.Log($"鐑樺共鍓╀綑鏃堕棿{hotDryTimeLeftTemp.value}"); + hotDryView.ChangeTime(hotDryTimeLeftTemp.state); } - var windDryTimeLeftTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.WindDryTimeLeft); + var windDryTimeLeftTemp = device.attributes.Find((sta) => sta.key == FunctionAttributeKey.WindDryTimeLeft); if (windDryTimeLeftTemp != null) { - windDryView.ChangeTime(windDryTimeLeftTemp.value); - MainPage.Log($"椋庡共鍓╀綑鏃堕棿{windDryTimeLeftTemp.value}"); + windDryView.ChangeTime(windDryTimeLeftTemp.state); } - var disinfectTimeLeftTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.DisinfectTimeLeft); + var disinfectTimeLeftTemp = device.attributes.Find((sta) => sta.key == FunctionAttributeKey.DisinfectTimeLeft); if (disinfectTimeLeftTemp != null) { - disinfectView.ChangeTime(disinfectTimeLeftTemp.value); - MainPage.Log($"娑堟瘨鍓╀綑鏃堕棿{disinfectTimeLeftTemp.value}"); + disinfectView.ChangeTime(disinfectTimeLeftTemp.state); } #endregion @@ -377,18 +432,6 @@ #endregion #region 鈻� 涓�鑸柟娉昣__________________________ - - /// <summary> - /// 鍒锋柊褰撳墠璁惧鐨勭姸鎬佺紦瀛� - /// </summary> - private void RefreshNowDeviceStatuMemory(Function i_LocalDevice) - { - foreach (var data in i_LocalDevice.status) - { - //寮�鍏� - //if (data.key == "on_off") { this.weepRobotData.Cleaning = data.value.ToLower() == "on"; } - } - } #endregion } @@ -407,9 +450,9 @@ /// </summary> public bool Lighting = false; - - public ClothesHangerControl(string iconPath1, string iconPath2,string title,string time) + + public ClothesHangerControl(string iconPath1, string iconPath2, string title, string time) { btnIcon = new Button() { @@ -448,16 +491,17 @@ /// 淇敼鏄剧ず鏃堕棿 /// </summary> /// <param name="newTime"></param> - public void ChangeTime (string newTime) + public void ChangeTime(string newTime) { int.TryParse(newTime, out leftTime); leftTime *= 60; if (countdownThread == null) { - countdownThread = new System.Threading.Thread(() => { - while(true) + countdownThread = new System.Threading.Thread(() => + { + while (true) { - if(leftTime > 1) + if (leftTime > 1) { Application.RunOnMainThread(() => { @@ -465,7 +509,8 @@ }); System.Threading.Thread.Sleep(1000); leftTime--; - }else + } + else { Application.RunOnMainThread(() => { @@ -473,7 +518,8 @@ }); } } - }) { IsBackground = true }; + }) + { IsBackground = true }; countdownThread.Start(); } } @@ -481,11 +527,6 @@ public void SetViewStatus(bool state) { btnIcon.IsSelected = btnTitle.IsSelected = btnTime.IsSelected = Lighting = state; - } - - public bool GetViewState() - { - return Lighting; } /// <summary> @@ -503,4 +544,4 @@ /// </summary> System.Threading.Thread countdownThread; } -} +} \ No newline at end of file -- Gitblit v1.8.0