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 TuyaWeepRobotPage : DeviceFunctionCardCommonForm
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 电池图标
|
/// </summary>
|
private IconViewControl btnBatteryIcon = null;
|
/// <summary>
|
/// 电池百分比控件
|
/// </summary>
|
private NormalViewControl btnBatteryView = null;
|
/// <summary>
|
/// 吸力调节图标
|
/// </summary>
|
private IconViewControl btnSuctionIcon = null;
|
/// <summary>
|
/// 吸力调节文本控件
|
/// </summary>
|
private NormalViewControl btnSuctionView = null;
|
/// <summary>
|
/// 充电图标
|
/// </summary>
|
private IconViewControl btnChargeIcon = null;
|
/// <summary>
|
/// 声音图标
|
/// </summary>
|
private IconViewControl btnVoiceIcon = null;
|
/// <summary>
|
/// 声音文本控件
|
/// </summary>
|
private NormalViewControl btnVoiceView = null;
|
/// <summary>
|
/// 清扫模式图标
|
/// </summary>
|
private IconViewControl btnModeIcon = null;
|
/// <summary>
|
/// 清扫模式文本控件
|
/// </summary>
|
private NormalViewControl btnModeView = null;
|
/// <summary>
|
/// 图像控制控件
|
/// </summary>
|
private DirectionImageControl ImageControl = null;
|
/// <summary>
|
/// 扫地机器人数据
|
/// </summary>
|
private WeepRobotData weepRobotData = new WeepRobotData();
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 初始化白色区域的内容
|
/// </summary>
|
public override void InitFrameWhiteContent()
|
{
|
base.SetTitleText(Language.StringByID(StringId.WeepRobot));
|
|
//添加第二索引页
|
this.AddSecondPage();
|
//初始化第一个索引页的内容
|
this.InitFrameWhiteContent1();
|
//初始化第二个索引页的内容
|
this.InitFrameWhiteContent2();
|
|
//刷新当前设备的状态缓存
|
this.RefreshNowDeviceStatuMemory(this.device);
|
//刷新界面状态
|
this.RefreshFormStatu();
|
}
|
|
/// <summary>
|
/// 初始化第一个索引页的内容
|
/// </summary>
|
private void InitFrameWhiteContent1()
|
{
|
//电池图标
|
this.btnBatteryIcon = new IconViewControl(24);
|
btnBatteryIcon.X = base.btnRoomName.Right + Application.GetRealWidth(24);
|
btnBatteryIcon.Y = base.btnRoomName.Y - (btnBatteryIcon.IconSize - base.btnRoomName.Height) / 2;
|
btnBatteryIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/Battery.png";
|
FrameWhiteCentet1.AddChidren(btnBatteryIcon);
|
//电池百分比
|
this.btnBatteryView = new NormalViewControl(30, 16, true);
|
btnBatteryView.X = btnBatteryIcon.Right + Application.GetRealWidth(4);
|
btnBatteryView.Y = btnBatteryIcon.Y + (btnBatteryIcon.Height - Application.GetRealHeight(16)) / 2;
|
btnBatteryView.Text = this.weepRobotData.ElectricityLeft + "%";
|
btnBatteryView.TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel;
|
btnBatteryView.TextColor = CSS_Color.PromptingColor1;
|
FrameWhiteCentet1.AddChidren(btnBatteryView);
|
//配置变更事件
|
base.SettionFinishEvent += () =>
|
{
|
btnBatteryIcon.X = base.btnRoomName.Right + Application.GetRealWidth(24);
|
btnBatteryView.X = btnBatteryIcon.Right + Application.GetRealWidth(4);
|
};
|
|
//初始化中间的那个图像控制控件
|
this.ImageControl = new DirectionImageControl();
|
ImageControl.Y = Application.GetRealHeight(108);
|
ImageControl.Width = Application.GetRealWidth(198);
|
ImageControl.Height = Application.GetRealWidth(198);
|
ImageControl.Gravity = Gravity.CenterHorizontal;
|
FrameWhiteCentet1.AddChidren(ImageControl);
|
//初始化控件
|
ImageControl.InitControl("FunctionIcon/Electrical/WeepRobot/ControlEnable.png", "FunctionIcon/Electrical/WeepRobot/ControlDisable.png",
|
"FunctionIcon/Electrical/WeepRobot/ControlUp.png", "FunctionIcon/Electrical/WeepRobot/ControlDown.png",
|
"FunctionIcon/Electrical/WeepRobot/ControlLeft.png", "FunctionIcon/Electrical/WeepRobot/ControlRight.png");
|
//控制事件(不支持Enable和Disable,都归为Mid)
|
ImageControl.ControlEvent += (select) =>
|
{
|
|
};
|
|
//吸力调节
|
this.btnSuctionIcon = new IconViewControl(28);
|
btnSuctionIcon.Y = ImageControl.Bottom + Application.GetRealHeight(64);
|
btnSuctionIcon.X = Application.GetRealWidth(33);
|
btnSuctionIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/Suction.png";
|
btnSuctionIcon.SelectedImagePath = "FunctionIcon/Electrical/WeepRobot/SuctionSelect.png";
|
FrameWhiteCentet1.AddChidren(btnSuctionIcon);
|
btnSuctionIcon.ButtonClickEvent += (sender, e) =>
|
{
|
};
|
this.btnSuctionView = new NormalViewControl(80, 54, true);
|
btnSuctionView.Y = btnSuctionIcon.Bottom + Application.GetRealHeight(10);
|
btnSuctionView.X = btnSuctionIcon.X - (Application.GetRealWidth(80) - btnSuctionIcon.Width) / 2;
|
btnSuctionView.TextAlignment = TextAlignment.TopCenter;
|
btnSuctionView.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
|
btnSuctionView.Text = Language.StringByID(StringId.SuctionAdjustment);
|
btnSuctionView.IsMoreLines = true;
|
FrameWhiteCentet1.AddChidren(btnSuctionView);
|
|
//充电图标
|
this.btnChargeIcon = new IconViewControl(28);
|
btnChargeIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/Charge.png";
|
btnChargeIcon.SelectedImagePath = "FunctionIcon/Electrical/WeepRobot/ChargeSelect.png";
|
btnChargeIcon.Y = btnSuctionIcon.Y;
|
btnChargeIcon.X = btnSuctionIcon.Right + Application.GetRealWidth(50);
|
FrameWhiteCentet1.AddChidren(btnChargeIcon);
|
btnChargeIcon.ButtonClickEvent += (sender, e) =>
|
{
|
};
|
var btnChargeView = new NormalViewControl(80, 18, true);
|
btnChargeView.Y = btnSuctionView.Y;
|
btnChargeView.X = btnChargeIcon.X - (Application.GetRealWidth(80) - btnChargeIcon.Width) / 2;
|
btnChargeView.TextAlignment = TextAlignment.TopCenter;
|
btnChargeView.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
|
btnChargeView.TextID = StringId.Charge;
|
FrameWhiteCentet1.AddChidren(btnChargeView);
|
|
//声音图标
|
this.btnVoiceIcon = new IconViewControl(28);
|
btnVoiceIcon.Y = btnSuctionIcon.Y;
|
btnVoiceIcon.X = btnChargeIcon.Right + Application.GetRealWidth(50);
|
btnVoiceIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/Voice.png";
|
btnVoiceIcon.SelectedImagePath = "FunctionIcon/Electrical/WeepRobot/VoiceSelect.png";
|
FrameWhiteCentet1.AddChidren(btnVoiceIcon);
|
btnVoiceIcon.ButtonClickEvent += (sender, e) =>
|
{
|
};
|
this.btnVoiceView = new NormalViewControl(80, 18, true);
|
btnVoiceView.Y = btnSuctionView.Y;
|
btnVoiceView.X = btnVoiceIcon.X - (Application.GetRealWidth(80) - btnVoiceIcon.Width) / 2;
|
btnVoiceView.TextAlignment = TextAlignment.TopCenter;
|
btnVoiceView.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
|
btnVoiceView.TextID = StringId.Mute;
|
FrameWhiteCentet1.AddChidren(btnVoiceView);
|
|
//清扫模式图标
|
this.btnModeIcon = new IconViewControl(28);
|
btnModeIcon.Y = btnSuctionIcon.Y;
|
btnModeIcon.X = btnVoiceIcon.Right + Application.GetRealWidth(50);
|
btnModeIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/Clean.png";
|
FrameWhiteCentet1.AddChidren(btnModeIcon);
|
btnModeIcon.ButtonClickEvent += (sender, e) =>
|
{
|
};
|
this.btnModeView = new NormalViewControl(80, 54, true);
|
btnModeView.Y = btnSuctionView.Y;
|
btnModeView.X = btnModeIcon.X - (Application.GetRealWidth(80) - btnModeIcon.Width) / 2;
|
btnModeView.TextAlignment = TextAlignment.TopCenter;
|
btnModeView.TextSize = CSS_FontSize.PromptFontSize_FirstLevel;
|
btnModeView.TextID = StringId.CleanMode;
|
btnModeView.IsMoreLines = true;
|
FrameWhiteCentet1.AddChidren(btnModeView);
|
}
|
|
/// <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.WeepRobot;
|
FrameWhiteCentet2.AddChidren(btnTitleName);
|
|
//耗材管理
|
var rowManment = new FrameRowControl();
|
rowManment.Height = Application.GetRealHeight(50);
|
rowManment.Width = FrameWhiteCentet2.Width;
|
rowManment.Y = Application.GetRealHeight(75);
|
FrameWhiteCentet2.AddChidren(rowManment);
|
rowManment.AddLeftCaption(Language.StringByID(StringId.ConsumablesManagement), 200);
|
rowManment.AddBottomLine();
|
rowManment.AddRightArrow();
|
rowManment.ButtonClickEvent += (sender, e) =>
|
{
|
};
|
|
//历史记录
|
var rowHistory = new FrameRowControl();
|
rowHistory.Height = Application.GetRealHeight(50);
|
rowHistory.Width = FrameWhiteCentet2.Width;
|
rowHistory.Y = rowManment.Bottom;
|
FrameWhiteCentet2.AddChidren(rowHistory);
|
rowHistory.AddLeftCaption(Language.StringByID(StringId.HistoryLog), 200);
|
rowHistory.AddBottomLine();
|
rowHistory.AddRightArrow();
|
rowHistory.ButtonClickEvent += (sender, e) =>
|
{
|
};
|
}
|
|
#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 SendSwitchComand()
|
{
|
//this.btnSwitch.CanClick = false;
|
|
//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.btnSwitch.CanClick = true;
|
// });
|
//});
|
}
|
|
#endregion
|
|
#region ■ 刷新界面状态_______________________
|
|
/// <summary>
|
/// 刷新界面状态
|
/// </summary>
|
private void RefreshFormStatu()
|
{
|
//静音(它有四个图标)
|
if (this.weepRobotData.VoiceSwitch == true)
|
{
|
//需要切换图标
|
if (this.btnVoiceIcon.UnSelectedImagePath != "FunctionIcon/Electrical/WeepRobot/Mute.png")
|
{
|
this.btnVoiceIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/Mute.png";
|
this.btnVoiceIcon.SelectedImagePath = "FunctionIcon/Electrical/WeepRobot/MuteSelect.png";
|
}
|
}
|
else
|
{
|
//需要切换图标
|
if (this.btnVoiceIcon.UnSelectedImagePath != "FunctionIcon/Electrical/WeepRobot/Voice.png")
|
{
|
this.btnVoiceIcon.UnSelectedImagePath = "FunctionIcon/Electrical/WeepRobot/Voice.png";
|
this.btnVoiceIcon.SelectedImagePath = "FunctionIcon/Electrical/WeepRobot/VoiceSelect.png";
|
}
|
}
|
}
|
|
#endregion
|
|
#region ■ 一般方法___________________________
|
|
/// <summary>
|
/// 刷新当前设备的状态缓存
|
/// </summary>
|
private void RefreshNowDeviceStatuMemory(Function i_LocalDevice)
|
{
|
foreach (var data in i_LocalDevice.attributes)
|
{
|
//开关
|
if (data.key == "on_off") { this.weepRobotData.Open = data.realValue.ToLower() == "on"; }
|
//寻找机器
|
else if (data.key == "seek") { this.weepRobotData.SearchRobot = data.realValue.ToLower() == "true"; }
|
//边刷重置
|
else if (data.key == "reset_edge_brush") { this.weepRobotData.ResetEdgeBrush = data.realValue.ToLower() == "true"; }
|
//滚刷重置
|
else if (data.key == "reset_roll_brush") { this.weepRobotData.ResetRollBrush = data.realValue.ToLower() == "true"; }
|
//滤网重置
|
else if (data.key == "reset_filter") { this.weepRobotData.ResetFilter = data.realValue.ToLower() == "true"; }
|
//吸力选择
|
else if (data.key == "suction") { this.weepRobotData.Suction = data.realValue; }
|
//工作模式
|
else if (data.key == "mode") { this.weepRobotData.Mode = data.realValue; }
|
//清扫方向
|
else if (data.key == "direction_control") { this.weepRobotData.DirectionControl = data.realValue; }
|
//声音开关
|
else if (data.key == "voice_switch") { this.weepRobotData.VoiceSwitch = data.realValue.ToLower() == "true"; }
|
//清扫面积
|
else if (data.key == "clean_area")
|
{
|
var value = data.realValue;
|
if (value != string.Empty)
|
{
|
this.weepRobotData.CleanArea = Convert.ToInt32(value);
|
}
|
}
|
//清扫记录
|
else if (data.key == "clean_record") { this.weepRobotData.CleanRecord = data.realValue; }
|
//边刷寿命
|
else if (data.key == "edge_brush")
|
{
|
var value = data.realValue;
|
if (value != string.Empty)
|
{
|
this.weepRobotData.EdgeBrush = Convert.ToInt32(value);
|
}
|
}
|
//滚刷寿命
|
else if (data.key == "roll_brush")
|
{
|
var value = data.realValue;
|
if (value != string.Empty)
|
{
|
this.weepRobotData.RollBrush = Convert.ToInt32(value);
|
}
|
}
|
//滤网寿命
|
else if (data.key == "filter")
|
{
|
var value = data.realValue;
|
if (value != string.Empty)
|
{
|
this.weepRobotData.Filter = Convert.ToInt32(value);
|
}
|
}
|
//清扫时间
|
else if (data.key == "clean_time")
|
{
|
var value = data.realValue;
|
if (value != string.Empty)
|
{
|
this.weepRobotData.CleanTime = Convert.ToInt32(value);
|
}
|
}
|
//剩余电量
|
else if (data.key == "electricity_left")
|
{
|
var value = data.realValue;
|
if (value != string.Empty)
|
{
|
this.weepRobotData.ElectricityLeft = Convert.ToInt32(value);
|
}
|
}
|
}
|
}
|
|
#endregion
|
|
#region ■ 结构体_____________________________
|
|
/// <summary>
|
/// 扫地机器人的数据
|
/// </summary>
|
private class WeepRobotData
|
{
|
/// <summary>
|
/// 是否打开
|
/// </summary>
|
public bool Open = true;
|
/// <summary>
|
/// 寻找机器
|
/// </summary>
|
public bool SearchRobot = false;
|
/// <summary>
|
/// 边刷重置
|
/// </summary>
|
public bool ResetEdgeBrush = false;
|
/// <summary>
|
/// 滚刷重置
|
/// </summary>
|
public bool ResetRollBrush = false;
|
/// <summary>
|
/// 滤网重置
|
/// </summary>
|
public bool ResetFilter = false;
|
/// <summary>
|
/// 吸力选择(strong:一档 normal:二挡 quiet:三挡)
|
/// </summary>
|
public string Suction = string.Empty;
|
/// <summary>
|
/// 工作模式(random:自动清扫 smart:定点清扫 wall_follow:沿墙清扫 spiral:区域清扫 chargego:充电)
|
/// </summary>
|
public string Mode = string.Empty;
|
/// <summary>
|
/// 清扫方向(forward:向前 backward:向后 turn_left:向左 turn_right:向右 stop:停止)
|
/// </summary>
|
public string DirectionControl = string.Empty;
|
/// <summary>
|
/// 静音
|
/// </summary>
|
public bool VoiceSwitch = false;
|
/// <summary>
|
/// 清扫面积
|
/// </summary>
|
public int CleanArea = 0;
|
/// <summary>
|
/// 清扫记录(目前都是空的)
|
/// </summary>
|
public string CleanRecord = string.Empty;
|
/// <summary>
|
/// 边刷寿命(百分比)
|
/// </summary>
|
public int EdgeBrush = 0;
|
/// <summary>
|
/// 滚刷寿命(百分比)
|
/// </summary>
|
public int RollBrush = 0;
|
/// <summary>
|
/// 滤网寿命(百分比)
|
/// </summary>
|
public int Filter = 0;
|
/// <summary>
|
/// 清扫时间(0-432000)
|
/// </summary>
|
public int CleanTime = 0;
|
/// <summary>
|
/// 剩余电量(百分比)
|
/// </summary>
|
public int ElectricityLeft = 0;
|
}
|
|
#endregion
|
}
|
}
|