private void Ok_Click(object sender, RoutedEventArgs e) { var closeOptionsWindow = true; try { _hotkey.Enabled = false; // Change the active hotkey _hotkey.Alt = _hotkeyViewModel.Alt; _hotkey.Shift = _hotkeyViewModel.Shift; _hotkey.Ctrl = _hotkeyViewModel.Ctrl; _hotkey.WindowsKey = _hotkeyViewModel.Windows; _hotkey.KeyCode = (Keys)KeyInterop.VirtualKeyFromKey(_hotkeyViewModel.KeyCode); _hotkey.Enabled = true; _hotkey.SaveSettings(); } catch (HotkeyAlreadyInUseException) { var boxText = "Sorry! The selected shortcut for activating Switcheroo is in use by another program. " + "Please choose another."; MessageBox.Show(boxText, "Shortcut already in use", MessageBoxButton.OK, MessageBoxImage.Warning); closeOptionsWindow = false; } Settings.Default.AltTabHook = AltTabCheckBox.IsChecked.GetValueOrDefault(); Settings.Default.RunAsAdmin = RunAsAdministrator.IsChecked.GetValueOrDefault(false); Settings.Default.Save(); if (closeOptionsWindow) { Close(); } }
private void Ok_Click(object sender, RoutedEventArgs e) { var closeOptionsWindow = true; try { _hotkey.Enabled = false; if (Settings.Default.EnableHotKey) { // Change the active hotkey _hotkey.Alt = _hotkeyViewModel.Alt; _hotkey.Shift = _hotkeyViewModel.Shift; _hotkey.Ctrl = _hotkeyViewModel.Ctrl; _hotkey.WindowsKey = _hotkeyViewModel.Windows; _hotkey.KeyCode = (Keys)KeyInterop.VirtualKeyFromKey(_hotkeyViewModel.KeyCode); _hotkey.Enabled = true; } _hotkey.SaveSettings(); } catch (HotkeyAlreadyInUseException) { var boxText = "Sorry! The selected shortcut for activating Switcheroo is in use by another program. " + "Please choose another."; MessageBox.Show(boxText, "Shortcut already in use", MessageBoxButton.OK, MessageBoxImage.Warning); closeOptionsWindow = false; } Settings.Default.EnableHotKey = HotKeyCheckBox.IsChecked.GetValueOrDefault(); Settings.Default.AltTabHook = AltTabCheckBox.IsChecked.GetValueOrDefault(); Settings.Default.AutoSwitch = AutoSwitch.IsChecked.GetValueOrDefault(); Settings.Default.RunAsAdmin = RunAsAdministrator.IsChecked.GetValueOrDefault(); var themeSetting = (Tuple <string, ThemeMode, string>)ThemeDropdown.SelectedItem; Settings.Default.ThemeMode = themeSetting.Item2.ToString(); Settings.Default.CustomTheme = themeSetting.Item3.ToString(); var behaviourSetting = (Tuple <string, DisplayBehaviour, int>)BehaviourDropdown.SelectedItem; Settings.Default.DisplayBehaviour = behaviourSetting.Item2.ToString(); Settings.Default.ScreenIndex = behaviourSetting.Item3; Settings.Default.Save(); if (closeOptionsWindow) { Close(); } }
private void Ok_Click(object sender, RoutedEventArgs e) { // Change the active hotkey hotkey.Alt = (bool)Alt.IsChecked; hotkey.Shift = (bool)Shift.IsChecked; hotkey.Ctrl = (bool)Ctrl.IsChecked; hotkey.WindowsKey = (bool)WindowsKey.IsChecked; hotkey.KeyCode = (Keys)Keys.SelectedItem; hotkey.SaveSettings(); // Save edited text list to app config string[] tempExclusionList = ExceptionList.Text.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);; Core.ExceptionList = tempExclusionList.ToList(); Properties.Settings.Default.Exceptions.Clear(); Properties.Settings.Default.Exceptions.AddRange(Core.ExceptionList.ToArray()); Properties.Settings.Default.Save(); Close(); }