wxr
2020-03-13 171bf03f3664226eeff2b20ee9bd2e914b63a17d
HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs
@@ -8,6 +8,14 @@
        void LoadEventList()
        {
            LoadColorChangeEvent();
            LoadCollectionEvent();
            LoadSwitchEvent();
            //回退刷新信息事件
            actionRefresh = () => {
                btnFunctionName.Text = btnFunctionName_Out.Text = light.name;
                btnFromFloor_Out.Text = btnFromFoorAndRoom.Text = light.GetRoomListName();
            };
        }
        /// <summary>
@@ -29,5 +37,38 @@
            };
        }
        /// <summary>
        /// 收藏功能按钮事件
        /// </summary>
        void LoadCollectionEvent()
        {
            btnCollection.MouseUpEventHandler += (sender, e) => {
                btnCollection.IsSelected = light.collection = btnCollection_Out.IsSelected = !btnCollection.IsSelected;
                DB_ResidenceData.residenceData.SaveResidenceData();
            };
        }
        /// <summary>
        /// 加载开关事件
        /// </summary>
        void LoadSwitchEvent()
        {
            btnSwitch.MouseUpEventHandler += (sender, e) =>
            {
                btnSwitch.IsSelected = !btnSwitch.IsSelected;
                new System.Threading.Thread(() =>
                {
                    var light = this.light as Light;
                    light.state = btnSwitch.IsSelected ? 1 : 0;
                    Control.Send("write", this.light, 3);
                })
                { IsBackground = true }.Start();
            };
        }
    }
}