using System;
using Shared.Common;
namespace Shared.Phone.Device.CommonForm
{
public class CategoryFunctionForWinRow:FrameLayout
{
///
/// name
///
public Button NameBtn;
///
/// Image
///
public Button ImageBtn;
///
/// ImageBG
///
public Button ImageBG;
///
/// ZoneBtn
///
private Button StatuBtn;
///
/// OpenOrUpBtn
///
public Button OpenOrUpBtn;
///
/// OpenOrUpBtn
///
public Button CloseOrDownBtn;
///
/// StopBtn
///
public Button StopBtn;
///
/// ClickBtn
///
public Button ClickBtn;
///
/// v_Selected
///
private bool v_Selected;
///
/// IsSelected
///
public bool IsSelected
{
set
{
v_Selected = value;
try
{
SetStatu(v_Selected);
}
catch
{
}
}
get
{
return v_Selected;
}
}
///
/// CategoryFunctionForWinRow
///
///
///
public CategoryFunctionForWinRow(int x = 0, int y = 0)
{
X = Application.GetRealWidth(x);
Y = Application.GetRealHeight(y);
Width = Application.GetRealWidth(1022);
Height = Application.GetRealHeight(127-2);
//BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor;
}
///
/// Init
///
///
public void Init(DeviceUI device)
{
ImageBG = new Button()
{
X = Application.GetRealWidth(45),
Width = Application.GetMinRealAverage(112),
Height = Application.GetMinRealAverage(112),
Gravity = Gravity.CenterVertical,
Radius = (uint)Application.GetMinRealAverage(112 / 2),
BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor,
SelectedBackgroundColor = ZigbeeColor.Current.GXCSelectedBackgroundColor,
};
AddChidren(ImageBG);
ImageBtn = new Button()
{
X = Application.GetRealWidth(63),
Width = Application.GetMinRealAverage(78),
Height = Application.GetMinRealAverage(78),
Gravity = Gravity.CenterVertical,
UnSelectedImagePath = device.IconPath,
SelectedImagePath = device.OnlineIconPath,
};
AddChidren(ImageBtn);
NameBtn = new Button()
{
X = Application.GetRealWidth(181),
Y = Application.GetRealHeight(14),
Width = Application.GetRealWidth(400),
Height = Application.GetRealHeight(58),
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
SelectedTextColor = ZigbeeColor.Current.GXCTextSelectedColor,
TextAlignment = TextAlignment.CenterLeft,
TextSize=14
};
AddChidren(NameBtn);
StatuBtn = new Button
{
X = Application.GetRealWidth(181),
Y = Application.GetRealHeight(72),
Width = Application.GetRealWidth(400),
Height = Application.GetRealHeight(49),
TextAlignment = TextAlignment.CenterLeft,
TextColor = ZigbeeColor.Current.GXCPlaceHolderTextColor2,
TextSize=10
};
AddChidren(StatuBtn);
OpenOrUpBtn = new Button
{
X = Application.GetRealWidth(625),
Width = Application.GetMinRealAverage(69),
Height = Application.GetMinRealAverage(69),
SelectedImagePath = "RollerShade/OpenSelected.png",
UnSelectedImagePath = "RollerShade/Open.png",
Gravity = Gravity.CenterVertical
};
AddChidren(OpenOrUpBtn);
OpenOrUpBtn.MouseUpEventHandler += (sender, e) =>
{
(device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(0);
};
StopBtn = new Button
{
X = Application.GetRealWidth(769),
Width = Application.GetMinRealAverage(69),
Height = Application.GetMinRealAverage(69),
SelectedImagePath = "RollerShade/StopSelected.png",
UnSelectedImagePath = "RollerShade/Stop.png",
Gravity = Gravity.CenterVertical
};
AddChidren(StopBtn);
StopBtn.MouseUpEventHandler += (sender, e) =>
{
(device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(2);
};
CloseOrDownBtn = new Button
{
X = Application.GetRealWidth(896),
Width = Application.GetMinRealAverage(69),
Height = Application.GetMinRealAverage(69),
SelectedImagePath = "RollerShade/CloseSelected.png",
UnSelectedImagePath = "RollerShade/Close.png",
Gravity = Gravity.CenterVertical
};
AddChidren(CloseOrDownBtn);
CloseOrDownBtn.MouseUpEventHandler += (sender, e) =>
{
(device.CommonDevice as ZigBee.Device.Rollershade).CurtainUpDownStopControl(1);
};
var line = new Button()
{
X = Application.GetRealWidth(181),
Y = Height - 1,
Width = Application.GetRealWidth(821),
Height = 1,
BackgroundColor = ZigbeeColor.Current.GXCGrayLineColor2,
Tag = Tag
};
AddChidren(line);
ClickBtn = new Button
{
Width = Application.GetRealWidth(600)
};
AddChidren(ClickBtn);
}
///
/// SetTitle
///
///
public void SetTitle(string title)
{
NameBtn.Text = title;
}
///
/// SetTitle
///
///
public void SetTitle(int title)
{
SetTitle(Language.StringByID(title));
}
///
/// SetZoneText
///
///
public void SetStatuText(string title)
{
StatuBtn.Text = title;
}
///
/// SetStatu
///
///
public void SetStatu(bool statu)
{
//OpenOrUpBtn.IsSelected = CloseOrDownBtn.IsSelected = StopBtn.IsSelected = statu;
NameBtn.IsSelected = ImageBG.IsSelected = ImageBtn.IsSelected = statu;
NameBtn.IsBold = statu;
}
///
/// SetStatu
///
///
public void SetOnLineStatu(bool statu)
{
NameBtn.IsSelected = ImageBG.IsSelected = ImageBtn.IsSelected = statu;
NameBtn.IsBold = statu;
}
///
/// HideSwitchBtn
///
///
public void HideSwitchBtn(bool statu)
{
}
///
/// WcdType=4:开合帘
/// WcdType=0:卷帘
///
///
public void SetRollerShadeIcon(int type)
{
if(type==0)
{
OpenOrUpBtn.UnSelectedImagePath = "RollerShade/Up.png";
OpenOrUpBtn.SelectedImagePath = "RollerShade/UpSelected.png";
CloseOrDownBtn.UnSelectedImagePath = "RollerShade/Down.png";
CloseOrDownBtn.SelectedImagePath = "RollerShade/DownSelected.png";
}
else
{
OpenOrUpBtn.UnSelectedImagePath = "RollerShade/Open.png";
OpenOrUpBtn.SelectedImagePath = "RollerShade/OpenSelected.png";
CloseOrDownBtn.UnSelectedImagePath = "RollerShade/Close.png";
CloseOrDownBtn.SelectedImagePath = "RollerShade/CloseSelected.png";
}
}
///
/// SetDeviceIcon
///
///
///
public void SetDeviceIcon(string imagePath, string selectedImagePath)
{
ImageBtn.UnSelectedImagePath = imagePath;
ImageBtn.SelectedImagePath = selectedImagePath;
}
}
}