New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using HDL_ON.DriverLayer; |
| | | using HDL_ON.Entity; |
| | | using HDL_ON.Stan; |
| | | using HDL_ON.UI.CSS; |
| | | using Shared; |
| | | |
| | | namespace HDL_ON.UI |
| | | { |
| | | /// <summary> |
| | | /// 金茂新风设备的控制界面 |
| | | /// </summary> |
| | | public class AirFreshControlPage : DeviceFunctionCardCommonForm |
| | | { |
| | | #region ■ 变量声明___________________________ |
| | | |
| | | /// <summary> |
| | | /// 室内湿度控件 |
| | | /// </summary> |
| | | private NormalViewControl btnHumidity = null; |
| | | /// <summary> |
| | | /// %控件 |
| | | /// </summary> |
| | | private NormalViewControl btnHumidityUnit = null; |
| | | /// <summary> |
| | | /// 室内温度控件 |
| | | /// </summary> |
| | | private NormalViewControl btnTemperature = null; |
| | | /// <summary> |
| | | /// ℃控件 |
| | | /// </summary> |
| | | private NormalViewControl btnTemperatureUnit = null; |
| | | /// <summary> |
| | | /// 当前滤网剩余控件 |
| | | /// </summary> |
| | | private NormalViewControl btnFilterScreen = null; |
| | | /// <summary> |
| | | /// 节能/舒适图标控件 |
| | | /// </summary> |
| | | private IconViewControl btnMode1 = null; |
| | | /// <summary> |
| | | /// 节能/舒适文本控件 |
| | | /// </summary> |
| | | private NormalViewControl btnMode1View = null; |
| | | /// <summary> |
| | | /// 通风/加湿图标控件 |
| | | /// </summary> |
| | | private IconViewControl btnMode2 = null; |
| | | /// <summary> |
| | | /// 通风/加湿文本控件 |
| | | /// </summary> |
| | | private NormalViewControl btnMode2View = null; |
| | | /// <summary> |
| | | /// 风速图标控件 |
| | | /// </summary> |
| | | private IconViewControl btnFan = null; |
| | | /// <summary> |
| | | /// 风速文本控件 |
| | | /// </summary> |
| | | private NormalViewControl btnFanView = null; |
| | | /// <summary> |
| | | /// 开关图标 |
| | | /// </summary> |
| | | private IconViewControl btnSwitch = null; |
| | | /// <summary> |
| | | /// 新风数据 |
| | | /// </summary> |
| | | private AirFreshData airFreshData = new AirFreshData(); |
| | | /// <summary> |
| | | /// 各种文本 |
| | | /// </summary> |
| | | private Dictionary<string, string> dicText = new Dictionary<string, string>(); |
| | | #endregion |
| | | |
| | | #region ■ 初始化_____________________________ |
| | | |
| | | /// <summary> |
| | | /// 初始化白色区域的内容 |
| | | /// </summary> |
| | | public override void InitFrameWhiteContent() |
| | | { |
| | | base.SetTitleText(Language.StringByID(StringId.AirFresh)); |
| | | //这个东西加个空格 |
| | | this.dicText["滤网剩余"] = Language.StringByID(StringId.ResidualFilterScreen) + " "; |
| | | this.dicText["节能"] = Language.StringByID(StringId.Energy); |
| | | this.dicText["舒适"] = Language.StringByID(StringId.Comfortable); |
| | | this.dicText["通风"] = Language.StringByID(StringId.Ventilated); |
| | | this.dicText["加湿"] = Language.StringByID(StringId.Humidification); |
| | | this.dicText["1档"] = Language.StringByID(StringId.OneGear); |
| | | this.dicText["2档"] = Language.StringByID(StringId.TwoGear); |
| | | this.dicText["3档"] = Language.StringByID(StringId.ThreeGear); |
| | | |
| | | //刷新当前设备的状态缓存 |
| | | this.RefreshNowDeviceStatuMemory(this.device); |
| | | //初始化第一个索引页的内容 |
| | | this.InitFrameWhiteContent1(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 初始化第一个索引页的内容 |
| | | /// </summary> |
| | | private void InitFrameWhiteContent1() |
| | | { |
| | | //一个背景图片 |
| | | var framePic = new FrameLayout(); |
| | | framePic.Y = Application.GetRealHeight(120); |
| | | framePic.Width = this.GetPictrueRealSize(303); |
| | | framePic.Height = this.GetPictrueRealSize(175); |
| | | framePic.Gravity = Gravity.CenterHorizontal; |
| | | framePic.BackgroundImagePath = "FunctionIcon/AirFresh/TempAndHumiBack.png"; |
| | | this.FrameWhiteCentet1.AddChidren(framePic); |
| | | |
| | | //室内湿度 的容器(为了重新计算坐标使用) |
| | | int frameWidth = framePic.Width / 2 - this.GetPictrueRealSize(21); |
| | | var frameHumidity = new FrameLayout(); |
| | | frameHumidity.X = this.GetPictrueRealSize(21); |
| | | frameHumidity.Y = this.GetPictrueRealSize(12); |
| | | frameHumidity.Width = frameWidth; |
| | | frameHumidity.Height = frameWidth; |
| | | framePic.AddChidren(frameHumidity); |
| | | //室内湿度值 |
| | | this.btnHumidity = new NormalViewControl(20, this.GetPicChidrenTextHeight(30), false); |
| | | btnHumidity.Y = this.GetPictrueRealSize(39); |
| | | btnHumidity.TextSize = 30; |
| | | btnHumidity.TextColor = CSS_Color.FirstLevelTitleColor; |
| | | btnHumidity.TextAlignment = TextAlignment.TopCenter; |
| | | frameHumidity.AddChidren(btnHumidity); |
| | | //% |
| | | this.btnHumidityUnit = new NormalViewControl(10, 10, true); |
| | | btnHumidityUnit.Y = btnHumidity.Y + this.GetPictrueRealSize(8); |
| | | btnHumidityUnit.TextColor = CSS_Color.TextualColor; |
| | | btnHumidityUnit.Text = "%"; |
| | | btnHumidityUnit.TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel; |
| | | btnHumidityUnit.Width = btnHumidityUnit.GetRealWidthByText(); |
| | | frameHumidity.AddChidren(btnHumidityUnit); |
| | | //室内湿度 |
| | | var btnHumidityView = new NormalViewControl(frameHumidity.Width, this.GetPicChidrenTextHeight(18), false); |
| | | btnHumidityView.Y = btnHumidity.Bottom + this.GetPictrueRealSize(8); |
| | | btnHumidityView.TextAlignment = TextAlignment.Center; |
| | | btnHumidityView.TextColor = CSS_Color.TextualColor; |
| | | btnHumidityView.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; |
| | | btnHumidityView.TextID = StringId.IndoorHumidity; |
| | | frameHumidity.AddChidren(btnHumidityView); |
| | | |
| | | //室内温度 的容器(为了重新计算坐标使用) |
| | | var frameTemperature = new FrameLayout(); |
| | | frameTemperature.Y = frameHumidity.Y; |
| | | frameTemperature.X = frameHumidity.Right; |
| | | frameTemperature.Width = frameWidth; |
| | | frameTemperature.Height = frameWidth; |
| | | framePic.AddChidren(frameTemperature); |
| | | //室内温度值 |
| | | this.btnTemperature = new NormalViewControl(20, this.GetPicChidrenTextHeight(30), false); |
| | | btnTemperature.Y = btnHumidity.Y; |
| | | btnTemperature.TextSize = 30; |
| | | btnTemperature.TextColor = CSS_Color.FirstLevelTitleColor; |
| | | btnTemperature.TextAlignment = TextAlignment.TopCenter; |
| | | btnTemperature.GetRealWidthByText(); |
| | | frameTemperature.AddChidren(btnTemperature); |
| | | //℃ |
| | | this.btnTemperatureUnit = new NormalViewControl(10, 10, true); |
| | | btnTemperatureUnit.Y = btnTemperature.Y + this.GetPictrueRealSize(8); |
| | | btnTemperatureUnit.TextColor = CSS_Color.TextualColor; |
| | | btnTemperatureUnit.Text = "℃"; |
| | | btnTemperatureUnit.TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel; |
| | | btnTemperatureUnit.Width = btnTemperatureUnit.GetRealWidthByText(); |
| | | frameTemperature.AddChidren(btnTemperatureUnit); |
| | | //室内温度 |
| | | var btnTemperatureView = new NormalViewControl(frameTemperature.Width, this.GetPicChidrenTextHeight(18), false); |
| | | btnTemperatureView.Y = btnTemperature.Bottom + this.GetPictrueRealSize(8); |
| | | btnTemperatureView.TextAlignment = TextAlignment.Center; |
| | | btnTemperatureView.TextColor = CSS_Color.TextualColor; |
| | | btnTemperatureView.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; |
| | | btnTemperatureView.TextID = StringId.IndoorTemp; |
| | | frameTemperature.AddChidren(btnTemperatureView); |
| | | |
| | | //当前滤网剩余0% |
| | | this.btnFilterScreen = new NormalViewControl(this.FrameWhiteCentet1.Width, Application.GetRealHeight(18), false); |
| | | btnFilterScreen.Y = framePic.Bottom; |
| | | btnFilterScreen.TextAlignment = TextAlignment.Center; |
| | | btnFilterScreen.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; |
| | | btnFilterScreen.TextColor = CSS_Color.MainColor; |
| | | this.FrameWhiteCentet1.AddChidren(btnFilterScreen); |
| | | |
| | | //节能/舒适图标 |
| | | this.btnMode1 = new IconViewControl(28); |
| | | btnMode1.X = Application.GetRealWidth(42); |
| | | btnMode1.Y = btnFilterScreen.Bottom + Application.GetRealHeight(61); |
| | | this.FrameWhiteCentet1.AddChidren(btnMode1); |
| | | btnMode1.ButtonClickEvent += (sender, e) => |
| | | { |
| | | //显示节能/舒适选择界面 |
| | | this.ShowMode1SelectView(); |
| | | }; |
| | | //节能/舒适文本 |
| | | this.btnMode1View = new NormalViewControl(this.FrameWhiteCentet1.Width / 3, Application.GetRealHeight(18), false); |
| | | btnMode1View.Y = btnMode1.Bottom + Application.GetRealHeight(6); |
| | | btnMode1View.TextAlignment = TextAlignment.Center; |
| | | btnMode1View.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; |
| | | btnMode1View.TextColor = CSS_Color.TextualColor; |
| | | this.FrameWhiteCentet1.AddChidren(btnMode1View); |
| | | |
| | | //通风/加湿图标 |
| | | this.btnMode2 = new IconViewControl(28); |
| | | btnMode2.Y = btnMode1.Y; |
| | | btnMode2.Gravity = Gravity.CenterHorizontal; |
| | | this.FrameWhiteCentet1.AddChidren(btnMode2); |
| | | btnMode2.ButtonClickEvent += (sender, e) => |
| | | { |
| | | //显示通风/加湿选择界面 |
| | | this.ShowMode2SelectView(); |
| | | }; |
| | | //通风/加湿文本 |
| | | this.btnMode2View = new NormalViewControl(this.FrameWhiteCentet1.Width / 3, Application.GetRealHeight(18), false); |
| | | btnMode2View.X = btnMode1View.Right; |
| | | btnMode2View.Y = btnMode2.Bottom + Application.GetRealHeight(6); |
| | | btnMode2View.TextAlignment = TextAlignment.Center; |
| | | btnMode2View.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; |
| | | btnMode2View.TextColor = CSS_Color.TextualColor; |
| | | this.FrameWhiteCentet1.AddChidren(btnMode2View); |
| | | |
| | | //风速图标 |
| | | this.btnFan = new IconViewControl(28); |
| | | btnFan.X = this.FrameWhiteCentet1.Width - btnMode1.X - btnFan.IconSize; |
| | | btnFan.Y = btnMode1.Y; |
| | | this.FrameWhiteCentet1.AddChidren(btnFan); |
| | | btnFan.ButtonClickEvent += (sender, e) => |
| | | { |
| | | //显示风速选择界面 |
| | | this.ShowFanSelectView(); |
| | | }; |
| | | //风速文本 |
| | | this.btnFanView = new NormalViewControl(this.FrameWhiteCentet1.Width / 3, Application.GetRealHeight(18), false); |
| | | btnFanView.X = btnMode2View.Right; |
| | | btnFanView.Y = btnFan.Bottom + Application.GetRealHeight(6); |
| | | btnFanView.TextAlignment = TextAlignment.Center; |
| | | btnFanView.TextSize = CSS_FontSize.PromptFontSize_FirstLevel; |
| | | btnFanView.TextColor = CSS_Color.TextualColor; |
| | | this.FrameWhiteCentet1.AddChidren(btnFanView); |
| | | |
| | | //开关图标 |
| | | this.btnSwitch = new IconViewControl(40); |
| | | btnSwitch.Gravity = Gravity.CenterHorizontal; |
| | | btnSwitch.Y = Application.GetRealHeight(468); |
| | | btnSwitch.UnSelectedImagePath = "Public/PowerClose.png"; |
| | | btnSwitch.SelectedImagePath = "Public/PowerOpen.png"; |
| | | FrameWhiteCentet1.AddChidren(btnSwitch); |
| | | btnSwitch.ButtonClickEvent += (sender, e) => |
| | | { |
| | | //发送开关命令 |
| | | this.SendSwitchComand(); |
| | | }; |
| | | |
| | | //刷新界面状态 |
| | | this.RefreshFormStatu(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 显示节能/舒适选择界面______________ |
| | | |
| | | /// <summary> |
| | | /// 显示节能/舒适选择界面 |
| | | /// </summary> |
| | | private void ShowMode1SelectView() |
| | | { |
| | | //整个灰色界面 |
| | | var frameBack = new Dialog(); |
| | | |
| | | var dialogBody = new NormalFrameLayout(); |
| | | frameBack.AddChidren(dialogBody); |
| | | dialogBody.ButtonClickEvent = (sender, e) => |
| | | { |
| | | frameBack.Close(); |
| | | }; |
| | | frameBack.Show(); |
| | | |
| | | //菜单控件(模式) |
| | | var menuContr = new DialogTitleMenuControl(2, Language.StringByID(StringId.Mode)); |
| | | menuContr.X = Application.GetRealWidth(6); |
| | | menuContr.Y = Application.GetRealHeight(277); |
| | | menuContr.Width = Application.GetRealWidth(160); |
| | | menuContr.Height = Application.GetRealHeight(154); |
| | | dialogBody.AddChidren(menuContr); |
| | | |
| | | //节能 |
| | | var iconPath = this.airFreshData.Energy == "true" ? "FunctionIcon/AirFresh/EnergySelect.png" : "FunctionIcon/AirFresh/Energy.png"; |
| | | menuContr.AddRowMenu(this.dicText["节能"], iconPath, this.airFreshData.Energy == "true", () => |
| | | { |
| | | frameBack.Close(); |
| | | //发送节能命令 |
| | | this.SendOtherComand(this.btnMode1, FunctionAttributeKey.Energy, "true"); |
| | | }); |
| | | |
| | | //舒适 |
| | | iconPath = this.airFreshData.Energy == "false" ? "FunctionIcon/AirFresh/ComfortableSelect.png" : "FunctionIcon/AirFresh/Comfortable.png"; |
| | | menuContr.AddRowMenu(this.dicText["舒适"], iconPath, this.airFreshData.Energy == "false", () => |
| | | { |
| | | frameBack.Close(); |
| | | //发送舒适命令 |
| | | this.SendOtherComand(this.btnMode1, FunctionAttributeKey.Energy, "false"); |
| | | }); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 显示通风/加湿选择界面______________ |
| | | |
| | | /// <summary> |
| | | /// 显示通风/加湿选择界面 |
| | | /// </summary> |
| | | private void ShowMode2SelectView() |
| | | { |
| | | //整个灰色界面 |
| | | var frameBack = new Dialog(); |
| | | |
| | | var dialogBody = new NormalFrameLayout(); |
| | | frameBack.AddChidren(dialogBody); |
| | | dialogBody.ButtonClickEvent = (sender, e) => |
| | | { |
| | | frameBack.Close(); |
| | | }; |
| | | frameBack.Show(); |
| | | |
| | | //菜单控件(模式) |
| | | var menuContr = new DialogTitleMenuControl(2, Language.StringByID(StringId.Mode)); |
| | | menuContr.Y = Application.GetRealHeight(277); |
| | | menuContr.Gravity = Gravity.CenterHorizontal; |
| | | menuContr.Width = Application.GetRealWidth(160); |
| | | menuContr.Height = Application.GetRealHeight(154); |
| | | dialogBody.AddChidren(menuContr); |
| | | |
| | | //通风 |
| | | var iconPath = this.airFreshData.Mode == "fan" ? "FunctionIcon/AirFresh/VentilateSelect.png" : "FunctionIcon/AirFresh/Ventilate.png"; |
| | | menuContr.AddRowMenu(this.dicText["通风"], iconPath, this.airFreshData.Mode == "fan", () => |
| | | { |
| | | frameBack.Close(); |
| | | //发送通风命令 |
| | | this.SendOtherComand(this.btnMode2, FunctionAttributeKey.Mode, "fan"); |
| | | }); |
| | | |
| | | //加湿 |
| | | iconPath = this.airFreshData.Mode == "humidification" ? "FunctionIcon/AirFresh/HumidificationSelect.png" : "FunctionIcon/AirFresh/Humidification.png"; |
| | | menuContr.AddRowMenu(this.dicText["加湿"], iconPath, this.airFreshData.Mode == "humidification", () => |
| | | { |
| | | frameBack.Close(); |
| | | //发送加湿命令 |
| | | this.SendOtherComand(this.btnMode2, FunctionAttributeKey.Mode, "humidification"); |
| | | }); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 显示风速选择界面___________________ |
| | | |
| | | /// <summary> |
| | | /// 显示风速选择界面 |
| | | /// </summary> |
| | | private void ShowFanSelectView() |
| | | { |
| | | //整个灰色界面 |
| | | var frameBack = new Dialog(); |
| | | |
| | | var dialogBody = new NormalFrameLayout(); |
| | | frameBack.AddChidren(dialogBody); |
| | | dialogBody.ButtonClickEvent = (sender, e) => |
| | | { |
| | | frameBack.Close(); |
| | | }; |
| | | frameBack.Show(); |
| | | |
| | | //菜单控件(风速) |
| | | var menuContr = new DialogTitleMenuControl(3, Language.StringByID(StringId.FanSpeed)); |
| | | menuContr.X = Application.GetRealWidth(209); |
| | | menuContr.Y = Application.GetRealHeight(231); |
| | | menuContr.Width = Application.GetRealWidth(160); |
| | | menuContr.Height = Application.GetRealHeight(199); |
| | | dialogBody.AddChidren(menuContr); |
| | | |
| | | //1档 |
| | | var iconPath = this.airFreshData.Fan == "level_1" ? "FunctionIcon/AirFresh/Fan1Select.png" : "FunctionIcon/AirFresh/Fan1.png"; |
| | | menuContr.AddRowMenu(Language.StringByID(StringId.FanOneGear), iconPath, this.airFreshData.Fan == "level_1", () => |
| | | { |
| | | frameBack.Close(); |
| | | //发送档位命令 |
| | | this.SendOtherComand(this.btnFan, FunctionAttributeKey.FanSpeed, "level_1"); |
| | | }); |
| | | |
| | | //2档 |
| | | iconPath = this.airFreshData.Fan == "level_2" ? "FunctionIcon/AirFresh/Fan2Select.png" : "FunctionIcon/AirFresh/Fan2.png"; |
| | | menuContr.AddRowMenu(Language.StringByID(StringId.FanTwoGear), iconPath, this.airFreshData.Fan == "level_2", () => |
| | | { |
| | | frameBack.Close(); |
| | | //发送档位命令 |
| | | this.SendOtherComand(this.btnFan, FunctionAttributeKey.FanSpeed, "level_2"); |
| | | }); |
| | | |
| | | //3档 |
| | | iconPath = this.airFreshData.Fan == "level_3" ? "FunctionIcon/AirFresh/Fan3Select.png" : "FunctionIcon/AirFresh/Fan3.png"; |
| | | menuContr.AddRowMenu(Language.StringByID(StringId.FanThreeGear), iconPath, this.airFreshData.Fan == "level_3", () => |
| | | { |
| | | frameBack.Close(); |
| | | //发送档位命令 |
| | | this.SendOtherComand(this.btnFan, FunctionAttributeKey.FanSpeed, "level_3"); |
| | | }); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 设备状态反馈_______________________ |
| | | |
| | | /// <summary> |
| | | /// 设备状态反馈 |
| | | /// </summary> |
| | | /// <param name="i_LocalDevice"></param> |
| | | public override void DeviceStatuPush(Function i_LocalDevice) |
| | | { |
| | | //不是同一个东西 |
| | | if (this.device.sid != i_LocalDevice.sid) { return; } |
| | | |
| | | //刷新当前设备的状态缓存 |
| | | this.RefreshNowDeviceStatuMemory(i_LocalDevice); |
| | | //刷新界面状态 |
| | | this.RefreshFormStatu(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 刷新界面状态_______________________ |
| | | |
| | | /// <summary> |
| | | /// 刷新界面状态 |
| | | /// </summary> |
| | | private void RefreshFormStatu() |
| | | { |
| | | //开关 |
| | | this.btnSwitch.IsSelected = this.airFreshData.Open; |
| | | //滤网剩余 |
| | | this.btnFilterScreen.Text = this.dicText["滤网剩余"] + this.airFreshData.Filter_remain + "%"; |
| | | |
| | | //室内湿度 |
| | | if (this.btnHumidity.Text == string.Empty || Convert.ToDecimal(this.btnHumidity.Text) != this.airFreshData.Indoor_humidity) |
| | | { |
| | | //变更了才改 |
| | | this.btnHumidity.Text = this.airFreshData.Indoor_humidity == 0 ? "0.0" : this.airFreshData.Indoor_humidity.ToString(); |
| | | this.btnHumidity.Width = this.btnHumidity.GetRealWidthByText(); |
| | | //重新计算坐标,让它们居中 |
| | | this.btnHumidity.X = (btnHumidity.Parent.Width - btnHumidity.Width - btnHumidityUnit.Width) / 2; |
| | | this.btnHumidityUnit.X = btnHumidity.Right; |
| | | } |
| | | //室内温度 |
| | | if (this.btnTemperature.Text == string.Empty || Convert.ToDecimal(this.btnTemperature.Text) != this.airFreshData.Indoor_temp) |
| | | { |
| | | //变更了才改 |
| | | this.btnTemperature.Text = this.airFreshData.Indoor_temp == 0 ? "0.0" : this.airFreshData.Indoor_temp.ToString(); |
| | | this.btnTemperature.Width = this.btnTemperature.GetRealWidthByText(); |
| | | //重新计算坐标,让它们居中 |
| | | this.btnTemperature.X = (btnHumidity.Parent.Width - btnTemperature.Width - btnTemperatureUnit.Width) / 2; |
| | | this.btnTemperatureUnit.X = btnTemperature.Right; |
| | | } |
| | | |
| | | //节能/舒适 |
| | | if (this.airFreshData.Energy == "true") |
| | | { |
| | | this.btnMode1.UnSelectedImagePath = "FunctionIcon/AirFresh/Energy.png"; |
| | | this.btnMode1.SelectedImagePath = "FunctionIcon/AirFresh/EnergySelect.png"; |
| | | this.btnMode1View.Text = this.dicText["节能"]; |
| | | } |
| | | else |
| | | { |
| | | this.btnMode1.UnSelectedImagePath = "FunctionIcon/AirFresh/Comfortable.png"; |
| | | this.btnMode1.SelectedImagePath = "FunctionIcon/AirFresh/ComfortableSelect.png"; |
| | | this.btnMode1View.Text = this.dicText["舒适"]; |
| | | } |
| | | this.btnMode1.IsSelected = this.airFreshData.Open; |
| | | this.btnMode1.CanClick = this.airFreshData.Open; |
| | | |
| | | //通风/加湿 |
| | | if (this.airFreshData.Mode == "fan") |
| | | { |
| | | this.btnMode2.UnSelectedImagePath = "FunctionIcon/AirFresh/Ventilate.png"; |
| | | this.btnMode2.SelectedImagePath = "FunctionIcon/AirFresh/VentilateSelect.png"; |
| | | this.btnMode2View.Text = this.dicText["通风"]; |
| | | } |
| | | else |
| | | { |
| | | this.btnMode2.UnSelectedImagePath = "FunctionIcon/AirFresh/Humidification.png"; |
| | | this.btnMode2.SelectedImagePath = "FunctionIcon/AirFresh/HumidificationSelect.png"; |
| | | this.btnMode2View.Text = this.dicText["加湿"]; |
| | | } |
| | | this.btnMode2.IsSelected = this.airFreshData.Open; |
| | | this.btnMode2.CanClick = this.airFreshData.Open; |
| | | |
| | | //风速 |
| | | if (this.airFreshData.Fan == "level_3") |
| | | { |
| | | this.btnFan.UnSelectedImagePath = "FunctionIcon/AirFresh/Fan3.png"; |
| | | this.btnFan.SelectedImagePath = "FunctionIcon/AirFresh/Fan3Select.png"; |
| | | this.btnFanView.Text = this.dicText["3档"]; |
| | | } |
| | | else if(this.airFreshData.Fan == "level_2") |
| | | { |
| | | this.btnFan.UnSelectedImagePath = "FunctionIcon/AirFresh/Fan2.png"; |
| | | this.btnFan.SelectedImagePath = "FunctionIcon/AirFresh/Fan2Select.png"; |
| | | this.btnFanView.Text = this.dicText["2档"]; |
| | | } |
| | | else |
| | | { |
| | | this.btnFan.UnSelectedImagePath = "FunctionIcon/AirFresh/Fan1.png"; |
| | | this.btnFan.SelectedImagePath = "FunctionIcon/AirFresh/Fan1Select.png"; |
| | | this.btnFanView.Text = this.dicText["1档"]; |
| | | } |
| | | this.btnFan.IsSelected = this.airFreshData.Open; |
| | | this.btnFan.CanClick = this.airFreshData.Open; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 发送各种命令_______________________ |
| | | |
| | | /// <summary> |
| | | /// 发送其他命令 |
| | | /// </summary> |
| | | /// <param name="btnIcon">按钮</param> |
| | | /// <param name="comadKey">命令主键</param> |
| | | /// <param name="comadValue">命令</param> |
| | | private void SendOtherComand(IconViewControl btnIcon, string comadKey, string comadValue) |
| | | { |
| | | btnIcon.CanClick = false; |
| | | |
| | | HdlThreadLogic.Current.RunThread(() => |
| | | { |
| | | //获取发送命令的样板(bus协议是需要一次性把全部命令一起发送的) |
| | | var dic = this.GetSendComandSample(); |
| | | dic[comadKey] = comadValue; |
| | | Control.Ins.SendWriteCommand(this.device, dic); |
| | | HdlThreadLogic.Current.RunMain(() => |
| | | { |
| | | btnIcon.CanClick = true; |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 发送开关命令 |
| | | /// </summary> |
| | | private void SendSwitchComand() |
| | | { |
| | | this.btnSwitch.CanClick = false; |
| | | |
| | | string statu = this.btnSwitch.IsSelected == true ? "off" : "on"; |
| | | HdlThreadLogic.Current.RunThread(() => |
| | | { |
| | | //获取发送命令的样板(bus协议是需要一次性把全部命令一起发送的) |
| | | var dic = this.GetSendComandSample(); |
| | | dic[FunctionAttributeKey.OnOff] = statu; |
| | | Control.Ins.SendWriteCommand(this.device, dic); |
| | | HdlThreadLogic.Current.RunMain(() => |
| | | { |
| | | this.btnSwitch.CanClick = true; |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取发送命令的样板(bus协议是需要一次性把全部命令一起发送的) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private Dictionary<string, string> GetSendComandSample() |
| | | { |
| | | var dic = new Dictionary<string, string>(); |
| | | //开关 |
| | | dic[FunctionAttributeKey.OnOff] = this.airFreshData.Open == true ? "on" : "off"; |
| | | //模式 |
| | | dic[FunctionAttributeKey.Mode] = this.airFreshData.Mode; |
| | | //节能 |
| | | dic[FunctionAttributeKey.Energy] = this.airFreshData.Energy; |
| | | //风速 |
| | | dic[FunctionAttributeKey.FanSpeed] = this.airFreshData.Fan ; |
| | | |
| | | return dic; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 一般方法___________________________ |
| | | |
| | | /// <summary> |
| | | /// 刷新当前设备的状态缓存 |
| | | /// </summary> |
| | | private void RefreshNowDeviceStatuMemory(Function i_LocalDevice) |
| | | { |
| | | for (int i = 0; i < i_LocalDevice.attributes.Count; i++) |
| | | { |
| | | var data = i_LocalDevice.attributes[i]; |
| | | //开关 |
| | | if (data.key == FunctionAttributeKey.OnOff) { this.airFreshData.Open = data.state == "on"; } |
| | | //模式 |
| | | else if (data.key == FunctionAttributeKey.Mode) { this.airFreshData.Mode = data.state; } |
| | | //节能 |
| | | else if (data.key == FunctionAttributeKey.Energy) { this.airFreshData.Energy = data.state; } |
| | | //风速 |
| | | else if (data.key == FunctionAttributeKey.FanSpeed) { this.airFreshData.Fan = data.state; } |
| | | //湿度 |
| | | else if (data.key == FunctionAttributeKey.Humidity) |
| | | { |
| | | if (data.state != string.Empty) |
| | | { |
| | | this.airFreshData.Humidity = Convert.ToInt32(data.state); |
| | | } |
| | | } |
| | | //室内温度 |
| | | else if (data.key == FunctionAttributeKey.IndoorTemp) |
| | | { |
| | | if (data.state != string.Empty) |
| | | { |
| | | this.airFreshData.Indoor_temp = Math.Round(Convert.ToDecimal(data.state), 1); |
| | | } |
| | | } |
| | | //室内湿度 |
| | | else if (data.key == FunctionAttributeKey.IndoorHumidity) |
| | | { |
| | | if (data.state != string.Empty) |
| | | { |
| | | this.airFreshData.Indoor_humidity = Math.Round(Convert.ToDecimal(data.state), 1); |
| | | } |
| | | } |
| | | //过滤网剩余量 |
| | | else if (data.key == FunctionAttributeKey.FilterRemain) |
| | | { |
| | | if (data.state != string.Empty) |
| | | { |
| | | this.airFreshData.Filter_remain = Convert.ToInt32(data.state); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 结构体_____________________________ |
| | | |
| | | /// <summary> |
| | | /// 新风的数据 |
| | | /// </summary> |
| | | private class AirFreshData |
| | | { |
| | | /// <summary> |
| | | /// 是否打开 |
| | | /// </summary> |
| | | public bool Open = false; |
| | | /// <summary> |
| | | /// humidification:加湿 fan:送风 |
| | | /// </summary> |
| | | public string Mode = string.Empty; |
| | | /// <summary> |
| | | /// true:节能 false:舒适 这个有问题的 |
| | | /// </summary> |
| | | public string Energy = string.Empty; |
| | | /// <summary> |
| | | /// level_1:1档 level_2:2档 level_3:3档 auto:自动(目前这个不用) |
| | | /// </summary> |
| | | public string Fan = string.Empty; |
| | | /// <summary> |
| | | /// 湿度(%) |
| | | /// </summary> |
| | | public int Humidity = 0; |
| | | /// <summary> |
| | | /// 室内温度(保留一位小数) |
| | | /// </summary> |
| | | public decimal Indoor_temp = 0; |
| | | /// <summary> |
| | | /// 室内湿度(保留一位小数) |
| | | /// </summary> |
| | | public decimal Indoor_humidity = 0; |
| | | /// <summary> |
| | | /// 剩余滤网(%) |
| | | /// </summary> |
| | | public int Filter_remain = 0; |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |