private void chckbxMinimize_CheckedChanged(object sender, EventArgs e) { // Save the minimizeToTray setting m_settings["minimizeToTray"] = chckbxMinimize.Checked ? "true" : "false"; // Only enable the reopen setting control when close before switching is enabled chckbxStartWithWindows.Enabled = chckbxMinimize.Checked; // Prevent stuff down there from getting executed when the checkbox Checked state was just initialized from the config file if (!m_checkboxesInitialized) { return; } // The start with windows feature only works when minimize to tray is also enabled. // With start with windows is enabled but minimize to system tray gets enabled/disabled, delete/create the autostart file if (m_settings["startWithWindows"] == "true") { // If minimize got enabled, create the autostart file if (chckbxMinimize.Checked) { AutostartUtils.UpdateAutostartFile(); } else // Otherwise remove it { AutostartUtils.RemoveAutostartFile(); } } }
public MainForm(bool silent) // silent is true if the program was started with windows, so it just starts in background { InitializeComponent(); m_silent = silent; // Check if the icon cache folder exists if (!Directory.Exists(Paths.IconCacheFolder)) { Directory.CreateDirectory(Paths.IconCacheFolder); } // Set the version label to the current version provided by the version checker lblVersion.Text = "Version: " + VersionChecker.CurrentVersion; // Initialize all settings with their default values m_settings.SetDefaultValue("minimizeToTray", "true"); m_settings.SetDefaultValue("sendTelemetry", "false"); m_settings.SetDefaultValue("closeOsuBeforeSwitching", "true"); m_settings.SetDefaultValue("reopenOsuAfterSwitching", "true"); m_settings.SetDefaultValue("useDiscordRichPresence", "false"); m_settings.SetDefaultValue("switchAccount", "false"); m_settings.SetDefaultValue("startWithWindows", "false"); // Initialize the list of saved accounts m_accounts.SetDefaultValue("accounts", JsonConvert.SerializeObject(new List <Account>())); // Initialize the switch history m_history.SetDefaultValue("history", JsonConvert.SerializeObject(new HistoryElement[] { })); // Set the settings controls to their state from the settings file chckbxMinimize.Checked = m_settings["minimizeToTray"] == "true"; chckbxSendTelemetry.Checked = m_settings["sendTelemetry"] == "true"; chckbxCloseBeforeSwitching.Checked = m_settings["closeOsuBeforeSwitching"] == "true"; chckbxReopenAfterSwitching.Checked = m_settings["reopenOsuAfterSwitching"] == "true"; chckbxUseDiscordRichPresence.Checked = m_settings["useDiscordRichPresence"] == "true"; chckbxSwitchAccount.Checked = m_settings["switchAccount"] == "true"; chckbxStartWithWindows.Checked = m_settings["startWithWindows"] == "true"; // Checkboxes have been initialized, CheckedChanged can now run properly m_checkboxesInitialized = true; // // Telemetry disabled because not finished yet // m_settings["sendTelemetry"] = "false"; chckbxSendTelemetry.Checked = false; chckbxSendTelemetry.Enabled = false; // When BOTH features are enabled, update the autostart file because the switcher executeable may have moved to another location // both because running in background does not work without having minimizing to system tray enabled if (m_settings["startWithWindows"] == "true" && m_settings["minimizeToTray"] == "true") { AutostartUtils.UpdateAutostartFile(); } }
private void chckbxStartWithWindows_CheckedChanged(object sender, EventArgs e) { // Save the startWithWindows setting m_settings["startWithWindows"] = chckbxStartWithWindows.Checked ? "true" : "false"; // Prevent stuff down there from getting executed when the checkbox Checked state was just initialized from the config file if (!m_checkboxesInitialized) { return; } // Add or remove the auto start shortcut if (chckbxStartWithWindows.Checked) { AutostartUtils.UpdateAutostartFile(); } else { AutostartUtils.RemoveAutostartFile(); } }