From 130a9b9cf4f5cd6ed8c11cb9cd4780f8b7da8bec Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期四, 24 十二月 2020 23:17:59 +0800 Subject: [PATCH] Update ColorTureLampPageBLL.cs --- HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs | 132 ++++++++++++++++++++++++++++---------------- 1 files changed, 84 insertions(+), 48 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs old mode 100755 new mode 100644 index 3ac7385..26276ea --- a/HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs @@ -20,22 +20,28 @@ return; if (uFunction.functionType == bodyView.light.functionType && uFunction.sid == bodyView.light.sid) { - if (uFunction.trait_on_off.curValue.ToString() == "on") { bodyView.dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); if (!bodyView.onDimmerBar) { bodyView.dimmerBar.Progress = uFunction.brightness; - } - bodyView.btnBrightnessText.Text = uFunction.brightness + "%"; - bodyView.btnBrightnessText.Y = ((100 - uFunction.brightness) * Application.GetRealHeight(222 - 16 - 16) / 100) + Application.GetRealWidth(40); + } + bodyView.btnBrightnessText.Text = uFunction.brightness + "%"; + bodyView.btnBrightnessText.Y = ((100 - uFunction.brightness) * Application.GetRealHeight(222 - 16) / 100) + Application.GetRealWidth(80); } else { bodyView.dimmerBar.SetProgressBarColors(CSS_Color.DividingLineColor, CSS_Color.DividingLineColor); } bodyView.btnSwitch.IsSelected = uFunction.trait_on_off.curValue.ToString() == "on"; + bodyView.barColorTemplatrue.Enable = uFunction.trait_on_off.curValue.ToString() == "on"; + var cct = 27; + int.TryParse(uFunction.Attr_CCT.curValue.ToString(), out cct); + bodyView.barColorTemplatrue.Progress = cct / 100; + //璁剧疆鍒濆鍊� + bodyView.barColorTemplatrue.SetCustomText(bodyView.barColorTemplatrue.Progress * 100 + "K"); + } } catch (Exception ex) @@ -64,11 +70,11 @@ /// </summary> void LoadEvet_ChangeFadeTime() { - barFadeTime.OnProgressChangedEvent = (sender, e) => - { - light.fadeTime = e; - light.SaveFunctionData(true); - }; + //barFadeTime.OnStopTrackingTouchEvent = (sender, e) => + //{ + // light.fadeTime = e; + // light.SaveFunctionData(true); + //}; } /// <summary> @@ -78,9 +84,29 @@ { barColorTemplatrue.OnProgressChangedEvent += (sender, value) => { - //璁剧疆鑷畾涔夌殑鏂囨湰 - barColorTemplatrue.SetCustomText(value * 100 + "K"); + new System.Threading.Thread(() => + { + Application.RunOnMainThread(() => + { + //璁剧疆鑷畾涔夌殑鏂囨湰 + barColorTemplatrue.SetCustomText(value * 100 + "K"); + light.Attr_CCT.curValue = value * 100; + //System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); + //d.Add(FunctionAttributeKey.CCT, light.Attr_CCT.curValue.ToString()); + //Control.Ins.SendWriteCommand(light, d); + }); + //System.Threading.Thread.Sleep(200); + }).Start(); + }; + + barColorTemplatrue.OnStopTrackingTouchEvent = (sender, value) => + { + light.Attr_CCT.curValue = value * 100; + System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); + d.Add(FunctionAttributeKey.CCT, light.Attr_CCT.curValue.ToString()); + Control.Ins.SendWriteCommand(light, d); }; + } /// <summary> @@ -90,7 +116,7 @@ { btnCollection.MouseUpEventHandler += (sender, e) => { btnCollection.IsSelected = light.collect = btnCollection_Out.IsSelected = !btnCollection.IsSelected; - light.SaveFunctionData(true); + light.CollectFunction(); }; } @@ -102,50 +128,59 @@ dimmerBar.OnStartTrackingTouchEvent = (sender, e) => { onDimmerBar = true; }; - dimmerBar.OnStopTrackingTouchEvent = (sender, e) => { + dimmerBar.OnStopTrackingTouchEvent = (sender, e) => + { onDimmerBar = false; light.brightness = dimmerBar.Progress; - //Control.Send(CommandType_A.write, light); System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); d.Add(FunctionAttributeKey.Brightness, light.brightness.ToString()); Control.Ins.SendWriteCommand(light, d); - light.fadeTime = barFadeTime.Progress; + //light.fadeTime = barFadeTime.Progress; + btnBrightnessText.Text = dimmerBar.Progress + "%"; + + dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); }; - dimmerBar.OnProgressChangedEvent = (sender, e) => { - light.fadeTime = 0; - if (!btnSwitch.IsSelected) - { - dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); - } - btnSwitch.IsSelected = e > 0 ? true : false; - light.brightness = e; - light.trait_on_off.curValue = e > 0 ? "on" : "off"; + dimmerBar.OnProgressChangedEvent = (sender, e) => + { + dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); + //light.fadeTime = 0; + //if (!btnSwitch.IsSelected) + //{ + // dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1); + //} + //btnSwitch.IsSelected = e > 0 ? true : false; + //light.brightness = e; + //light.trait_on_off.curValue = e > 0 ? "on" : "off"; - if (e == 0 || e == 100) - { - //Control.Send(CommandType_A.write, this.light); - System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); - d.Add(FunctionAttributeKey.Brightness, light.brightness.ToString()); - Control.Ins.SendWriteCommand(light, d); - } - else - { - if (200 < (DateTime.Now - light.refreshTime).TotalMilliseconds) - { - light.refreshTime = DateTime.Now; - new System.Threading.Thread(() => - { - System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); - d.Add(FunctionAttributeKey.Brightness, light.brightness.ToString()); - Control.Ins.SendWriteCommand(light, d); - }) - { IsBackground = true }.Start(); - } - } + //if (e == 0 || e == 100) + //{ + // System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); + // d.Add(FunctionAttributeKey.Brightness, light.brightness.ToString()); + // Control.Ins.SendWriteCommand(light, d); + //} + //else + //{ + // if (200 < (DateTime.Now - light.refreshTime).TotalMilliseconds) + // { + // light.refreshTime = DateTime.Now; + // new System.Threading.Thread(() => + // { + // System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); + // d.Add(FunctionAttributeKey.Brightness, light.brightness.ToString()); + // Control.Ins.SendWriteCommand(light, d); + // }) + // { IsBackground = true }.Start(); + // } + //} - btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16 - 16) / 100) + Application.GetRealWidth(40); - btnBrightnessText.Text = light.brightness + "%"; + //btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16 - 16) / 100) + Application.GetRealWidth(40); + //btnBrightnessText.Text = light.brightness + "%"; + + btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100) + Application.GetRealWidth(80); + btnBrightnessText.Text = dimmerBar.Progress + "%"; }; + + } /// <summary> @@ -155,7 +190,7 @@ { btnSwitch.MouseUpEventHandler += (sender, e) => { - light.fadeTime = barFadeTime.Progress; + //light.fadeTime = barFadeTime.Progress; btnSwitch.IsSelected = !btnSwitch.IsSelected; if (btnSwitch.IsSelected) { @@ -170,6 +205,7 @@ light.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off"; System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>(); d.Add(FunctionAttributeKey.OnOff, light.trait_on_off.curValue.ToString()); + d.Add(FunctionAttributeKey.FadeTime, light.fadeTime.ToString()); if (btnSwitch.IsSelected) { d.Add(FunctionAttributeKey.Brightness, light.lastBrightness.ToString()); -- Gitblit v1.8.0