Exemplo n.º 1
0
 /// <summary>
 /// Closes the view.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="CancelEventArgs"/> instance containing the event data.</param>
 private void CloseView(object sender, CancelEventArgs e)
 {
     //if we are on the player the was left
     if (closeWin == true)
     {
         return;
     }
     //else we are on the player that want to leave.
     closeWin = true;
     vm.Close();
 }
Exemplo n.º 2
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(CancelEventArgs e)
        {
            MessageBoxButton mbb    = MessageBoxButton.YesNo;
            MessageBoxResult result = MessageBox.Show("Are you sure you to exit?", "Exit Game", mbb);

            if (result == MessageBoxResult.Yes)
            {
                try
                {
                    vm.Close();
                } catch (Exception)
                {
                } finally
                {
                    MainWindow win = (MainWindow)Application.Current.MainWindow;
                    win.Show();
                }
            }
            else
            {
                e.Cancel = true;
            }
        }