Esempio n. 1
0
        /// <summary>
        ///     Raises the <see cref="E:System.Windows.Forms.Form.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)
        {
            if (_isDemoRunning)
            {
                if (
                    MessageBox.Show(this,
                                    $"A demo is still playing. Your key bindings will only be restored if quit {_runningGameVersion.GetFullName()} before you close this application.\n" +
                                    "Are you sure you want to close this application?",
                                    "Demo is running", MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
                                    MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    e.Cancel = true;
                    return;
                }
            }

            base.OnClosing(e);
        }