diff --git a/Flow.Launcher.Infrastructure/UserSettings/CustomShortcutModel.cs b/Flow.Launcher.Infrastructure/UserSettings/CustomShortcutModel.cs new file mode 100644 index 000000000..750adf9ee --- /dev/null +++ b/Flow.Launcher.Infrastructure/UserSettings/CustomShortcutModel.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Flow.Launcher.Infrastructure.UserSettings +{ + public class CustomShortcutModel + { + public string Key { get; set; } + public string Value { get; set; } + + public CustomShortcutModel(string key, string value) + { + Key = key; + Value = value; + } + + public override bool Equals(object obj) + { + return obj is CustomShortcutModel other && + Key == other.Key && + Value == other.Value; + } + + public override int GetHashCode() + { + return HashCode.Combine(Key, Value); + } + + public void Deconstruct(out string key, out string value) + { + key = Key; + value = Value; + } + + public static implicit operator (string Key, string Value)(CustomShortcutModel shortcut) + { + return (shortcut.Key, shortcut.Value); + } + + public static implicit operator CustomShortcutModel((string Key, string Value) shortcut) + { + return new CustomShortcutModel(shortcut.Key, shortcut.Value); + } + } +} diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 872af4560..8feba325c 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -220,44 +220,4 @@ namespace Flow.Launcher.Infrastructure.UserSettings Light, Dark } - - public struct CustomShortcutModel - { - public string Key { get; set; } - public string Value { get; set; } - - public CustomShortcutModel(string key, string value) - { - Key = key; - Value = value; - } - - public override bool Equals(object obj) - { - return obj is CustomShortcutModel other && - Key == other.Key && - Value == other.Value; - } - - public override int GetHashCode() - { - return HashCode.Combine(Key, Value); - } - - public void Deconstruct(out string key, out string value) - { - key = Key; - value = Value; - } - - public static implicit operator (string Key, string Value)(CustomShortcutModel value) - { - return (value.Key, value.Value); - } - - public static implicit operator CustomShortcutModel((string Key, string Value) value) - { - return new CustomShortcutModel(value.Key, value.Value); - } - } } diff --git a/Flow.Launcher/CustomShortcutSetting.xaml.cs b/Flow.Launcher/CustomShortcutSetting.xaml.cs index ce16981d8..2a03d483b 100644 --- a/Flow.Launcher/CustomShortcutSetting.xaml.cs +++ b/Flow.Launcher/CustomShortcutSetting.xaml.cs @@ -14,12 +14,12 @@ namespace Flow.Launcher { private SettingWindow _settingWidow; private bool update; - private CustomPluginHotkey updateCustomHotkey; private Settings _settings; public string Key { get; set; } public string Value { get; set; } public CustomShortcutModel ShortCut => (Key, Value); + public CustomShortcutSetting() { InitializeComponent(); diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 10a69f572..2db00f959 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -365,11 +365,14 @@ namespace Flow.Launcher restoreButton.Visibility = Visibility.Collapsed; } } + private void Window_StateChanged(object sender, EventArgs e) { RefreshMaximizeRestoreButton(); } + #region Shortcut + private void OnDeleteCustomShortCutClick(object sender, RoutedEventArgs e) { var item = viewModel.SelectedCustomShortcut; @@ -386,15 +389,16 @@ namespace Flow.Launcher MessageBox.Show(deleteWarning, InternationalizationManager.Instance.GetTranslation("delete"), MessageBoxButton.YesNo) == MessageBoxResult.Yes) { - settings.CustomShortcuts.Remove(item.Value); + settings.CustomShortcuts.Remove(item); } } + private void OnEditCustomShortCutClick(object sender, RoutedEventArgs e) { var item = viewModel.SelectedCustomShortcut; if (item != null) { - var shortcutSettingWindow = new CustomShortcutSetting(item.Value); + var shortcutSettingWindow = new CustomShortcutSetting(item); if (shortcutSettingWindow.ShowDialog() == true) { settings.CustomShortcuts[viewModel.SelectCustomShortcutIndex.Value] = shortcutSettingWindow.ShortCut; @@ -414,5 +418,8 @@ namespace Flow.Launcher settings.CustomShortcuts.Add(shortcutSettingWindow.ShortCut); } } + + #endregion + } }