From d4811b7d34b45ff6b21b97f11da128b5572ec526 Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期三, 03 三月 2021 16:03:03 +0800 Subject: [PATCH] 20210303-1 --- HDL_ON/UI/UI2/FuntionControlView/Electrical/ClothesHangerPage.cs | 171 +++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 131 insertions(+), 40 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Electrical/ClothesHangerPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Electrical/ClothesHangerPage.cs index 3e848e6..6454ccb 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Electrical/ClothesHangerPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Electrical/ClothesHangerPage.cs @@ -126,6 +126,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,10 +208,12 @@ { FrameWhiteCentet1.AddChidren(hotDryView); - EventHandler<MouseEventArgs> eventHandler = (sender, e) => { - device.SetAttrState(FunctionAttributeKey.HotDry, "true"); + EventHandler<MouseEventArgs> eventHandler = (sender, e) => + { + string onoff = hotDryView.Lighting ? "false" : "true"; + device.SetAttrState(FunctionAttributeKey.HotDry, onoff); Dictionary<string, string> d = new Dictionary<string, string>(); - d.Add(FunctionAttributeKey.HotDry, "true"); + d.Add(FunctionAttributeKey.HotDry, onoff); Control.Ins.SendWriteCommand(device, d); }; hotDryView.SetThouchEvent(eventHandler); @@ -173,16 +231,18 @@ 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) => { - device.SetAttrState(FunctionAttributeKey.WindDry, "true"); + EventHandler<MouseEventArgs> eventHandler = (sender, e) => + { + string onoff = windDryView.Lighting ? "false" : "true"; + device.SetAttrState(FunctionAttributeKey.WindDry, onoff); Dictionary<string, string> d = new Dictionary<string, string>(); - d.Add(FunctionAttributeKey.WindDry, "true"); + d.Add(FunctionAttributeKey.WindDry, onoff); Control.Ins.SendWriteCommand(device, d); }; windDryView.SetThouchEvent(eventHandler); @@ -190,7 +250,7 @@ index++; } - + disinfectView = new ClothesHangerControl( "FunctionIcon/Electrical/ClothesHanger/ClothesHangerDisinfectIcon.png", @@ -202,7 +262,7 @@ disinfectView.Height = Application.GetRealHeight(74); if (attrs.Contains(menu[2])) { - if(index == 1) + if (index == 1) { disinfectView.Gravity = Gravity.CenterHorizontal; } @@ -212,10 +272,12 @@ } FrameWhiteCentet1.AddChidren(disinfectView); - EventHandler<MouseEventArgs> eventHandler = (sender, e) => { - device.SetAttrState(FunctionAttributeKey.Disinfect, "true"); + EventHandler<MouseEventArgs> eventHandler = (sender, e) => + { + string onoff = disinfectView.Lighting ? "false" : "true"; + device.SetAttrState(FunctionAttributeKey.Disinfect, onoff); Dictionary<string, string> d = new Dictionary<string, string>(); - d.Add(FunctionAttributeKey.Disinfect, "true"); + d.Add(FunctionAttributeKey.Disinfect, onoff); Control.Ins.SendWriteCommand(device, d); }; disinfectView.SetThouchEvent(eventHandler); @@ -232,10 +294,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) @@ -249,7 +312,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>(); @@ -260,6 +324,32 @@ index++; } + + #endregion + + + #region 鏃堕棿璁剧疆 + var timeSetView = new ClothesHangerControl( + "FunctionIcon/Electrical/ClothesHanger/ClothesHangerTimeIcon.png", + "FunctionIcon/Electrical/ClothesHanger/ClothesHangerTimeIconOn.png", + Language.StringByID(StringId.Time), + ""); + timeSetView.Width = Application.GetRealWidth(96); + timeSetView.Height = Application.GetRealHeight(74); + timeSetView.Y = Application.GetRealHeight(409); + timeSetView.X = Application.GetRealWidth(266 - 33); + + + EventHandler<MouseEventArgs> eventHandler_timeSetView = (sender, e) => + { + var setTimePage = new ClothesHangerSetTimePage(device); + MainPage.BasePageView.AddChidren(setTimePage); + setTimePage.LoadPage(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + timeSetView.SetThouchEvent(eventHandler_timeSetView); + + FrameWhiteCentet1.AddChidren(timeSetView); #endregion } @@ -295,7 +385,8 @@ /// </summary> private void RefreshFormStatu() { - Application.RunOnMainThread(() => { + Application.RunOnMainThread(() => + { btnIcon.IsSelected = true; #region 鐐逛寒鏂囨湰 var hotDryTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.HotDry); @@ -325,16 +416,19 @@ if (hotDryTimeLeftTemp != null) { hotDryView.ChangeTime(hotDryTimeLeftTemp.value); + MainPage.Log($"鐑樺共鍓╀綑鏃堕棿{hotDryTimeLeftTemp.value}"); } var windDryTimeLeftTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.WindDryTimeLeft); if (windDryTimeLeftTemp != null) { windDryView.ChangeTime(windDryTimeLeftTemp.value); + MainPage.Log($"椋庡共鍓╀綑鏃堕棿{windDryTimeLeftTemp.value}"); } var disinfectTimeLeftTemp = device.status.Find((sta) => sta.key == FunctionAttributeKey.DisinfectTimeLeft); if (disinfectTimeLeftTemp != null) { disinfectView.ChangeTime(disinfectTimeLeftTemp.value); + MainPage.Log($"娑堟瘨鍓╀綑鏃堕棿{disinfectTimeLeftTemp.value}"); } #endregion @@ -367,11 +461,17 @@ private Button btnTitle; private Button btnTime; /// <summary> + /// 鍊掕鏃舵椂闂� + /// </summary> + private int leftTime = 0; + /// <summary> /// 鎺т欢鏄惁鐐逛寒 /// </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() { @@ -410,31 +510,26 @@ /// 淇敼鏄剧ず鏃堕棿 /// </summary> /// <param name="newTime"></param> - public void ChangeTime (string newTime) + public void ChangeTime(string newTime) { - if(newTime == "0") - { - newTime = ""; - } - - int time = 0; - int.TryParse(newTime, out time); - time = time * 60; - + 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(time>1) + if (leftTime > 1) { Application.RunOnMainThread(() => { - btnTime.Text = new TimeSpan(0, 0, time).ToString(); + btnTime.Text = new TimeSpan(0, 0, leftTime).ToString(); }); System.Threading.Thread.Sleep(1000); - time--; - }else + leftTime--; + } + else { Application.RunOnMainThread(() => { @@ -442,7 +537,8 @@ }); } } - }) { IsBackground = true }; + }) + { IsBackground = true }; countdownThread.Start(); } } @@ -450,11 +546,6 @@ public void SetViewStatus(bool state) { btnIcon.IsSelected = btnTitle.IsSelected = btnTime.IsSelected = Lighting = state; - } - - public bool GetViewState() - { - return Lighting; } /// <summary> @@ -472,4 +563,4 @@ /// </summary> System.Threading.Thread countdownThread; } -} +} \ No newline at end of file -- Gitblit v1.8.0