using Shared;
|
using HDL_ON.UI.CSS;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
|
namespace HDL_ON.Stan
|
{
|
/// <summary>
|
/// 底部弹窗的菜单选择控件(不需要加入父控件,AddMenu添加菜单)
|
/// </summary>
|
public class BottomMenuSelectControl
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 菜单高度
|
/// </summary>
|
private int menuHeight = Application.GetRealHeight(44);
|
/// <summary>
|
/// 菜单桌布控件
|
/// </summary>
|
private FrameLayout frameMenuTable = null;
|
/// <summary>
|
/// 整个弹窗对象
|
/// </summary>
|
private Dialog FrameDialog = null;
|
/// <summary>
|
/// 点击背景时,是否关闭弹窗
|
/// </summary>
|
public bool ClickBackClose = true;
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 底部弹窗的菜单选择控件(不需要加入父控件,AddMenu添加菜单)
|
/// </summary>
|
/// <param name="i_menuCount">菜单总数(不含取消菜单)</param>
|
public BottomMenuSelectControl(int i_menuCount)
|
{
|
//初始化控件
|
this.InitControl(i_menuCount);
|
}
|
|
/// <summary>
|
/// 初始化控件
|
/// </summary>
|
/// <param name="menuCount">菜单总数(不含取消菜单)</param>
|
private void InitControl(int menuCount)
|
{
|
//整个灰色界面
|
this.FrameDialog = new Dialog();
|
FrameDialog.Show();
|
|
var dialogBody = new NormalFrameLayout();
|
dialogBody.Height = FrameDialog.Height;
|
FrameDialog.AddChidren(dialogBody);
|
dialogBody.ButtonClickEvent += (sender, e) =>
|
{
|
if (ClickBackClose == true)
|
{
|
FrameDialog.Close();
|
}
|
};
|
|
//取消菜单
|
var frameCancel = new FrameLayout();
|
frameCancel.Y = dialogBody.Height - this.menuHeight - Application.GetRealHeight(12);
|
frameCancel.Gravity = Gravity.CenterHorizontal;
|
frameCancel.Radius = (uint)Application.GetRealHeight(12);
|
frameCancel.Width = Application.GetRealWidth(343);
|
frameCancel.Height = this.menuHeight;
|
frameCancel.BackgroundColor = CSS_Color.MainBackgroundColor;
|
FrameDialog.AddChidren(frameCancel);
|
var btnCancel = new NormalViewControl(Application.GetRealWidth(150), this.menuHeight, false);
|
btnCancel.Gravity = Gravity.Center;
|
btnCancel.TextAlignment = TextAlignment.Center;
|
btnCancel.TextColor = CSS_Color.AuxiliaryColor2;
|
btnCancel.TextSize = CSS_FontSize.SubheadingFontSize;
|
btnCancel.TextID = StringId.Cancel;
|
frameCancel.AddChidren(btnCancel);
|
btnCancel.ButtonClickEvent += (sender, e) =>
|
{
|
//关闭界面
|
FrameDialog.Close();
|
};
|
|
//菜单的桌布控件
|
int framebackHeight = this.menuHeight * menuCount;
|
this.frameMenuTable = new FrameLayout();
|
frameMenuTable.Y = frameCancel.Y - framebackHeight - Application.GetRealHeight(8);
|
frameMenuTable.Height = framebackHeight;
|
frameMenuTable.Width = Application.GetRealWidth(343);
|
frameMenuTable.Gravity = Gravity.CenterHorizontal;
|
frameMenuTable.BackgroundColor = CSS_Color.MainBackgroundColor;
|
frameMenuTable.Radius = (uint)Application.GetRealWidth(12);
|
FrameDialog.AddChidren(frameMenuTable);
|
}
|
|
#endregion
|
|
#region ■ 一般方法___________________________
|
|
/// <summary>
|
/// 添加菜单
|
/// </summary>
|
/// <param name="strMenu">菜单文本</param>
|
/// <param name="selectEvent">菜单选择的事件</param>
|
/// <param name="textColor">文本颜色(设置为0,则使用默认的蓝色字体)</param>
|
/// <param name="clickClose">菜单点击时,是否无条件关闭界面</param>
|
public void AddMenu(string strMenu, Action selectEvent, uint textColor = 0, bool clickClose = true)
|
{
|
//线
|
if (this.frameMenuTable.ChildrenCount > 0)
|
{
|
var btnLine = new NormalViewControl(frameMenuTable.Width, HdlControlResourse.BottomLineHeight, false);
|
btnLine.BackgroundColor = CSS_Color.DividingLineColor;
|
btnLine.Y = this.frameMenuTable.GetChildren(this.frameMenuTable.ChildrenCount - 1).Bottom;
|
this.frameMenuTable.AddChidren(btnLine);
|
}
|
|
//菜单
|
var btnMenu = new NormalViewControl(Application.GetRealWidth(300), this.menuHeight, false);
|
if (this.frameMenuTable.ChildrenCount > 0)
|
{
|
btnMenu.Y = this.frameMenuTable.GetChildren(this.frameMenuTable.ChildrenCount - 1).Bottom;
|
}
|
btnMenu.Gravity = Gravity.CenterHorizontal;
|
btnMenu.TextAlignment = TextAlignment.Center;
|
btnMenu.TextColor = textColor == 0 ? CSS_Color.MainColor : textColor;
|
btnMenu.TextSize = CSS_FontSize.SubheadingFontSize;
|
btnMenu.Text = strMenu;
|
this.frameMenuTable.AddChidren(btnMenu);
|
btnMenu.ButtonClickEvent += (sender, e) =>
|
{
|
if (clickClose == true)
|
{
|
//关闭界面
|
FrameDialog.Close();
|
}
|
selectEvent?.Invoke();
|
selectEvent = null;
|
};
|
}
|
|
#endregion
|
}
|
}
|