示例#1
0
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            if (_gameVM.HasGame)
            {
                var result = MessageBox.Show("Would you like to save the game before exiting?", MessageBoxButtons.YesNoCancel, MessageBoxType.Question, MessageBoxDefaultButton.Yes);

                switch (result)
                {
                case DialogResult.Yes:
                    var saveGame = new SaveGame(_gameVM);
                    saveGame.Execute();
                    break;

                case DialogResult.Cancel:
                    e.Cancel = true;
                    break;
                }
            }
        }