private async void MetroWindow_Closing_Async(object sender, System.ComponentModel.CancelEventArgs e)
        {
            e.Cancel = !_shutdown;
            if (_shutdown)
            {
                return;
            }

            var mySettings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "Quit",
                NegativeButtonText    = "Cancel",
                AnimateShow           = true,
                AnimateHide           = false
            };

            var result = await this.ShowMessageAsync("Quit",
                                                     "Close Game?",
                                                     MessageDialogStyle.AffirmativeAndNegative, mySettings);

            bool affirm = result == MessageDialogResult.Affirmative;

            if (affirm)
            {
                // Close Game
                // Todo: save score
                // Todo: save score on dispose
            }
            _shutdown = affirm;

            if (_shutdown)
            {
                MainGFX.Dispose();
                //this.Close();
                System.Windows.Application.Current.Shutdown();
            }
        }
Example #2
0
        private async void MetroWindow_Closing_Async(object sender, System.ComponentModel.CancelEventArgs e)
        {
            e.Cancel = !_shutdown;
            if (_shutdown)
            {
                return;
            }

            var mySettings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "Save & Quit",
                NegativeButtonText    = "Quit",
                AnimateShow           = true,
                AnimateHide           = false
            };

            var result = await this.ShowMessageAsync("Quit Gamedesigner?",
                                                     "Do you want to save changes?",
                                                     MessageDialogStyle.AffirmativeAndNegative, mySettings);

            bool affirm = result == MessageDialogResult.Affirmative;

            if (affirm)
            {
                cmdSaveLevel_Click(this, new RoutedEventArgs());
            }

            _shutdown = true;

            if (_shutdown)
            {
                MainGFX.Dispose();
                System.Windows.Application.Current.Shutdown();
                //this.Close();
            }
        }