using System;
|
using System.Collections.Generic;
|
using System.Text;
|
|
namespace Shared.Phone.UserCenter
|
{
|
/// <summary>
|
/// 做成一个存在于右上角的菜单控件
|
/// </summary>
|
public class TopRightMenuControl : FrameLayout
|
{
|
/// <summary>
|
/// 框框控件
|
/// </summary>
|
private FrameLayout frameLine = null;
|
/// <summary>
|
/// 行高度
|
/// </summary>
|
private int RowHeight = 100;
|
/// <summary>
|
/// 行宽度
|
/// </summary>
|
private int RowWidth = 310;
|
/// <summary>
|
/// 线的高度
|
/// </summary>
|
private int LineHeight = 1;
|
/// <summary>
|
/// 菜单数计数
|
/// </summary>
|
private int menuCount = 0;
|
/// <summary>
|
/// 做成一个存在于右上角的菜单控件
|
/// </summary>
|
/// <param name="frame">父容器控件</param>
|
/// <param name="i_RowCount">一共有几行</param>
|
public TopRightMenuControl(FrameLayout frame, int i_RowCount)
|
{
|
//初始化画面的控件
|
this.InitFormControl(frame, i_RowCount);
|
}
|
|
/// <summary>
|
/// 添加菜单行
|
/// </summary>
|
/// <param name="TextValue">显示的文字</param>
|
/// <param name="action">单击菜单执行的事件</param>
|
/// <param name="pramter">调用action所传递的参数</param>
|
/// <param name="closeOnClick">单击的时候,关闭菜单</param>
|
public void AddRowMenu(string TextValue, Action<object> action, object pramter = null, bool closeOnClick = true)
|
{
|
ViewNormalControl btnLine = null;
|
if (this.menuCount > 0)
|
{
|
//画线
|
btnLine = new ViewNormalControl(Application.GetRealWidth(RowWidth), LineHeight);
|
btnLine.Y = Application.GetRealHeight(RowHeight * this.menuCount) + this.menuCount * LineHeight;
|
btnLine.BackgroundColor = UserCenterColor.Current.Line;
|
frameLine.AddChidren(btnLine);
|
}
|
this.menuCount++;
|
|
//显示文字
|
var btnText = new ViewNormalControl(RowWidth, RowHeight, true);
|
btnText.Text = TextValue;
|
btnText.TextAlignment = TextAlignment.Center;
|
if (btnLine != null)
|
{
|
btnText.Y = btnLine.Bottom;
|
}
|
frameLine.AddChidren(btnText);
|
btnText.MouseUpEventHandler += (sender, e) =>
|
{
|
if (closeOnClick == true)
|
{
|
this.RemoveFromParent();
|
}
|
|
if (action != null)
|
{
|
action(pramter);
|
}
|
};
|
}
|
|
/// <summary>
|
/// 初始化画面的控件
|
/// </summary>
|
/// <param name="frame">父容器控件</param>
|
/// <param name="i_RowCount">一共有几行</param>
|
private void InitFormControl(FrameLayout frame, int i_RowCount)
|
{
|
this.BackgroundColor = UserCenterColor.Current.DialogBackColor;
|
this.MouseUpEventHandler += (sender2, e2) =>
|
{
|
//关闭自身
|
this.RemoveFromParent();
|
};
|
frame.AddChidren(this);
|
|
//一个框
|
this.frameLine = new FrameLayout
|
{
|
X = Application.GetRealWidth(740),
|
Y = Application.GetRealHeight(200),
|
Width = Application.GetRealWidth(RowWidth),
|
Height = Application.GetRealHeight(RowHeight * i_RowCount) + (i_RowCount - 1) * LineHeight,
|
BackgroundColor = UserCenterColor.Current.White,
|
Radius = 6,
|
BorderColor = UserCenterColor.Current.TextFrameColor,
|
BorderWidth = 1
|
};
|
this.AddChidren(frameLine);
|
}
|
}
|
}
|