using System;
|
using System.Collections.Generic;
|
using HDL_ON.DriverLayer;
|
using HDL_ON.Entity;
|
using HDL_ON.Stan;
|
using HDL_ON.UI.CSS;
|
using Shared;
|
|
namespace HDL_ON.UI
|
{
|
public class TuyaWaterValvePage : DeviceFunctionCardCommonForm
|
{
|
#region ■ 变量声明___________________________
|
/// <summary>
|
/// 图片控件
|
/// </summary>
|
private PicViewControl btnPictrue = null;
|
/// <summary>
|
/// 滤芯使用率控件
|
/// </summary>
|
private NormalViewControl btnUsePersent = null;
|
/// <summary>
|
/// 天气延时
|
/// </summary>
|
private NormalViewControl btnWeatherDelay = null;
|
/// <summary>
|
/// 湿度
|
/// </summary>
|
private NormalViewControl btnWeatherDelayControl = null;
|
/// <summary>
|
/// 开关控件
|
/// </summary>
|
private IconViewControl btnSwitch = null;
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 初始化白色区域的内容
|
/// </summary>
|
public override void InitFrameWhiteContent()
|
{
|
base.SetTitleText(Language.StringByID(StringId.AirCleaner));
|
|
//添加第二索引页
|
this.AddSecondPage();
|
//初始化第一个索引页的内容
|
this.InitFrameWhiteContent1();
|
//刷新界面状态
|
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/WaterValve/WaterValveBg.png";
|
btnPictrue.SelectedImagePath = "FunctionIcon/Electrical/WaterValve/WaterValveOnBg.png";
|
FrameWhiteCentet1.AddChidren(btnPictrue);
|
btnPictrue.ButtonClickEvent += (sender, e) =>
|
{
|
//发送开关命令
|
this.SendSwitchComand();
|
};
|
|
//开关图标
|
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();
|
};
|
}
|
#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.RefreshFormStatu();
|
}
|
|
#endregion
|
|
#region ■ 发送各种命令_______________________
|
|
/// <summary>
|
/// 发送开关命令
|
/// </summary>
|
private void SendSwitchComand()
|
{
|
this.btnPictrue.CanClick = false;
|
this.btnSwitch.CanClick = false;
|
|
string statu = this.btnSwitch.IsSelected == true ? "off" : "on";
|
//btnSwitch.IsSelected = !btnSwitch.IsSelected;
|
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;
|
});
|
});
|
}
|
|
#endregion
|
|
#region ■ 刷新界面状态_______________________
|
|
/// <summary>
|
/// 刷新界面状态
|
/// </summary>
|
private void RefreshFormStatu()
|
{
|
Application.RunOnMainThread(() =>
|
{
|
foreach (var data in this.device.attributes)
|
{
|
if (data.key == FunctionAttributeKey.OnOff)
|
{
|
this.btnSwitch.IsSelected = this.btnPictrue.IsSelected = data.curValue.ToString() == "on";
|
}
|
}
|
});
|
}
|
#endregion
|
|
}
|
}
|