mac
2024-07-25 3f6685c77beeb12baf840733fb890860f4c26e7c
HDL_ON/UI/UI2/FuntionControlView/Light/RGBPage.cs
@@ -1,4 +1,5 @@
using System;
using HDL_ON.DriverLayer;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using Shared;
@@ -49,15 +50,20 @@
        /// 色盘里面那个会滑动的球
        /// </summary>
        Button btnWhiteRound;
        /// <summary>
        /// 炫彩开关按钮
        /// </summary>
        Button btnColorfulSwitch;
        #endregion
        #region 区域变量
        Light lightTemp;
        Function function;
        Button btnCollection_Out;
        Button btnFunctionName_Out;
        Button btnFromFloor_Out;
        bool onDimmerBar = false;
        Function function;
        /// <summary>
        /// 最后打开的颜色
@@ -85,10 +91,16 @@
            //new TopViewDiv(bodyView, Language.StringByID(StringId.Lights)).LoadTopView(function,null);
            //new PublicAssmebly().LoadTopView(bodyView, Language.StringByID(StringId.Lights), function);
            int magriHeight = 0;
            if (function.GetAttribute(FunctionAttributeKey.FadeTime) != null && function.GetAttribute(FunctionAttributeKey.Colorful) != null)
            {
                magriHeight = 80;
            }
            FrameLayout controlView = new FrameLayout()
            {
                Gravity = Gravity.CenterHorizontal,
                Y = Application.GetRealHeight(88),
                Y = Application.GetRealHeight(88 + 10),
                Width = Application.GetRealWidth(327),
                Height = Application.GetRealHeight(526),
                BackgroundImagePath = "Public/Fragmentbg.png",
@@ -155,8 +167,9 @@
            var framePickerBack = new FrameLayout();
            framePickerBack.Gravity = Gravity.CenterHorizontal;
            framePickerBack.Y = btnFromFoorAndRoom.Bottom + Application.GetRealHeight(1);
            framePickerBack.Width = Application.GetMinRealAverage(216);
            framePickerBack.Height = Application.GetMinRealAverage(216);
            framePickerBack.Width = Application.GetMinRealAverage(216-magriHeight);
            framePickerBack.Height = Application.GetMinRealAverage(216 - magriHeight);
            //framePickerBack.BackgroundColor = 0xFFFF0000;
            controlView.AddChidren(framePickerBack);
            colorPicker = new ColorPicker()
@@ -177,10 +190,17 @@
            //};
            //白点控件
            this.btnWhiteRound = new Button();
            btnWhiteRound.Width = Application.GetRealWidth(24);
            btnWhiteRound.Height = Application.GetRealWidth(24);
            btnWhiteRound.UnSelectedImagePath = "FunctionIcon/Light/ColorWheelTip.png";
            var diameter = Application.GetRealWidth(12);
            this.btnWhiteRound = new Button()
            {
                Width = diameter,
                Height = diameter,
                Radius = (uint)Application.GetRealWidth(6),
                BorderWidth = (uint)Application.GetRealWidth(1),
                BorderColor = CSS_Color.MainBackgroundColor,
                Enable = false,
            };
            //btnWhiteRound.UnSelectedImagePath = "FunctionIcon/Light/ColorWheelTip.png";
            btnWhiteRound.Visible = false;
            framePickerBack.AddChidren(btnWhiteRound);
@@ -188,7 +208,7 @@
            var btnBrightnessText = new Button()
            {
                X = Application.GetRealWidth(35),
                Y = Application.GetRealHeight(308),
                Y = Application.GetRealHeight(308 - magriHeight),
                Width = Application.GetRealWidth(224),
                Height = Application.GetRealHeight(21),
                TextAlignment = TextAlignment.CenterLeft,
@@ -214,7 +234,7 @@
            dimmerBar = new DiyImageSeekBar()
            {
                X = Application.GetRealWidth(35 + 22),
                Y = Application.GetRealHeight(312),
                Y = Application.GetRealHeight(316 - magriHeight),
                Width = Application.GetRealWidth(210),
                Height = Application.GetRealHeight(54),
                SeekBarViewHeight = Application.GetRealHeight(8),
@@ -243,21 +263,22 @@
            controlView.AddChidren(btnMaxValuesText);
            #endregion
            int heightMore = 375 - magriHeight;
            if (function.GetAttribute(FunctionAttributeKey.FadeTime) != null)
            {
                #region 渐变时间调节
                var btnGradualChangeText = new Button()
                {
                    X = Application.GetRealWidth(35),
                    Y = Application.GetRealHeight(375),
                    Y = Application.GetRealHeight(heightMore),
                    Width = Application.GetRealWidth(224),
                    Height = Application.GetRealHeight(21),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                    TextID = StringId.SpeedOfChange,
                    Visible = function.GetAttribute(FunctionAttributeKey.FadeTime) != null,
                    Enable = function.GetAttribute(FunctionAttributeKey.FadeTime) != null,
                };
                controlView.AddChidren(btnGradualChangeText);
@@ -271,15 +292,13 @@
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.PromptingColor1,
                    TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                    Visible = function.GetAttribute(FunctionAttributeKey.FadeTime) != null,
                    Enable = function.GetAttribute(FunctionAttributeKey.FadeTime) != null,
                };
                controlView.AddChidren(btnGradualChangeMinValuesText);
                barFadeTime = new DiyImageSeekBar()
                {
                    X = btnGradualChangeMinValuesText.Right,
                    Y = Application.GetRealHeight(412 - 21),
                    X = Application.GetRealWidth(35 + 22),
                    Y = Application.GetRealHeight(412 - 21-magriHeight),
                    Width = Application.GetRealWidth(210),
                    Height = Application.GetRealHeight(54),
                    SeekBarViewHeight = Application.GetRealHeight(8),
@@ -293,15 +312,13 @@
                    MaxValue = 10,
                    Progress = Convert.ToInt32(function.GetAttrState(FunctionAttributeKey.FadeTime)),
                    SeekBarPadding = Application.GetRealWidth(20),
                    Visible = function.GetAttribute(FunctionAttributeKey.FadeTime) != null,
                    Enable = function.GetAttribute(FunctionAttributeKey.FadeTime) != null,
                };
                controlView.AddChidren(barFadeTime);
                barFadeTime.OnStopTrackingTouchEvent = (sender, e) =>
                {
                    function.SetAttrState(FunctionAttributeKey.FadeTime, barFadeTime.Progress);
                    function.UpdataFuncitonInfo();
                };
                //barFadeTime.OnStopTrackingTouchEvent = (sender, e) =>
                //{
                //    function.SetAttrState(FunctionAttributeKey.FadeTime, barFadeTime.Progress);
                //    function.UpdataFuncitonInfo();
                //};
                var btnGradualChangeMaxValuesText = new Button()
                {
@@ -318,8 +335,99 @@
                };
                controlView.AddChidren(btnGradualChangeMaxValuesText);
                #endregion
                //heightMore += 70;
            }
            if (function.GetAttribute(FunctionAttributeKey.Colorful)!= null)
            {
                #region 炫彩功能
                var btnGradualChangeText = new Button()
                {
                    X = Application.GetRealWidth(35),
                    Y = Application.GetRealHeight(heightMore + magriHeight),
                    Width = Application.GetRealWidth(224),
                    Height = Application.GetRealHeight(21),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                    TextID = StringId.ColorfulFunction,
                };
                controlView.AddChidren(btnGradualChangeText);
                var btnEditColorful = new Button()
                {
                    X = Application.GetRealWidth(35),
                    Y = btnGradualChangeText.Bottom + Application.GetRealHeight(10),
                    Width = Application.GetRealWidth(22),
                    Height = Application.GetRealHeight(21),
                    UnSelectedImagePath = "Public/Edit.png",
                };
                controlView.AddChidren(btnEditColorful);
                btnEditColorful.MouseUpEventHandler = (sender, e) => {
                    var rgbView = new ColorfulInfoPage(function);
                    MainPage.BasePageView.AddChidren(rgbView);
                    rgbView.LoadPage();
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                };
                var barColorful = new FrameLayout()
                {
                    X = btnEditColorful.Right + Application.GetRealWidth(15),
                    Y = Application.GetRealHeight(37 + heightMore + magriHeight),
                    Width = Application.GetRealWidth(180),
                    Height = Application.GetRealHeight(8),
                    BackgroundImagePath = "FunctionIcon/Light/ColorfulBar.png",
                };
                controlView.AddChidren(barColorful);
                btnColorfulSwitch = new Button()
                {
                    X = barColorful.Right + Application.GetRealWidth(8),
                    Y = btnGradualChangeText.Bottom + Application.GetRealHeight(10),
                    Width = Application.GetRealWidth(38),
                    Height = Application.GetRealHeight(24),
                    UnSelectedImagePath = "Public/Switch.png",
                    SelectedImagePath = "Public/SwitchOn.png",
                };
                controlView.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);
                            System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.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();
                };
                #endregion
            }
            btnRestoredPoint = new Button()
            {
                X = Application.GetRealWidth(116),
@@ -347,13 +455,12 @@
            new TopViewDiv(bodyView, Language.StringByID(StringId.Lights)).LoadTopView_FunctionTop(function, actionRefresh);
            new System.Threading.Thread(() =>
            {
                DriverLayer.Control.Ins.SendReadCommand(function);
                Control.Ins.SendReadCommand(function);
            })
            { IsBackground = true }.Start();
            new System.Threading.Thread(() => {
            new System.Threading.Thread(() =>
            {
                while (true)
                {
                    System.Threading.Thread.Sleep(1000);
@@ -367,7 +474,8 @@
                    }
                    else
                    {
                        DriverLayer.Control.Ins.SendReadCommand(function);
                        System.Threading.Thread.Sleep(1000);
                        Control.Ins.SendReadCommand(function);
                        curDimmerStatus = true;
                    }
                }