Ejemplo n.º 1
0
 /// <summary>
 /// Execute closing function and persist session data here.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnClosed(ViewModel.AppViewModel appVM, Window win)
 {
     try
     {
         Console.WriteLine("Closing down apllication.");
     }
     catch (System.Exception exp)
     {
         MessageBox.Show(exp.ToString(), "Error in OnClosed method", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Evaluate whether application is ready to shutdown and print a corresponding message if not.
        /// </summary>
        /// <returns></returns>
        private bool OnSessionEnding()
        {
            ViewModel.AppViewModel tVM = this.MainWindow.DataContext as ViewModel.AppViewModel;

            if (tVM != null)
            {
                if (tVM.IsReadyToClose == false)
                {
                    //MessageBox.Show("Application is not ready to exit.\n" +
                    //                "Hint: Check the checkbox in the MainWindow before exiting the application.",
                    //                "Cannot exit application", MessageBoxButton.YesNoCancel);

                    return(!tVM.IsReadyToClose); // Cancel close down request if ViewModel is not ready, yet
                }

                //tVM.OnRequestClose(false);

                return(!tVM.IsReadyToClose); // Cancel close down request if ViewModel is not ready, yet
            }

            return(true);
        }