From 2d5cd35af7437ad4015d38594d8c721dc6166b11 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期二, 29 八月 2023 09:22:38 +0800
Subject: [PATCH] Merge branch 'wjc' of http://59.41.255.150:6688/r/~wxr/OnPro into wjc

---
 HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs |  171 +++++++++++++++++++++++++++++++-------------------------
 1 files changed, 95 insertions(+), 76 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs
index b05731e..8269b50 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Light/GroupControlPage_V2.cs
@@ -1,7 +1,5 @@
 锘縰sing System;
 using System.Collections.Generic;
-using HDL_ON.Common;
-using HDL_ON.DriverLayer;
 using HDL_ON.Entity;
 using HDL_ON.UI.CSS;
 using Shared;
@@ -209,31 +207,39 @@
 
             attrView.AddChidren(new Button() { Height = Application.GetRealHeight(18) });
 
-            btnSwitch = new Button()
+            var btnOn = new Button()
             {
-                Gravity = Gravity.CenterHorizontal,
+                X = Application.GetRealWidth(100),
+                Y = Application.GetRealHeight(466),
+                Width = Application.GetMinRealAverage(32),
+                Height = Application.GetMinRealAverage(32),
+                //UnSelectedImagePath = "Public/PowerClose.png",
+                UnSelectedImagePath = "Public/PowerOpen.png",
+            };
+            controlView.AddChidren(btnOn);
+
+            var btnOff = new Button()
+            {
+                X = Application.GetRealWidth(180),
                 Y = Application.GetRealHeight(466),
                 Width = Application.GetMinRealAverage(32),
                 Height = Application.GetMinRealAverage(32),
                 UnSelectedImagePath = "Public/PowerClose.png",
-                SelectedImagePath = "Public/PowerOpen.png",
+                //UnSelectedImagePath = "Public/PowerOpen.png",
             };
-            controlView.AddChidren(btnSwitch);
-            btnSwitch.MouseUpEventHandler = (sender, e) => {
-                if (btnSwitch.IsSelected)
-                {
-                    btnSwitch.IsSelected = false;
-                    var d = new Dictionary<string, string>();
-                    d.Add(FunctionAttributeKey.OnOff, "off");
-                    function.Control(d);
-                }
-                else
-                {
-                    btnSwitch.IsSelected = true;
-                    var d = new Dictionary<string, string>();
-                    d.Add(FunctionAttributeKey.OnOff, "on");
-                    function.Control(d);
-                }
+            controlView.AddChidren(btnOff);
+            btnOn.MouseUpEventHandler = (sender, e) =>
+            {
+                var d = new Dictionary<string, string>();
+                d.Add(FunctionAttributeKey.OnOff, "on");
+                function.Control(d);
+            };
+
+            btnOff.MouseUpEventHandler = (sender, e) =>
+            {
+                var d = new Dictionary<string, string>();
+                d.Add(FunctionAttributeKey.OnOff, "off");
+                function.Control(d);
             };
 
 
@@ -267,21 +273,16 @@
                 btnSwitchIcon.MouseUpEventHandler = (sender, e) => {
                     if (btnSwitchIcon.IsSelected)
                     {
-                        btnSwitchIcon.IsSelected = btnSwitch.IsSelected = false;
                         var d = new Dictionary<string, string>();
                         d.Add(FunctionAttributeKey.OnOff, "off");
                         function.Control(d);
                     }
                     else
                     {
-                        btnSwitchIcon.IsSelected = btnSwitch.IsSelected = true;
                         var d = new Dictionary<string, string>();
                         d.Add(FunctionAttributeKey.OnOff, "on");
                         function.Control(d);
                     }
-                };
-                btnSwitch.MouseUpEventHandler += (sender, e) => {
-                    btnSwitchIcon.IsSelected = btnSwitch.IsSelected;
                 };
             }
 
@@ -289,7 +290,6 @@
 
 
         }
-        Button btnSwitch;
 
         /// <summary>
         /// 鍔犺浇璋冨厜灞炴�ц缃帶浠�
