From af27540db0ba53b655574612a456447fbf10477a Mon Sep 17 00:00:00 2001 From: JLdgu <114992499+JLdgu@users.noreply.github.com> Date: Mon, 25 Nov 2024 17:18:59 +0000 Subject: [PATCH] Use shared ViewModelBase in Demo3 (#3729) --- .../Domain/DemoItem.cs | 3 +- .../Domain/DialogsViewModel.cs | 1 + .../Domain/FieldsViewModel.cs | 4 +- .../Domain/IconPackViewModel.cs | 1 + .../Domain/ListsAndGridsViewModel.cs | 1 + .../Domain/PaletteSelectorViewModel.cs | 1 + .../Domain/PickersViewModel.cs | 4 +- .../Domain/SampleDialogViewModel.cs | 2 + .../Domain/SampleItem.cs | 3 +- .../Domain/SelectableViewModel.cs | 4 +- .../Domain/SlidersViewModel.cs | 4 +- .../Domain/ThemeSettingsViewModel.cs | 3 +- .../Domain/TreesViewModel.cs | 1 + .../Domain/ViewModelBase.cs | 37 ------------------- .../TransitionsDemo/Slide1_Intro.xaml.cs | 1 + 15 files changed, 26 insertions(+), 44 deletions(-) delete mode 100644 src/MaterialDesign3.Demo.Wpf/Domain/ViewModelBase.cs diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/DemoItem.cs b/src/MaterialDesign3.Demo.Wpf/Domain/DemoItem.cs index fd255b4361..4f80042786 100644 --- a/src/MaterialDesign3.Demo.Wpf/Domain/DemoItem.cs +++ b/src/MaterialDesign3.Demo.Wpf/Domain/DemoItem.cs @@ -1,4 +1,5 @@ -using MaterialDesignThemes.Wpf; +using MaterialDesignDemo.Shared.Domain; +using MaterialDesignThemes.Wpf; namespace MaterialDesign3Demo.Domain; diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/DialogsViewModel.cs b/src/MaterialDesign3.Demo.Wpf/Domain/DialogsViewModel.cs index 9f4eefeb72..d7f66e5598 100644 --- a/src/MaterialDesign3.Demo.Wpf/Domain/DialogsViewModel.cs +++ b/src/MaterialDesign3.Demo.Wpf/Domain/DialogsViewModel.cs @@ -1,4 +1,5 @@ using System.Diagnostics; +using MaterialDesignDemo.Shared.Domain; using MaterialDesignThemes.Wpf; namespace MaterialDesign3Demo.Domain; diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/FieldsViewModel.cs b/src/MaterialDesign3.Demo.Wpf/Domain/FieldsViewModel.cs index f65a456698..10c6951059 100644 --- a/src/MaterialDesign3.Demo.Wpf/Domain/FieldsViewModel.cs +++ b/src/MaterialDesign3.Demo.Wpf/Domain/FieldsViewModel.cs @@ -1,4 +1,6 @@ -namespace MaterialDesign3Demo.Domain; +using MaterialDesignDemo.Shared.Domain; + +namespace MaterialDesign3Demo.Domain; public class FieldsViewModel : ViewModelBase { diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/IconPackViewModel.cs b/src/MaterialDesign3.Demo.Wpf/Domain/IconPackViewModel.cs index bddf441d8d..7f840fbf21 100644 --- a/src/MaterialDesign3.Demo.Wpf/Domain/IconPackViewModel.cs +++ b/src/MaterialDesign3.Demo.Wpf/Domain/IconPackViewModel.cs @@ -1,6 +1,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using BluwolfIcons; +using MaterialDesignDemo.Shared.Domain; using MaterialDesignThemes.Wpf; using Microsoft.Win32; diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/ListsAndGridsViewModel.cs b/src/MaterialDesign3.Demo.Wpf/Domain/ListsAndGridsViewModel.cs index ceb90def6d..ae6cc56bd5 100644 --- a/src/MaterialDesign3.Demo.Wpf/Domain/ListsAndGridsViewModel.cs +++ b/src/MaterialDesign3.Demo.Wpf/Domain/ListsAndGridsViewModel.cs @@ -1,4 +1,5 @@ using System.Collections.ObjectModel; +using MaterialDesignDemo.Shared.Domain; namespace MaterialDesign3Demo.Domain; diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/PaletteSelectorViewModel.cs b/src/MaterialDesign3.Demo.Wpf/Domain/PaletteSelectorViewModel.cs index d80a06d109..db8d03c4f6 100644 --- a/src/MaterialDesign3.Demo.Wpf/Domain/PaletteSelectorViewModel.cs +++ b/src/MaterialDesign3.Demo.Wpf/Domain/PaletteSelectorViewModel.cs @@ -1,4 +1,5 @@ using MaterialDesignColors; +using MaterialDesignDemo.Shared.Domain; using MaterialDesignThemes.Wpf; namespace MaterialDesign3Demo.Domain; diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/PickersViewModel.cs b/src/MaterialDesign3.Demo.Wpf/Domain/PickersViewModel.cs index ca5e576bd4..ddd0f88f3b 100644 --- a/src/MaterialDesign3.Demo.Wpf/Domain/PickersViewModel.cs +++ b/src/MaterialDesign3.Demo.Wpf/Domain/PickersViewModel.cs @@ -1,4 +1,6 @@ -namespace MaterialDesign3Demo.Domain; +using MaterialDesignDemo.Shared.Domain; + +namespace MaterialDesign3Demo.Domain; public class PickersViewModel : ViewModelBase { diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/SampleDialogViewModel.cs b/src/MaterialDesign3.Demo.Wpf/Domain/SampleDialogViewModel.cs index 4355f3ea55..6cf8338112 100644 --- a/src/MaterialDesign3.Demo.Wpf/Domain/SampleDialogViewModel.cs +++ b/src/MaterialDesign3.Demo.Wpf/Domain/SampleDialogViewModel.cs @@ -1,3 +1,5 @@ +using MaterialDesignDemo.Shared.Domain; + namespace MaterialDesign3Demo.Domain; public class SampleDialogViewModel : ViewModelBase diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/SampleItem.cs b/src/MaterialDesign3.Demo.Wpf/Domain/SampleItem.cs index da3e612898..b58da99f1b 100644 --- a/src/MaterialDesign3.Demo.Wpf/Domain/SampleItem.cs +++ b/src/MaterialDesign3.Demo.Wpf/Domain/SampleItem.cs @@ -1,4 +1,5 @@ -using MaterialDesignThemes.Wpf; +using MaterialDesignDemo.Shared.Domain; +using MaterialDesignThemes.Wpf; namespace MaterialDesign3Demo.Domain; diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/SelectableViewModel.cs b/src/MaterialDesign3.Demo.Wpf/Domain/SelectableViewModel.cs index 2228211c3e..0602268993 100644 --- a/src/MaterialDesign3.Demo.Wpf/Domain/SelectableViewModel.cs +++ b/src/MaterialDesign3.Demo.Wpf/Domain/SelectableViewModel.cs @@ -1,4 +1,6 @@ -namespace MaterialDesign3Demo.Domain; +using MaterialDesignDemo.Shared.Domain; + +namespace MaterialDesign3Demo.Domain; public class SelectableViewModel : ViewModelBase { diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/SlidersViewModel.cs b/src/MaterialDesign3.Demo.Wpf/Domain/SlidersViewModel.cs index bb3604ade6..178a294934 100644 --- a/src/MaterialDesign3.Demo.Wpf/Domain/SlidersViewModel.cs +++ b/src/MaterialDesign3.Demo.Wpf/Domain/SlidersViewModel.cs @@ -1,4 +1,6 @@ -namespace MaterialDesign3Demo.Domain; +using MaterialDesignDemo.Shared.Domain; + +namespace MaterialDesign3Demo.Domain; public class SlidersViewModel : ViewModelBase { diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/ThemeSettingsViewModel.cs b/src/MaterialDesign3.Demo.Wpf/Domain/ThemeSettingsViewModel.cs index 1115ebcaed..101b0fa0e8 100644 --- a/src/MaterialDesign3.Demo.Wpf/Domain/ThemeSettingsViewModel.cs +++ b/src/MaterialDesign3.Demo.Wpf/Domain/ThemeSettingsViewModel.cs @@ -1,4 +1,5 @@ -using MaterialDesignThemes.Wpf; +using MaterialDesignDemo.Shared.Domain; +using MaterialDesignThemes.Wpf; namespace MaterialDesign3Demo.Domain; diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/TreesViewModel.cs b/src/MaterialDesign3.Demo.Wpf/Domain/TreesViewModel.cs index 825cf9fbae..4bf803bf61 100644 --- a/src/MaterialDesign3.Demo.Wpf/Domain/TreesViewModel.cs +++ b/src/MaterialDesign3.Demo.Wpf/Domain/TreesViewModel.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Collections.ObjectModel; +using MaterialDesignDemo.Shared.Domain; using MaterialDesignThemes.Wpf; namespace MaterialDesign3Demo.Domain; diff --git a/src/MaterialDesign3.Demo.Wpf/Domain/ViewModelBase.cs b/src/MaterialDesign3.Demo.Wpf/Domain/ViewModelBase.cs deleted file mode 100644 index 86dd57402a..0000000000 --- a/src/MaterialDesign3.Demo.Wpf/Domain/ViewModelBase.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.ComponentModel; -using System.Runtime.CompilerServices; - -namespace MaterialDesign3Demo.Domain; - -public abstract class ViewModelBase : INotifyPropertyChanged -{ - public event PropertyChangedEventHandler? PropertyChanged; - - /// - /// Sets property if it does not equal existing value. Notifies listeners if change occurs. - /// - /// Type of property. - /// The property's backing field. - /// The new value. - /// Name of the property used to notify listeners. This - /// value is optional and can be provided automatically when invoked from compilers - /// that support . - protected virtual bool SetProperty(ref T member, T value, [CallerMemberName] string? propertyName = null) - { - if (EqualityComparer.Default.Equals(member, value)) - { - return false; - } - - member = value; - OnPropertyChanged(propertyName); - return true; - } - - /// - /// Notifies listeners that a property value has changed. - /// - /// Name of the property, used to notify listeners. - protected void OnPropertyChanged([CallerMemberName] string? propertyName = null) - => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); -} diff --git a/src/MaterialDesign3.Demo.Wpf/TransitionsDemo/Slide1_Intro.xaml.cs b/src/MaterialDesign3.Demo.Wpf/TransitionsDemo/Slide1_Intro.xaml.cs index 9ed096ddd6..a82b57d56d 100644 --- a/src/MaterialDesign3.Demo.Wpf/TransitionsDemo/Slide1_Intro.xaml.cs +++ b/src/MaterialDesign3.Demo.Wpf/TransitionsDemo/Slide1_Intro.xaml.cs @@ -1,4 +1,5 @@ using MaterialDesign3Demo.Domain; +using MaterialDesignDemo.Shared.Domain; namespace MaterialDesign3Demo.TransitionsDemo;