using System;
using Shared.Common;
namespace Shared.Phone.Device.CommonForm
{
public class TopFrameLayout : FrameLayout
{
#region ◆ 变量__________________________
///
/// 返回键
///
public BackButton backButton;
///
/// 状态栏-高度为80
///
public FrameLayout topStatuFrameLayout;
///
/// The top view.
///
public FrameLayout topView;
///
/// 标题
///
public Button topTitle;
#endregion
#region ◆ 构造方法_______________________
///
/// 构造方法
///
public TopFrameLayout(FrameLayout parentFrameLayout)
{
BackgroundColor = ZigbeeColor.Current.GXCTopViewBackgroundColor;
Width = Application.GetRealWidth(1080);
Height = Application.GetRealHeight(CommonFormRrsouce.TopFrameLayout_Height);
//先加载到父容器,否则子控件布局有问题
parentFrameLayout.AddChidren(this);
//初始化
InitTopview(parentFrameLayout);
}
#endregion
#region ◆ 初始化__________________________
private void InitTopview(FrameLayout parentFrameLayout)
{
//状态栏
AddTopStatuFrame();
//topview
AddTopview();
//添加返回键
AddBackBtn(parentFrameLayout);
//标题
AddTitle();
}
#endregion
#region ◆ topview________________________
///
/// Adds the topview.
///
private void AddTopview()
{
topView = new FrameLayout
{
Y = Application.GetRealHeight(CommonFormRrsouce.TopStatuFrameLayout_Height),
Height = Application.GetRealHeight(CommonFormRrsouce.Topview_Height),
Width = Application.GetRealWidth(1080)
};
AddChidren(topView);
}
#endregion
#region ◆ 返回键__________________________
///
/// 返回键
///
/// The back button.
private void AddBackBtn(FrameLayout parentFrameLayout)
{
backButton = new BackButton { };
topView.AddChidren(backButton);
backButton.MouseUpEventHandler += (sender, e) =>
{
parentFrameLayout.RemoveFromParent();
};
}
#endregion
#region ◆ 状态栏__________________________
///
/// 状态栏
///
private void AddTopStatuFrame()
{
topStatuFrameLayout = new FrameLayout
{
Height = Application.GetRealHeight(CommonFormRrsouce.TopStatuFrameLayout_Height),
Width = Application.GetRealWidth(1080)
};
AddChidren(topStatuFrameLayout);
}
#endregion
#region ◆ 标题___________________________
///
/// 标题
///
private void AddTitle()
{
topTitle = new Button
{
Height = Application.GetRealHeight(CommonFormRrsouce.TopFrameLayout_Height - CommonFormRrsouce.TopStatuFrameLayout_Height),
Width = Application.GetRealWidth(CommonFormRrsouce.TopTitle_Width),
TextSize = CommonFormRrsouce.TopTitle_TextSize,
TextColor = ZigbeeColor.Current.GXCTextBlackColor,
Gravity = Gravity.CenterHorizontal,
};
topView.AddChidren(topTitle);
}
///
/// 设置标题
///
/// Title.
public void SetTopTitle(string title)
{
topTitle.Text = title;
}
#endregion
}
}