using System;
|
using Shared.Common;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.Device.AC
|
{
|
public class ACControl : FrameLayout,ZigBee.Common.IStatus
|
{
|
#region ◆ 变量__________________________
|
/// <summary>
|
/// The action.
|
/// </summary>
|
public Action action;
|
///// <summary>
|
///// The top view.
|
///// </summary>
|
private CommonForm.TopFrameLayout top;
|
/// <summary>
|
/// 更多设置
|
/// </summary>
|
private Button moreBtn;
|
/// <summary>
|
/// 传过来的设备
|
/// </summary>
|
private DeviceUI device;
|
/// <summary>
|
/// 传过来的ac
|
/// </summary>
|
private ZigBee.Device.AC ac;
|
/// <summary>
|
/// 传过来的房间
|
/// </summary>
|
private Shared.Common.Room room;
|
/// <summary>
|
/// The middle fl.
|
/// </summary>
|
private FrameLayout midFL;
|
/// <summary>
|
/// 收藏按钮
|
/// </summary>
|
private Button collectionBtn;
|
/// <summary>
|
/// 当前室内温度
|
/// </summary>
|
private Button indoorTemperatureBtn;
|
/// <summary>
|
/// 当前模式
|
/// </summary>
|
private Button currentModeBtn;
|
/// <summary>
|
/// 当前温度
|
/// </summary>
|
private Button currentTemperatureBtn;
|
/// <summary>
|
/// 添加温度
|
/// </summary>
|
private Button addTemperatureBtn;
|
/// <summary>
|
/// 降低温度
|
/// </summary>
|
private Button reduceTemperatureBtn;
|
/// <summary>
|
/// 空调模式
|
/// </summary>
|
private Button modeBtn;
|
/// <summary>
|
/// 开启或关闭
|
/// </summary>
|
private Button switchBtn;
|
/// <summary>
|
/// 风速模式
|
/// </summary>
|
private Button fanModeBtn;
|
/// <summary>
|
/// 风速选择视图
|
/// </summary>
|
private Dialog fanModeDialog;
|
/// <summary>
|
/// 模式选择视图
|
/// </summary>
|
private Dialog acModeDialog;
|
|
|
#endregion
|
|
#region ◆ 接口__________________________
|
/// <summary>
|
/// 处理变化事件 --将弃用 改用DeviceInfoChange()
|
/// </summary>
|
/// <returns>The changed.</returns>
|
/// <param name="common">Common.</param>
|
public void Changed(CommonDevice common)
|
{
|
|
}
|
/// <summary>
|
/// Changeds the IL ogic status.
|
/// </summary>
|
/// <param name="logic">Logic.</param>
|
public void ChangedILogicStatus(ZigBee.Device.Logic logic)
|
{
|
//throw new NotImplementedException();
|
}
|
/// <summary>
|
/// Changeds the IS cene status.
|
/// </summary>
|
/// <param name="scene">Scene.</param>
|
public void ChangedISceneStatus(Scene scene)
|
{
|
//throw new NotImplementedException();
|
}
|
/// <summary>
|
/// 设备状态更新接口
|
/// <para>type:如果为 DeviceInComingRespon:设备新上报</para>
|
/// <para>type:如果为 IASInfoReport:RemoveDeviceRespon</para>
|
/// <para>type:如果为 DeviceStatusReport:设备上报</para>
|
/// <para>type:如果为 IASInfoReport:IAS安防信息上报</para>
|
/// <para>type:如果为 OnlineStatusChange: 设备在线状态更新</para>
|
/// </summary>
|
/// <param name="common">Common.</param>
|
/// <param name="typeTag">Type tag.</param>
|
public void DeviceInfoChange(CommonDevice common, string typeTag)
|
{
|
if (typeTag == "DeviceStatusReport")
|
{
|
Application.RunOnMainThread(() =>
|
{
|
try
|
{
|
var deviceUI = device;
|
//设备为空
|
if (deviceUI.CommonDevice == null)
|
{
|
return;
|
}
|
//是否为当前设备
|
if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr)
|
{
|
return;
|
}
|
if (deviceUI.CommonDevice.Type == DeviceType.Thermostat)
|
{
|
//Thermostat功能
|
if (common.DeviceStatusReport.CluterID == 513)
|
{
|
var attriButeList = common.DeviceStatusReport.AttriBute;
|
if (attriButeList == null || attriButeList.Count == 0)
|
{
|
return;
|
}
|
ac.DeviceStatusReport = common.DeviceStatusReport;
|
switch (attriButeList[0].AttributeId)
|
{
|
case 0:
|
//此属性表明室内当前的温度 * 100,实际温度为“LocalTemperature / 100”,单位:℃
|
ac.currentLocalTemperature = (attriButeList[0].AttriButeData / 100 > ACControlBase.Temperature_High || attriButeList[0].AttriButeData / 100 < ACControlBase.Temperature_Low) ? attriButeList[0].AttriButeData / 100 : ACControlBase.Temperature_Default;
|
ac.LastDateTime = DateTime.Now;
|
indoorTemperatureBtn.Text = $"{Language.StringByID(R.MyInternationalizationString.IndoorTemperature)} {ac.currentLocalTemperature} ℃";
|
//currentTemperatureBtn.Text = $"{ac.currentLocalTemperature} ℃";
|
break;
|
|
case 17:
|
//此属性表明此设备当前的制冷温度,实际温度为“CoolingSetpoint / 100”,单位:℃。
|
ac.currentCoolingSetpoint = (attriButeList[0].AttriButeData / 100 > ACControlBase.Temperature_High || attriButeList[0].AttriButeData / 100 < ACControlBase.Temperature_Low) ? attriButeList[0].AttriButeData / 100 : ACControlBase.Temperature_Default;
|
ac.LastDateTime = DateTime.Now;
|
break;
|
|
case 18:
|
//此属性表明此设备当前的制热温度,实际温度为“HeatingSetpoint / 100”,单位:℃。
|
ac.currentHeatingSetpoint = (attriButeList[0].AttriButeData / 100 > ACControlBase.Temperature_High || attriButeList[0].AttriButeData / 100 < ACControlBase.Temperature_Low) ? attriButeList[0].AttriButeData / 100 : ACControlBase.Temperature_Default;
|
ac.LastDateTime = DateTime.Now;
|
break;
|
|
case 4096:
|
//此属性表明此设备当前的自动温度,实际温度为“AutoSetpoint / 100”,单位:℃。
|
ac.currentAutoSetpoint = (attriButeList[0].AttriButeData / 100 > ACControlBase.Temperature_High || attriButeList[0].AttriButeData / 100 < ACControlBase.Temperature_Low) ? attriButeList[0].AttriButeData / 100 : ACControlBase.Temperature_Default;
|
ac.LastDateTime = DateTime.Now;
|
break;
|
|
case 28:
|
//此属性描述恒温设备正处于哪种模式
|
//Off = 0 Auto = 1 Cool = 3 Heat = 4 FanOnly = 7 Dry = 8
|
ac.currentSystemMode = attriButeList[0].AttriButeData;
|
ac.LastDateTime = DateTime.Now;
|
if (ac.currentSystemMode == 0)
|
{
|
switchBtn.IsSelected = false;
|
modeBtn.IsSelected = false;
|
modeBtn.SelectedImagePath = ACControlBase.GetModeSelectedImagePathByModeId(ac.currentSystemMode);
|
modeBtn.UnSelectedImagePath = ACControlBase.GetModeUnSelectedImagePathByModeId(ac.currentSystemMode);
|
currentModeBtn.Text = ACControlBase.GetModeNameByModeId(ac.currentSystemMode);
|
}
|
else if (ac.currentSystemMode == 1 || ac.currentSystemMode == 3 || ac.currentSystemMode == 4 || ac.currentSystemMode == 7 || ac.currentSystemMode == 8)
|
{
|
switchBtn.IsSelected = true;
|
modeBtn.IsSelected = true;
|
modeBtn.SelectedImagePath = ACControlBase.GetModeSelectedImagePathByModeId(ac.currentSystemMode);
|
modeBtn.UnSelectedImagePath = ACControlBase.GetModeUnSelectedImagePathByModeId(ac.currentSystemMode);
|
currentModeBtn.Text = ACControlBase.GetModeNameByModeId(ac.currentSystemMode);
|
|
currentTemperatureBtn.Text = $"{ACControlBase.GetCurrentModeTemperature(ac)} ℃";
|
}
|
break;
|
}
|
|
}
|
}
|
//Fan Control功能
|
if (common.DeviceStatusReport.CluterID == 514)
|
{
|
var attriButeList = common.DeviceStatusReport.AttriBute;
|
if (attriButeList == null || attriButeList.Count == 0)
|
{
|
return;
|
}
|
ac.DeviceStatusReport = common.DeviceStatusReport;
|
switch (attriButeList[0].AttributeId)
|
{
|
case 0:
|
//风扇当前的工作模式 1=Low 2=Medium 3=High
|
ac.currentFanMode = attriButeList[0].AttriButeData;
|
ac.LastDateTime = DateTime.Now;
|
fanModeBtn.IsSelected = true;
|
fanModeBtn.SelectedImagePath = ACControlBase.GetFanModeSelectedImagePathByFanModeId(ac.currentFanMode);
|
fanModeBtn.UnSelectedImagePath = ACControlBase.GetFanModeUnSelectedImagePathByFanModeId(ac.currentFanMode);
|
break;
|
}
|
//***新改***设备状态上报中,当CluterID=3,证明设备在线,直接标记
|
//else if ((common as ToggleLight).DeviceStatusReport.CluterID == 3)
|
//{
|
//var light = deviceUI.CommonDevice as ToggleLight;
|
//light.IsOnline = 1;
|
//deviceIMG.IsSelected = light.IsOnline == 1;
|
//light.LastDateTime = DateTime.Now;
|
//}
|
|
}
|
}
|
catch (Exception ex)
|
{
|
System.Console.WriteLine($"Error:{ex.Message}");
|
}
|
});
|
}
|
else if (typeTag == "OnlineStatusChange")
|
{
|
Application.RunOnMainThread(() =>
|
{
|
try
|
{
|
var deviceUI = device;
|
//设备为空
|
if (deviceUI.CommonDevice == null)
|
{
|
return;
|
}
|
//是否为当前设备
|
if (deviceUI.CommonDevice.DeviceEpoint != common.DeviceEpoint || deviceUI.CommonDevice.DeviceAddr != common.DeviceAddr)
|
{
|
return;
|
}
|
if (deviceUI.CommonDevice.Type == DeviceType.Thermostat)
|
{
|
ac = deviceUI.CommonDevice as ZigBee.Device.AC;
|
ac.IsOnline = (common as DimmableLight).IsOnline;
|
ac.LastDateTime = DateTime.Now;
|
}
|
}
|
catch (Exception ex)
|
{
|
System.Console.WriteLine($"Error:{ex.Message}");
|
}
|
});
|
}
|
}
|
|
|
#endregion
|
|
#region ◆ 重写移除_______________________
|
|
/// <summary>
|
/// Removes from parent.
|
/// </summary>
|
public override void RemoveFromParent()
|
{
|
ZbGateway.StatusList.Remove(this);
|
base.RemoveFromParent();
|
}
|
|
#endregion
|
|
#region ◆ 构造方法_______________________
|
/// <summary>
|
/// 构造方法
|
/// </summary>
|
public ACControl()
|
{
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
|
}
|
|
#endregion
|
|
#region ◆ 初始化________________________
|
|
/// <summary>
|
/// 初始化
|
/// </summary>
|
/// <param name="device">Device.</param>
|
/// <param name="room">Room.</param>
|
private void InitAC(DeviceUI device, Common.Room room)
|
{
|
ZbGateway.StatusList.Add(this);
|
this.device = device;
|
this.room = room;
|
this.ac = device.CommonDevice as ZigBee.Device.AC;
|
|
//添加topview
|
AddTopView();
|
//添加midview
|
AddMidview();
|
//绑定事件
|
BindEvent();
|
//收藏
|
InitCollection();
|
|
if (ac.Gateway.IsVirtual)
|
{
|
//发送读取状态命令
|
UserView.UserHomeView.ReadStatus(ac, () =>
|
{
|
ac.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
|
ac.ReadLocalTemperature();
|
ac.ReadCoolingSetpoint();
|
ac.ReadHeatingSetpoint();
|
ac.ReadAutoSetpoint();
|
ac.ReadFanMode();
|
ac.ReadSystemMode();
|
});
|
}
|
else
|
{
|
//防止短时间内多次读取设备状态
|
if ((DateTime.Now - ac.LastDateTime).TotalSeconds > CommonPage.ReadDeviceStatuSpan)
|
{
|
ac.ReadAttri(Cluster_ID.Identify, AttriButeId.Switch);
|
ac.ReadLocalTemperature();
|
ac.ReadCoolingSetpoint();
|
ac.ReadHeatingSetpoint();
|
ac.ReadAutoSetpoint();
|
ac.ReadFanMode();
|
ac.ReadSystemMode();
|
}
|
}
|
|
}
|
|
/// <summary>
|
/// Inits the collection.
|
/// </summary>
|
private void InitCollection()
|
{
|
var dev = Shared.Common.Room.LoveRoomDeviceUIFilePathList.Find((obj) => obj == device.FileName);
|
if (dev == null)
|
{
|
collectionBtn.IsSelected = false;
|
}
|
else
|
{
|
collectionBtn.IsSelected = true;
|
}
|
}
|
|
|
#endregion
|
|
#region ◆ 显示界面_______________________
|
/// <summary>
|
/// 显示界面
|
/// </summary>
|
/// <param name="device">Device.</param>
|
/// <param name="room">Room.</param>
|
public void Show(DeviceUI device, Shared.Common.Room room)
|
{
|
InitAC(device, room);
|
}
|
|
#endregion
|
|
#region ◆ topview_______________________
|
|
/// <summary>
|
/// Adds the top view.
|
/// </summary>
|
private void AddTopView()
|
{
|
top = new CommonForm.TopFrameLayout();
|
AddChidren(top);
|
top.InitTopview();
|
top.backButton.MouseUpEventHandler += (sender, e) =>
|
{
|
RemoveFromParent();
|
};
|
|
AddMoreview();
|
}
|
|
/// <summary>
|
/// Adds the moreview.
|
/// </summary>
|
private void AddMoreview()
|
{
|
moreBtn = new CommonForm.SelectedStatuButton()
|
{
|
X = Application.GetRealWidth(CommonPage.AppRealWidth - 150),
|
Width = Application.GetMinReal(110),
|
Height = Application.GetMinReal(110),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Item/More.png",
|
SelectedImagePath = "Item/MoreSelected.png",
|
};
|
top.topView.AddChidren(moreBtn);
|
}
|
|
/// <summary>
|
/// 更多设置
|
/// </summary>
|
/// <param name="sender">Sender.</param>
|
/// <param name="e">E.</param>
|
private void MoreEvent(object sender, MouseEventArgs e)
|
{
|
var detailInfo = new Device.CommonForm.DeviceDetailInfo { };
|
UserView.HomePage.Instance.AddChidren(detailInfo);
|
UserView.HomePage.Instance.PageIndex += 1;
|
detailInfo.Show(device, room);
|
detailInfo.action = () =>
|
{
|
Show(device, room);
|
};
|
}
|
|
#endregion
|
|
#region ◆ midview_______________________
|
|
/// <summary>
|
/// Adds the midview.
|
/// </summary>
|
private void AddMidview()
|
{
|
midFL = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(CommonPage.AppRealHeight - CommonPage.Navigation_Height),
|
Y = top.Bottom,
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
|
};
|
AddChidren(midFL);
|
|
AddItemview();
|
}
|
|
#endregion
|
|
#region ◆ itemview_______________________
|
/// <summary>
|
/// Adds the itemview.
|
/// </summary>
|
private void AddItemview()
|
{
|
var itemView = new FrameLayout()
|
{
|
Y=Application.GetRealHeight(115),
|
Width = Application.GetRealWidth(965),
|
Height = Application.GetRealHeight(1316),
|
Radius = CommonPage.BigFormRadius,
|
Gravity = Gravity.CenterHorizontal,
|
BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor
|
};
|
midFL.AddChidren(itemView);
|
var deviceView = new FrameLayout()
|
{
|
X = 2,
|
Y = 2,
|
Width = itemView.Width - 4,
|
Height = itemView.Height - Application.GetRealHeight(138),
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
Tag = device
|
};
|
itemView.AddChidren(deviceView);
|
|
collectionBtn = new Button()
|
{
|
X = deviceView.Width - Application.GetRealWidth(130),
|
Y = Application.GetRealHeight(20),
|
Width = Application.GetMinReal(110),
|
Height = Application.GetMinReal(110),
|
UnSelectedImagePath = "Item/Collection.png",
|
SelectedImagePath = "Item/CollectionSelected.png"
|
};
|
deviceView.AddChidren(collectionBtn);
|
|
var deviceName = new Button()
|
{
|
Y = Application.GetRealHeight(50),
|
Height = Application.GetRealHeight(80),
|
Width = Application.GetRealWidth(600),
|
Gravity = Gravity.CenterHorizontal,
|
Text=device.CommonDevice.DeviceEpointName,
|
TextSize=15,
|
TextColor=ZigbeeColor.Current.GXCTextBlackColor
|
};
|
deviceView.AddChidren(deviceName);
|
|
indoorTemperatureBtn = new Button()
|
{
|
Y = deviceName.Bottom,
|
Height = Application.GetRealHeight(80),
|
Width = Application.GetRealWidth(300),
|
Gravity = Gravity.CenterHorizontal,
|
Text = $"{Language.StringByID(R.MyInternationalizationString.IndoorTemperature)} {ac.currentLocalTemperature}°C" ,
|
TextSize = 12,
|
TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor
|
};
|
deviceView.AddChidren(indoorTemperatureBtn);
|
|
var controlBG = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(323),
|
Height = Application.GetMinRealAverage(547),
|
Width = Application.GetMinRealAverage(671),
|
Gravity = Gravity.CenterHorizontal,
|
BackgroundImagePath = "AC/Group.png"
|
};
|
deviceView.AddChidren(controlBG);
|
|
var controlBG2 = new Button()
|
{
|
Y=Application.GetRealHeight(783),
|
Height=Application.GetMinRealAverage(121),
|
Width=Application.GetMinRealAverage(351),
|
UnSelectedImagePath="AC/Path.png",
|
Gravity=Gravity.CenterHorizontal
|
};
|
deviceView.AddChidren(controlBG2);
|
//当前模式
|
currentModeBtn = new Button()
|
{
|
Y = Application.GetRealHeight(187),
|
Height = Application.GetRealHeight(80),
|
Width = Application.GetRealWidth(200),
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
Gravity=Gravity.CenterHorizontal,
|
Text=ACControlBase.GetModeNameByModeId(ac.currentSystemMode)
|
};
|
controlBG.AddChidren(currentModeBtn);
|
//降低温度
|
reduceTemperatureBtn = new Button()
|
{
|
X = Application.GetRealWidth(112),
|
Y = Application.GetRealHeight(268),
|
Width = Application.GetMinRealAverage(80),
|
Height = Application.GetMinRealAverage(80),
|
UnSelectedImagePath = "AC/Reduce.png"
|
};
|
controlBG.AddChidren(reduceTemperatureBtn);
|
|
//温度
|
currentTemperatureBtn = new Button()
|
{
|
//X = Application.GetRealWidth(239),
|
Y = Application.GetRealHeight(248),
|
Width = Application.GetRealWidth(180),
|
Height = Application.GetRealHeight(100),
|
TextColor=ZigbeeColor.Current.GXCTextBlackColor,
|
TextSize=15,
|
Text=$"{ACControlBase.GetCurrentModeTemperature(ac)} °C",
|
Gravity=Gravity.CenterHorizontal
|
};
|
controlBG.AddChidren(currentTemperatureBtn);
|
|
//添加温度
|
addTemperatureBtn = new Button()
|
{
|
X = Application.GetRealWidth(472),
|
Y = Application.GetRealHeight(268),
|
Width = Application.GetMinRealAverage(80),
|
Height = Application.GetMinRealAverage(80),
|
UnSelectedImagePath = "AC/Add.png"
|
};
|
controlBG.AddChidren(addTemperatureBtn);
|
|
//模式
|
modeBtn = new Button()
|
{
|
X = Application.GetRealWidth(207),
|
Y = Application.GetRealHeight(996),
|
Width = Application.GetMinRealAverage(80),
|
Height = Application.GetMinRealAverage(80),
|
UnSelectedImagePath = ACControlBase.GetModeUnSelectedImagePathByModeId(ac.currentSystemMode),
|
SelectedImagePath = ACControlBase.GetModeSelectedImagePathByModeId(ac.currentSystemMode),
|
IsSelected = ACControlBase.IsOpen(ac)
|
};
|
deviceView.AddChidren(modeBtn);
|
|
//开关
|
switchBtn = new Button()
|
{
|
X = Application.GetRealWidth(446),
|
Y = Application.GetRealHeight(996),
|
Width = Application.GetMinRealAverage(80),
|
Height = Application.GetMinRealAverage(80),
|
UnSelectedImagePath = "AC/OpenOrClose.png",
|
SelectedImagePath = "AC/OpenOrCloseSelected.png",
|
IsSelected = ACControlBase.IsOpen(ac)
|
};
|
deviceView.AddChidren(switchBtn);
|
|
//风速
|
fanModeBtn = new Button()
|
{
|
X = Application.GetRealWidth(667),
|
Y = Application.GetRealHeight(996),
|
Width = Application.GetMinRealAverage(80),
|
Height = Application.GetMinRealAverage(80),
|
UnSelectedImagePath = ACControlBase.GetFanModeUnSelectedImagePathByFanModeId(ac.currentFanMode),
|
SelectedImagePath = ACControlBase.GetFanModeSelectedImagePathByFanModeId(ac.currentFanMode),
|
IsSelected = ACControlBase.IsOpen(ac)
|
};
|
deviceView.AddChidren(fanModeBtn);
|
|
var roomBtn = new Button()
|
{
|
X = Application.GetRealWidth(50),
|
Y = Application.GetRealHeight(25) + deviceView.Bottom,
|
Width = Application.GetMinReal(80),
|
Height = Application.GetMinReal(80),
|
UnSelectedImagePath = "Item/Room.png",
|
SelectedImagePath = "Item/RoomSelected.png"
|
};
|
itemView.AddChidren(roomBtn);
|
|
var roomName = new Button()
|
{
|
X = roomBtn.Right + Application.GetRealWidth(20),
|
Y = roomBtn.Y,
|
Width = Application.GetRealWidth(400),
|
Height = Application.GetRealHeight(80),
|
Text = room.Name,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
SelectedTextColor = ZigbeeColor.Current.GXCTextBlueColor
|
};
|
itemView.AddChidren(roomName);
|
}
|
|
#endregion
|
|
#region ◆ 切换风速_______________________
|
|
/// <summary>
|
/// 切换风速
|
/// </summary>
|
/// <param name="sender">Sender.</param>
|
/// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
|
private void ShowChangeFan_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs)
|
{
|
int fanItem_X = 80;
|
int fanItem_Height = 150;
|
int fanItem_Width = 449;
|
|
fanModeDialog = new Dialog();
|
fanModeDialog.Show();
|
var closeBGview = new FrameLayout();
|
fanModeDialog.AddChidren(closeBGview);
|
closeBGview.MouseUpEventHandler += (send1, e1) =>
|
{
|
fanModeDialog.Close();
|
};
|
|
var changeFanModeBG = new Button()
|
{
|
X = Application.GetRealWidth(553),
|
Y = Application.GetRealHeight(655),
|
Height = Application.GetRealHeight(625),
|
Width = Application.GetRealWidth(fanItem_Width),
|
UnSelectedImagePath = "AC/SelectedFanModeBG.png"
|
};
|
closeBGview.AddChidren(changeFanModeBG);
|
|
var changeFanModeFL = new FrameLayout()
|
{
|
X = Application.GetRealWidth(553),
|
Y = Application.GetRealHeight(655),
|
Height = Application.GetRealHeight(600),
|
Width = Application.GetRealWidth(fanItem_Width),
|
Radius = CommonPage.BigFormRadius,
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
};
|
closeBGview.AddChidren(changeFanModeFL);
|
|
var changeFanBtn = new Button()
|
{
|
X = Application.GetRealWidth(fanItem_X),
|
Width = Application.GetRealWidth(fanItem_Width - fanItem_X),
|
Height = Application.GetRealHeight(fanItem_Height),
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
TextID = R.MyInternationalizationString.SelectFanMode,
|
TextAlignment = TextAlignment.CenterLeft
|
};
|
changeFanModeFL.AddChidren(changeFanBtn);
|
|
var fan_Low = new CommonForm.ACLeftIconButtonRowLayout()
|
{
|
Y = changeFanBtn.Bottom,
|
Width = Application.GetRealWidth(fanItem_Width),
|
Height = Application.GetRealHeight(fanItem_Height),
|
Tag = ZigBee.Device.AC.FanMode.Low
|
};
|
changeFanModeFL.AddChidren(fan_Low);
|
fan_Low.Init("AC/Fan_Low.png", "AC/Fan_LowSelected.png", Language.StringByID(R.MyInternationalizationString.Fan_Low));
|
|
var fan_Middle = new CommonForm.ACLeftIconButtonRowLayout()
|
{
|
Y = fan_Low.Bottom,
|
Width = Application.GetRealWidth(fanItem_Width),
|
Height = Application.GetRealHeight(fanItem_Height),
|
Tag = ZigBee.Device.AC.FanMode.Medium
|
};
|
changeFanModeFL.AddChidren(fan_Middle);
|
fan_Middle.Init("AC/Fan_Middle.png", "AC/Fan_MiddleSelected.png", Language.StringByID(R.MyInternationalizationString.Fan_Middle));
|
|
var fan_Height = new CommonForm.ACLeftIconButtonRowLayout()
|
{
|
Y = fan_Middle.Bottom,
|
Width = Application.GetRealWidth(fanItem_Width),
|
Height = Application.GetRealHeight(fanItem_Height),
|
Tag = ZigBee.Device.AC.FanMode.High
|
};
|
changeFanModeFL.AddChidren(fan_Height);
|
fan_Height.Init("AC/Fan_Height.png", "AC/Fan_HeightSelected.png", Language.StringByID(R.MyInternationalizationString.Fan_Height), false);
|
|
fan_Low.TitleButton.MouseUpEventHandler += ChangeFan_MouseUpEvent;
|
fan_Low.IconButton.MouseUpEventHandler += ChangeFan_MouseUpEvent;
|
|
fan_Middle.TitleButton.MouseUpEventHandler += ChangeFan_MouseUpEvent;
|
fan_Middle.IconButton.MouseUpEventHandler += ChangeFan_MouseUpEvent;
|
|
fan_Height.TitleButton.MouseUpEventHandler += ChangeFan_MouseUpEvent;
|
fan_Height.IconButton.MouseUpEventHandler += ChangeFan_MouseUpEvent;
|
|
if (ACControlBase.IsOpen(ac))
|
{
|
if (ac.currentFanMode == 1)
|
{
|
fan_Low.SetSelectedStatu();
|
}
|
else if (ac.currentFanMode == 2)
|
{
|
fan_Middle.SetSelectedStatu();
|
}
|
else if (ac.currentFanMode == 3)
|
{
|
fan_Height.SetSelectedStatu();
|
}
|
}
|
}
|
|
/// <summary>
|
/// 切换风速
|
/// </summary>
|
/// <param name="sender">Sender.</param>
|
/// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
|
private void ChangeFan_MouseUpEvent(object sender,MouseEventArgs mouseEventArgs)
|
{
|
var tag = (sender as Button).Tag.ToString();
|
ZigBee.Device.AC.FanMode mode= ZigBee.Device.AC.FanMode.Low;
|
if (tag == "Low")
|
{
|
mode = ZigBee.Device.AC.FanMode.Low;
|
}
|
else if (tag == "Medium")
|
{
|
mode = ZigBee.Device.AC.FanMode.Medium;
|
}
|
else if (tag == "High")
|
{
|
mode = ZigBee.Device.AC.FanMode.High;
|
}
|
|
ChangeFan(mode);
|
}
|
|
/// <summary>
|
/// 切换风速
|
/// </summary>
|
/// <param name="fanMode">Fan mode.</param>
|
private void ChangeFan(ZigBee.Device.AC.FanMode fanMode)
|
{
|
fanModeDialog.Close();
|
if (ACControlBase.IsOpen(ac) == false)
|
{
|
ACControlBase.ShowACIsCloseTip();
|
return;
|
}
|
fanModeBtn.IsSelected = true;
|
fanModeBtn.SelectedImagePath = ACControlBase.GetFanModeSelectedImagePathByFanMode(fanMode);
|
fanModeBtn.UnSelectedImagePath = ACControlBase.GetFanModeUnSelectedImagePathByFanMode(fanMode);
|
ac.currentFanMode = (int)(fanMode);
|
|
(device.CommonDevice as ZigBee.Device.AC).SetFanModeAsync(fanMode);
|
}
|
|
#endregion
|
|
#region ◆ 切换模式_______________________
|
/// <summary>
|
/// 切换模式
|
/// </summary>
|
/// <param name="sender">Sender.</param>
|
/// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
|
private void ShowChangeMode_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs)
|
{
|
int modeItem_X = 80;
|
int modeItem_Height = 150;
|
int modeItem_Width = 449;
|
|
acModeDialog = new Dialog();
|
acModeDialog.Show();
|
var closeBGview = new FrameLayout();
|
acModeDialog.AddChidren(closeBGview);
|
closeBGview.MouseUpEventHandler += (send1, e1) =>
|
{
|
acModeDialog.Close();
|
};
|
|
var changeModeBG = new Button()
|
{
|
X = Application.GetRealWidth(80),
|
Y = Application.GetRealHeight(360),
|
Height = Application.GetRealHeight(933),
|
Width = Application.GetRealWidth(modeItem_Width),
|
UnSelectedImagePath = "AC/SelectedModeBG.png"
|
};
|
closeBGview.AddChidren(changeModeBG);
|
|
var changeModeFL = new FrameLayout()
|
{
|
X = Application.GetRealWidth(80),
|
Y = Application.GetRealHeight(360),
|
Height = Application.GetRealHeight(900),
|
Width = Application.GetRealWidth(modeItem_Width),
|
Radius = CommonPage.BigFormRadius,
|
BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor,
|
//BackgroundIagePath="AC/SelectedModeBG.png"
|
};
|
closeBGview.AddChidren(changeModeFL);
|
|
var changeModeBtn = new Button()
|
{
|
X = Application.GetRealWidth(modeItem_X),
|
Width = Application.GetRealWidth(modeItem_Width - modeItem_X),
|
Height = Application.GetRealHeight(modeItem_Height),
|
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
|
TextID = R.MyInternationalizationString.SelectFanMode,
|
TextAlignment = TextAlignment.CenterLeft
|
};
|
changeModeFL.AddChidren(changeModeBtn);
|
|
var mode_Auto = new CommonForm.ACLeftIconButtonRowLayout()
|
{
|
Y = changeModeBtn.Bottom,
|
Width = Application.GetRealWidth(modeItem_Width),
|
Height = Application.GetRealHeight(modeItem_Height),
|
Tag = ZigBee.Device.AC.AcMode.Auto
|
};
|
changeModeFL.AddChidren(mode_Auto);
|
mode_Auto.Init("AC/Mode_Auto.png", "AC/Mode_AutoSelected.png", Language.StringByID(R.MyInternationalizationString.Mode_Auto));
|
|
var mode_Cool = new CommonForm.ACLeftIconButtonRowLayout()
|
{
|
Y = mode_Auto.Bottom,
|
Width = Application.GetRealWidth(modeItem_Width),
|
Height = Application.GetRealHeight(modeItem_Height),
|
Tag = ZigBee.Device.AC.AcMode.Cool
|
};
|
changeModeFL.AddChidren(mode_Cool);
|
mode_Cool.Init("AC/Mode_Cool.png", "AC/Mode_CoolSelected.png", Language.StringByID(R.MyInternationalizationString.Mode_Cool));
|
|
var mode_Heat = new CommonForm.ACLeftIconButtonRowLayout()
|
{
|
Y = mode_Cool.Bottom,
|
Width = Application.GetRealWidth(modeItem_Width),
|
Height = Application.GetRealHeight(modeItem_Height),
|
Tag = ZigBee.Device.AC.AcMode.Heat
|
};
|
changeModeFL.AddChidren(mode_Heat);
|
mode_Heat.Init("AC/Mode_Heat.png", "AC/Mode_HeatSelected.png", Language.StringByID(R.MyInternationalizationString.Mode_Heat));
|
|
var mode_Dry = new CommonForm.ACLeftIconButtonRowLayout()
|
{
|
Y = mode_Heat.Bottom,
|
Width = Application.GetRealWidth(modeItem_Width),
|
Height = Application.GetRealHeight(modeItem_Height),
|
Tag = ZigBee.Device.AC.AcMode.Dry
|
};
|
changeModeFL.AddChidren(mode_Dry);
|
mode_Dry.Init("AC/Mode_Dry.png", "AC/Mode_DrySelected.png", Language.StringByID(R.MyInternationalizationString.Mode_Dry));
|
|
var mode_Fan = new CommonForm.ACLeftIconButtonRowLayout()
|
{
|
Y = mode_Dry.Bottom,
|
Width = Application.GetRealWidth(modeItem_Width),
|
Height = Application.GetRealHeight(modeItem_Height),
|
Tag = ZigBee.Device.AC.AcMode.FanOnly
|
};
|
changeModeFL.AddChidren(mode_Fan);
|
mode_Fan.Init("AC/Mode_Fan.png", "AC/Mode_FanSelected.png", Language.StringByID(R.MyInternationalizationString.Mode_FanOnly), false);
|
|
mode_Auto.TitleButton.MouseUpEventHandler += ChangeMode_MouseUpEvent;
|
mode_Auto.IconButton.MouseUpEventHandler += ChangeMode_MouseUpEvent;
|
|
mode_Cool.TitleButton.MouseUpEventHandler += ChangeMode_MouseUpEvent;
|
mode_Cool.IconButton.MouseUpEventHandler += ChangeMode_MouseUpEvent;
|
|
mode_Heat.TitleButton.MouseUpEventHandler += ChangeMode_MouseUpEvent;
|
mode_Heat.IconButton.MouseUpEventHandler += ChangeMode_MouseUpEvent;
|
|
mode_Dry.TitleButton.MouseUpEventHandler += ChangeMode_MouseUpEvent;
|
mode_Dry.IconButton.MouseUpEventHandler += ChangeMode_MouseUpEvent;
|
|
mode_Fan.TitleButton.MouseUpEventHandler += ChangeMode_MouseUpEvent;
|
mode_Fan.IconButton.MouseUpEventHandler += ChangeMode_MouseUpEvent;
|
|
if (ACControlBase.IsOpen(ac))
|
{
|
if (ac.currentSystemMode == 1)
|
{
|
mode_Auto.SetSelectedStatu();
|
}
|
else if (ac.currentSystemMode == 3)
|
{
|
mode_Cool.SetSelectedStatu();
|
}
|
else if (ac.currentSystemMode == 4)
|
{
|
mode_Heat.SetSelectedStatu();
|
}
|
else if (ac.currentSystemMode == 8)
|
{
|
mode_Dry.SetSelectedStatu();
|
}
|
else if (ac.currentSystemMode == 7)
|
{
|
mode_Fan.SetSelectedStatu();
|
}
|
}
|
}
|
|
/// <summary>
|
/// 切换模式
|
/// </summary>
|
/// <param name="sender">Sender.</param>
|
/// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
|
private void ChangeMode_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs)
|
{
|
var tag = (sender as Button).Tag.ToString();
|
ZigBee.Device.AC.AcMode mode = ZigBee.Device.AC.AcMode.Cool;
|
|
if (tag == "Auto")
|
{
|
mode = ZigBee.Device.AC.AcMode.Auto;
|
}
|
else if (tag == "Cool")
|
{
|
mode = ZigBee.Device.AC.AcMode.Cool;
|
}
|
else if (tag == "Heat")
|
{
|
mode = ZigBee.Device.AC.AcMode.Heat;
|
}
|
else if(tag =="Dry")
|
{
|
mode = ZigBee.Device.AC.AcMode.Dry;
|
}
|
else if(tag == "FanOnly")
|
{
|
mode = ZigBee.Device.AC.AcMode.FanOnly;
|
}
|
|
ChangeMode(mode);
|
}
|
|
/// <summary>
|
/// 切换模式
|
/// </summary>
|
/// <param name="acMode">Ac mode.</param>
|
private void ChangeMode(ZigBee.Device.AC.AcMode acMode)
|
{
|
acModeDialog.Close();
|
if (ACControlBase.IsOpen(ac) == false)
|
{
|
ACControlBase.ShowACIsCloseTip();
|
return;
|
}
|
modeBtn.IsSelected = true;
|
modeBtn.SelectedImagePath = ACControlBase.GetModeSelectedImagePathByMode(acMode);
|
modeBtn.UnSelectedImagePath = ACControlBase.GetModeUnSelectedImagePathByMode(acMode);
|
currentModeBtn.Text = ACControlBase.GetModeNameByMode(acMode);
|
ac.currentSystemMode = (int)acMode;
|
currentTemperatureBtn.Text = $"{ACControlBase.GetCurrentModeTemperature(ac)} °C";
|
(device.CommonDevice as ZigBee.Device.AC).SetSystemModeAsync(acMode);
|
}
|
|
#endregion
|
|
#region ◆ 开关__________________________
|
|
/// <summary>
|
/// 开关
|
/// </summary>
|
/// <param name="sender">Sender.</param>
|
/// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
|
private void Switch_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs)
|
{
|
switchBtn.IsSelected = !switchBtn.IsSelected;
|
if (switchBtn.IsSelected == true)
|
{
|
ac.Open();
|
modeBtn.IsSelected = true;
|
fanModeBtn.IsSelected = true;
|
}
|
else
|
{
|
ac.Close();
|
modeBtn.IsSelected = false;
|
fanModeBtn.IsSelected = false;
|
}
|
}
|
|
#endregion
|
|
#region ◆ 升温__________________________
|
/// <summary>
|
/// 升温
|
/// </summary>
|
/// <param name="sender">Sender.</param>
|
/// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
|
private void Add_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs)
|
{
|
if (ACControlBase.IsOpen(ac) == false)
|
{
|
ACControlBase.ShowACIsCloseTip();
|
return;
|
}
|
//cool //dry
|
if (ac.currentSystemMode == 3 || ac.currentSystemMode==8)
|
{
|
if(ac.currentCoolingSetpoint>=ACControlBase.Temperature_High)
|
{
|
return;
|
}
|
ac.currentCoolingSetpoint += 1;
|
ac.SetCoolingTemperatureAsync(ac.currentCoolingSetpoint*100);
|
currentTemperatureBtn.Text = $"{ac.currentCoolingSetpoint} °C";
|
}
|
//heat
|
else if (ac.currentSystemMode == 4)
|
{
|
if(ac.currentHeatingSetpoint>=ACControlBase.Temperature_High)
|
{
|
return;
|
}
|
ac.currentHeatingSetpoint += 1;
|
ac.SetHeatingTemperatureAsync(ac.currentHeatingSetpoint*100);
|
currentTemperatureBtn.Text = $"{ac.currentHeatingSetpoint} °C";
|
}
|
//auto
|
else if (ac.currentSystemMode == 1)
|
{
|
if (ac.currentAutoSetpoint >= ACControlBase.Temperature_High)
|
{
|
return;
|
}
|
ac.currentAutoSetpoint += 1;
|
ac.SetAutoTemperatureAsync(ac.currentAutoSetpoint*100);
|
currentTemperatureBtn.Text = $"{ac.currentAutoSetpoint} °C";
|
}
|
|
|
}
|
|
#endregion
|
|
#region ◆ 降温__________________________
|
|
/// <summary>
|
/// 降温
|
/// </summary>
|
/// <param name="sender">Sender.</param>
|
/// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
|
private void Reduce_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs)
|
{
|
if (ACControlBase.IsOpen(ac) == false)
|
{
|
ACControlBase.ShowACIsCloseTip();
|
return;
|
}
|
//cool //dry
|
if (ac.currentSystemMode == 3 || ac.currentSystemMode == 8)
|
{
|
if (ac.currentCoolingSetpoint <= ACControlBase.Temperature_Low)
|
{
|
return;
|
}
|
ac.currentCoolingSetpoint -= 1;
|
ac.SetCoolingTemperatureAsync(ac.currentCoolingSetpoint*100);
|
|
currentTemperatureBtn.Text = $"{ac.currentCoolingSetpoint} °C";
|
}
|
//heat
|
else if (ac.currentSystemMode == 4)
|
{
|
if (ac.currentHeatingSetpoint <= ACControlBase.Temperature_Low)
|
{
|
return;
|
}
|
ac.currentHeatingSetpoint -= 1;
|
ac.SetHeatingTemperatureAsync(ac.currentHeatingSetpoint*100);
|
|
currentTemperatureBtn.Text = $"{ac.currentHeatingSetpoint} °C";
|
}
|
//auto
|
else if (ac.currentSystemMode == 1)
|
{
|
if (ac.currentAutoSetpoint <= ACControlBase.Temperature_Low)
|
{
|
return;
|
}
|
ac.currentAutoSetpoint -= 1;
|
ac.SetAutoTemperatureAsync(ac.currentAutoSetpoint*100);
|
|
currentTemperatureBtn.Text = $"{ac.currentAutoSetpoint} °C";
|
}
|
|
}
|
|
#endregion
|
|
#region ◆ 收藏__________________________
|
/// <summary>
|
/// 收藏到主页
|
/// </summary>
|
/// <param name="sender">Sender.</param>
|
/// <param name="e">E.</param>
|
private void Collection(object sender, MouseEventArgs e)
|
{
|
//collection
|
if (collectionBtn.IsSelected)
|
{
|
Shared.Common.Room.Lists[0].DeleteDevice(device.FileName);
|
collectionBtn.IsSelected = false;
|
}
|
else
|
{
|
Shared.Common.Room.Lists[0].AddDevice(device.FileName);
|
collectionBtn.IsSelected = true;
|
}
|
}
|
|
#endregion
|
|
#region ◆ 绑定按钮_______________________
|
/// <summary>
|
/// 绑定按钮的事件
|
/// </summary>
|
private void BindEvent()
|
{
|
switchBtn.MouseUpEventHandler += Switch_MouseUpEvent;
|
reduceTemperatureBtn.MouseUpEventHandler += Reduce_MouseUpEvent;
|
addTemperatureBtn.MouseUpEventHandler += Add_MouseUpEvent;
|
collectionBtn.MouseUpEventHandler += Collection;
|
moreBtn.MouseUpEventHandler += MoreEvent;
|
fanModeBtn.MouseUpEventHandler += ShowChangeFan_MouseUpEvent;
|
modeBtn.MouseUpEventHandler += ShowChangeMode_MouseUpEvent;
|
}
|
|
#endregion
|
|
}
|
}
|