Exemple #1
0
 public ErrorDialogViewModel(string errorMessage)
 {
     ErrorMessage           = errorMessage;
     IgnoreCommand          = new CommandHandler(() => DialogClosing?.Invoke(this, false), true);
     ExitCommand            = new CommandHandler(() => DialogClosing?.Invoke(this, true), true);
     CopyToClipboardCommand = new CommandHandler(() => Clipboard.SetText(ErrorMessage), true);
 }
Exemple #2
0
 void Dialog_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (e.CloseReason == CloseReason.MdiFormClosing)
     {
         EveryFileExplorerUtil.DisableFileDependencyDialog();
     }
     if (DialogClosing != null)
     {
         e.Cancel = !DialogClosing.Invoke(this);
     }
 }
Exemple #3
0
        /// <summary>
        /// Event raised when the dialog is being closed.</summary>
        /// <param name="e">A <see cref="T:System.ComponentModel.CancelEventArgs" /> that contains the event data.</param>
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            if (!e.Cancel)
            {
                var args = new HostClosingEventArgs {
                    DialogResult = DialogResult
                };
                DialogClosing.Raise(this, args);

                e.Cancel = args.Cancel;

                // Prevent main application disappearing behind other windows:
                // http://stackoverflow.com/questions/13209526/main-window-disappears-behind-other-applications-windows-after-a-sub-window-use
                if (!e.Cancel && Owner != null)
                {
                    Owner.Focus();
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Request that the dialog close with given dialog result.
        /// DialogClosing event is raised, allowing subscribers the chance to cancel.
        /// </summary>
        /// <param name="dialogResult">The desired dialog result to close with</param>
        /// <exception cref="System.InvalidOperationException">Owner is null</exception>
        public void RequestClose(bool?dialogResult)
        {
            var owner = Owner as IDialogSite;

            if (owner == null)
            {
                throw new InvalidOperationException("");
            }

            var args = new HostClosingEventArgs()
            {
                DialogResult = dialogResult
            };

            DialogClosing.Raise(this, args);

            if (!args.Cancel)
            {
                owner.HideSite();
                owner.Site.Children.Remove(m_dialogContent);
                m_dialogResult   = args.DialogResult;
                m_frame.Continue = false;
            }
        }
Exemple #5
0
 protected virtual void OnDialogClosing(EventArgs e)
 {
     DialogClosing?.Invoke(this, e);
 }
Exemple #6
0
 private void OnDialogClosing(DialogEventArgs e)
 {
     DialogClosing?.Invoke(this, e);
 }