@@ -337,23 +337,32 @@
             };
             dimmerView.AddChidren(btnBrightnessText);
 
+            dimmerBar.OnStopTrackingTouchEvent = (sender, e) => {
+                new System.Threading.Thread(() =>
+                {
+                    var d = new Dictionary<string, string>();
+                    d.Add(FunctionAttributeKey.Brightness, e.ToString());
+                    function.Control(d);
+                })
+                { IsBackground = true }.Start();
+            };
+
             dimmerBar.OnProgressChangedEvent = (sender, e) =>
             {
                 if (e == 0 && lastBrightness != 0)
                 {
-                    btnSwitch.IsSelected = false;
                     lastBrightness = 0;
                 }
                 else
                 {
                     if (lastBrightness == 0)
                         lastBrightness = e;
-                    btnSwitch.IsSelected = true;
                 }
                 if (e == 0 || e == 100)
                 {
                     var d = new Dictionary<string, string>();
                     d.Add(FunctionAttributeKey.Brightness, e.ToString());
+                    d.Add(FunctionAttributeKey.OnOff, e == 0 ? "off" : "on");
                     function.Control(d);
                 }
                 else
@@ -372,19 +381,6 @@
                 }
 
 
-                btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100);
-                btnBrightnessText.Text = dimmerBar.Progress + "%";
-            };
-
-            btnSwitch.MouseUpEventHandler += (sender, e) => {
-                if (btnSwitch.IsSelected)
-                {
-                    dimmerBar.Progress = 100;
-                }
-                else
-                {
-                    dimmerBar.Progress = 0;
-                }
                 btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100);
                 btnBrightnessText.Text = dimmerBar.Progress + "%";
             };
@@ -435,24 +431,33 @@
             };
             dimmerView.AddChidren(btnBrightnessText);
 
+            dimmerBar.OnStopTrackingTouchEvent = (sender, e) => {
+                new System.Threading.Thread(() =>
+                {
+                    var d = new Dictionary<string, string>();
+                    d.Add(FunctionAttributeKey.Brightness, e.ToString());
+                    function.Control(d);
+                })
+                { IsBackground = true }.Start();
+            };
+
             dimmerBar.OnProgressChangedEvent = (sender, e) =>
             {
                 if (e == 0 && lastBrightness != 0)
                 {
-                    btnSwitch.IsSelected = false;
                     lastBrightness = 0;
                 }
                 else
                 {
                     if (lastBrightness == 0)
                         lastBrightness = e;
-                    btnSwitch.IsSelected = true;
                 }
 
                 if (e == 0 || e == 100)
                 {
                     var d = new Dictionary<string, string>();
                     d.Add(FunctionAttributeKey.Brightness, e.ToString());
+                    d.Add(FunctionAttributeKey.OnOff, e == 0 ? "off" : "on");
                     function.Control(d);
                 }
                 else
@@ -475,19 +480,7 @@
                 btnBrightnessText.Text = dimmerBar.Progress + "%";
             };
 
-            btnSwitch.MouseUpEventHandler += (sender, e) => {
-                if (btnSwitch.IsSelected)
-                {
-                    dimmerBar.Progress = 100;
-                }
-                else
-                {
-                    dimmerBar.Progress = 0;
-                }
-                btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16) / 100);
-                btnBrightnessText.Text = dimmerBar.Progress + "%";
-            };
-
+      
             //attrView.AddChidren(new Button() { Height = Application.GetRealHeight(10) });
 
             #region 鑹叉俯
