From 80075a89316729927db0ad65ca7674f81a942a93 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 26 七月 2023 09:22:41 +0800
Subject: [PATCH] Merge branch 'Dev-Branch' into wjc

---
 HDL_ON/UI/UI2/FuntionControlView/Light/ColorfulInfoPage.cs |   93 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 89 insertions(+), 4 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/ColorfulInfoPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/ColorfulInfoPage.cs
index 63cd333..9a24099 100644
--- a/HDL_ON/UI/UI2/FuntionControlView/Light/ColorfulInfoPage.cs
+++ b/HDL_ON/UI/UI2/FuntionControlView/Light/ColorfulInfoPage.cs
@@ -41,6 +41,80 @@
             };
             bodyView.AddChidren(contentView);
 
+            #region 鐐僵寮�鍏�
+            contentView.AddChidren(new Button
+            {
+                Height = Application.GetRealHeight(10),
+                BackgroundColor = CSS_Color.BackgroundColor,
+            });
+
+            var viewSwitch = new FrameLayout()
+            {
+                Height = Application.GetRealHeight(50),
+                BackgroundColor = CSS_Color.MainBackgroundColor,
+            };
+            contentView.AddChidren(viewSwitch);
+
+            var btnSwitchText = new Button()
+            {
+                X = Application.GetRealWidth(16),
+                TextAlignment = TextAlignment.CenterLeft,
+                TextColor = CSS_Color.FirstLevelTitleColor,
+                TextSize = CSS_FontSize.SubheadingFontSize,
+                TextID = StringId.CulorfulTest,
+            };
+            viewSwitch.AddChidren(btnSwitchText);
+
+            var btnColorfulSwitch = new Button()
+            {
+                X = Application.GetRealWidth(314),
+                Gravity = Gravity.CenterVertical,
+                Width = Application.GetMinRealAverage(48),
+                Height = Application.GetMinRealAverage(36),
+                UnSelectedImagePath = "Public/Switch.png",
+                SelectedImagePath = "Public/SwitchOn.png",
+                IsSelected = function.GetAttrState(FunctionAttributeKey.Colorful) == "on"
+            };
+            viewSwitch.AddChidren(btnColorfulSwitch);
+
+            btnColorfulSwitch.MouseUpEventHandler = (sender, e) => {
+                btnColorfulSwitch.IsSelected = !btnColorfulSwitch.IsSelected;
+                new System.Threading.Thread(() =>
+                {
+                    try
+                    {
+                        var controlColorfulState = btnColorfulSwitch.IsSelected ? "on" : "off";
+                        function.SetAttrState(FunctionAttributeKey.Colorful, controlColorfulState);
+                        var d = new Dictionary<string, string>();
+                        d.Add(FunctionAttributeKey.Colorful, controlColorfulState);
+                        if (controlColorfulState == "on")
+                        {
+                            var color = function.GetAttrState(FunctionAttributeKey.ColorfulBegin).Split(",");
+                            var sendColorString = color[0] + "," + color[1] + "," + color[2];
+                            d.Add(FunctionAttributeKey.ColorfulBegin, sendColorString);
+                            color = function.GetAttrState(FunctionAttributeKey.ColorfulEnd).Split(",");
+                            sendColorString = color[0] + "," + color[1] + "," + color[2];
+                            d.Add(FunctionAttributeKey.ColorfulEnd, sendColorString);
+                            d.Add(FunctionAttributeKey.ColorfulTime, function.GetAttrState(FunctionAttributeKey.ColorfulTime));
+                        }
+                        Control.Ins.SendWriteCommand(function, d);
+                    }
+                    catch (Exception ex)
+                    {
+                        MainPage.Log($"鎺у埗鐐僵寮�鍏冲紓甯�:{ex.Message}");
+                    }
+                })
+                { IsBackground = true }.Start();
+            };
+
+            contentView.AddChidren(new Button
+            {
+                Height = Application.GetRealHeight(10),
+                BackgroundColor = CSS_Color.BackgroundColor,
+            });
+
+            #endregion
+
             #region 璧峰棰滆壊
             var startView = new FrameLayout()
             {
@@ -87,7 +161,7 @@
             btnStartColor.MouseUpEventHandler = (sender, e) => {
                 Action<uint> action = (color) => {
                     btnStartColor.BackgroundColor = color;
-                    function.SetAttrState(FunctionAttributeKey.ColorfulBegin, color);
+                    //function.SetAttrState(FunctionAttributeKey.ColorfulBegin, color);
                 };
                 var rgbView = new ColorfulSettingPage(function, action,true);
                 MainPage.BasePageView.AddChidren(rgbView);
@@ -197,6 +271,13 @@
             };
             workHoursView.AddChidren(btnWorkHours);
 
+            var time = Convert.ToInt32( function.GetAttrState(FunctionAttributeKey.ColorfulTime));
+
+
+            btnWorkHours.Text = time/ 360 + Language.StringByID(StringId.h);
+            btnWorkHours.Text += time / 60 + Language.StringByID(StringId.m);
+            btnWorkHours.Text += time % 60 + Language.StringByID(StringId.s);
+
             var waitPage = new Loading();
             this.AddChidren(waitPage);
 
@@ -211,11 +292,17 @@
                         {
                             LoadEditDialog(() =>
                             {
+                                if(hour == 0 && minute == 0 && second == 0)
+                                {
+                                    new PublicAssmebly().TipMsg(StringId.Tip, StringId.TimeInvalid);
+                                    return;
+                                }
                                 btnWorkHours.Text = hour + "鏃�";
                                 btnWorkHours.Text += minute + "鍒�";
                                 btnWorkHours.Text += second + "绉�";
                                 new System.Threading.Thread(() => {
-                                    System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
+                                    var d = new Dictionary<string, string>();
+                                    function.SetAttrState(FunctionAttributeKey.ColorfulTime, (hour * 360 + minute * 60 + second).ToString());
                                     d.Add(FunctionAttributeKey.ColorfulTime, (hour * 360 + minute * 60 + second).ToString());
                                     Control.Ins.SendWriteCommand(function, d);
                                 }) { IsBackground = true }.Start();
@@ -235,8 +322,6 @@
             btnWorkHours.MouseUpEventHandler = eventHandler;
             workHoursView.MouseUpEventHandler = eventHandler;
             btnWorkHoursRight.MouseUpEventHandler = eventHandler;
-
-
             #endregion
 
 

--
Gitblit v1.8.0