wei
2020-12-23 f345087dbefecef9146fdb13481cb9ee3320d576
HDL_ON/UI/UI2/FuntionControlView/Light/ColorTureLampPageBLL.cs
@@ -64,11 +64,11 @@
        /// </summary>
        void LoadEvet_ChangeFadeTime()
        {
            barFadeTime.OnStopTrackingTouchEvent = (sender, e) =>
            {
                light.fadeTime = e;
                light.SaveFunctionData(true);
            };
            //barFadeTime.OnStopTrackingTouchEvent = (sender, e) =>
            //{
            //    light.fadeTime = e;
            //    light.SaveFunctionData(true);
            //};
        }
        /// <summary>
@@ -85,13 +85,22 @@
                        //设置自定义的文本
                        barColorTemplatrue.SetCustomText(value * 100 + "K");
                        light.Attr_CCT.curValue = value * 100;
                        System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                        d.Add(FunctionAttributeKey.CCT, light.Attr_CCT.curValue.ToString());
                        Control.Ins.SendWriteCommand(light, d);
                        //System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                        //d.Add(FunctionAttributeKey.CCT, light.Attr_CCT.curValue.ToString());
                        //Control.Ins.SendWriteCommand(light, d);
                    });
                    System.Threading.Thread.Sleep(200);
                    //System.Threading.Thread.Sleep(200);
                }).Start();
            };
            barColorTemplatrue.OnStopTrackingTouchEvent = (sender, value) =>
            {
                light.Attr_CCT.curValue = value * 100;
                System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                d.Add(FunctionAttributeKey.CCT, light.Attr_CCT.curValue.ToString());
                Control.Ins.SendWriteCommand(light, d);
            };
        }
        /// <summary>
@@ -101,7 +110,7 @@
        {
            btnCollection.MouseUpEventHandler += (sender, e) => {
                btnCollection.IsSelected = light.collect = btnCollection_Out.IsSelected = !btnCollection.IsSelected;
                light.SaveFunctionData(true);
                light.CollectFunction();
            };
        }
@@ -116,46 +125,48 @@
            dimmerBar.OnStopTrackingTouchEvent = (sender, e) => {
                onDimmerBar = false;
                light.brightness = dimmerBar.Progress;
                //Control.Send(CommandType_A.write, light);
                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;
                //light.fadeTime = barFadeTime.Progress;
            };
            dimmerBar.OnProgressChangedEvent = (sender, e) => {
                light.fadeTime = 0;
                if (!btnSwitch.IsSelected)
                {
                    dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1);
                }
                btnSwitch.IsSelected = e > 0 ? true : false;
                light.brightness = e;
                light.trait_on_off.curValue = e > 0 ? "on" : "off";
            dimmerBar.OnProgressChangedEvent = (sender, e) =>
            {
                //light.fadeTime = 0;
                //if (!btnSwitch.IsSelected)
                //{
                //    dimmerBar.SetProgressBarColors(CSS_Color.AuxiliaryColor1, CSS_Color.AuxiliaryColor1);
                //}
                //btnSwitch.IsSelected = e > 0 ? true : false;
                //light.brightness = e;
                //light.trait_on_off.curValue = e > 0 ? "on" : "off";
                if (e == 0 || e == 100)
                {
                    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);
                }
                else
                {
                    if (200 < (DateTime.Now - light.refreshTime).TotalMilliseconds)
                    {
                        light.refreshTime = DateTime.Now;
                        new System.Threading.Thread(() =>
                        {
                            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);
                        })
                        { IsBackground = true }.Start();
                    }
                }
                //if (e == 0 || e == 100)
                //{
                //    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);
                //}
                //else
                //{
                //    if (200 < (DateTime.Now - light.refreshTime).TotalMilliseconds)
                //    {
                //        light.refreshTime = DateTime.Now;
                //        new System.Threading.Thread(() =>
                //        {
                //            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);
                //        })
                //        { IsBackground = true }.Start();
                //    }
                //}
                btnBrightnessText.Y = ((100 - dimmerBar.Progress) * Application.GetRealHeight(222 - 16 - 16) / 100) + Application.GetRealWidth(40);
                btnBrightnessText.Text = light.brightness + "%";
            };
        }
        /// <summary>
@@ -165,7 +176,7 @@
        {
            btnSwitch.MouseUpEventHandler += (sender, e) =>
            {
                light.fadeTime = barFadeTime.Progress;
                //light.fadeTime = barFadeTime.Progress;
                btnSwitch.IsSelected = !btnSwitch.IsSelected;
                if (btnSwitch.IsSelected)
                {