wei
2021-03-08 37c315988c2dc11e4f477233f7a9f87d57bb61aa
HDL_ON/UI/UI2/FuntionControlView/Electrical/FanPageBLL.cs
@@ -10,7 +10,7 @@
        /// <summary>
        /// 更新灯光状态
        /// </summary>
        public static void UpdataState(Fan uFan)
        public static void UpdataState(Function updateTemp)
        {
            Application.RunOnMainThread(() =>
            {
@@ -18,9 +18,9 @@
                {
                    if (bodyView == null)
                        return;
                    bodyView.btnSwitch.IsSelected = bodyView.btnSwitchIcon.IsSelected = uFan.trait_on_off.curValue.ToString() == "on";
                    bodyView.barGradualChange.ProgressBarColor = uFan.trait_on_off.curValue.ToString() == "on" ? CSS.CSS_Color.MainColor : CSS.CSS_Color.PromptingColor2;
                    bodyView.barGradualChange.Progress = uFan.openLevel;
                    bodyView.btnSwitch.IsSelected = bodyView.btnSwitchIcon.IsSelected = updateTemp.trait_on_off.curValue.ToString() == "on";
                    bodyView.barGradualChange.ProgressBarColor = updateTemp.trait_on_off.curValue.ToString() == "on" ? CSS.CSS_Color.MainColor : CSS.CSS_Color.PromptingColor2;
                    bodyView.barGradualChange.Progress = Convert.ToInt32(updateTemp.GetAttrState(FunctionAttributeKey.OpenLevel));
                }
                catch (Exception ex)
                {
@@ -38,9 +38,9 @@
            //回退刷新信息事件
            actionRefresh = () => {
                btnFunctionName.Text = btnFunctionName_Out.Text = fan.name;
                btnFromFloor_Out.Text = btnFromFoorAndRoom.Text = fan.GetRoomListName();
                //fan.SaveFunctionData(true);
                btnFunctionName.Text = btnFunctionName_Out.Text = function.name;
                btnFromFloor_Out.Text = btnFromFoorAndRoom.Text = function.GetRoomListName();
                //function.SaveFunctionData(true);
            };
        }
@@ -50,8 +50,8 @@
        void LoadCollectionEvent()
        {
            btnCollection.MouseUpEventHandler += (sender, e) => {
                btnCollection.IsSelected = fan.collect = btnCollection_Out.IsSelected = !btnCollection.IsSelected;
                fan.CollectFunction();
                btnCollection.IsSelected = function.collect = btnCollection_Out.IsSelected = !btnCollection.IsSelected;
                function.CollectFunction();
            };
        }
@@ -66,11 +66,11 @@
                new System.Threading.Thread(() =>
                {
                    fan.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
                    //Control.Send(CommandType_A.write, this.fan);
                    function.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
                    //Control.Send(CommandType_A.write, this.function);
                    System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                    d.Add("on_off", fan.trait_on_off.curValue.ToString());
                    Control.Ins.SendWriteCommand(fan, d);
                    d.Add(FunctionAttributeKey.OnOff, function.trait_on_off.curValue.ToString());
                    Control.Ins.SendWriteCommand(function, d);
                })
                { IsBackground = true }.Start();
            };
@@ -80,24 +80,22 @@
                new System.Threading.Thread(() =>
                {
                    fan.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
                    //Control.Send(CommandType_A.write, this.fan);
                    function.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
                    System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                    d.Add("on_off", fan.trait_on_off.curValue.ToString());
                    Control.Ins.SendWriteCommand(fan, d);
                    d.Add(FunctionAttributeKey.OnOff, function.trait_on_off.curValue.ToString());
                    Control.Ins.SendWriteCommand(function, d);
                })
                { IsBackground = true }.Start();
            };
            barGradualChange.OnProgressChangedEvent = (sender, e) => {
                fan.openLevel = e;
                function.SetAttrState(FunctionAttributeKey.OpenLevel, e.ToString());
                new System.Threading.Thread(() =>
                {
                    fan.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
                    //Control.Send(CommandType_A.write, this.fan);
                    function.trait_on_off.curValue = btnSwitch.IsSelected ? "on" : "off";
                    System.Collections.Generic.Dictionary<string, string> d = new System.Collections.Generic.Dictionary<string, string>();
                    d.Add("on_off", fan.trait_on_off.curValue.ToString());
                    Control.Ins.SendWriteCommand(fan, d);
                    d.Add(FunctionAttributeKey.OnOff, function.trait_on_off.curValue.ToString());
                    Control.Ins.SendWriteCommand(function, d);
                })
                { IsBackground = true }.Start();
            };