@@ -666,7 +659,22 @@
             };
             colorPicker.ColorChaged += (sender2, e2) =>
             {
+                if (  pointIsRight == false)
+                {
+                    return;
+                }
+                //if (colorPicker.ColorImagePath == "FunctionIcon/Light/ColorWheelGray.png")
+                //{
+                //    return;
+                //}
+                    if (function.refreshTime.AddMilliseconds(350) > DateTime.Now)
+                {
+                    MainPage.Log("棰戠箒鎺у埗锛岄��鍑�");
+                    return;
+                }
+                function.refreshTime = DateTime.Now;
                 rgbString = (e2[0] + "," + e2[1] + "," + e2[2]).ToString();
+
                 btnCurColor.BackgroundColor = (uint)(0xFF000000 + rgbTemp.GetRGBcolor(rgbString));
                 var d = new Dictionary<string, string>();
                 d.Add(FunctionAttributeKey.RGB, rgbString);
@@ -677,9 +685,13 @@
                 pointIsRight = this.CheckPoint(circleR, colorPicker.Width / 2, colorPicker.Height / 2, (int)e.X, (int)e.Y);
                 if (pointIsRight == false)
                 {
-                    //鐐圭殑鍖哄煙涓嶆槸鍦嗙洏鍐�
+                    //pointIsRight:鐐圭殑鍖哄煙涓嶆槸鍦嗙洏鍐�
                     return;
                 }
+                //if (colorPicker.ColorImagePath == "FunctionIcon/Light/ColorWheelGray.png")
+                //{
+                //    return;
+                //}
                 //鏄剧ず鐧界偣
                 btnWhiteRound.X = (int)e.X - btnWhiteRound.Width / 2;
                 btnWhiteRound.Y = (int)e.Y - btnWhiteRound.Height / 2;
@@ -694,8 +706,6 @@
                 //褰撻紶鏍囩偣涓嬩簨浠跺鐞�
                 colorPicker.MouseDownEventHandler(sender, e);
             };
-
-
 
             #region 浜害璋冭妭
             var btnBrightnessText = new Button()
@@ -742,24 +752,32 @@
             };
             controlView.AddChidren(dimmerBar);
 
+            dimmerBar.OnStopTrackingTouchEvent = (sender, e) => {
+                new System.Threading.Thread(() =>
+                {
+                    var d = new Dictionary<string, string>();
+                    d.Add(FunctionAttributeKey.Brightness, e.ToString());
+                    function.Control(d);
+                })
+                { IsBackground = true }.Start();
+            };
 
             dimmerBar.OnProgressChangedEvent = (sender, e) =>
             {
                 if (e == 0 && lastBrightness != 0)
                 {
-                    btnSwitch.IsSelected = false;
                     lastBrightness = 0;
                 }
                 else
                 {
                     if (lastBrightness == 0)
                         lastBrightness = e;
-                    btnSwitch.IsSelected = true;
                 }
                 if (e == 0 || e == 100)
                 {
                     var d = new Dictionary<string, string>();
                     d.Add(FunctionAttributeKey.Brightness, e.ToString());
+                    d.Add(FunctionAttributeKey.OnOff, e == 0 ? "off" : "on");
                     function.Control(d);
                 }
                 else
@@ -776,7 +794,22 @@
                         { IsBackground = true }.Start();
                     }
                 }
+                //if (e == 0)
+                //{
+                //    if (colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheelGray.png")
+                //    {
+                //        colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png";
+                //    }
+                //}
+                //else
+                //{
+                //    if (colorPicker.ColorImagePath != "FunctionIcon/Light/ColorWheel.png")
+                //    {
+                //        colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheel.png";
+                //    }
+                //}
             };
+
 
 
             var btnMaxValuesText = new Button()
@@ -792,16 +825,6 @@
             };
             controlView.AddChidren(btnMaxValuesText);
 
-            btnSwitch.MouseUpEventHandler += (sender, e) => {
-                if (btnSwitch.IsSelected)
-                {
-                    dimmerBar.Progress = 100;
-                }
-                else
-                {
-                    dimmerBar.Progress = 0;
-                }
-            };
             #endregion
 
             int heightMore = 375 - magriHeight-20;
@@ -902,9 +925,7 @@
 
                 #endregion
 
-
                 heightMore = 70;
-
             }
 
             if (hadColorful)
@@ -986,8 +1007,6 @@
                 };
 
                 #endregion
-
-
             }
 
 

--
Gitblit v1.8.0