using Shared;
|
using HDL_ON.Stan;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using HDL_ON.UI.CSS;
|
using HDL_ON.Entity;
|
using HDL_ON.DriverLayer;
|
|
namespace HDL_ON.UI
|
{
|
/// <summary>
|
/// 涂鸦空气净化器的控制界面
|
/// </summary>
|
public class TuyaAirCleanerPage : DeviceFunctionCardCommonForm
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 图片控件
|
/// </summary>
|
private PicViewControl btnPictrue = null;
|
/// <summary>
|
/// 滤芯使用率控件
|
/// </summary>
|
private NormalViewControl btnUsePersent = null;
|
/// <summary>
|
/// 温度
|
/// </summary>
|
private NormalViewControl btnTemperature = null;
|
/// <summary>
|
/// 湿度
|
/// </summary>
|
private NormalViewControl btnHumidity = null;
|
/// <summary>
|
/// PM2.5
|
/// </summary>
|
private NormalViewControl btnPm25 = null;
|
/// <summary>
|
/// 开关控件
|
/// </summary>
|
private IconViewControl btnSwitch = null;
|
/// <summary>
|
/// 模式控件
|
/// </summary>
|
private IconViewControl btnMode = null;
|
/// <summary>
|
/// 模式的显示文本控件
|
/// </summary>
|
private NormalViewControl btnModeView = null;
|
/// <summary>
|
/// 风速控件
|
/// </summary>
|
private IconViewControl btnFan = null;
|
/// <summary>
|
/// 风速的显示文本控件
|
/// </summary>
|
private NormalViewControl btnFanView = null;
|
/// <summary>
|
/// 定时控件
|
/// </summary>
|
private IconViewControl btnTime = null;
|
/// <summary>
|
/// 定时的显示文本控件
|
/// </summary>
|
private NormalViewControl btnTimeView = null;
|
/// <summary>
|
/// 童锁开关控件
|
/// </summary>
|
private MostRightIconControl btnLockSwitch = null;
|
/// <summary>
|
/// 负离子开关控件
|
/// </summary>
|
private MostRightIconControl btnAnionSwitch = null;
|
/// <summary>
|
/// 滤芯复位开关控件
|
/// </summary>
|
private MostRightIconControl btnResetSwitch = null;
|
/// <summary>
|
/// 空气质量数据
|
/// </summary>
|
private AirCleanerData airCleanerData = new AirCleanerData();
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 初始化白色区域的内容
|
/// </summary>
|
public override void InitFrameWhiteContent()
|
{
|
base.SetTitleText(Language.StringByID(StringId.AirCleaner));
|
|
//添加第二索引页
|
this.AddSecondPage();
|
//初始化第一个索引页的内容
|
this.InitFrameWhiteContent1();
|
//初始化第二个索引页的内容
|
this.InitFrameWhiteContent2();
|
|
//刷新当前设备的状态缓存
|
this.RefreshNowDeviceStatuMemory(this.device);
|
//刷新界面状态
|
this.RefreshFormStatu();
|
}
|
|
/// <summary>
|
/// 初始化第一个索引页的内容
|
/// </summary>
|
private void InitFrameWhiteContent1()
|
{
|
//图片控件
|
this.btnPictrue = new PicViewControl(94, 130);
|
btnPictrue.Y = Application.GetRealHeight(90);
|
btnPictrue.Gravity = Gravity.CenterHorizontal;
|
btnPictrue.UnSelectedImagePath = "FunctionIcon/Electrical/Fan/AirCleanerOff.png";
|
btnPictrue.SelectedImagePath = "FunctionIcon/Electrical/Fan/AirCleanerOn.png";
|
FrameWhiteCentet1.AddChidren(btnPictrue);
|
btnPictrue.ButtonClickEvent += (sender, e) =>
|
{
|
//发送开关命令
|
this.SendSwitchComand();
|
};
|
|
//滤芯使用
|
this.btnUsePersent = new NormalViewControl(FrameWhiteCentet1.Width, Application.GetRealHeight(20), false);
|
btnUsePersent.TextAlignment = TextAlignment.Center;
|
btnUsePersent.Y = btnPictrue.Bottom + Application.GetRealHeight(16);
|
btnUsePersent.TextColor = CSS.CSS_Color.MainColor;
|
FrameWhiteCentet1.AddChidren(btnUsePersent);
|
//温度
|
this.btnTemperature = new NormalViewControl(106, 28, true);
|
btnTemperature.Y = btnUsePersent.Bottom + Application.GetRealHeight(23);
|
btnTemperature.TextSize = CSS.CSS_FontSize.EmphasisFontSize_Secondary;
|
btnTemperature.TextAlignment = TextAlignment.Center;
|
btnTemperature.Text = "22℃";
|
FrameWhiteCentet1.AddChidren(btnTemperature);
|
//室内温度
|
var btnTemperatureView = new NormalViewControl(btnTemperature.Width, Application.GetRealHeight(14), false);
|
btnTemperatureView.Y = btnTemperature.Bottom + Application.GetRealHeight(4);
|
btnTemperatureView.TextSize = CSS.CSS_FontSize.PromptFontSize_SecondaryLevel;
|
btnTemperatureView.TextAlignment = TextAlignment.Center;
|
btnTemperatureView.TextID = StringId.IndoorTemp;
|
FrameWhiteCentet1.AddChidren(btnTemperatureView);
|
//一条竖线
|
var btnLine1 = new NormalViewControl(1, Application.GetRealHeight(19), false);
|
btnLine1.X = btnTemperature.Right;
|
btnLine1.Y = btnTemperature.Y + (btnTemperature.Height - Application.GetRealHeight(19)) / 2;
|
btnLine1.BackgroundColor = CSS.CSS_Color.TextualColor;
|
FrameWhiteCentet1.AddChidren(btnLine1);
|
|
//PM2.5
|
this.btnPm25 = new NormalViewControl(106, 28, true);
|
btnPm25.Y = btnTemperature.Y;
|
btnPm25.X = btnLine1.Right;
|
btnPm25.TextSize = CSS.CSS_FontSize.EmphasisFontSize_Secondary;
|
btnPm25.TextAlignment = TextAlignment.Center;
|
btnPm25.Text = "0";
|
FrameWhiteCentet1.AddChidren(btnPm25);
|
//PM2.5
|
var btnPm25View = new NormalViewControl(btnPm25.Width, Application.GetRealHeight(14), false);
|
btnPm25View.X = btnPm25.X;
|
btnPm25View.Y = btnTemperatureView.Y;
|
btnPm25View.TextSize = CSS.CSS_FontSize.PromptFontSize_SecondaryLevel;
|
btnPm25View.TextAlignment = TextAlignment.Center;
|
btnPm25View.Text = "PM2.5";
|
FrameWhiteCentet1.AddChidren(btnPm25View);
|
|
//一条竖线
|
var btnLine2 = new NormalViewControl(1, btnLine1.Height, false);
|
btnLine2.X = btnPm25.Right;
|
btnLine2.Y = btnLine1.Y;
|
btnLine2.BackgroundColor = CSS_Color.TextualColor;
|
FrameWhiteCentet1.AddChidren(btnLine2);
|
|
//湿度
|
this.btnHumidity = new NormalViewControl(114, 28, true);
|
btnHumidity.Y = btnTemperature.Y;
|
btnHumidity.X = btnLine2.Right;
|
btnHumidity.TextSize = CSS.CSS_FontSize.EmphasisFontSize_Secondary;
|
btnHumidity.TextAlignment = TextAlignment.Center;
|
btnHumidity.Text = "50%";
|
FrameWhiteCentet1.AddChidren(btnHumidity);
|
//室内湿度
|
var btnHumidityView = new NormalViewControl(btnHumidity.Width, Application.GetRealHeight(14), false);
|
btnHumidityView.X = btnHumidity.X;
|
btnHumidityView.Y = btnTemperatureView.Y;
|
btnHumidityView.TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel;
|
btnHumidityView.TextAlignment = TextAlignment.Center;
|
btnHumidityView.TextID = StringId.IndoorHumidity;
|
FrameWhiteCentet1.AddChidren(btnHumidityView);
|
|
//2021.01.26 目前不用温度和湿度
|
btnTemperature.RemoveFromParent();
|
btnTemperatureView.RemoveFromParent();
|
btnLine1.RemoveFromParent();
|
btnLine2.RemoveFromParent();
|
btnHumidity.RemoveFromParent();
|
btnHumidityView.RemoveFromParent();
|
|
//风速图标
|
this.btnFan = new IconViewControl(38);
|
btnFan.UnSelectedImagePath = "FunctionIcon/Electrical/Fan/Fan.png";
|
btnFan.X = Application.GetRealWidth(40);
|
btnFan.Y = btnPm25View.Bottom + Application.GetRealHeight(40);
|
FrameWhiteCentet1.AddChidren(btnFan);
|
btnFan.ButtonClickEvent += (sender, e) =>
|
{
|
//显示风速界面
|
this.ShowFanSpeedView();
|
};
|
this.btnFanView = new NormalViewControl(80, 18, true);
|
btnFanView.Y = btnFan.Bottom + Application.GetRealHeight(10);
|
btnFanView.X = btnFan.X - (Application.GetRealWidth(80) - btnFan.Width) / 2;
|
btnFanView.TextAlignment = TextAlignment.Center;
|
btnFanView.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
|
btnFanView.Text = Language.StringByID(StringId.FanSpeed);
|
FrameWhiteCentet1.AddChidren(btnFanView);
|
|
//定时图标
|
this.btnTime = new IconViewControl(38);
|
btnTime.UnSelectedImagePath = "FunctionIcon/Electrical/Fan/Time.png";
|
btnTime.Y = btnFan.Y;
|
btnTime.Gravity = Gravity.CenterHorizontal;
|
FrameWhiteCentet1.AddChidren(btnTime);
|
btnTime.ButtonClickEvent += (sender, e) =>
|
{
|
//显示定时界面
|
this.ShowTimingSelectView();
|
};
|
this.btnTimeView = new NormalViewControl(80, 18, true);
|
btnTimeView.Y = btnFanView.Y;
|
btnTimeView.X = btnTime.X - (Application.GetRealWidth(80) - btnTime.Width) / 2;
|
btnTimeView.TextAlignment = TextAlignment.Center;
|
btnTimeView.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
|
FrameWhiteCentet1.AddChidren(btnTimeView);
|
|
//模式图标
|
this.btnMode = new IconViewControl(38);
|
btnMode.Y = btnFan.Y;
|
btnMode.X = btnTime.Right + Application.GetRealWidth(66);
|
FrameWhiteCentet1.AddChidren(btnMode);
|
btnMode.ButtonClickEvent += (sender, e) =>
|
{
|
//显示模式界面
|
this.ShowModeSelectView();
|
};
|
this.btnModeView = new NormalViewControl(80, 18, true);
|
btnModeView.Y = btnFanView.Y;
|
btnModeView.X = btnMode.X - (Application.GetRealWidth(80) - btnMode.Width) / 2;
|
btnModeView.TextAlignment = TextAlignment.Center;
|
btnModeView.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
|
FrameWhiteCentet1.AddChidren(btnModeView);
|
|
//开关图标
|
this.btnSwitch = new IconViewControl(40);
|
btnSwitch.Gravity = Gravity.CenterHorizontal;
|
btnSwitch.Y = btnMode.Bottom + Application.GetRealHeight(61);
|
btnSwitch.UnSelectedImagePath = "Public/PowerClose.png";
|
btnSwitch.SelectedImagePath = "Public/PowerOpen.png";
|
FrameWhiteCentet1.AddChidren(btnSwitch);
|
btnSwitch.ButtonClickEvent += (sender, e) =>
|
{
|
//发送开关命令
|
this.SendSwitchComand();
|
};
|
}
|
|
/// <summary>
|
/// 初始化第二个索引页的内容
|
/// </summary>
|
private void InitFrameWhiteContent2()
|
{
|
//开关
|
var btnTitleName = new NormalViewControl(270, 37, true);
|
btnTitleName.X = Application.GetRealWidth(16);
|
btnTitleName.Y = Application.GetRealHeight(18);
|
btnTitleName.TextColor = CSS_Color.FirstLevelTitleColor;
|
btnTitleName.TextSize = CSS_FontSize.EmphasisFontSize_FirstLevel;
|
btnTitleName.TextID = StringId.OnOff;
|
FrameWhiteCentet2.AddChidren(btnTitleName);
|
|
//童锁
|
var rowLock = new FrameRowControl();
|
rowLock.Height = Application.GetRealHeight(50);
|
rowLock.Width = FrameWhiteCentet2.Width;
|
rowLock.Y = Application.GetRealHeight(75);
|
FrameWhiteCentet2.AddChidren(rowLock);
|
rowLock.AddLeftCaption(Language.StringByID(StringId.V_chip), 200);
|
rowLock.AddBottomLine();
|
this.btnLockSwitch = rowLock.AddMostRightSwitchIcon();
|
btnLockSwitch.IsSelected = this.airCleanerData.Lock;
|
btnLockSwitch.ButtonClickEvent += (sender, e) =>
|
{
|
if (this.btnSwitch.IsSelected == false)
|
{
|
//还没有打开开关
|
return;
|
}
|
//发送使能命令
|
this.SendEnableComand(btnLockSwitch, "lock", btnLockSwitch.IsSelected == true ? "false" : "true");
|
};
|
|
//负离子
|
var rowAnion = new FrameRowControl();
|
rowAnion.Height = Application.GetRealHeight(50);
|
rowAnion.Width = FrameWhiteCentet2.Width;
|
rowAnion.Y = rowLock.Bottom;
|
FrameWhiteCentet2.AddChidren(rowAnion);
|
rowAnion.AddLeftCaption(Language.StringByID(StringId.Anion), 200);
|
rowAnion.AddBottomLine();
|
this.btnAnionSwitch = rowAnion.AddMostRightSwitchIcon();
|
btnAnionSwitch.IsSelected = this.airCleanerData.Anion;
|
btnAnionSwitch.ButtonClickEvent += (sender, e) =>
|
{
|
if (this.btnSwitch.IsSelected == false)
|
{
|
//还没有打开开关
|
return;
|
}
|
//发送使能命令
|
this.SendEnableComand(btnAnionSwitch, "anion", btnAnionSwitch.IsSelected == true ? "false" : "true");
|
};
|
|
//滤芯复位
|
var rowReset = new FrameRowControl();
|
rowReset.Height = Application.GetRealHeight(50);
|
rowReset.Width = FrameWhiteCentet2.Width;
|
rowReset.Y = rowAnion.Bottom;
|
FrameWhiteCentet2.AddChidren(rowReset);
|
rowReset.AddLeftCaption(Language.StringByID(StringId.FilterElementReset), 200);
|
rowReset.AddBottomLine();
|
this.btnResetSwitch = rowReset.AddMostRightSwitchIcon();
|
btnResetSwitch.IsSelected = this.airCleanerData.FilterReset;
|
btnResetSwitch.ButtonClickEvent += (sender, e) =>
|
{
|
if (this.btnSwitch.IsSelected == false)
|
{
|
//还没有打开开关
|
return;
|
}
|
//请确认是否已实际重置滤芯并按{0}照说明书要求操作设备进行滤芯{0}寿命重新计时
|
string msg = Language.StringByID(StringId.FilterElementResetMsg).Replace("{0}", "\r\n");
|
this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
{
|
//发送使能命令
|
this.SendEnableComand(btnResetSwitch, "filter_reset", btnResetSwitch.IsSelected == true ? "false" : "true");
|
});
|
};
|
}
|
|
#endregion
|
|
#region ■ 显示风速界面_______________________
|
|
/// <summary>
|
/// 显示风速界面
|
/// </summary>
|
private void ShowFanSpeedView()
|
{
|
//整个灰色界面
|
var frameBack = new Dialog();
|
|
var dialogBody = new NormalFrameLayout();
|
frameBack.AddChidren(dialogBody);
|
dialogBody.ButtonClickEvent = (sender, e) =>
|
{
|
frameBack.Close();
|
};
|
frameBack.Show();
|
|
//菜单控件(选择风速)
|
var menuContr = new DialogTitleMenuControl(4, Language.StringByID(StringId.WindSpeedSelection));
|
menuContr.X = Application.GetRealWidth(5);
|
menuContr.Y = Application.GetRealHeight(240);
|
menuContr.Width = Application.GetRealWidth(160);
|
menuContr.Height = Application.GetRealHeight(200);
|
dialogBody.AddChidren(menuContr);
|
|
//低档
|
var iconPath = this.airCleanerData.Gear == "1" ? "FunctionIcon/Electrical/Fan/LowGearSelect.png" : "FunctionIcon/Electrical/Fan/LowGear.png";
|
menuContr.AddRowMenu(Language.StringByID(StringId.LowGear), iconPath, this.airCleanerData.Gear == "1", () =>
|
{
|
frameBack.Close();
|
//发送风速命令
|
this.SendFanSpeedComand("1");
|
});
|
|
//中档
|
iconPath = this.airCleanerData.Gear == "2" ? "FunctionIcon/Electrical/Fan/MidGearSelect.png" : "FunctionIcon/Electrical/Fan/MidGear.png";
|
menuContr.AddRowMenu(Language.StringByID(StringId.MidGear), iconPath, this.airCleanerData.Gear == "2", () =>
|
{
|
frameBack.Close();
|
//发送风速命令
|
this.SendFanSpeedComand("2");
|
});
|
|
//高档
|
iconPath = this.airCleanerData.Gear == "3" ? "FunctionIcon/Electrical/Fan/HeightGearSelect.png" : "FunctionIcon/Electrical/Fan/HeightGear.png";
|
menuContr.AddRowMenu(Language.StringByID(StringId.HeightGear), iconPath, this.airCleanerData.Gear == "3", () =>
|
{
|
frameBack.Close();
|
//发送风速命令
|
this.SendFanSpeedComand("3");
|
});
|
}
|
|
#endregion
|
|
#region ■ 显示定时界面_______________________
|
|
/// <summary>
|
/// 显示定时界面
|
/// </summary>
|
private void ShowTimingSelectView()
|
{
|
var listText = new List<string>();
|
listText.Add(Language.StringByID(StringId.CancelTiming));
|
listText.Add("1" + Language.StringByID(StringId.Hour1));
|
listText.Add("2" + Language.StringByID(StringId.Hour1));
|
listText.Add("4" + Language.StringByID(StringId.Hour1));
|
listText.Add("8" + Language.StringByID(StringId.Hour1));
|
|
//默认选择
|
int defultIndex = this.airCleanerData.Timing == string.Empty ? -1 : Convert.ToInt32(this.airCleanerData.Timing);
|
if (defultIndex == 0) { defultIndex = -1; }
|
|
var contr = new BottomItemSelectControl(5, Language.StringByID(StringId.TimingSetting));
|
contr.AddRowMenu(listText, new List<int> { defultIndex });
|
contr.FinishOnlyEvent += (div, selectIndex) =>
|
{
|
if (div == 1)
|
{
|
if (selectIndex == 0)
|
{
|
//发送定时命令
|
this.SendTimingComand("cancel");
|
}
|
else
|
{
|
//发送定时命令
|
this.SendTimingComand(selectIndex.ToString());
|
}
|
|
}
|
};
|
}
|
|
#endregion
|
|
#region ■ 显示模式界面_______________________
|
|
/// <summary>
|
/// 显示模式界面
|
/// </summary>
|
private void ShowModeSelectView()
|
{
|
//整个灰色界面
|
var frameBack = new Dialog();
|
|
var dialogBody = new NormalFrameLayout();
|
frameBack.AddChidren(dialogBody);
|
dialogBody.ButtonClickEvent = (sender, e) =>
|
{
|
frameBack.Close();
|
};
|
frameBack.Show();
|
|
//菜单控件
|
var menuContr = new DialogTitleMenuControl(4, Language.StringByID(StringId.ChooseMode));
|
menuContr.X = Application.GetRealWidth(210);
|
menuContr.Y = Application.GetRealHeight(197);
|
menuContr.Width = Application.GetRealWidth(160);
|
menuContr.Height = Application.GetRealHeight(243);
|
dialogBody.AddChidren(menuContr);
|
|
//自动模式
|
var iconPath = this.airCleanerData.Mode == "auto" ? "FunctionIcon/Electrical/Fan/AutoModeSelect.png" : "FunctionIcon/Electrical/Fan/AutoMode.png";
|
menuContr.AddRowMenu(Language.StringByID(StringId.AutoMode), iconPath, this.airCleanerData.Mode == "auto", () =>
|
{
|
frameBack.Close();
|
//发送模式命令
|
this.SendModeComand("auto");
|
});
|
|
//手动模式
|
iconPath = this.airCleanerData.Mode == "manual" ? "FunctionIcon/Electrical/Fan/HandModeSelect.png" : "FunctionIcon/Electrical/Fan/HandMode.png";
|
menuContr.AddRowMenu(Language.StringByID(StringId.HandMode), iconPath, this.airCleanerData.Mode == "manual", () =>
|
{
|
frameBack.Close();
|
//发送模式命令
|
this.SendModeComand("manual");
|
});
|
|
//强劲模式
|
iconPath = this.airCleanerData.Mode == "strong" ? "FunctionIcon/Electrical/Fan/ComfortableModeSelect.png" : "FunctionIcon/Electrical/Fan/ComfortableMode.png";
|
menuContr.AddRowMenu(Language.StringByID(StringId.StrongMode), iconPath, this.airCleanerData.Mode == "strong", () =>
|
{
|
frameBack.Close();
|
//发送模式命令
|
this.SendModeComand("strong");
|
});
|
|
//睡眠模式
|
iconPath = this.airCleanerData.Mode == "sleep" ? "FunctionIcon/Electrical/Fan/SleepModeSelect.png" : "FunctionIcon/Electrical/Fan/SleepMode.png";
|
menuContr.AddRowMenu(Language.StringByID(StringId.SleepMode), iconPath, this.airCleanerData.Mode == "sleep", () =>
|
{
|
frameBack.Close();
|
//发送模式命令
|
this.SendModeComand("sleep");
|
});
|
}
|
|
#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>
|
/// <param name="value">auto:自动 sleep:睡眠 manual:手动 strong:强烈</param>
|
private void SendModeComand(string value)
|
{
|
this.btnMode.CanClick = false;
|
HdlThreadLogic.Current.RunThread(() =>
|
{
|
var dic = new Dictionary<string, string>();
|
dic.Add("mode", value);
|
Control.Ins.SendWriteCommand(this.device, dic, true);
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
this.btnMode.CanClick = true;
|
});
|
});
|
}
|
|
/// <summary>
|
/// 发送定时命令
|
/// </summary>
|
/// <param name="value">canel:取消 1:1小时 2:2小时 3:4小时 4:8小时</param>
|
private void SendTimingComand(string value)
|
{
|
this.btnTime.CanClick = false;
|
HdlThreadLogic.Current.RunThread(() =>
|
{
|
var dic = new Dictionary<string, string>();
|
dic.Add("countdown", value);
|
Control.Ins.SendWriteCommand(this.device, dic, true);
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
this.btnTime.CanClick = true;
|
});
|
});
|
}
|
|
/// <summary>
|
/// 发送风速命令
|
/// </summary>
|
/// <param name="value">1:低档 2:中档 3:高档</param>
|
private void SendFanSpeedComand(string value)
|
{
|
this.btnFan.CanClick = false;
|
HdlThreadLogic.Current.RunThread(() =>
|
{
|
var dic = new Dictionary<string, string>();
|
dic.Add("speed", value);
|
Control.Ins.SendWriteCommand(this.device, dic, true);
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
this.btnFan.CanClick = true;
|
});
|
});
|
}
|
|
/// <summary>
|
/// 发送开关命令
|
/// </summary>
|
private void SendSwitchComand()
|
{
|
this.btnPictrue.CanClick = false;
|
this.btnSwitch.CanClick = false;
|
|
//其他三个按钮的点击也要控制
|
this.btnFan.CanClick = this.btnSwitch.IsSelected;
|
this.btnMode.CanClick = this.btnSwitch.IsSelected;
|
this.btnTime.CanClick = this.btnSwitch.IsSelected;
|
|
string statu = this.btnSwitch.IsSelected == true ? "off" : "on";
|
HdlThreadLogic.Current.RunThread(() =>
|
{
|
var dic = new Dictionary<string, string>();
|
dic.Add(FunctionAttributeKey.OnOff, statu);
|
Control.Ins.SendWriteCommand(this.device, dic, true);
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
this.btnPictrue.CanClick = true;
|
this.btnSwitch.CanClick = true;
|
});
|
});
|
}
|
|
/// <summary>
|
/// 发送使能命令
|
/// </summary>
|
private void SendEnableComand(MostRightIconControl btnSwitch, string sendKey, string value)
|
{
|
btnSwitch.CanClick = false;
|
HdlThreadLogic.Current.RunThread(() =>
|
{
|
var dic = new Dictionary<string, string>();
|
dic.Add(sendKey, value);
|
Control.Ins.SendWriteCommand(this.device, dic, true);
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
btnSwitch.CanClick = true;
|
});
|
});
|
}
|
|
#endregion
|
|
#region ■ 刷新界面状态_______________________
|
|
/// <summary>
|
/// 刷新界面状态
|
/// </summary>
|
private void RefreshFormStatu()
|
{
|
//=======模式=======
|
//强劲模式
|
if (this.airCleanerData.Mode == "strong")
|
{
|
if (this.btnModeView.TextID != StringId.StrongMode)
|
{
|
//相同不变更
|
this.btnMode.UnSelectedImagePath = "FunctionIcon/Electrical/Fan/ComfortableModeSelect.png";
|
this.btnModeView.TextID = StringId.StrongMode;
|
}
|
}
|
//睡眠模式
|
else if (this.airCleanerData.Mode == "sleep")
|
{
|
if (this.btnModeView.TextID != StringId.SleepMode)
|
{
|
//相同不变更
|
this.btnMode.UnSelectedImagePath = "FunctionIcon/Electrical/Fan/SleepModeSelect.png";
|
this.btnModeView.TextID = StringId.SleepMode;
|
}
|
}
|
//手动模式
|
else if (this.airCleanerData.Mode == "manual")
|
{
|
if (this.btnModeView.TextID != StringId.HandMode)
|
{
|
//相同不变更
|
this.btnMode.UnSelectedImagePath = "FunctionIcon/Electrical/Fan/HandModeSelect.png";
|
this.btnModeView.TextID = StringId.HandMode;
|
}
|
}
|
//自动模式
|
else
|
{
|
if (this.btnModeView.TextID != StringId.AutoMode)
|
{
|
//相同不变更
|
this.btnMode.UnSelectedImagePath = "FunctionIcon/Electrical/Fan/AutoModeSelect.png";
|
this.btnModeView.TextID = StringId.AutoMode;
|
}
|
}
|
|
//开关
|
if (this.btnSwitch.IsSelected != this.airCleanerData.Open)
|
{
|
//相同不变更
|
this.btnSwitch.IsSelected = this.airCleanerData.Open;
|
this.btnPictrue.IsSelected = this.airCleanerData.Open;
|
//其他三个按钮的点击也要控制
|
this.btnFan.CanClick = this.airCleanerData.Open;
|
this.btnMode.CanClick = this.airCleanerData.Open;
|
this.btnTime.CanClick = this.airCleanerData.Open;
|
}
|
|
//=====风速=====
|
//高档
|
if (airCleanerData.Gear == "3")
|
{
|
if (this.btnFanView.TextID != StringId.HeightGear)
|
{
|
//相同不变更
|
this.btnFan.UnSelectedImagePath = "FunctionIcon/Electrical/Fan/HeightGearSelect.png";
|
this.btnFanView.TextID = StringId.HeightGear;
|
}
|
}
|
//中档
|
else if (airCleanerData.Gear == "2")
|
{
|
if (this.btnFanView.TextID != StringId.MidGear)
|
{
|
//相同不变更
|
this.btnFan.UnSelectedImagePath = "FunctionIcon/Electrical/Fan/MidGearSelect.png";
|
this.btnFanView.TextID = StringId.MidGear;
|
}
|
}
|
//低档
|
else
|
{
|
if (this.btnFanView.TextID != StringId.LowGear)
|
{
|
//相同不变更
|
this.btnFan.UnSelectedImagePath = "FunctionIcon/Electrical/Fan/LowGearSelect.png";
|
this.btnFanView.TextID = StringId.LowGear;
|
}
|
}
|
|
//定时
|
if (airCleanerData.Timing == "1")
|
{
|
btnTimeView.Text = "1" + Language.StringByID(StringId.Hour1);
|
}
|
else if (airCleanerData.Timing == "2")
|
{
|
btnTimeView.Text = "2" + Language.StringByID(StringId.Hour1);
|
}
|
else if (airCleanerData.Timing == "3")
|
{
|
btnTimeView.Text = "4" + Language.StringByID(StringId.Hour1);
|
}
|
else if (airCleanerData.Timing == "4")
|
{
|
btnTimeView.Text = "8" + Language.StringByID(StringId.Hour1);
|
}
|
else
|
{
|
btnTimeView.Text = Language.StringByID(StringId.Timing);
|
}
|
|
//滤芯使用
|
this.btnUsePersent.Text = Language.StringByID(StringId.UseOfFilterElement) + airCleanerData.FilterPersent + "%";
|
//PM2.5
|
this.btnPm25.Text = airCleanerData.PM25Value.ToString();
|
//童锁
|
if (this.btnLockSwitch.IsSelected != this.airCleanerData.Lock)
|
{
|
this.btnLockSwitch.IsSelected = this.airCleanerData.Lock;
|
}
|
//负离子
|
if (this.btnAnionSwitch.IsSelected != this.airCleanerData.Anion)
|
{
|
this.btnAnionSwitch.IsSelected = this.airCleanerData.Anion;
|
}
|
//滤芯复位
|
if (this.btnResetSwitch.IsSelected != this.airCleanerData.FilterReset)
|
{
|
this.btnResetSwitch.IsSelected = this.airCleanerData.FilterReset;
|
}
|
}
|
|
#endregion
|
|
#region ■ 一般方法___________________________
|
|
/// <summary>
|
/// 刷新当前设备的状态缓存
|
/// </summary>
|
private void RefreshNowDeviceStatuMemory(Function i_LocalDevice)
|
{
|
foreach (var data in i_LocalDevice.attributes)
|
{
|
//模式
|
if (data.key == "mode") { this.airCleanerData.Mode = data.realValue; }
|
//风速档位
|
else if (data.key == "speed") { this.airCleanerData.Gear = data.realValue; }
|
//开关
|
else if (data.key == "on_off") { this.airCleanerData.Open = data.realValue.ToLower() == "on"; }
|
//童锁
|
else if (data.key == "lock") { this.airCleanerData.Lock = data.realValue.ToLower() == "true"; }
|
//滤芯复位
|
else if (data.key == "filter_reset") { this.airCleanerData.FilterReset = data.realValue.ToLower() == "true"; }
|
//负离子
|
else if (data.key == "anion") { this.airCleanerData.Anion = data.realValue.ToLower() == "true"; }
|
//定时
|
else if (data.key == "countdown")
|
{
|
this.airCleanerData.Timing = data.realValue;
|
if (this.airCleanerData.Timing == "cancel")
|
{
|
this.airCleanerData.Timing = "0";
|
}
|
}
|
//空气质量
|
else if (data.key == "pm25")
|
{
|
var value = data.realValue;
|
if (value != string.Empty)
|
{
|
this.airCleanerData.PM25Value = Convert.ToInt32(value);
|
}
|
}
|
//滤芯使用率
|
else if (data.key == "filter")
|
{
|
var value = data.realValue;
|
if (value != string.Empty)
|
{
|
this.airCleanerData.FilterPersent = Convert.ToInt32(value);
|
}
|
}
|
}
|
}
|
|
#endregion
|
|
#region ■ 结构体_____________________________
|
|
/// <summary>
|
/// 空气净化器的数据
|
/// </summary>
|
private class AirCleanerData
|
{
|
/// <summary>
|
/// 是否打开
|
/// </summary>
|
public bool Open = true;
|
/// <summary>
|
/// 档位 1:低档 2:中档 3:高档
|
/// </summary>
|
public string Gear = "0";
|
/// <summary>
|
/// auto:自动 sleep:睡眠 manual:手动 strong:强烈
|
/// </summary>
|
public string Mode = string.Empty;
|
/// <summary>
|
/// cancel:取消 1:1小时 2:2小时 3:4小时 4:8小时
|
/// </summary>
|
public string Timing = "0";
|
/// <summary>
|
/// 童锁
|
/// </summary>
|
public bool Lock = false;
|
/// <summary>
|
/// 滤芯复位
|
/// </summary>
|
public bool FilterReset = false;
|
/// <summary>
|
/// 负离子
|
/// </summary>
|
public bool Anion = false;
|
/// <summary>
|
/// PM2.5的值
|
/// </summary>
|
public int PM25Value = 0;
|
/// <summary>
|
/// 滤芯使用率 0-100
|
/// </summary>
|
public int FilterPersent = 0;
|
}
|
|
#endregion
|
}
|
}
|