private void LoadSettings() { //Fix to stop the registry thing being removed and not re-added Program.Settings.AutoStartWithWindows = Program.Settings.AutoStartWithWindows; chkCloseToTray.Checked = Program.Settings.CloseToTray; chkStartMinimized.Checked = Program.Settings.StartMinimized; chkAutoStartWithWindows.Checked = Program.Settings.AutoStartWithWindows; chkDisableHotKeys.Checked = Program.Settings.DisableHotKeys; chkQuickSwitch.Checked = Program.Settings.EnableQuickSwitch; chkDualSwitchMode.Checked = Program.Settings.DualSwitchMode; chkNotifyUpdates.Checked = Program.Settings.UpdateNotificationsEnabled; chkShowDiabledDevices.Checked = Program.Settings.ShowDisabledDevices; chkShowDisconnectedDevices.Checked = Program.Settings.ShowDisconnectedDevices; chkShowDPDeviceIconInTray.Checked = Program.Settings.ShowDPDeviceIconInTray; Width = Program.Settings.WindowWidth; Height = Program.Settings.WindowHeight; FavouriteDeviceManager.FavouriteDevicesChanged += AudioDeviceManger_FavouriteDevicesChanged; var favDeviceStr = Program.Settings.FavouriteDevices.Split(new[] { ",", "[", "]" }, StringSplitOptions.RemoveEmptyEntries); FavouriteDeviceManager.LoadFavouriteDevices(Array.ConvertAll(favDeviceStr, x => { var r = new Regex(ConfigurationSettings.GUID_REGEX); foreach (var match in r.Matches(x)) { return(new Guid(match.ToString())); } return(Guid.Empty); })); //Ensure to delete the key if it's not set Program.Settings.AutoStartWithWindows = Program.Settings.AutoStartWithWindows; if (Program.Settings.ShowDisabledDevices) { _deviceStateFilter |= DeviceState.Disabled; } if (Program.Settings.ShowDisconnectedDevices) { _deviceStateFilter |= DeviceState.Unplugged; } }
private void LoadSettings() { //Fix to stop the registry thing being removed and not re-added ConfigurationSettings.AutoStartWithWindows = ConfigurationSettings.AutoStartWithWindows; chkCloseToTray.Checked = ConfigurationSettings.CloseToTray; chkStartMinimized.Checked = ConfigurationSettings.StartMinimized; chkAutoStartWithWindows.Checked = ConfigurationSettings.AutoStartWithWindows; chkDisableHotKeys.Checked = ConfigurationSettings.DisableHotKeys; chkQuickSwitch.Checked = ConfigurationSettings.EnableQuickSwitch; //chkNotifyUpdates.Checked = ConfigurationSettings.CheckForUpdatesOnStartup; chkPollForUpdates.Checked = ConfigurationSettings.PollForUpdates >= 1; spinPollMinutes.Enabled = chkPollForUpdates.Checked; Width = ConfigurationSettings.WindowWidth; Height = ConfigurationSettings.WindowHeight; FavouriteDeviceManager.FavouriteDevicesChanged += AudioDeviceManger_FavouriteDevicesChanged; FavouriteDeviceManager.LoadFavouriteDevices( ConfigurationSettings.FavouriteDevices.Split(new[] { ",", "[", "]" }, StringSplitOptions.RemoveEmptyEntries)); //Ensure the registry key is added/removed if (ConfigurationSettings.AutoStartWithWindows) { RegistryKey add = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); add.SetValue("AudioSwitcher", "\"" + Application.ExecutablePath + "\""); } else { RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); try { key.DeleteValue("AudioSwitcher"); } catch { } //Don't care as it isn't found } }