diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/ActionKeywordModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/ActionKeywordModel.cs index 745032d2c..2c4c4e54f 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/ActionKeywordModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/ActionKeywordModel.cs @@ -1,16 +1,11 @@ -using System.ComponentModel; -using System.Runtime.CompilerServices; +#nullable enable -#nullable enable - -namespace Flow.Launcher.Plugin.Explorer.Views +namespace Flow.Launcher.Plugin.Explorer.ViewModels { - public class ActionKeywordModel : INotifyPropertyChanged + public partial class ActionKeywordModel : BaseModel { private static Settings _settings = null!; - public event PropertyChangedEventHandler? PropertyChanged; - public static void Init(Settings settings) { _settings = settings; @@ -28,13 +23,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views internal Settings.ActionKeyword KeywordProperty { get; } - private void OnPropertyChanged([CallerMemberName] string propertyName = "") - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } - private string? keyword; - public string Keyword { get => keyword ??= _settings.GetActionKeyword(KeywordProperty); @@ -45,8 +34,8 @@ namespace Flow.Launcher.Plugin.Explorer.Views OnPropertyChanged(); } } - private bool? enabled; + private bool? enabled; public bool Enabled { get => enabled ??= _settings.GetActionKeywordEnabled(KeywordProperty); diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs index 10ce28fe4..829a2feed 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs @@ -1,16 +1,13 @@ -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Runtime.CompilerServices; +using System.Linq; using System.Windows; using System.Windows.Input; +using CommunityToolkit.Mvvm.ComponentModel; +using Flow.Launcher.Plugin.Explorer.ViewModels; namespace Flow.Launcher.Plugin.Explorer.Views { - /// - /// Interaction logic for ActionKeywordSetting.xaml - /// - public partial class ActionKeywordSetting : INotifyPropertyChanged + [INotifyPropertyChanged] + public partial class ActionKeywordSetting { private ActionKeywordModel CurrentActionKeyword { get; } @@ -21,14 +18,14 @@ namespace Flow.Launcher.Plugin.Explorer.Views { // Set Enable to be true if user change ActionKeyword KeywordEnabled = true; - _ = SetField(ref actionKeyword, value); + _ = SetProperty(ref actionKeyword, value); } } public bool KeywordEnabled { get => _keywordEnabled; - set => SetField(ref _keywordEnabled, value); + set => _ = SetProperty(ref _keywordEnabled, value); } private string actionKeyword; @@ -116,20 +113,5 @@ namespace Flow.Launcher.Plugin.Explorer.Views e.CancelCommand(); } } - - public event PropertyChangedEventHandler PropertyChanged; - protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } - - private bool SetField(ref T field, T value, [CallerMemberName] string propertyName = null) - { - if (EqualityComparer.Default.Equals(field, value)) - return false; - field = value; - OnPropertyChanged(propertyName); - return true; - } } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml index 8f4b4d862..59373b4de 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml @@ -8,7 +8,6 @@ xmlns:qa="clr-namespace:Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks" xmlns:ui="http://schemas.modernwpf.com/2019" xmlns:viewModels="clr-namespace:Flow.Launcher.Plugin.Explorer.ViewModels" - xmlns:views="clr-namespace:Flow.Launcher.Plugin.Explorer.Views" d:DataContext="{d:DesignInstance viewModels:SettingsViewModel}" d:DesignHeight="450" d:DesignWidth="800" @@ -18,7 +17,7 @@ - +