mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
UI - Use PropertyChanged.SourceGenerator everywhere else
This commit is contained in:
1 parent
d656c6960d
commit
190d797f1a
40 files changed
+223
-934
No files matched your search
@@ -4,16 +4,17 @@ using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Shared;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Validation.Extensions;
|
||||
|
||||
namespace Artemis.UI.Screens.Sidebar;
|
||||
|
||||
public class SidebarCategoryEditViewModel : ContentDialogViewModelBase
|
||||
public partial class SidebarCategoryEditViewModel : ContentDialogViewModelBase
|
||||
{
|
||||
private readonly ProfileCategory? _category;
|
||||
private readonly IProfileService _profileService;
|
||||
private string? _categoryName;
|
||||
[Notify] private string? _categoryName;
|
||||
|
||||
public SidebarCategoryEditViewModel(IProfileService profileService, ProfileCategory category)
|
||||
{
|
||||
@@ -27,13 +28,7 @@ public class SidebarCategoryEditViewModel : ContentDialogViewModelBase
|
||||
this.ValidationRule(vm => vm.CategoryName, categoryName => !string.IsNullOrWhiteSpace(categoryName?.Trim()), "You must specify a valid name");
|
||||
this.ValidationRule(vm => vm.CategoryName, categoryName => profileService.ProfileCategories.All(c => c.Name != categoryName?.Trim()), "You must specify a unique name");
|
||||
}
|
||||
|
||||
public string? CategoryName
|
||||
{
|
||||
get => _categoryName;
|
||||
set => RaiseAndSetIfChanged(ref _categoryName, value);
|
||||
}
|
||||
|
||||
|
||||
public ReactiveCommand<Unit, Unit> Confirm { get; }
|
||||
|
||||
private void ExecuteConfirm()
|
||||
|
||||
@@ -4,15 +4,16 @@ using System.Timers;
|
||||
using Artemis.Core.Modules;
|
||||
using Artemis.UI.Shared;
|
||||
using Humanizer;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Sidebar;
|
||||
|
||||
public class ModuleActivationRequirementViewModel : ActivatableViewModelBase
|
||||
public partial class ModuleActivationRequirementViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly IModuleActivationRequirement _activationRequirement;
|
||||
private string _requirementDescription;
|
||||
private bool _requirementMet;
|
||||
[Notify] private string _requirementDescription;
|
||||
[Notify] private bool _requirementMet;
|
||||
|
||||
public ModuleActivationRequirementViewModel(IModuleActivationRequirement activationRequirement)
|
||||
{
|
||||
@@ -31,18 +32,6 @@ public class ModuleActivationRequirementViewModel : ActivatableViewModelBase
|
||||
|
||||
public string RequirementName { get; }
|
||||
|
||||
public string RequirementDescription
|
||||
{
|
||||
get => _requirementDescription;
|
||||
set => RaiseAndSetIfChanged(ref _requirementDescription, value);
|
||||
}
|
||||
|
||||
public bool RequirementMet
|
||||
{
|
||||
get => _requirementMet;
|
||||
set => RaiseAndSetIfChanged(ref _requirementMet, value);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
RequirementDescription = _activationRequirement.GetUserFriendlyDescription();
|
||||
|
||||
@@ -17,28 +17,29 @@ using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Threading;
|
||||
using Material.Icons;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Sidebar;
|
||||
|
||||
public class ProfileConfigurationEditViewModel : DialogViewModelBase<ProfileConfiguration?>
|
||||
public partial class ProfileConfigurationEditViewModel : DialogViewModelBase<ProfileConfiguration?>
|
||||
{
|
||||
private readonly ObservableAsPropertyHelper<ModuleActivationRequirementsViewModel?> _moduleActivationRequirementsViewModel;
|
||||
private readonly ProfileCategory _profileCategory;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly IWindowService _windowService;
|
||||
private Hotkey? _disableHotkey;
|
||||
private Hotkey? _enableHotkey;
|
||||
private bool _fadeInAndOut;
|
||||
private ProfileConfigurationHotkeyMode _hotkeyMode;
|
||||
private ProfileConfigurationIconType _iconType;
|
||||
private ProfileConfiguration _profileConfiguration;
|
||||
private string _profileName;
|
||||
private Bitmap? _selectedBitmapSource;
|
||||
private string? _selectedIconPath;
|
||||
private ProfileIconViewModel? _selectedMaterialIcon;
|
||||
private ProfileModuleViewModel? _selectedModule;
|
||||
[Notify] private ProfileConfigurationIconType _iconType;
|
||||
[Notify] private Bitmap? _selectedBitmapSource;
|
||||
[Notify] private ProfileIconViewModel? _selectedMaterialIcon;
|
||||
[Notify] private Hotkey? _disableHotkey;
|
||||
[Notify] private Hotkey? _enableHotkey;
|
||||
[Notify] private bool _fadeInAndOut;
|
||||
[Notify] private ProfileConfigurationHotkeyMode _hotkeyMode;
|
||||
[Notify] private ProfileConfiguration _profileConfiguration;
|
||||
[Notify] private string _profileName;
|
||||
[Notify] private ProfileModuleViewModel? _selectedModule;
|
||||
|
||||
public ProfileConfigurationEditViewModel(
|
||||
ProfileCategory profileCategory,
|
||||
@@ -88,51 +89,7 @@ public class ProfileConfigurationEditViewModel : DialogViewModelBase<ProfileConf
|
||||
}
|
||||
|
||||
public bool IsNew { get; }
|
||||
|
||||
public ProfileConfiguration ProfileConfiguration
|
||||
{
|
||||
get => _profileConfiguration;
|
||||
set => RaiseAndSetIfChanged(ref _profileConfiguration, value);
|
||||
}
|
||||
|
||||
public string ProfileName
|
||||
{
|
||||
get => _profileName;
|
||||
set => RaiseAndSetIfChanged(ref _profileName, value);
|
||||
}
|
||||
|
||||
public ProfileConfigurationHotkeyMode HotkeyMode
|
||||
{
|
||||
get => _hotkeyMode;
|
||||
set => RaiseAndSetIfChanged(ref _hotkeyMode, value);
|
||||
}
|
||||
|
||||
public Hotkey? EnableHotkey
|
||||
{
|
||||
get => _enableHotkey;
|
||||
set => RaiseAndSetIfChanged(ref _enableHotkey, value);
|
||||
}
|
||||
|
||||
public Hotkey? DisableHotkey
|
||||
{
|
||||
get => _disableHotkey;
|
||||
set => RaiseAndSetIfChanged(ref _disableHotkey, value);
|
||||
}
|
||||
|
||||
public bool FadeInAndOut
|
||||
{
|
||||
get => _fadeInAndOut;
|
||||
set => RaiseAndSetIfChanged(ref _fadeInAndOut, value);
|
||||
}
|
||||
|
||||
public ObservableCollection<ProfileModuleViewModel?> Modules { get; }
|
||||
|
||||
public ProfileModuleViewModel? SelectedModule
|
||||
{
|
||||
get => _selectedModule;
|
||||
set => RaiseAndSetIfChanged(ref _selectedModule, value);
|
||||
}
|
||||
|
||||
public NodeScriptViewModel VisualEditorViewModel { get; }
|
||||
public ModuleActivationRequirementsViewModel? ModuleActivationRequirementsViewModel => _moduleActivationRequirementsViewModel.Value;
|
||||
|
||||
@@ -179,25 +136,7 @@ public class ProfileConfigurationEditViewModel : DialogViewModelBase<ProfileConf
|
||||
}
|
||||
|
||||
#region Icon
|
||||
|
||||
public ProfileConfigurationIconType IconType
|
||||
{
|
||||
get => _iconType;
|
||||
set => RaiseAndSetIfChanged(ref _iconType, value);
|
||||
}
|
||||
|
||||
public ProfileIconViewModel? SelectedMaterialIcon
|
||||
{
|
||||
get => _selectedMaterialIcon;
|
||||
set => RaiseAndSetIfChanged(ref _selectedMaterialIcon, value);
|
||||
}
|
||||
|
||||
public Bitmap? SelectedBitmapSource
|
||||
{
|
||||
get => _selectedBitmapSource;
|
||||
set => RaiseAndSetIfChanged(ref _selectedBitmapSource, value);
|
||||
}
|
||||
|
||||
|
||||
private void LoadIcon()
|
||||
{
|
||||
// Preselect the icon based on streams if needed
|
||||
|
||||
@@ -19,11 +19,12 @@ using Artemis.UI.Shared.Services.Builders;
|
||||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
using Newtonsoft.Json;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Sidebar;
|
||||
|
||||
public class SidebarCategoryViewModel : ActivatableViewModelBase
|
||||
public partial class SidebarCategoryViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly IRouter _router;
|
||||
@@ -31,7 +32,7 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
|
||||
private readonly IWindowService _windowService;
|
||||
private ObservableAsPropertyHelper<bool>? _isCollapsed;
|
||||
private ObservableAsPropertyHelper<bool>? _isSuspended;
|
||||
private SidebarProfileConfigurationViewModel? _selectedProfileConfiguration;
|
||||
[Notify] private SidebarProfileConfigurationViewModel? _selectedProfileConfiguration;
|
||||
|
||||
public SidebarCategoryViewModel(ProfileCategory profileCategory, IProfileService profileService, IWindowService windowService, ISidebarVmFactory vmFactory, IRouter router)
|
||||
{
|
||||
@@ -102,16 +103,9 @@ public class SidebarCategoryViewModel : ActivatableViewModelBase
|
||||
|
||||
public ProfileCategory ProfileCategory { get; }
|
||||
public ReadOnlyObservableCollection<SidebarProfileConfigurationViewModel> ProfileConfigurations { get; }
|
||||
|
||||
public bool IsCollapsed => _isCollapsed?.Value ?? false;
|
||||
public bool IsSuspended => _isSuspended?.Value ?? false;
|
||||
|
||||
public SidebarProfileConfigurationViewModel? SelectedProfileConfiguration
|
||||
{
|
||||
get => _selectedProfileConfiguration;
|
||||
set => RaiseAndSetIfChanged(ref _selectedProfileConfiguration, value);
|
||||
}
|
||||
|
||||
|
||||
public void AddProfileConfiguration(ProfileConfiguration profileConfiguration, int? index)
|
||||
{
|
||||
ProfileCategory oldCategory = profileConfiguration.Category;
|
||||
|
||||
@@ -3,12 +3,13 @@ using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Artemis.UI.Shared;
|
||||
using Material.Icons;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
|
||||
namespace Artemis.UI.Screens.Sidebar;
|
||||
|
||||
public class SidebarScreenViewModel : ViewModelBase
|
||||
public partial class SidebarScreenViewModel : ViewModelBase
|
||||
{
|
||||
private bool _isExpanded;
|
||||
[Notify] private bool _isExpanded;
|
||||
|
||||
public SidebarScreenViewModel(MaterialIconKind icon, string displayName, string path, string? rootPath = null, ObservableCollection<SidebarScreenViewModel>? screens = null)
|
||||
{
|
||||
@@ -22,15 +23,8 @@ public class SidebarScreenViewModel : ViewModelBase
|
||||
public MaterialIconKind Icon { get; }
|
||||
public string Path { get; }
|
||||
public string RootPath { get; }
|
||||
|
||||
public ObservableCollection<SidebarScreenViewModel> Screens { get; }
|
||||
|
||||
public bool IsExpanded
|
||||
{
|
||||
get => _isExpanded;
|
||||
set => RaiseAndSetIfChanged(ref _isExpanded, value);
|
||||
}
|
||||
|
||||
|
||||
public bool Matches(string? path)
|
||||
{
|
||||
if (path == null)
|
||||
|
||||
@@ -16,19 +16,20 @@ using Avalonia.Threading;
|
||||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
using Material.Icons;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.Sidebar;
|
||||
|
||||
public class SidebarViewModel : ActivatableViewModelBase
|
||||
public partial class SidebarViewModel : ActivatableViewModelBase
|
||||
{
|
||||
public const string ROOT_SCREEN = "root";
|
||||
|
||||
private readonly IRouter _router;
|
||||
private readonly IWindowService _windowService;
|
||||
private ReadOnlyObservableCollection<SidebarCategoryViewModel> _sidebarCategories = new(new ObservableCollection<SidebarCategoryViewModel>());
|
||||
private SidebarScreenViewModel? _selectedScreen;
|
||||
private bool _updating;
|
||||
[Notify] private ReadOnlyObservableCollection<SidebarCategoryViewModel> _sidebarCategories = new(new ObservableCollection<SidebarCategoryViewModel>());
|
||||
[Notify] private SidebarScreenViewModel? _selectedScreen;
|
||||
|
||||
public SidebarViewModel(IRouter router, IProfileService profileService, IWindowService windowService, ISidebarVmFactory sidebarVmFactory)
|
||||
{
|
||||
@@ -91,19 +92,6 @@ public class SidebarViewModel : ActivatableViewModelBase
|
||||
}
|
||||
|
||||
public SidebarScreenViewModel SidebarScreen { get; }
|
||||
|
||||
public SidebarScreenViewModel? SelectedScreen
|
||||
{
|
||||
get => _selectedScreen;
|
||||
set => RaiseAndSetIfChanged(ref _selectedScreen, value);
|
||||
}
|
||||
|
||||
public ReadOnlyObservableCollection<SidebarCategoryViewModel> SidebarCategories
|
||||
{
|
||||
get => _sidebarCategories;
|
||||
set => RaiseAndSetIfChanged(ref _sidebarCategories, value);
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> AddCategory { get; }
|
||||
|
||||
private async Task ExecuteAddCategory()
|
||||
|
||||
Reference in new issue
Block a user