From af6a098440ab45a5da3d7fe20d30d08a87ea4b6a Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期五, 10 六月 2022 13:59:58 +0800
Subject: [PATCH] 2022年06月10日13:59:24

---
 HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs |  135 +++++++++++++++++++++++++++++----------------
 1 files changed, 87 insertions(+), 48 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs
index c5349dd..fc62ae0 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs
@@ -85,7 +85,17 @@
         /// 淇敼鑹叉俯
         /// </summary>
         void LoadEvet_ChangeColorTemplatrue()
-        {
+        {
+            //if (!function.online)
+            //{
+            //    new Tip()
+            //    {
+            //        CloseTime = 1,
+            //        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+            //        Direction = AMPopTipDirection.None,
+            //    }.Show(MainPage.BaseView);
+            //    return;
+            //}
             barColorTemplatrue.OnProgressChangedEvent += (sender, value) =>
             {
                 new System.Threading.Thread(() =>
@@ -129,62 +139,80 @@
         /// </summary>
         void LoadEvent_DimmerBar()
         {
-            dimmerBar.OnStartTrackingTouchEvent = (sender, e) => {
-                onDimmerBar = true;
-            };
             dimmerBar.OnStopTrackingTouchEvent = (sender, e) =>
-            {
+            {
+                //if (!function.online)
+                //{
+                //    new Tip()
+                //    {
+                //        CloseTime = 1,
+                //        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+                //        Direction = AMPopTipDirection.None,
+                //    }.Show(MainPage.BaseView);
+                //    return;
+                //}
                 onDimmerBar = false;
                 function.SetAttrState(FunctionAttributeKey.Brightness, dimmerBar.Progress);
                 System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                d.Add(FunctionAttributeKey.Brightness, dimmerBar.Progress.ToString());
+                d.Add(FunctionAttributeKey.Brightness, dimmerBar.Progress.ToString());
+                d.Add(FunctionAttributeKey.FadeTime, function.GetAttrState(FunctionAttributeKey.FadeTime));
+                if (dimmerBar.Progress > 0)
+                {
+                    d.Add(FunctionAttributeKey.OnOff, "on");
+                }
                 Control.Ins.SendWriteCommand(function, d);
                 //function.fadeTime = barFadeTime.Progress;
                 btnBrightnessText.Text = dimmerBar.Progress + "%";
 
                 dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1);
-            };
-            dimmerBar.OnProgressChangedEvent = (sender, e) =>
-            {
-                dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1);
-                //function.fadeTime = 0;
-                //if (!btnSwitch.IsSelected)
-                //{
-                //    dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1);
-                //}
-                //btnSwitch.IsSelected = e > 0 ? true : false;
-                //function.brightness = e;
-                //function.trait_on_off.curValue = e > 0 ? "on" : "off";
-
-                //if (e == 0 || e == 100)
-                //{
-                //    System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                //    d.Add(FunctionAttributeKey.Brightness, function.brightness.ToString());
-                //    Control.Ins.SendWriteCommand(function, d);
-                //}
-                //else
-                //{
-                //    if (200 < (DateTime.Now - function.refreshTime).TotalMilliseconds)
-                //    {
-                //        function.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, function.brightness.ToString());
-                //            Control.Ins.SendWriteCommand(function, d);
-                //        })
-                //        { IsBackground = true }.Start();
-                //    }
-                //}
-
-                //btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16 - 16) / 100) + Application.GetRealWidth(40);
-                //btnBrightnessText.Text = function.brightness + "%";
-
+            };
+            //if (function.online)
+            {
+                dimmerBar.OnStartTrackingTouchEvent = (sender, e) =>
+                {
+                    onDimmerBar = true;
+                };
+                dimmerBar.OnProgressChangedEvent = (sender, e) =>
+                {
+                    dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1);
+                //function.fadeTime = 0;
+                //if (!btnSwitch.IsSelected)
+                //{
+                //    dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1);
+                //}
+                //btnSwitch.IsSelected = e > 0 ? true : false;
+                //function.brightness = e;
+                //function.trait_on_off.curValue = e > 0 ? "on" : "off";
+
+                //if (e == 0 || e == 100)
+                //{
+                //    System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
+                //    d.Add(FunctionAttributeKey.Brightness, function.brightness.ToString());
+                //    Control.Ins.SendWriteCommand(function, d);
+                //}
+                //else
+                //{
+                //    if (200 < (DateTime.Now - function.refreshTime).TotalMilliseconds)
+                //    {
+                //        function.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, function.brightness.ToString());
+                //            Control.Ins.SendWriteCommand(function, d);
+                //        })
+                //        { IsBackground = true }.Start();
+                //    }
+                //}
+
+                //btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16 - 16) / 100) + Application.GetRealWidth(40);
+                //btnBrightnessText.Text = function.brightness + "%";
+
                 btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100) + Application.GetRealWidth(80);
-                btnBrightnessText.Text = dimmerBar.Progress + "%";
-            };
-
-
+                    btnBrightnessText.Text = dimmerBar.Progress + "%";
+                };
+
+            }
         }
 
         /// <summary>
@@ -193,7 +221,17 @@
         void LoadSwitchEvent()
         {
             btnSwitch.MouseUpEventHandler += (sender, e) =>
-            {
+            {
+                //if (!function.online)
+                //{
+                //    new Tip()
+                //    {
+                //        CloseTime = 1,
+                //        Text = Language.StringByID(StringId.DeviceOfflineCannotOption),
+                //        Direction = AMPopTipDirection.None,
+                //    }.Show(MainPage.BaseView);
+                //    return;
+                //}
                 //function.fadeTime = barFadeTime.Progress;
                 btnSwitch.IsSelected = !btnSwitch.IsSelected;
                 if (btnSwitch.IsSelected)
@@ -209,6 +247,7 @@
                     function.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, function.trait_on_off.curValue.ToString());
+                    d.Add(FunctionAttributeKey.FadeTime, function.GetAttrState(FunctionAttributeKey.FadeTime));
                     if (btnSwitch.IsSelected)
                     {
                         d.Add(FunctionAttributeKey.Brightness, function.lastBrightness.ToString());

--
Gitblit v1.8.0