using System;
using System.Collections.Generic;
using System.Text;
namespace Shared.Phone.UserCenter
{
///
/// 底部弹窗的菜单选择控件
///
public class BottomMenuSelectForm : DialogCommonForm
{
#region ■ 变量声明___________________________
///
/// 菜单高度
///
private int menuHeight = Application.GetRealHeight(156);
///
/// 菜单总数
///
private int m_MenuCount = 0;
///
/// 菜单桌布控件
///
private FrameLayout frameMenuTable = null;
///
/// 容器
///
private FrameLayout frameAnimateTable = null;
#endregion
#region ■ 初始化_____________________________
///
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
///
/// 菜单总数(不含取消菜单)
public void ShowForm(int menuCount)
{
this.m_MenuCount = menuCount;
//初始化中部信息
this.InitMiddleFrame(menuCount);
}
///
/// 初始化中部信息
///
/// 菜单总数(不含取消菜单)
private void InitMiddleFrame(int menuCount)
{
//容器
int framebackHeight = this.menuHeight * (menuCount + 1) + Application.GetRealHeight(23) * 2;
this.frameAnimateTable = new FrameLayout();
frameAnimateTable.Height = framebackHeight;
frameAnimateTable.Y = bodyFrameLayout.Height - framebackHeight;
bodyFrameLayout.AddChidren(frameAnimateTable);
//菜单的桌布控件
this.frameMenuTable = new FrameLayout();
frameMenuTable.Gravity = Gravity.CenterHorizontal;
frameMenuTable.Radius = (uint)Application.GetRealHeight(35);
frameMenuTable.Width = Application.GetRealWidth(1034);
frameMenuTable.Height = this.menuHeight * menuCount;
frameMenuTable.BackgroundColor = UserCenterColor.Current.White;
frameAnimateTable.AddChidren(frameMenuTable);
//取消
var frameCancel = new FrameLayout();
frameCancel.Y = frameAnimateTable.Height - this.menuHeight - Application.GetRealHeight(23);
frameCancel.Gravity = Gravity.CenterHorizontal;
frameCancel.Radius = (uint)Application.GetRealHeight(35);
frameCancel.Width = Application.GetRealWidth(1034);
frameCancel.Height = this.menuHeight;
frameCancel.BackgroundColor = UserCenterColor.Current.White;
frameAnimateTable.AddChidren(frameCancel);
var btnCancel = new NormalViewControl(Application.GetRealWidth(900), this.menuHeight, false);
btnCancel.Y = frameAnimateTable.Height - this.menuHeight - Application.GetRealHeight(23);
btnCancel.Gravity = Gravity.CenterHorizontal;
btnCancel.TextAlignment = TextAlignment.Center;
btnCancel.TextColor = 0xff0075ff;
btnCancel.TextSize = 17;
btnCancel.TextID = R.MyInternationalizationString.uCancel;
frameAnimateTable.AddChidren(btnCancel);
btnCancel.ButtonClickEvent += (sender, e) =>
{
//关闭界面
this.CloseForm();
};
}
#endregion
#region ■ 一般方法___________________________
///
/// 添加菜单
///
/// 菜单文本
/// 菜单选择的事件
/// 菜单点击时,是否无条件关闭界面
public void AddMenu(string strMenu, Action selectEvent, bool clickClose = true)
{
//线
if (this.frameMenuTable.ChildrenCount > 0)
{
var btnLine = new NormalViewControl(frameMenuTable.Width, ControlCommonResourse.BottomLineHeight, false);
btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine;
btnLine.Y = this.frameMenuTable.GetChildren(this.frameMenuTable.ChildrenCount - 1).Bottom;
this.frameMenuTable.AddChidren(btnLine);
}
//菜单
var btnMenu = new NormalViewControl(Application.GetRealWidth(900), 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 = 0xff0075ff;
btnMenu.TextSize = 17;
btnMenu.Text = strMenu;
this.frameMenuTable.AddChidren(btnMenu);
btnMenu.ButtonClickEvent += (sender, e) =>
{
if (clickClose == true)
{
//关闭界面
this.CloseForm();
}
selectEvent?.Invoke();
selectEvent = null;
};
}
#endregion
}
}