private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (!_IsExit) { if (SettingsManager.Configuration.CloseToTray) { e.Cancel = true; ShowInTaskbar = false; Hide(); return; } } SettingsManager.Save(); LoggingManager.Log.Info("Exiting application."); LoggingManager.Flush(); }
private void SetupForm_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.ApplicationExitCall) { return; } if (string.IsNullOrEmpty(SettingsManager.Configuration.Notifications.TwitchToken) || string.IsNullOrEmpty(SettingsManager.Configuration.Notifications.TwitchChannel)) { DialogResult answer = MessageBox.Show($"You never entered your OAuth Token and/or Twitch channel.{Environment.NewLine}{Environment.NewLine}Are you sure you want to exit?", "No OAuth Token or Twitch channel", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (answer == DialogResult.No) { e.Cancel = true; } else { LoggingManager.Log.Fatal("No OAuth Token and/or Twitch channel, first run setup exited by user."); LoggingManager.Flush(); Environment.Exit(12); } } }