using Shared.Common;
|
using Shared.Phone.UserCenter;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.MainPage.ControlForm
|
{
|
/// <summary>
|
/// 空调类型的深度卡片界面
|
/// </summary>
|
public class DeviceAcDetailCardForm : DeviceDetailCardCommonForm
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 界面上可以操作的控件
|
/// </summary>
|
private List<ButtonBase> listControl = new List<ButtonBase>();
|
/// <summary>
|
/// 空调控件
|
/// </summary>
|
private ArcScaleSeekBar arcScaleSeekBar = null;
|
/// <summary>
|
/// 空调控件里面的那个显示制热,制冷的控件
|
/// </summary>
|
private NormalViewControl btnNowModeView = null;
|
/// <summary>
|
/// 减号控件
|
/// </summary>
|
private IconViewControl btnReduce = null;
|
/// <summary>
|
/// 加号控件
|
/// </summary>
|
private IconViewControl btnAdd = null;
|
/// <summary>
|
/// 是否设置进度值(只使用一次后,就变更值)
|
/// </summary>
|
private bool notSetProgress = false;
|
/// <summary>
|
/// 能否发送进度值命令
|
/// </summary>
|
private bool canSetProgress = true;
|
/// <summary>
|
/// 清洗滤网提示的FrameLayout
|
/// </summary>
|
private FrameLayout frameClrean = null;
|
/// <summary>
|
/// 当前的温度进度值
|
/// </summary>
|
private int nowProgressValue = -1;
|
/// <summary>
|
/// 空调控件
|
/// </summary>
|
private AC deviceAc = null;
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 底层初始化中部控件完成之后
|
/// </summary>
|
/// <param name="frameWhiteBack"></param>
|
public override void InitMiddleFrameAfter(FrameLayout frameWhiteBack)
|
{
|
//左滑不能
|
this.ScrollEnabled = false;
|
this.deviceAc = (AC)this.device;
|
//先清空
|
this.listControl = new List<ButtonBase>();
|
if (device.HadReadDeviceStatu == true && DeviceAcDetailCardMethord.IsOpen(deviceAc) == true)
|
{
|
//设置状态文字 当前室温
|
this.SetStatuText(deviceAc.currentLocalTemperature + "℃");
|
}
|
else
|
{
|
//设置状态文字 关闭
|
this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close));
|
}
|
|
//清洗滤网提示的FrameLayout
|
this.frameClrean = new FrameLayout();
|
frameClrean.Width = Application.GetRealWidth(600);
|
frameClrean.Height = this.GetPictrueRealSize(69);
|
frameClrean.X = HdlControlResourse.XXLeft;
|
frameClrean.Y = Application.GetRealHeight(35);
|
frameWhiteBack.AddChidren(frameClrean);
|
frameClrean.Visible = false;
|
//清洗滤网提示的图标
|
var btnTipIcon = new IconViewControl(69);
|
btnTipIcon.UnSelectedImagePath = "AC/AC_TIP.png";
|
frameClrean.AddChidren(btnTipIcon);
|
//请注意清洗滤网哦
|
var btnClrean = new NormalViewControl(Application.GetRealWidth(400), frameClrean.Height, false);
|
btnClrean.TextID = R.MyInternationalizationString.uPleaseClreanACfilter;
|
btnClrean.X = frameClrean.Right + Application.GetRealWidth(12);
|
frameClrean.AddChidren(btnClrean);
|
|
//调整设备和状态控件的Y轴
|
this.ResetDeviceNameAndStatuPoint(Application.GetRealHeight(184), Application.GetRealHeight(256));
|
|
//初始化空调控件
|
this.InitAcControl(frameWhiteBack);
|
}
|
|
/// <summary>
|
/// 初始化空调控件
|
/// </summary>
|
/// <param name="frameWhiteBack"></param>
|
private void InitAcControl(FrameLayout frameWhiteBack)
|
{
|
bool isAcOpen = DeviceAcDetailCardMethord.IsOpen(deviceAc);
|
|
//空调控件的容器
|
var frameAcBack = new FrameLayout();
|
frameAcBack.Y = Application.GetRealHeight(412);
|
frameAcBack.Width = this.GetPictrueRealSize(671);
|
frameAcBack.Height = this.GetPictrueRealSize(671);
|
frameAcBack.Gravity = Gravity.CenterHorizontal;
|
frameWhiteBack.AddChidren(frameAcBack);
|
|
this.nowProgressValue = DeviceAcDetailCardMethord.GetCurrentModeTemperature(deviceAc);
|
if (nowProgressValue < 16) { nowProgressValue = 16; }
|
if (nowProgressValue > 32) { nowProgressValue = 32; }
|
//空调控件
|
this.arcScaleSeekBar = new ArcScaleSeekBar();
|
arcScaleSeekBar.Width = frameAcBack.Width;
|
arcScaleSeekBar.Height = frameAcBack.Height;
|
arcScaleSeekBar.MinValue = 16;
|
arcScaleSeekBar.MaxValue = 32;
|
arcScaleSeekBar.Progress = nowProgressValue;
|
arcScaleSeekBar.IsClickable = isAcOpen;
|
arcScaleSeekBar.ProgressBarUnitSring = string.Empty;
|
frameAcBack.AddChidren(arcScaleSeekBar);
|
if (isAcOpen == true)
|
{
|
arcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCArcScaleSeekBarStartColor, ZigbeeColor.Current.GXCArcScaleSeekBarEndColor);
|
}
|
else
|
{
|
arcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor);
|
}
|
|
//空调控件里面的那个显示制热,制冷的控件
|
this.btnNowModeView = new NormalViewControl(200, 55, true);
|
btnNowModeView.Y = this.GetPictrueRealSize(184);
|
btnNowModeView.Gravity = Gravity.CenterHorizontal;
|
btnNowModeView.Text = DeviceAcDetailCardMethord.GetModeNameByModeId(deviceAc.currentSystemMode);
|
btnNowModeView.TextSize = 12;
|
btnNowModeView.TextAlignment = TextAlignment.Center;
|
frameAcBack.AddChidren(btnNowModeView);
|
|
//减号
|
this.btnReduce = new IconViewControl(81);
|
btnReduce.CanClick = isAcOpen;
|
btnReduce.UnSelectedImagePath = "AC/Reduce.png";
|
btnReduce.X = this.GetPictrueRealSize(132);
|
btnReduce.Y = this.GetPictrueRealSize(268);
|
frameAcBack.AddChidren(btnReduce);
|
btnReduce.ButtonClickEvent += (sender, e) =>
|
{
|
if (arcScaleSeekBar.Progress > 16)
|
{
|
this.nowProgressValue = arcScaleSeekBar.Progress - 1;
|
arcScaleSeekBar.Progress = this.nowProgressValue;
|
}
|
};
|
|
//加号
|
this.btnAdd = new IconViewControl(81);
|
btnAdd.CanClick = isAcOpen;
|
btnAdd.UnSelectedImagePath = "AC/Add.png";
|
btnAdd.X = frameAcBack.Width - this.GetPictrueRealSize(81 + 132);
|
btnAdd.Y = btnReduce.Y;
|
frameAcBack.AddChidren(btnAdd);
|
btnAdd.ButtonClickEvent += (sender, e) =>
|
{
|
if (arcScaleSeekBar.Progress < 32)
|
{
|
this.nowProgressValue = arcScaleSeekBar.Progress + 1;
|
arcScaleSeekBar.Progress = this.nowProgressValue;
|
}
|
};
|
|
//℃
|
var btnUint = new NormalViewControl(100, 66, true);
|
btnUint.Y = this.GetPictrueRealSize(366);
|
btnUint.Gravity = Gravity.CenterHorizontal;
|
btnUint.TextAlignment = TextAlignment.Center;
|
btnUint.Text = "℃";
|
btnUint.TextSize = 18;
|
frameAcBack.AddChidren(btnUint);
|
|
//送风没有温度的概念
|
if (deviceAc.currentSystemMode == 7)
|
{
|
//颜色变更
|
arcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor);
|
arcScaleSeekBar.IsClickable = false;
|
this.btnReduce.CanClick = false;
|
this.btnAdd.CanClick = false;
|
}
|
|
//是否启用摆风
|
int IconSpace = Application.GetRealWidth(156);
|
int YY = frameAcBack.Bottom + Application.GetRealHeight(69);
|
int XX = Application.GetRealWidth(207);
|
|
//扫风模式(第一个图标)
|
var btnFanSwingMode = new IconViewControl(81);
|
if (deviceAc.UseSwingFunction)
|
{
|
IconSpace = Application.GetRealWidth(109);
|
XX = Application.GetRealWidth(156);
|
|
btnFanSwingMode.X = XX;
|
btnFanSwingMode.Y = YY;
|
btnFanSwingMode.UnSelectedImagePath = DeviceAcDetailCardMethord.GetFanSwingModeUnSelectedImagePathByFanSwingModeId(deviceAc.currentFanSwingMode);
|
btnFanSwingMode.SelectedImagePath = DeviceAcDetailCardMethord.GetFanSwingModeSelectedImagePathByFanSwingModeId(deviceAc.currentFanSwingMode);
|
btnFanSwingMode.IsSelected = isAcOpen;
|
frameWhiteBack.AddChidren(btnFanSwingMode);
|
btnFanSwingMode.ButtonClickEvent += (sender, e) =>
|
{
|
//空调打开状态才能点击
|
if (DeviceAcDetailCardMethord.IsOpen(deviceAc) == true)
|
{
|
//选择摆风
|
this.SelectFanSwing(frameWhiteBack);
|
}
|
};
|
|
XX = btnFanSwingMode.Right + IconSpace;
|
}
|
this.listControl.Add(btnFanSwingMode);
|
|
//空调模式(第二个图标)
|
var btnModel = new IconViewControl(81);
|
btnModel.X = XX;
|
btnModel.Y = YY;
|
btnModel.UnSelectedImagePath = DeviceAcDetailCardMethord.GetModeUnSelectedImagePathByModeId(deviceAc.currentSystemMode);
|
btnModel.SelectedImagePath = DeviceAcDetailCardMethord.GetModeSelectedImagePathByModeId(deviceAc.currentSystemMode);
|
btnModel.IsSelected = isAcOpen;
|
frameWhiteBack.AddChidren(btnModel);
|
XX = btnModel.Right + IconSpace;
|
this.listControl.Add(btnModel);
|
btnModel.ButtonClickEvent += (sender, e) =>
|
{
|
//空调打开状态才能点击
|
if (DeviceAcDetailCardMethord.IsOpen(deviceAc) == true)
|
{
|
//选择模式
|
this.SelectAcModel(frameWhiteBack);
|
}
|
};
|
|
//开关(第三个图标)
|
var btnSwitch = new IconViewControl(81);
|
btnSwitch.X = XX;
|
btnSwitch.Y = YY;
|
btnSwitch.UnSelectedImagePath = "AC/OpenOrClose.png";
|
btnSwitch.SelectedImagePath = "AC/OpenOrCloseSelected.png";
|
btnSwitch.IsSelected = isAcOpen;
|
frameWhiteBack.AddChidren(btnSwitch);
|
XX = btnSwitch.Right + IconSpace;
|
this.listControl.Add(btnSwitch);
|
btnSwitch.ButtonClickEvent += (sender, e) =>
|
{
|
this.SetSwitchComand(!btnSwitch.IsSelected);
|
};
|
|
//风速模式(第四个图标)
|
var btnFanMode = new IconViewControl(81);
|
btnFanMode.X = XX;
|
btnFanMode.Y = YY;
|
btnFanMode.UnSelectedImagePath = DeviceAcDetailCardMethord.GetFanModeUnSelectedImagePathByFanModeId(deviceAc.currentFanMode);
|
btnFanMode.SelectedImagePath = DeviceAcDetailCardMethord.GetFanModeSelectedImagePathByFanModeId(deviceAc.currentFanMode);
|
btnFanMode.IsSelected = isAcOpen;
|
frameWhiteBack.AddChidren(btnFanMode);
|
this.listControl.Add(btnFanMode);
|
btnFanMode.ButtonClickEvent += (sender, e) =>
|
{
|
//空调打开状态才能点击
|
if (DeviceAcDetailCardMethord.IsOpen(deviceAc) == true)
|
{
|
//选择模式
|
this.SelectAcWindSpeed(frameWhiteBack);
|
}
|
};
|
|
//初始化空调控件事件
|
this.InitAcControlEvent();
|
}
|
|
/// <summary>
|
/// 初始化空调控件事件
|
/// </summary>
|
private void InitAcControlEvent()
|
{
|
//滑动过程中
|
int oldProgressValue = arcScaleSeekBar.Progress;//之前的值
|
arcScaleSeekBar.OnStopTrackingTouchEvent += (send2, value) =>
|
{
|
nowProgressValue = value;
|
};
|
|
//开一个线程,监视是否滑动的滑动条,每秒检测一次
|
HdlThreadLogic.Current.RunThread(() =>
|
{
|
int timeCount = 0;
|
while (this.Parent != null)
|
{
|
if (this.canSetProgress == false)
|
{
|
//网关没有回复前,不再发送
|
timeCount++;
|
if (timeCount <= 3)
|
{
|
System.Threading.Thread.Sleep(1000);
|
continue;
|
}
|
//如果3秒内还没有接收到数据的话,可以继续发送
|
}
|
//计数置空
|
timeCount = 0;
|
|
if (nowProgressValue == oldProgressValue)
|
{
|
//值一样
|
continue;
|
}
|
//发送一次后,不能再次发送
|
this.canSetProgress = false;
|
oldProgressValue = nowProgressValue;
|
//发送进度值给设备
|
this.SetProgressValueToDevice(oldProgressValue);
|
|
System.Threading.Thread.Sleep(1000);
|
}
|
if (nowProgressValue != oldProgressValue)
|
{
|
//当界面关闭时,值还处于不一样时,直接发送
|
this.SetProgressValueToDevice(nowProgressValue);
|
}
|
});
|
}
|
|
/// <summary>
|
/// 发送进度值给设备
|
/// </summary>
|
/// <param name="value"></param>
|
private void SetProgressValueToDevice(int value)
|
{
|
//自己发过去的东西,不需要再次设置(防止进度条来回跳动),只使用一次
|
this.notSetProgress = true;
|
//发送进度值
|
if (deviceAc.currentSystemMode == 3 || deviceAc.currentSystemMode == 8)
|
{
|
//如果住宅是虚拟住宅
|
if (Common.Config.Instance.Home.IsVirtually == true)
|
{
|
this.canSetProgress = true;
|
deviceAc.currentCoolingSetpoint = value;
|
return;
|
}
|
deviceAc.SetCoolingTemperatureAsync(value * 100);
|
}
|
else if (deviceAc.currentSystemMode == 4)
|
{
|
//如果住宅是虚拟住宅
|
if (Common.Config.Instance.Home.IsVirtually == true)
|
{
|
this.canSetProgress = true;
|
deviceAc.currentHeatingSetpoint = value;
|
return;
|
}
|
deviceAc.SetHeatingTemperatureAsync(value * 100);
|
}
|
else if (deviceAc.currentSystemMode == 1)
|
{
|
//如果住宅是虚拟住宅
|
if (Common.Config.Instance.Home.IsVirtually == true)
|
{
|
this.canSetProgress = true;
|
deviceAc.currentAutoSetpoint = value;
|
return;
|
}
|
deviceAc.SetAutoTemperatureAsync(value * 100);
|
}
|
}
|
|
#endregion
|
|
#region ■ 选择摆风(第一个图标)_______________
|
|
/// <summary>
|
/// 选择摆风
|
/// </summary>
|
private void SelectFanSwing(FrameLayout frameWhiteBack)
|
{
|
var form = new DialogCommonForm();
|
//不调用底层的显示界面方法
|
form.AutoLoadShowFormMethord = false;
|
form.AddForm();
|
//白色背景框
|
var frameBack = new FrameLayout();
|
//计算出它的箭头正对着图片中间的X轴
|
frameBack.X = frameWhiteBack.X + this.listControl[0].X - (Application.GetRealWidth(449) - this.listControl[0].Width) / 2;
|
//计算出它的Y轴 35为底部箭头与图标的间距
|
frameBack.Y = topFrameLayout.Bottom + frameWhiteBack.Y + this.listControl[0].Y - Application.GetRealHeight(1089 + 35);
|
frameBack.Height = Application.GetRealHeight(1089);
|
frameBack.Width = Application.GetRealWidth(449);
|
frameBack.BackgroundImagePath = "AC/SwingBackground.png";
|
form.bodyFrameLayout.AddChidren(frameBack);
|
|
//选择摆风
|
var frameTitle = new FrameLayout();
|
frameTitle.Width = frameBack.Width;
|
frameTitle.Height = Application.GetRealHeight(150);
|
frameBack.AddChidren(frameTitle);
|
var btnTitle = new NormalViewControl(frameBack.Width - Application.GetRealWidth(81), Application.GetRealHeight(60), false);
|
btnTitle.X = Application.GetRealWidth(81);
|
btnTitle.Y = Application.GetRealHeight(57);
|
btnTitle.IsBold = true;
|
btnTitle.TextID = R.MyInternationalizationString.SelectSwing;
|
frameTitle.AddChidren(btnTitle);
|
|
//1挡
|
this.InitFanSwingSelectRow(frameBack, AC.FanSwingMode.First,
|
R.MyInternationalizationString.Swing_First, "AC/Swing_1.png", "AC/Swing_1Selected.png");
|
//2挡
|
this.InitFanSwingSelectRow(frameBack, AC.FanSwingMode.Second,
|
R.MyInternationalizationString.Swing_Second, "AC/Swing_2.png", "AC/Swing_2Selected.png");
|
//3挡
|
this.InitFanSwingSelectRow(frameBack, AC.FanSwingMode.Thrid,
|
R.MyInternationalizationString.Swing_Thrid, "AC/Swing_3.png", "AC/Swing_3Selected.png");
|
//4挡
|
this.InitFanSwingSelectRow(frameBack, AC.FanSwingMode.Fourth,
|
R.MyInternationalizationString.Swing_Fourth, "AC/Swing_4.png", "AC/Swing_4Selected.png");
|
//5挡
|
this.InitFanSwingSelectRow(frameBack, AC.FanSwingMode.Fifth,
|
R.MyInternationalizationString.Swing_Fifth, "AC/Swing_5.png", "AC/Swing_5Selected.png");
|
//自动
|
this.InitFanSwingSelectRow(frameBack, AC.FanSwingMode.Auto,
|
R.MyInternationalizationString.Swing_Auto, "AC/Swing_Auto.png", "AC/Swing_AutoSelected.png");
|
}
|
|
/// <summary>
|
/// 初始化摆风选择行控件
|
/// </summary>
|
/// <param name="frameBack"></param>
|
/// <param name="i_div"></param>
|
/// <param name="textId"></param>
|
/// <param name="unSelectPath"></param>
|
/// <param name="selectPath"></param>
|
private void InitFanSwingSelectRow(FrameLayout frameBack, AC.FanSwingMode i_div, int textId,
|
string unSelectPath, string selectPath)
|
{
|
var rowFrame = new FrameRowControl();
|
rowFrame.Y = frameBack.GetChildren(frameBack.ChildrenCount - 1).Bottom;
|
rowFrame.LeftOffset = Application.GetRealWidth(81) - HdlControlResourse.XXLeft;
|
rowFrame.Height = Application.GetRealHeight(150);
|
frameBack.AddChidren(rowFrame);
|
|
//图标
|
var btnIcon = rowFrame.AddLeftIcon(81);
|
btnIcon.UnSelectedImagePath = unSelectPath;
|
btnIcon.SelectedImagePath = selectPath;
|
//显示文字
|
var btnText = rowFrame.AddLeftCaption(Language.StringByID(textId), 288);
|
btnText.TextColor = ZigbeeColor.Current.GXCTextGrayColor;
|
btnText.SelectedTextColor = ZigbeeColor.Current.GXCACSelectedTextColor2;
|
btnText.X = Application.GetRealWidth(173);
|
//底线
|
if (i_div != AC.FanSwingMode.Auto)
|
{
|
var btnLine = rowFrame.AddBottomLine();
|
btnLine.X = Application.GetRealWidth(81);
|
}
|
if (deviceAc.currentFanSwingMode == (int)i_div)
|
{
|
//设置为选择状态
|
btnIcon.IsSelected = true;
|
btnText.IsSelected = true;
|
btnText.IsBold = true;
|
}
|
//按键点击
|
rowFrame.ButtonClickEvent += (sender, e) =>
|
{
|
((DialogCommonForm)frameBack.Parent.Parent).CloseForm();
|
//发送摆风命令
|
this.SetFanSwingComand(i_div);
|
};
|
}
|
|
/// <summary>
|
/// 发送摆风命令
|
/// </summary>
|
/// <param name="fanSwingMode">Fan mode.</param>
|
private void SetFanSwingComand(AC.FanSwingMode fanSwingMode)
|
{
|
//如果住宅为虚拟住宅,则直接修改缓存
|
if (Common.Config.Instance.Home.IsVirtually == true)
|
{
|
deviceAc.currentFanSwingMode = (int)fanSwingMode;
|
var tempDevice = new CommonDevice();
|
tempDevice.DeviceStatusReport = new CommonDevice.DeviceStatusReportData() { CluterID = 514 };
|
tempDevice.DeviceStatusReport.AttriBute = new List<CommonDevice.AttributeDataObj>() { new CommonDevice.AttributeDataObj() { AttributeId = 4096 } };
|
this.CheckResponeResultStatu(ReceiveComandDiv.A设备属性上报, tempDevice);
|
return;
|
}
|
var oldModel = (AC.FanSwingMode)deviceAc.currentFanSwingMode;
|
if (oldModel == fanSwingMode)
|
{
|
//选择的是同一个
|
return;
|
}
|
//检测是否获取网关反馈的结果,如果网关没有回复,则会弹出消息
|
this.StartCheckResponeResult(this.listControl, (result) =>
|
{
|
if (result == true)
|
{
|
//接收到网关的回复
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
listControl[0].SelectedImagePath = DeviceAcDetailCardMethord.GetFanSwingModeSelectedImagePathByFanSwingMode(fanSwingMode);
|
listControl[0].UnSelectedImagePath = DeviceAcDetailCardMethord.GetFanSwingModeUnSelectedImagePathByFanSwingMode(fanSwingMode);
|
});
|
}
|
});
|
|
deviceAc.SetFanSwingAsyncMode(fanSwingMode);
|
}
|
|
#endregion
|
|
#region ■ 选择模式(第二个图标)_______________
|
|
/// <summary>
|
/// 选择模式
|
/// </summary>
|
private void SelectAcModel(FrameLayout frameWhiteBack)
|
{
|
//获取模式菜单个数
|
int menuCount = this.GetSupportModelMenuCount();
|
if (menuCount == 0)
|
{
|
//空调模式为空,请先配置
|
this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.AC_Model_None));
|
return;
|
}
|
int frameBackHeight = 183 + menuCount * 150;
|
|
var form = new DialogCommonForm();
|
//不调用底层的显示界面方法
|
form.AutoLoadShowFormMethord = false;
|
form.AddForm();
|
//白色背景框
|
var frameBack = new FrameLayout();
|
//计算出它的箭头正对着图片中间的X轴
|
frameBack.X = frameWhiteBack.X + this.listControl[1].X - (Application.GetRealWidth(449) - this.listControl[1].Width) / 2;
|
//计算出它的Y轴 35为底部箭头与图标的间距
|
frameBack.Y = topFrameLayout.Bottom + frameWhiteBack.Y + this.listControl[1].Y - Application.GetRealHeight(frameBackHeight + 35);
|
frameBack.Height = Application.GetRealHeight(frameBackHeight);
|
frameBack.Width = Application.GetRealWidth(449);
|
frameBack.BackgroundImagePath = "AC/SelectedModeBG.png";
|
form.bodyFrameLayout.AddChidren(frameBack);
|
|
//选择模式
|
var frameTitle = new FrameLayout();
|
frameTitle.Width = frameBack.Width;
|
frameTitle.Height = Application.GetRealHeight(150);
|
frameBack.AddChidren(frameTitle);
|
var btnTitle = new NormalViewControl(frameBack.Width - Application.GetRealWidth(81), Application.GetRealHeight(60), false);
|
btnTitle.X = Application.GetRealWidth(81);
|
btnTitle.Y = Application.GetRealHeight(57);
|
btnTitle.IsBold = true;
|
btnTitle.TextID = R.MyInternationalizationString.SelectMode;
|
frameTitle.AddChidren(btnTitle);
|
|
if (deviceAc.listSupportMode[4] == 1)
|
{
|
//自动
|
this.InitAcModelSelectRow(frameBack, AC.AcMode.Auto,
|
R.MyInternationalizationString.Mode_Auto, "AC/Mode_Auto.png", "AC/Mode_AutoSelected.png", ZigbeeColor.Current.GXCTextBlackColor, frameBack.ChildrenCount != menuCount);
|
}
|
if (deviceAc.listSupportMode[0] == 1)
|
{
|
//制冷
|
this.InitAcModelSelectRow(frameBack, AC.AcMode.Cool,
|
R.MyInternationalizationString.Mode_Cool, "AC/Mode_Cool.png", "AC/Mode_CoolSelected.png", ZigbeeColor.Current.GXCACSelectedTextColor_Cool, frameBack.ChildrenCount != menuCount);
|
}
|
if (deviceAc.listSupportMode[1] == 1)
|
{
|
//制热
|
this.InitAcModelSelectRow(frameBack, AC.AcMode.Heat,
|
R.MyInternationalizationString.Mode_Heat, "AC/Mode_Heat.png", "AC/Mode_HeatSelected.png", ZigbeeColor.Current.GXCACSelectedTextColor_Heat, frameBack.ChildrenCount != menuCount);
|
}
|
if (deviceAc.listSupportMode[3] == 1)
|
{
|
//除湿
|
this.InitAcModelSelectRow(frameBack, AC.AcMode.Dry,
|
R.MyInternationalizationString.Mode_Dry, "AC/Mode_Dry.png", "AC/Mode_DrySelected.png", ZigbeeColor.Current.GXCACSelectedTextColor_Dry, frameBack.ChildrenCount != menuCount);
|
}
|
if (deviceAc.listSupportMode[2] == 1)
|
{
|
//送风
|
this.InitAcModelSelectRow(frameBack, AC.AcMode.FanOnly,
|
R.MyInternationalizationString.Mode_FanOnly, "AC/Mode_Fan.png", "AC/Mode_FanSelected.png", ZigbeeColor.Current.GXCACSelectedTextColor_Fan, frameBack.ChildrenCount != menuCount);
|
}
|
}
|
|
/// <summary>
|
/// 初始化模式选择行控件
|
/// </summary>
|
/// <param name="frameBack"></param>
|
/// <param name="i_div"></param>
|
/// <param name="textId"></param>
|
/// <param name="unSelectPath"></param>
|
/// <param name="selectPath"></param>
|
private void InitAcModelSelectRow(FrameLayout frameBack, AC.AcMode i_div, int textId,
|
string unSelectPath, string selectPath, uint selectColor, bool addLine)
|
{
|
var rowFrame = new FrameRowControl();
|
rowFrame.Y = frameBack.GetChildren(frameBack.ChildrenCount - 1).Bottom;
|
rowFrame.LeftOffset = Application.GetRealWidth(81) - HdlControlResourse.XXLeft;
|
rowFrame.Height = Application.GetRealHeight(150);
|
frameBack.AddChidren(rowFrame);
|
|
//图标
|
var btnIcon = rowFrame.AddLeftIcon(81);
|
btnIcon.UnSelectedImagePath = unSelectPath;
|
btnIcon.SelectedImagePath = selectPath;
|
//显示文字
|
var btnText = rowFrame.AddLeftCaption(Language.StringByID(textId), 288);
|
btnText.TextColor = ZigbeeColor.Current.GXCTextGrayColor;
|
btnText.SelectedTextColor = selectColor;
|
btnText.X = Application.GetRealWidth(173);
|
//底线
|
if (addLine == true)
|
{
|
var btnLine = rowFrame.AddBottomLine();
|
btnLine.X = Application.GetRealWidth(81);
|
}
|
if (deviceAc.currentSystemMode == (int)i_div)
|
{
|
//设置为选择状态
|
btnIcon.IsSelected = true;
|
btnText.IsSelected = true;
|
btnText.IsBold = true;
|
}
|
//按键点击
|
rowFrame.ButtonClickEvent += (sender, e) =>
|
{
|
((DialogCommonForm)frameBack.Parent.Parent).CloseForm();
|
//发送模式命令
|
this.SetAcModelComand(i_div);
|
};
|
}
|
|
/// <summary>
|
/// 发送模式命令
|
/// </summary>
|
/// <param name="mode">mode.</param>
|
private void SetAcModelComand(AC.AcMode mode)
|
{
|
var oldModel = (AC.AcMode)deviceAc.currentSystemMode;
|
if (oldModel == mode)
|
{
|
//选择的是同一个
|
return;
|
}
|
|
//如果住宅为虚拟住宅,则直接修改缓存
|
if (Common.Config.Instance.Home.IsVirtually == true)
|
{
|
deviceAc.currentSystemMode = (int)mode;
|
var tempDevice = new CommonDevice();
|
tempDevice.DeviceStatusReport = new CommonDevice.DeviceStatusReportData() { CluterID = 513 };
|
tempDevice.DeviceStatusReport.AttriBute = new List<CommonDevice.AttributeDataObj>() { new CommonDevice.AttributeDataObj() { AttributeId = 28 } };
|
this.CheckResponeResultStatu(ReceiveComandDiv.A设备属性上报, tempDevice);
|
//送风的时候,没有温度的概念
|
if (mode == AC.AcMode.FanOnly)
|
{
|
//加减不可以点击
|
btnAdd.CanClick = false;
|
btnReduce.CanClick = false;
|
}
|
//如果原来的状态是送风的话
|
else if (oldModel == AC.AcMode.FanOnly)
|
{
|
//加减可以点击
|
btnAdd.CanClick = true;
|
btnReduce.CanClick = true;
|
}
|
return;
|
}
|
|
//检测是否获取网关反馈的结果,如果网关没有回复,则会弹出消息
|
this.StartCheckResponeResult(this.listControl, (result) =>
|
{
|
if (result == true)
|
{
|
//接收到网关回复
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
listControl[1].SelectedImagePath = DeviceAcDetailCardMethord.GetModeSelectedImagePathByMode(mode);
|
listControl[1].UnSelectedImagePath = DeviceAcDetailCardMethord.GetModeUnSelectedImagePathByMode(mode);
|
|
//送风的时候,没有温度的概念
|
if (mode == AC.AcMode.FanOnly)
|
{
|
//颜色变更
|
arcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor);
|
arcScaleSeekBar.IsClickable = false;
|
//加减不可以点击
|
btnAdd.CanClick = false;
|
btnReduce.CanClick = false;
|
}
|
else if (oldModel == AC.AcMode.FanOnly)
|
{
|
//如果原来的状态是送风的话
|
arcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCArcScaleSeekBarStartColor, ZigbeeColor.Current.GXCArcScaleSeekBarEndColor);
|
arcScaleSeekBar.IsClickable = true;
|
//加减可以点击
|
btnAdd.CanClick = true;
|
btnReduce.CanClick = true;
|
}
|
});
|
}
|
});
|
deviceAc.SetSystemModeAsync(mode);
|
}
|
|
/// <summary>
|
/// 获取模式菜单个数
|
/// </summary>
|
/// <returns></returns>
|
private int GetSupportModelMenuCount()
|
{
|
int count = 0;
|
foreach (var m in deviceAc.listSupportMode)
|
{
|
if (m == 1)
|
{
|
count++;
|
}
|
}
|
return count;
|
}
|
|
#endregion
|
|
#region ■ 开关按钮(第三个图标)_______________
|
|
/// <summary>
|
/// 发送开关命令
|
/// </summary>
|
/// <param name="isOpen"></param>
|
private void SetSwitchComand(bool isOpen)
|
{
|
//如果住宅为虚拟住宅,则直接修改缓存
|
if (Common.Config.Instance.Home.IsVirtually == true)
|
{
|
deviceAc.currentSystemMode = isOpen == true ? 3 : 0;
|
var tempDevice = new CommonDevice();
|
tempDevice.DeviceStatusReport = new CommonDevice.DeviceStatusReportData() { CluterID = 513 };
|
tempDevice.DeviceStatusReport.AttriBute = new List<CommonDevice.AttributeDataObj>() { new CommonDevice.AttributeDataObj() { AttributeId = 28 } };
|
this.CheckResponeResultStatu(ReceiveComandDiv.A设备属性上报, tempDevice);
|
//加减是否可以点击
|
btnAdd.CanClick = isOpen;
|
btnReduce.CanClick = isOpen;
|
return;
|
}
|
|
//检测是否获取网关反馈的结果,如果网关没有回复,则会弹出消息
|
this.StartCheckResponeResult(this.listControl, (result) =>
|
{
|
//接收到网关回复
|
if (result == true)
|
{
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
//那四个图标变更
|
this.listControl[0].IsSelected = isOpen;
|
this.listControl[1].IsSelected = isOpen;
|
this.listControl[2].IsSelected = isOpen;
|
this.listControl[3].IsSelected = isOpen;
|
if (isOpen == true)
|
{
|
//颜色变更
|
arcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCArcScaleSeekBarStartColor, ZigbeeColor.Current.GXCArcScaleSeekBarEndColor);
|
arcScaleSeekBar.IsClickable = true;
|
//加减可以点击
|
btnAdd.CanClick = true;
|
btnReduce.CanClick = true;
|
}
|
else
|
{
|
//颜色变更
|
arcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor);
|
arcScaleSeekBar.IsClickable = false;
|
//加减不可以点击
|
btnAdd.CanClick = false;
|
btnReduce.CanClick = false;
|
}
|
});
|
}
|
});
|
|
if (isOpen == true)
|
{
|
deviceAc.Open();
|
}
|
else
|
{
|
deviceAc.Close();
|
}
|
}
|
|
#endregion
|
|
#region ■ 选择风速(第四个图标)_______________
|
|
/// <summary>
|
/// 选择风速
|
/// </summary>
|
private void SelectAcWindSpeed(FrameLayout frameWhiteBack)
|
{
|
var form = new DialogCommonForm();
|
//不调用底层的显示界面方法
|
form.AutoLoadShowFormMethord = false;
|
form.AddForm();
|
//白色背景框
|
var frameBack = new FrameLayout();
|
//计算出它的箭头正对着图片中间的X轴
|
frameBack.X = frameWhiteBack.X + this.listControl[3].X - (Application.GetRealWidth(449) - this.listControl[3].Width) / 2;
|
//计算出它的Y轴 35为底部箭头与图标的间距
|
frameBack.Y = topFrameLayout.Bottom + frameWhiteBack.Y + this.listControl[3].Y - Application.GetRealHeight(625 + 35);
|
frameBack.Height = Application.GetRealHeight(625);
|
frameBack.Width = Application.GetRealWidth(449);
|
frameBack.BackgroundImagePath = "AC/SelectedFanModeBG.png";
|
form.bodyFrameLayout.AddChidren(frameBack);
|
|
//选择风速
|
var frameTitle = new FrameLayout();
|
frameTitle.Width = frameBack.Width;
|
frameTitle.Height = Application.GetRealHeight(150);
|
frameBack.AddChidren(frameTitle);
|
var btnTitle = new NormalViewControl(frameBack.Width - Application.GetRealWidth(81), Application.GetRealHeight(60), false);
|
btnTitle.X = Application.GetRealWidth(81);
|
btnTitle.Y = Application.GetRealHeight(57);
|
btnTitle.IsBold = true;
|
btnTitle.TextID = R.MyInternationalizationString.SelectFanMode;
|
frameTitle.AddChidren(btnTitle);
|
|
//低风
|
this.InitAcWindSpeedSelectRow(frameBack, AC.FanMode.Low,
|
R.MyInternationalizationString.Fan_Low, "AC/Fan_Low.png", "AC/Fan_LowSelected.png");
|
//中风
|
this.InitAcWindSpeedSelectRow(frameBack, AC.FanMode.Medium,
|
R.MyInternationalizationString.Fan_Middle, "AC/Fan_Middle.png", "AC/Fan_MiddleSelected.png");
|
//高风
|
this.InitAcWindSpeedSelectRow(frameBack, AC.FanMode.High,
|
R.MyInternationalizationString.Fan_Height, "AC/Fan_Height.png", "AC/Fan_HeightSelected.png");
|
}
|
|
/// <summary>
|
/// 初始化风速选择行控件
|
/// </summary>
|
/// <param name="frameBack"></param>
|
/// <param name="i_div"></param>
|
/// <param name="textId"></param>
|
/// <param name="unSelectPath"></param>
|
/// <param name="selectPath"></param>
|
private void InitAcWindSpeedSelectRow(FrameLayout frameBack, AC.FanMode i_div, int textId,
|
string unSelectPath, string selectPath)
|
{
|
var rowFrame = new FrameRowControl();
|
rowFrame.Y = frameBack.GetChildren(frameBack.ChildrenCount - 1).Bottom;
|
rowFrame.LeftOffset = Application.GetRealWidth(81) - HdlControlResourse.XXLeft;
|
rowFrame.Height = Application.GetRealHeight(150);
|
frameBack.AddChidren(rowFrame);
|
|
//图标
|
var btnIcon = rowFrame.AddLeftIcon(81);
|
btnIcon.UnSelectedImagePath = unSelectPath;
|
btnIcon.SelectedImagePath = selectPath;
|
//显示文字
|
var btnText = rowFrame.AddLeftCaption(Language.StringByID(textId), 288);
|
btnText.TextColor = ZigbeeColor.Current.GXCTextGrayColor;
|
btnText.SelectedTextColor = ZigbeeColor.Current.GXCACSelectedTextColor_FanModel;
|
btnText.X = Application.GetRealWidth(173);
|
//底线
|
if (i_div != AC.FanMode.High)
|
{
|
var btnLine = rowFrame.AddBottomLine();
|
btnLine.X = Application.GetRealWidth(81);
|
}
|
if (deviceAc.currentFanMode == (int)i_div)
|
{
|
//设置为选择状态
|
btnIcon.IsSelected = true;
|
btnText.IsSelected = true;
|
btnText.IsBold = true;
|
}
|
//按键点击
|
rowFrame.ButtonClickEvent += (sender, e) =>
|
{
|
((DialogCommonForm)frameBack.Parent.Parent).CloseForm();
|
|
//如果住宅为虚拟住宅,则直接修改缓存
|
if (Common.Config.Instance.Home.IsVirtually == true)
|
{
|
deviceAc.currentFanMode = (int)i_div;
|
var tempDevice = new CommonDevice();
|
tempDevice.DeviceStatusReport = new CommonDevice.DeviceStatusReportData() { CluterID = 514 };
|
tempDevice.DeviceStatusReport.AttriBute = new List<CommonDevice.AttributeDataObj>() { new CommonDevice.AttributeDataObj() { AttributeId = 0 } };
|
this.CheckResponeResultStatu(ReceiveComandDiv.A设备属性上报, tempDevice);
|
return;
|
}
|
//发送风速命令
|
this.SetAcWindSpeedComand(i_div);
|
};
|
}
|
|
/// <summary>
|
/// 发送风速命令
|
/// </summary>
|
/// <param name="mode">mode.</param>
|
private void SetAcWindSpeedComand(AC.FanMode mode)
|
{
|
var oldModel = (AC.FanMode)deviceAc.currentFanMode;
|
if (oldModel == mode)
|
{
|
//选择的是同一个
|
return;
|
}
|
//检测是否获取网关反馈的结果,如果网关没有回复,则会弹出消息
|
this.StartCheckResponeResult(this.listControl, (result) =>
|
{
|
//接收到网关回复
|
if (result == true)
|
{
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
listControl[3].SelectedImagePath = DeviceAcDetailCardMethord.GetFanModeSelectedImagePathByFanMode(mode);
|
listControl[3].UnSelectedImagePath = DeviceAcDetailCardMethord.GetFanModeSelectedImagePathByFanMode(mode);
|
});
|
}
|
});
|
|
deviceAc.SetFanModeAsync(mode);
|
}
|
|
#endregion
|
|
#region ■ 是否获取网关反馈的结果_____________
|
|
/// <summary>
|
/// 检测网关的反馈结果(属性上报的对象:device.DeviceStatusReport)
|
/// </summary>
|
/// <param name="comandDiv">命令区分</param>
|
/// <param name="report">上报数据</param>
|
/// <returns></returns>
|
public override bool CheckResponeResultStatu(ReceiveComandDiv comandDiv, CommonDevice report)
|
{
|
if (comandDiv == ReceiveComandDiv.A设备属性上报)
|
{
|
if (report.DeviceStatusReport.CluterID == 513)
|
{
|
var attriButeList = report.DeviceStatusReport.AttriBute;
|
foreach (var attList in attriButeList)
|
{
|
if (attList.AttributeId == 0)
|
{
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
//设置状态文字 当前室温
|
this.SetStatuText(deviceAc.currentLocalTemperature + "℃");
|
});
|
}
|
else if (attList.AttributeId == 17)
|
{
|
if (deviceAc.currentSystemMode == 3 || deviceAc.currentSystemMode == 8)
|
{
|
//允许同步进度值时才同步
|
if (this.notSetProgress == false)
|
{
|
//制冷
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
arcScaleSeekBar.Progress = deviceAc.currentCoolingSetpoint;
|
});
|
}
|
//接收到数据反馈
|
this.canSetProgress = true;
|
//状态还原(只使用一次)
|
this.notSetProgress = false;
|
}
|
}
|
else if (attList.AttributeId == 18)
|
{
|
if (deviceAc.currentSystemMode == 4)
|
{
|
//允许同步进度值时才同步
|
if (this.notSetProgress == false)
|
{
|
//制热
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
arcScaleSeekBar.Progress = deviceAc.currentHeatingSetpoint;
|
});
|
}
|
//接收到数据反馈
|
this.canSetProgress = true;
|
//状态还原(只使用一次)
|
this.notSetProgress = false;
|
}
|
}
|
else if (attList.AttributeId == 4096)
|
{
|
if (deviceAc.currentSystemMode == 1)
|
{
|
//允许同步进度值时才同步
|
if (this.notSetProgress == false)
|
{
|
//自动
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
arcScaleSeekBar.Progress = deviceAc.currentAutoSetpoint;
|
});
|
}
|
//接收到数据反馈
|
this.canSetProgress = true;
|
//状态还原(只使用一次)
|
this.notSetProgress = false;
|
}
|
}
|
else if (attList.AttributeId == 28)
|
{
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
//如果是关闭空调的话,直接变暗即可
|
if (deviceAc.currentSystemMode == 0)
|
{
|
if (this.listControl[1].IsSelected == true)
|
{
|
this.listControl[0].IsSelected = false;
|
this.listControl[1].IsSelected = false;
|
this.listControl[2].IsSelected = false;
|
this.listControl[3].IsSelected = false;
|
}
|
arcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor);
|
//设置状态文字 关闭
|
this.SetStatuText(Language.StringByID(R.MyInternationalizationString.Close));
|
return;
|
}
|
else if (deviceAc.currentSystemMode == 1 || deviceAc.currentSystemMode == 3 ||
|
deviceAc.currentSystemMode == 4 || deviceAc.currentSystemMode == 7 ||
|
deviceAc.currentSystemMode == 8)
|
{
|
if (this.listControl[1].IsSelected == false)
|
{
|
this.listControl[0].IsSelected = true;
|
this.listControl[1].IsSelected = true;
|
this.listControl[2].IsSelected = true;
|
this.listControl[3].IsSelected = true;
|
}
|
arcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCArcScaleSeekBarStartColor, ZigbeeColor.Current.GXCArcScaleSeekBarEndColor);
|
}
|
this.listControl[1].SelectedImagePath = DeviceAcDetailCardMethord.GetModeSelectedImagePathByModeId(deviceAc.currentSystemMode);
|
this.listControl[1].UnSelectedImagePath = DeviceAcDetailCardMethord.GetModeUnSelectedImagePathByModeId(deviceAc.currentSystemMode);
|
this.btnNowModeView.Text = DeviceAcDetailCardMethord.GetModeNameByModeId(deviceAc.currentSystemMode);
|
arcScaleSeekBar.Progress = DeviceAcDetailCardMethord.GetCurrentModeTemperature(deviceAc);
|
arcScaleSeekBar.IsClickable = DeviceAcDetailCardMethord.IsOpen(deviceAc);
|
//设置状态文字 当前室温
|
this.SetStatuText(deviceAc.currentLocalTemperature + "℃");
|
//送风没有温度的概念
|
if (deviceAc.currentSystemMode == 7)
|
{
|
//颜色变更
|
arcScaleSeekBar.SetProgressBarColors(ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor, ZigbeeColor.Current.GXCWaveSeekBarUnSelectedColor);
|
arcScaleSeekBar.IsClickable = false;
|
}
|
});
|
//已经接收到网关的反馈
|
return true;
|
}
|
else if (attList.AttributeId == 4097)
|
{
|
//清理滤网
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
frameClrean.Visible = deviceAc.CleanStatu;
|
});
|
}
|
}
|
}
|
else if (report.DeviceStatusReport.CluterID == 514)
|
{
|
var attriButeList = report.DeviceStatusReport.AttriBute;
|
foreach (var attList in attriButeList)
|
{
|
if (attList.AttributeId == 0)
|
{
|
//风速
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
if (this.listControl[3].IsSelected == false)
|
{
|
this.listControl[3].IsSelected = true;
|
}
|
this.listControl[3].SelectedImagePath = DeviceAcDetailCardMethord.GetFanModeSelectedImagePathByFanModeId(deviceAc.currentFanMode);
|
this.listControl[3].UnSelectedImagePath = DeviceAcDetailCardMethord.GetFanModeUnSelectedImagePathByFanModeId(deviceAc.currentFanMode);
|
});
|
//已经接收到网关的反馈
|
return true;
|
}
|
else if (attList.AttributeId == 4096)
|
{
|
//扫风
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
if (this.listControl[0].IsSelected == false)
|
{
|
this.listControl[0].IsSelected = true;
|
}
|
this.listControl[0].SelectedImagePath = DeviceAcDetailCardMethord.GetFanSwingModeSelectedImagePathByFanSwingModeId(deviceAc.currentFanSwingMode);
|
this.listControl[0].UnSelectedImagePath = DeviceAcDetailCardMethord.GetFanSwingModeUnSelectedImagePathByFanSwingModeId(deviceAc.currentFanSwingMode);
|
});
|
//已经接收到网关的反馈
|
return true;
|
}
|
}
|
}
|
}
|
return false;
|
}
|
|
#endregion
|
}
|
}
|