wei
2020-12-17 bb6ad792b598927a5459a5fb6f6c27fb1aa9e94e
HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs
@@ -23,9 +23,19 @@
                        {
                            bodyView.dimmerBar.Progress = uFunction.brightness;
                        }
                        bodyView.dimmerBar.ProgressBarColor = uFunction.trait_on_off.curValue.ToString() == "on" ? CSS.CSS_Color.AuxiliaryColor1 : CSS.CSS_Color.PromptingColor2;
                        bodyView.btnSwitch.IsSelected = uFunction.trait_on_off.curValue.ToString() == "on";
                        bodyView.btnCurColor.BackgroundColor = (uint)(0xFF000000 + bodyView.light.GetRGBcolor());
                        if (uFunction.trait_on_off.curValue.ToString() == "on")
                        {
                            bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheel.png";
                            bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.AuxiliaryColor1;
                            bodyView.btnSwitch.IsSelected = true;
                            bodyView.btnCurColor.BackgroundColor = (uint)(0xFF000000 + bodyView.light.GetRGBcolor());
                        }
                        else
                        {
                            bodyView.colorPicker.ColorImagePath = "FunctionIcon/Light/ColorWheelGray.png";
                            bodyView.dimmerBar.ProgressBarColor = CSS.CSS_Color.PromptingColor2;
                            bodyView.btnSwitch.IsSelected = false;
                        }
                    }
                }
                catch (Exception ex)
@@ -59,6 +69,10 @@
        {
            DateTime colorChangeTime = DateTime.MinValue;
            colorPicker.ColorChaged += (sender2, e2) => {
                if(light.trait_on_off.curValue.ToString() == "off")
                {
                    return;
                }
                if ((DateTime.Now - colorChangeTime).TotalMilliseconds > 200)
                {
                    light.SetRGBcolor(e2);
@@ -98,13 +112,16 @@
                onDimmerBar = true;
            };
            dimmerBar.OnStopTrackingTouchEvent = (sender, e) => {
                onDimmerBar = false;
                new System.Threading.Thread(() => {
                    System.Threading.Thread.Sleep(100);
                    onDimmerBar = false;
                })
                { IsBackground = true }.Start();
                light.brightness = dimmerBar.Progress;
                System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                d.Add(FunctionAttributeKey.Brightness, light.brightness.ToString());
                Control.Ins.SendWriteCommand(light, d);
                light.fadeTime = barFadeTime.Progress;
                //Control.Send(CommandType_A.write, light);
            };
            dimmerBar.OnProgressChangedEvent = (sender, e) => {
                light.fadeTime = 0;
@@ -150,9 +167,9 @@
        /// </summary>
        void LoadEvet_ChangeFadeTime()
        {
            barFadeTime.OnProgressChangedEvent = (sender, e) =>
            barFadeTime.MouseUpEventHandler = (sender, e) =>
            {
                light.fadeTime = e;
                light.fadeTime = barFadeTime.Progress;
                light.SaveFunctionData(true);
            };
        }
@@ -170,6 +187,14 @@
                    light.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
                    System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                    d.Add(FunctionAttributeKey.OnOff, light.trait_on_off.curValue.ToString());
                    if (btnSwitch.IsSelected)
                    {
                        d.Add(FunctionAttributeKey.Brightness, light.lastBrightness.ToString());
                    }
                    else
                    {
                        light.lastBrightness = light.brightness;
                    }
                    Control.Ins.SendWriteCommand(light, d);
                })
                { IsBackground = true }.Start();