using System;
|
using Shared.Common;
|
|
namespace Shared.Phone.Device.CommonForm
|
{
|
/// <summary>
|
/// 房间按钮图片
|
/// </summary>
|
public class RoomButton : FrameLayout
|
{
|
#region ◆ 变量____________________________
|
/// <summary>
|
/// name
|
/// </summary>
|
public Button NameBtn;
|
/// <summary>
|
/// 背景图
|
/// </summary>
|
public Button BackGroundBtn;
|
/// <summary>
|
/// 点击事件
|
/// </summary>
|
public Action<RoomButton, MouseEventArgs> ButtonClickEvent;
|
/// <summary>
|
/// isSelected
|
/// </summary>
|
private bool v_Selected;
|
/// <summary>
|
/// IsSelected
|
/// </summary>
|
public bool IsSelected
|
{
|
set
|
{
|
try
|
{
|
v_Selected = value;
|
SetStatu(v_Selected);
|
}
|
catch
|
{
|
v_Selected = false;
|
SetStatu(v_Selected);
|
}
|
}
|
get
|
{
|
return v_Selected;
|
}
|
}
|
|
#endregion
|
|
#region ◆ 构造方法_________________________
|
|
/// <summary>
|
/// ButtonLineForm
|
/// </summary>
|
/// <param name="x"></param>
|
/// <param name="y"></param>
|
public RoomButton(int x, int y)
|
{
|
X = Application.GetRealWidth(x);
|
Y = Application.GetRealHeight(y);
|
Width = Application.GetMinRealAverage(255);
|
Height = Application.GetMinRealAverage(159);
|
}
|
|
#endregion
|
|
#region ◆ 外部方法________________________
|
/// <summary>
|
/// Init
|
/// </summary>
|
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;
|
}
|
|
/// <summary>
|
/// SetTitle
|
/// </summary>
|
/// <param name="title"></param>
|
public void SetTitle(string title)
|
{
|
NameBtn.Text = title;
|
}
|
/// <summary>
|
/// SetTitle
|
/// </summary>
|
/// <param name="title"></param>
|
public void SetTitle(int title)
|
{
|
SetTitle(Language.StringByID(title));
|
}
|
|
/// <summary>
|
/// SetStatu
|
/// </summary>
|
/// <param name="statu"></param>
|
public void SetStatu(bool statu)
|
{
|
NameBtn.IsSelected = BackGroundBtn.IsSelected = statu;
|
//NameBtn.TextSize = statu ? CommonFormResouce.TextSize_Selected : CommonFormResouce.TextSize;
|
NameBtn.IsBold = statu;
|
}
|
|
#endregion
|
|
#region ◆ 点击事件_________________________
|
|
/// <summary>
|
/// 点击事件
|
/// </summary>
|
/// <param name="sender"></param>
|
/// <param name="e"></param>
|
private void Button_MouseUpEventHandler(object sender, MouseEventArgs e)
|
{
|
try
|
{
|
this.ButtonClickEvent?.Invoke(this, e);
|
}
|
catch (Exception ex)
|
{
|
}
|
}
|
#endregion
|
}
|
}
|