Esempio n. 1
0
        public static DialogResult Show(Form parent, MessageBoxModel pMessageBoxModel)
        {
            using (frm_MessageBox frm = new frm_MessageBox(pMessageBoxModel))
            {
                if (parent == null || parent.IsDisposed)
                {
                    frm.StartPosition = FormStartPosition.CenterScreen;
                    if (pMessageBoxModel.FormWidth != 0)
                    {
                        frm.Width = pMessageBoxModel.FormWidth;
                    }
                    if (pMessageBoxModel.FormHeight != 0)
                    {
                        frm.Height = pMessageBoxModel.FormHeight;
                    }

                    return(frm.ShowDialog());
                }
                else
                {
                    frm.StartPosition = FormStartPosition.CenterParent;
                    if (pMessageBoxModel.FormWidth != 0)
                    {
                        frm.Width = pMessageBoxModel.FormWidth;
                    }
                    if (pMessageBoxModel.FormHeight != 0)
                    {
                        frm.Height = pMessageBoxModel.FormHeight;
                    }

                    return(frm.ShowDialog(parent));
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 支持修改弹出框的按钮标题描述
        /// </summary>
        /// <param name="pMessageBoxModel"></param>
        public frm_MessageBox(MessageBoxModel pMessageBoxModel)
        {
            InitializeComponent();
            if (pMessageBoxModel == null)
            {
                pMessageBoxModel = new MessageBoxModel();
            }

            this.ControlBox       = false;
            this.text             = pMessageBoxModel.MsgText;
            this.Text             = pMessageBoxModel.FormText ?? "Stephen's UserControl";
            this.caption          = pMessageBoxModel.FormText;
            this.buttons          = pMessageBoxModel.MsgButton;
            this.icon             = pMessageBoxModel.MsgIcon;
            this.defaultButton    = pMessageBoxModel.MsgxDefaultButton;
            this._MessageBoxModel = pMessageBoxModel;
        }