using System;  
 | 
using System.Collections.Generic;  
 | 
using System.Text;  
 | 
  
 | 
namespace Shared.Phone.UserCenter  
 | 
{  
 | 
    /// <summary>  
 | 
    /// 底部弹窗的菜单选择控件  
 | 
    /// </summary>  
 | 
    public class BottomMenuSelectForm : DialogCommonForm  
 | 
    {  
 | 
        #region ■ 变量声明___________________________  
 | 
  
 | 
        /// <summary>  
 | 
        /// 菜单高度  
 | 
        /// </summary>  
 | 
        private int menuHeight = Application.GetRealHeight(156);  
 | 
        /// <summary>  
 | 
        /// 菜单总数  
 | 
        /// </summary>  
 | 
        private int m_MenuCount = 0;  
 | 
        /// <summary>  
 | 
        /// 菜单桌布控件  
 | 
        /// </summary>  
 | 
        private FrameLayout frameMenuTable = null;  
 | 
        /// <summary>  
 | 
        /// 容器  
 | 
        /// </summary>  
 | 
        private FrameLayout frameAnimateTable = null;  
 | 
  
 | 
        #endregion  
 | 
  
 | 
        #region ■ 初始化_____________________________  
 | 
  
 | 
        /// <summary>  
 | 
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)  
 | 
        /// </summary>  
 | 
        /// <param name="menuCount">菜单总数(不含取消菜单)</param>  
 | 
        public void ShowForm(int menuCount)  
 | 
        {  
 | 
            this.m_MenuCount = menuCount;  
 | 
            //初始化中部信息  
 | 
            this.InitMiddleFrame(menuCount);  
 | 
        }  
 | 
  
 | 
        /// <summary>  
 | 
        /// 初始化中部信息  
 | 
        /// </summary>  
 | 
        /// <param name="menuCount">菜单总数(不含取消菜单)</param>  
 | 
        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 ■ 一般方法___________________________  
 | 
  
 | 
        /// <summary>  
 | 
        /// 添加菜单  
 | 
        /// </summary>  
 | 
        /// <param name="strMenu">菜单文本</param>  
 | 
        /// <param name="selectEvent">菜单选择的事件</param>  
 | 
        /// <param name="clickClose">菜单点击时,是否无条件关闭界面</param>  
 | 
        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  
 | 
    }  
 | 
}  
 |