Exemplo n.º 1
0
        /// <summary>
        /// 关闭对话框
        /// </summary>
        /// <param name="view">对话框视图</param>
        protected void CloseDialog(BaseDialog view)
        {
            view.Confirm.Click -= (sender, args) => CloseDialog(view);
            view.Cancel.Click  -= (sender, args) => view.Close();
            view.Closing       -= (sender, args) => DialogClosing(view, args);
            view.Closed        -= (sender, args) => view.Dispose();

            view.DialogResult = DialogResult.OK;
            view.Close();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 对话框关闭时弹出确认信息
        /// </summary>
        /// <param name="view">对话框视图</param>
        /// <param name="e">对话框视图关闭事件</param>
        private void DialogClosing(BaseDialog view, CancelEventArgs e)
        {
            if (view.DialogResult == DialogResult.OK)
            {
                return;
            }

            const string msg = "您确定要放弃所做的变更,并关闭对话框吗?";

            if (!Messages.ShowConfirm(msg))
            {
                e.Cancel = true;
            }

            view.Confirm.Click -= (sender, args) => CloseDialog(view);
            view.Cancel.Click  -= (sender, args) => view.Close();
            view.Closing       -= (sender, args) => DialogClosing(view, args);
            view.Closed        -= (sender, args) => view.Dispose();

            view.DialogResult = DialogResult.Cancel;
        }
Exemplo n.º 3
0
 /// <summary>
 /// 订阅对话框关闭事件
 /// </summary>
 /// <param name="view">对话框视图</param>
 protected void SubCloseEvent(BaseDialog view)
 {
     view.Cancel.Click += (sender, args) => view.Close();
     view.Closing      += (sender, args) => DialogClosing(view, args);
     view.Closed       += (sender, args) => view.Dispose();
 }