From 3f6685c77beeb12baf840733fb890860f4c26e7c Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 25 七月 2024 17:25:59 +0800
Subject: [PATCH] 2024年07月25日17:24:45

---
 HDL_ON/UI/UI2/FuntionControlView/Light/ColorfulInfoPage.cs |  111 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 97 insertions(+), 14 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/Light/ColorfulInfoPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Light/ColorfulInfoPage.cs
index 63cd333..ea2dd01 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,12 +292,18 @@
                         {
                             LoadEditDialog(() =>
                             {
-                                btnWorkHours.Text = hour + "鏃�";
-                                btnWorkHours.Text += minute + "鍒�";
-                                btnWorkHours.Text += second + "绉�";
+                                if( second == 0)
+                                {
+                                    new PublicAssmebly().TipMsg(StringId.Tip, StringId.TimeInvalid);
+                                    return;
+                                }
+                                //btnWorkHours.Text = hour + "鏃�";
+                                btnWorkHours.Text = second/60 + "鍒�";
+                                btnWorkHours.Text += second%60 + "绉�";
                                 new System.Threading.Thread(() => {
-                                    System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
-                                    d.Add(FunctionAttributeKey.ColorfulTime, (hour * 360 + minute * 60 + second).ToString());
+                                    var d = new Dictionary<string, string>();
+                                    function.SetAttrState(FunctionAttributeKey.ColorfulTime, ( minute * 60 + second).ToString());
+                                    d.Add(FunctionAttributeKey.ColorfulTime, ( 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
 
 
@@ -317,13 +402,13 @@
             {
                 item1.Add(i+Language.StringByID(StringId.h));
             }
-            for (int i = 0; i <= 59; i += 1)
+            for (int i = 1; i <= 120; i += 1)
             {
                 item2.Add(i + Language.StringByID(StringId.m));
                 item3.Add(i + Language.StringByID(StringId.s));
             }
-            uIPickerView.setNPicker(item1, item2,item3);
-            uIPickerView.setCurrentItems(hour, minute, second);
+            uIPickerView.setNPicker( item3,null,null);
+            uIPickerView.setCurrentItems(second-1,0,0);
             optionBaseView.AddChidren(uIPickerView);
 
             dialog.Show();
@@ -336,9 +421,7 @@
                 dialog.Close();
             };
             uIPickerView.OnSelectChangeEvent = (int1, int2, int3) => {
-                hour = int1;
-                minute = int2;
-                second = int3;
+                second = int1+1;
             };
             btnConfrim.MouseUpEventHandler = (sender, e) => {
                 dialog.Close();

--
Gitblit v1.8.0