Exemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Window.Closing"/> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.ComponentModel.CancelEventArgs"/> that contains the event data.</param>
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            if (PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.RebootRequired) ||
                PropertyBagDictionary.Instance.PropertyExists(PropertyBagConstants.UserRejectUpgrade))
            {
                // If a reboot is required,
                // or the user rejects upgrade, the user already had a confirmation message box
                // therefore we continue without further checks...
            }
            else
            {
                // Make sure we are have a next page... if we don't
                // we don't need to warn about closing as that is what should happen
                if (PageNavigation.Instance.HasNextPage)
                {
                    // Cast because CanClose is not a member of IPageUI
                    BasePageForWpfControls currentPage =
                        PageNavigation.Instance.CurrentPage.PageUI as BasePageForWpfControls;
                    if (currentPage.CanClose())
                    {
                        // Make sure the user wants to cancel
                        // e.Cancel - if set to false, we will cancel, if set to true, the cancel will be aborted.
                        e.Cancel = !VerifyUserClose();
                    }
                    else
                    {
                        e.Cancel = true;
                    }
                }
            }

            base.OnClosing(e);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the Click event of the buttonCancel control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void ButtonCancelClick(object sender, RoutedEventArgs e)
        {
            // Cast because OnCancel is not a member of IPageUI
            BasePageForWpfControls currentPage = PageNavigation.Instance.CurrentPage.PageUI as BasePageForWpfControls;

            if (currentPage.OnCancel())
            {
                this.Close();
            }
        }