Beispiel #1
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();
                }
            }
        }
Beispiel #2
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;
            }
        }