using System;
using Shared.Common;
namespace Shared.Phone.Device.CommonForm
{
public class ButtonLineForm : FrameLayout
{
///
/// name
///
public Button NameBtn;
///
/// line
///
public Button Line;
///
/// 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;
}
}
///
/// ButtonLineForm
///
///
///
public ButtonLineForm(int x, int y)
{
X = Application.GetRealWidth(x);
Y = Application.GetRealHeight(y);
Width = Application.GetRealWidth(100);
Height = Application.GetRealHeight(85);
}
///
/// Init
///
public void Init()
{
NameBtn = new Button()
{
Width = Width,
Height = Height - Application.GetRealHeight(6),
TextColor = ZigbeeColor.Current.GXCTextGrayColor4,
SelectedTextColor = ZigbeeColor.Current.GXCTextBlackColor,
TextSize = CommonFormResouce.TextSize,
TextAlignment = TextAlignment.CenterLeft
};
AddChidren(NameBtn);
Line = new Button
{
X = 0,
Y = Height - Application.GetRealHeight(6),
Width = 10,
Height = Application.GetRealHeight(6),
Radius = (uint)Application.GetRealHeight(6 / 2),
BackgroundColor = ZigbeeColor.Current.GXCButtonSelectedColor,
Visible = false
};
AddChidren(Line);
}
///
/// SetTitle
///
///
public void SetTitle(string title)
{
NameBtn.Text = title;
RefreshWidth();
}
///
/// RefreshWidth
///
public void RefreshWidth()
{
NameBtn.Width = NameBtn.GetTextWidth() + Application.GetRealWidth(100);
Width = NameBtn.Width;
Line.X = NameBtn.GetTextWidth() / 4;
Line.Width= NameBtn.GetTextWidth() / 2;
}
///
/// SetTitle
///
///
public void SetTitle(int title)
{
SetTitle(Language.StringByID(title));
}
///
/// SetStatu
///
///
public void SetStatu(bool statu)
{
NameBtn.IsSelected = Line.Visible = statu;
NameBtn.TextSize = statu ? CommonFormResouce.TextSize_Selected : CommonFormResouce.TextSize;
NameBtn.IsBold = statu;
RefreshWidth();
}
}
}