mac
2024-07-25 3f6685c77beeb12baf840733fb890860f4c26e7c
HDL_ON/UI/UI2/FuntionControlView/Light/ColorfulInfoPage.cs
@@ -1,6 +1,7 @@

using System;
using System.Collections.Generic;
using HDL_ON.DriverLayer;
using HDL_ON.Entity;
using HDL_ON.Stan;
using HDL_ON.UI.CSS;
@@ -39,6 +40,80 @@
                ScrollEnabled = false,
            };
            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()
@@ -86,9 +161,9 @@
            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(action);
                var rgbView = new ColorfulSettingPage(function, action,true);
                MainPage.BasePageView.AddChidren(rgbView);
                rgbView.LoadPage(function.GetAttrState(FunctionAttributeKey.ColorfulBegin));
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
@@ -134,7 +209,7 @@
                Radius = (uint)Application.GetRealWidth(14),
                BorderColor = CSS_Color.DividingLineColor,
                BorderWidth = 1,
                BackgroundColor = (uint)(0xFF000000 + lightTemp.GetRGBcolor(function.GetAttrState(FunctionAttributeKey.ColorfulBegin)))
                BackgroundColor = (uint)(0xFF000000 + lightTemp.GetRGBcolor(function.GetAttrState(FunctionAttributeKey.ColorfulEnd)))
            };
            endColorView.AddChidren(btnEndColor);
@@ -145,7 +220,7 @@
                    btnEndColor.BackgroundColor = color;
                    function.SetAttrState(FunctionAttributeKey.ColorfulEnd, color);
                };
                var rgbView = new ColorfulSettingPage(action);
                var rgbView = new ColorfulSettingPage(function, action,false);
                MainPage.BasePageView.AddChidren(rgbView);
                rgbView.LoadPage(function.GetAttrState(FunctionAttributeKey.ColorfulEnd));
                MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
@@ -155,7 +230,7 @@
            #endregion
            #region 工作时长
            #region 炫彩周期
            var workHoursView = new FrameLayout()
            {
                Height = Application.GetRealHeight(50),
@@ -196,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);
@@ -210,9 +292,20 @@
                        {
                            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(() => {
                                    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();
                            });
                        });
                    }
@@ -229,8 +322,6 @@
            btnWorkHours.MouseUpEventHandler = eventHandler;
            workHoursView.MouseUpEventHandler = eventHandler;
            btnWorkHoursRight.MouseUpEventHandler = eventHandler;
            #endregion
@@ -307,17 +398,17 @@
                Height = Application.GetRealHeight(210),
                Radius = (uint)Application.GetRealWidth(12),
            };
            for (int i = 0; i <= 23; i += 1)
            for (int i = 0; i <= 15; i += 1)
            {
                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();
@@ -330,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();