using System;
using Shared.Common;
namespace Shared.Phone.Device.CommonForm
{
///
/// 房间按钮图片
///
public class RoomButton : FrameLayout
{
#region ◆ 变量____________________________
///
/// name
///
public Button NameBtn;
///
/// 背景图
///
public Button BackGroundBtn;
///
/// 点击事件
///
public Action ButtonClickEvent;
///
/// isSelected
///
private bool v_Selected;
///
/// IsSelected
///
public bool IsSelected
{
set
{
try
{
v_Selected = value;
SetStatu(v_Selected);
}
catch
{
v_Selected = false;
SetStatu(v_Selected);
}
}
get
{
return v_Selected;
}
}
#endregion
#region ◆ 构造方法_________________________
///
/// ButtonLineForm
///
///
///
public RoomButton(int x, int y)
{
X = Application.GetRealWidth(x);
Y = Application.GetRealHeight(y);
Width = Application.GetMinRealAverage(255);
Height = Application.GetMinRealAverage(159);
}
#endregion
#region ◆ 外部方法________________________
///
/// Init
///
public void Init()
{
BackGroundBtn = new Button
{
Width = Application.GetMinRealAverage(255),
Height = Application.GetMinRealAverage(159),
UnSelectedImagePath = "Room/IconBackground.png",
SelectedImagePath = "Room/IconSelectedBackground.png",
Gravity = Gravity.Center
};
AddChidren(BackGroundBtn);
NameBtn = new Button()
{
Width = Application.GetMinRealAverage(160),
Height = Application.GetMinRealAverage(159 / 2),
Gravity = Gravity.Center,
TextColor = ZigbeeColor.Current.GXCTextGrayColor,
SelectedTextColor = ZigbeeColor.Current.GXCTextWhiteColor,
TextSize = 12
};
AddChidren(NameBtn);
BackGroundBtn.MouseUpEventHandler += Button_MouseUpEventHandler;
NameBtn.MouseUpEventHandler += Button_MouseUpEventHandler;
}
///
/// SetTitle
///
///
public void SetTitle(string title)
{
NameBtn.Text = title;
}
///
/// SetTitle
///
///
public void SetTitle(int title)
{
SetTitle(Language.StringByID(title));
}
///
/// SetStatu
///
///
public void SetStatu(bool statu)
{
NameBtn.IsSelected = BackGroundBtn.IsSelected = statu;
//NameBtn.TextSize = statu ? CommonFormResouce.TextSize_Selected : CommonFormResouce.TextSize;
NameBtn.IsBold = statu;
}
#endregion
#region ◆ 点击事件_________________________
///
/// 点击事件
///
///
///
private void Button_MouseUpEventHandler(object sender, MouseEventArgs e)
{
try
{
this.ButtonClickEvent?.Invoke(this, e);
}
catch (Exception ex)
{
}
}
#endregion
}
}