Exemplo n.º 1
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            if (_launcher.State != GameLauncherState.Idle)
            {
                e.Cancel = true;

                if (_closeOnIdle)
                {
                    return;
                }

                switch (_launcher.State)
                {
                case GameLauncherState.Recording:
                    if (MessageBox.Show("Closing the program will cause recording to be stopped. Do you want to continue?",
                                        "Close program",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Warning,
                                        MessageBoxDefaultButton.Button2) != DialogResult.Yes)
                    {
                        return;
                    }
                    break;

                case GameLauncherState.GameStarted:
                case GameLauncherState.GameStartedAndRecording:
                    if (MessageBox.Show("Please close down the game first so that game settings can be restored. Do you want to force terminating the process of the game so that AVI Recorder can be closed immediately? (not recommended)",
                                        "Close program",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Warning,
                                        MessageBoxDefaultButton.Button2) != DialogResult.Yes)
                    {
                        return;
                    }
                    break;

                default:
                    break;
                }

                _closeOnIdle = true;
                _launcher.ForceStop();
            }

            base.OnFormClosing(e);
        }