diff --git a/src/Artemis.UI/Screens/Debugger/DebugViewModel.cs b/src/Artemis.UI/Screens/Debugger/DebugViewModel.cs index 87cc92d7d..6ccd0cbb8 100644 --- a/src/Artemis.UI/Screens/Debugger/DebugViewModel.cs +++ b/src/Artemis.UI/Screens/Debugger/DebugViewModel.cs @@ -8,13 +8,14 @@ using Artemis.UI.Screens.Debugger.Render; using Artemis.UI.Screens.Debugger.Routing; using Artemis.UI.Services.Interfaces; using Artemis.UI.Shared; +using PropertyChanged.SourceGenerator; using ReactiveUI; namespace Artemis.UI.Screens.Debugger; -public class DebugViewModel : ActivatableViewModelBase, IScreen +public partial class DebugViewModel : ActivatableViewModelBase, IScreen { - private ViewModelBase _selectedItem; + [Notify] private ViewModelBase _selectedItem; public DebugViewModel(IDebugService debugService, RenderDebugViewModel render, DataModelDebugViewModel dataModel, PerformanceDebugViewModel performance, RoutingDebugViewModel routing, LogsDebugViewModel logs) { @@ -25,13 +26,7 @@ public class DebugViewModel : ActivatableViewModelBase, IScreen } public ObservableCollection Items { get; } - - public ViewModelBase SelectedItem - { - get => _selectedItem; - set => RaiseAndSetIfChanged(ref _selectedItem, value); - } - + public void Activate() { OnActivationRequested(); diff --git a/src/Artemis.UI/Screens/Debugger/Tabs/DataModel/DataModelDebugViewModel.cs b/src/Artemis.UI/Screens/Debugger/Tabs/DataModel/DataModelDebugViewModel.cs index a0f9586dc..09ceb0a70 100644 --- a/src/Artemis.UI/Screens/Debugger/Tabs/DataModel/DataModelDebugViewModel.cs +++ b/src/Artemis.UI/Screens/Debugger/Tabs/DataModel/DataModelDebugViewModel.cs @@ -12,21 +12,21 @@ using Artemis.UI.Shared.DataModelVisualization.Shared; using Artemis.UI.Shared.Services; using Avalonia.Threading; using DynamicData; +using PropertyChanged.SourceGenerator; using ReactiveUI; namespace Artemis.UI.Screens.Debugger.DataModel; -public class DataModelDebugViewModel : ActivatableViewModelBase +public partial class DataModelDebugViewModel : ActivatableViewModelBase { private readonly IDataModelUIService _dataModelUIService; private readonly IPluginManagementService _pluginManagementService; private readonly DispatcherTimer _updateTimer; - private bool _isModuleFilterEnabled; - private DataModelPropertiesViewModel? _mainDataModel; - private string? _propertySearch; private Module? _selectedModule; private bool _slowUpdates; + [Notify] private DataModelPropertiesViewModel? _mainDataModel; + [Notify] private string? _propertySearch; public DataModelDebugViewModel(IDataModelUIService dataModelUIService, IPluginManagementService pluginManagementService) { @@ -57,18 +57,6 @@ public class DataModelDebugViewModel : ActivatableViewModelBase }); } - public DataModelPropertiesViewModel? MainDataModel - { - get => _mainDataModel; - set => RaiseAndSetIfChanged(ref _mainDataModel, value); - } - - public string? PropertySearch - { - get => _propertySearch; - set => RaiseAndSetIfChanged(ref _propertySearch, value); - } - public bool SlowUpdates { get => _slowUpdates; diff --git a/src/Artemis.UI/Screens/Debugger/Tabs/Performance/PerformanceDebugMeasurementViewModel.cs b/src/Artemis.UI/Screens/Debugger/Tabs/Performance/PerformanceDebugMeasurementViewModel.cs index 2358a5a1d..d76dc500e 100644 --- a/src/Artemis.UI/Screens/Debugger/Tabs/Performance/PerformanceDebugMeasurementViewModel.cs +++ b/src/Artemis.UI/Screens/Debugger/Tabs/Performance/PerformanceDebugMeasurementViewModel.cs @@ -1,16 +1,17 @@ using Artemis.Core; using Artemis.UI.Shared; +using PropertyChanged.SourceGenerator; namespace Artemis.UI.Screens.Debugger.Performance; -public class PerformanceDebugMeasurementViewModel : ViewModelBase +public partial class PerformanceDebugMeasurementViewModel : ViewModelBase { - private string? _average; - private string? _last; - private string? _max; - private string? _min; - private string? _percentile; - private string? _count; + [Notify] private string? _average; + [Notify] private string? _last; + [Notify] private string? _max; + [Notify] private string? _min; + [Notify] private string? _percentile; + [Notify] private string? _count; public PerformanceDebugMeasurementViewModel(ProfilingMeasurement measurement) { @@ -19,42 +20,6 @@ public class PerformanceDebugMeasurementViewModel : ViewModelBase public ProfilingMeasurement Measurement { get; } - public string? Last - { - get => _last; - set => RaiseAndSetIfChanged(ref _last, value); - } - - public string? Average - { - get => _average; - set => RaiseAndSetIfChanged(ref _average, value); - } - - public string? Min - { - get => _min; - set => RaiseAndSetIfChanged(ref _min, value); - } - - public string? Max - { - get => _max; - set => RaiseAndSetIfChanged(ref _max, value); - } - - public string? Percentile - { - get => _percentile; - set => RaiseAndSetIfChanged(ref _percentile, value); - } - - public string? Count - { - get => _count; - set => RaiseAndSetIfChanged(ref _count, value); - } - public void Update() { Last = Measurement.GetLast().TotalMilliseconds + " ms"; diff --git a/src/Artemis.UI/Screens/Debugger/Tabs/Performance/PerformanceDebugViewModel.cs b/src/Artemis.UI/Screens/Debugger/Tabs/Performance/PerformanceDebugViewModel.cs index d61cc8c25..cefb569dc 100644 --- a/src/Artemis.UI/Screens/Debugger/Tabs/Performance/PerformanceDebugViewModel.cs +++ b/src/Artemis.UI/Screens/Debugger/Tabs/Performance/PerformanceDebugViewModel.cs @@ -7,20 +7,21 @@ using Artemis.Core; using Artemis.Core.Services; using Artemis.UI.Shared; using Avalonia.Threading; +using PropertyChanged.SourceGenerator; using ReactiveUI; using SkiaSharp; namespace Artemis.UI.Screens.Debugger.Performance; -public class PerformanceDebugViewModel : ActivatableViewModelBase +public partial class PerformanceDebugViewModel : ActivatableViewModelBase { private readonly IRenderService _renderService; private readonly IPluginManagementService _pluginManagementService; private readonly DispatcherTimer _updateTimer; - private double _currentFps; - private string? _renderer; - private int _renderHeight; - private int _renderWidth; + [Notify] private double _currentFps; + [Notify] private string? _renderer; + [Notify] private int _renderHeight; + [Notify] private int _renderWidth; public PerformanceDebugViewModel(IRenderService renderService, IPluginManagementService pluginManagementService) { @@ -59,31 +60,7 @@ public class PerformanceDebugViewModel : ActivatableViewModelBase } public ObservableCollection Items { get; } = new(); - - public double CurrentFps - { - get => _currentFps; - set => RaiseAndSetIfChanged(ref _currentFps, value); - } - - public int RenderWidth - { - get => _renderWidth; - set => RaiseAndSetIfChanged(ref _renderWidth, value); - } - - public int RenderHeight - { - get => _renderHeight; - set => RaiseAndSetIfChanged(ref _renderHeight, value); - } - - public string? Renderer - { - get => _renderer; - set => RaiseAndSetIfChanged(ref _renderer, value); - } - + private void HandleActivation() { Renderer = Constants.ManagedGraphicsContext != null ? Constants.ManagedGraphicsContext.GetType().Name : "Software"; diff --git a/src/Artemis.UI/Screens/Debugger/Tabs/Render/RenderDebugViewModel.cs b/src/Artemis.UI/Screens/Debugger/Tabs/Render/RenderDebugViewModel.cs index b10317022..b4594eee3 100644 --- a/src/Artemis.UI/Screens/Debugger/Tabs/Render/RenderDebugViewModel.cs +++ b/src/Artemis.UI/Screens/Debugger/Tabs/Render/RenderDebugViewModel.cs @@ -4,21 +4,21 @@ using Artemis.Core; using Artemis.Core.Services; using Artemis.UI.Shared; using Avalonia.Media.Imaging; +using PropertyChanged.SourceGenerator; using ReactiveUI; using SkiaSharp; namespace Artemis.UI.Screens.Debugger.Render; -public class RenderDebugViewModel : ActivatableViewModelBase +public partial class RenderDebugViewModel : ActivatableViewModelBase { private readonly IRenderService _renderService; - private double _currentFps; - - private Bitmap? _currentFrame; private string? _frameTargetPath; - private string? _renderer; - private int _renderHeight; - private int _renderWidth; + [Notify] private double _currentFps; + [Notify] private Bitmap? _currentFrame; + [Notify] private string? _renderer; + [Notify] private int _renderHeight; + [Notify] private int _renderWidth; public RenderDebugViewModel(IRenderService renderService) { @@ -33,36 +33,6 @@ public class RenderDebugViewModel : ActivatableViewModelBase }); } - public Bitmap? CurrentFrame - { - get => _currentFrame; - set => RaiseAndSetIfChanged(ref _currentFrame, value); - } - - public double CurrentFps - { - get => _currentFps; - set => RaiseAndSetIfChanged(ref _currentFps, value); - } - - public int RenderWidth - { - get => _renderWidth; - set => RaiseAndSetIfChanged(ref _renderWidth, value); - } - - public int RenderHeight - { - get => _renderHeight; - set => RaiseAndSetIfChanged(ref _renderHeight, value); - } - - public string? Renderer - { - get => _renderer; - set => RaiseAndSetIfChanged(ref _renderer, value); - } - private void HandleActivation() { Renderer = Constants.ManagedGraphicsContext != null ? Constants.ManagedGraphicsContext.GetType().Name : "Software"; diff --git a/src/Artemis.UI/Screens/Debugger/Tabs/Routing/RoutingDebugViewModel.cs b/src/Artemis.UI/Screens/Debugger/Tabs/Routing/RoutingDebugViewModel.cs index 63fc7cf10..3ad7cf71e 100644 --- a/src/Artemis.UI/Screens/Debugger/Tabs/Routing/RoutingDebugViewModel.cs +++ b/src/Artemis.UI/Screens/Debugger/Tabs/Routing/RoutingDebugViewModel.cs @@ -11,18 +11,19 @@ using Artemis.UI.Shared.Routing; using Avalonia.Controls.Documents; using Avalonia.Media; using Avalonia.Threading; +using PropertyChanged.SourceGenerator; using ReactiveUI; using Serilog.Events; using Serilog.Formatting.Display; namespace Artemis.UI.Screens.Debugger.Routing; -public class RoutingDebugViewModel : ActivatableViewModelBase +public partial class RoutingDebugViewModel : ActivatableViewModelBase { private readonly IRouter _router; private const int MAX_ENTRIES = 1000; private readonly MessageTemplateTextFormatter _formatter; - private string? _route; + [Notify] private string? _route; public RoutingDebugViewModel(IRouter router) { @@ -49,12 +50,6 @@ public class RoutingDebugViewModel : ActivatableViewModelBase public InlineCollection Lines { get; } = new(); public ReactiveCommand Navigate { get; } - public string? Route - { - get => _route; - set => RaiseAndSetIfChanged(ref _route, value); - } - private void OnLogEventAdded(object? sender, LogEventEventArgs e) { Dispatcher.UIThread.Post(() => AddLogEvent(e.LogEvent)); diff --git a/src/Artemis.UI/Screens/Device/DevicePropertiesViewModel.cs b/src/Artemis.UI/Screens/Device/DevicePropertiesViewModel.cs index a87966726..204ff48ac 100644 --- a/src/Artemis.UI/Screens/Device/DevicePropertiesViewModel.cs +++ b/src/Artemis.UI/Screens/Device/DevicePropertiesViewModel.cs @@ -6,16 +6,17 @@ using Artemis.Core; using Artemis.Core.Services; using Artemis.UI.DryIoc.Factories; using Artemis.UI.Shared; +using PropertyChanged.SourceGenerator; using ReactiveUI; using RGB.NET.Core; using SkiaSharp; namespace Artemis.UI.Screens.Device; -public class DevicePropertiesViewModel : DialogViewModelBase +public partial class DevicePropertiesViewModel : DialogViewModelBase { private readonly IDeviceVmFactory _deviceVmFactory; - private ArtemisDevice _device; + [Notify] private ArtemisDevice _device; public DevicePropertiesViewModel(ArtemisDevice device, IRenderService renderService, IDeviceService deviceService, IDeviceVmFactory deviceVmFactory) { @@ -42,12 +43,6 @@ public class DevicePropertiesViewModel : DialogViewModelBase ClearSelectedLeds = ReactiveCommand.Create(ExecuteClearSelectedLeds); } - public ArtemisDevice Device - { - get => _device; - set => RaiseAndSetIfChanged(ref _device, value); - } - public ObservableCollection SelectedLeds { get; } public ObservableCollection Tabs { get; } public ReactiveCommand ClearSelectedLeds { get; } diff --git a/src/Artemis.UI/Screens/Device/DeviceSettingsViewModel.cs b/src/Artemis.UI/Screens/Device/DeviceSettingsViewModel.cs index 55f01460d..9f4aba543 100644 --- a/src/Artemis.UI/Screens/Device/DeviceSettingsViewModel.cs +++ b/src/Artemis.UI/Screens/Device/DeviceSettingsViewModel.cs @@ -8,18 +8,19 @@ using Artemis.UI.Shared; using Artemis.UI.Shared.Services; using Avalonia.Threading; using Humanizer; +using PropertyChanged.SourceGenerator; using ReactiveUI; using RGB.NET.Core; namespace Artemis.UI.Screens.Device; -public class DeviceSettingsViewModel : ActivatableViewModelBase +public partial class DeviceSettingsViewModel : ActivatableViewModelBase { private readonly IDeviceService _deviceService; private readonly DevicesTabViewModel _devicesTabViewModel; private readonly IDeviceVmFactory _deviceVmFactory; private readonly IWindowService _windowService; - private bool _togglingDevice; + [Notify] private bool _togglingDevice; public DeviceSettingsViewModel(ArtemisDevice device, DevicesTabViewModel devicesTabViewModel, IDeviceService deviceService, IWindowService windowService, IDeviceVmFactory deviceVmFactory) { @@ -51,12 +52,6 @@ public class DeviceSettingsViewModel : ActivatableViewModelBase set => Dispatcher.UIThread.InvokeAsync(async () => await UpdateIsDeviceEnabled(value)); } - public bool TogglingDevice - { - get => _togglingDevice; - set => RaiseAndSetIfChanged(ref _togglingDevice, value); - } - public void IdentifyDevice() { _deviceService.IdentifyDevice(Device); diff --git a/src/Artemis.UI/Screens/Device/Tabs/DeviceGeneralTabViewModel.cs b/src/Artemis.UI/Screens/Device/Tabs/DeviceGeneralTabViewModel.cs index 3d5ffc832..12275f57a 100644 --- a/src/Artemis.UI/Screens/Device/Tabs/DeviceGeneralTabViewModel.cs +++ b/src/Artemis.UI/Screens/Device/Tabs/DeviceGeneralTabViewModel.cs @@ -6,38 +6,35 @@ using Artemis.Core; using Artemis.Core.Services; using Artemis.UI.Shared; using Artemis.UI.Shared.Services; +using PropertyChanged.SourceGenerator; using ReactiveUI; using RGB.NET.Core; using SkiaSharp; namespace Artemis.UI.Screens.Device; -public class DeviceGeneralTabViewModel : ActivatableViewModelBase +public partial class DeviceGeneralTabViewModel : ActivatableViewModelBase { - private readonly ICoreService _coreService; private readonly IDeviceService _deviceService; private readonly IRenderService _renderService; private readonly IWindowService _windowService; private readonly List _categories; - private readonly float _initialBlueScale; private readonly float _initialGreenScale; private readonly float _initialRedScale; - private int _rotation; - private float _scale; - private int _x; - private int _y; + [Notify] private int _rotation; + [Notify] private float _scale; + [Notify] private int _x; + [Notify] private int _y; + [Notify] private float _redScale; + [Notify] private float _greenScale; + [Notify] private float _blueScale; + [Notify] private SKColor _currentColor; + [Notify] private bool _displayOnDevices; - private float _redScale; - private float _greenScale; - private float _blueScale; - private SKColor _currentColor; - private bool _displayOnDevices; - - public DeviceGeneralTabViewModel(ArtemisDevice device, ICoreService coreService, IDeviceService deviceService, IRenderService renderService, IWindowService windowService) + public DeviceGeneralTabViewModel(ArtemisDevice device, IDeviceService deviceService, IRenderService renderService, IWindowService windowService) { - _coreService = coreService; _deviceService = deviceService; _renderService = renderService; _windowService = windowService; @@ -76,31 +73,7 @@ public class DeviceGeneralTabViewModel : ActivatableViewModelBase public bool RequiresManualSetup => !Device.DeviceProvider.CanDetectPhysicalLayout || !Device.DeviceProvider.CanDetectLogicalLayout; public ArtemisDevice Device { get; } - - public int X - { - get => _x; - set => RaiseAndSetIfChanged(ref _x, value); - } - - public int Y - { - get => _y; - set => RaiseAndSetIfChanged(ref _y, value); - } - - public float Scale - { - get => _scale; - set => RaiseAndSetIfChanged(ref _scale, value); - } - - public int Rotation - { - get => _rotation; - set => RaiseAndSetIfChanged(ref _rotation, value); - } - + public bool IsKeyboard => Device.DeviceType == RGBDeviceType.Keyboard; public bool HasDeskCategory @@ -132,37 +105,7 @@ public class DeviceGeneralTabViewModel : ActivatableViewModelBase get => GetCategory(DeviceCategory.Peripherals); set => SetCategory(DeviceCategory.Peripherals, value); } - - public float RedScale - { - get => _redScale; - set => RaiseAndSetIfChanged(ref _redScale, value); - } - - public float GreenScale - { - get => _greenScale; - set => RaiseAndSetIfChanged(ref _greenScale, value); - } - - public float BlueScale - { - get => _blueScale; - set => RaiseAndSetIfChanged(ref _blueScale, value); - } - - public SKColor CurrentColor - { - get => _currentColor; - set => RaiseAndSetIfChanged(ref _currentColor, value); - } - - public bool DisplayOnDevices - { - get => _displayOnDevices; - set => RaiseAndSetIfChanged(ref _displayOnDevices, value); - } - + private bool GetCategory(DeviceCategory category) { return _categories.Contains(category); diff --git a/src/Artemis.UI/Screens/Device/Tabs/DeviceLogicalLayoutDialogViewModel.cs b/src/Artemis.UI/Screens/Device/Tabs/DeviceLogicalLayoutDialogViewModel.cs index 47afd8fdf..f41937466 100644 --- a/src/Artemis.UI/Screens/Device/Tabs/DeviceLogicalLayoutDialogViewModel.cs +++ b/src/Artemis.UI/Screens/Device/Tabs/DeviceLogicalLayoutDialogViewModel.cs @@ -8,18 +8,18 @@ using Artemis.Core; using Artemis.UI.Shared; using Artemis.UI.Shared.Services; using FluentAvalonia.UI.Controls; +using PropertyChanged.SourceGenerator; using ReactiveUI; using ContentDialogButton = Artemis.UI.Shared.Services.Builders.ContentDialogButton; namespace Artemis.UI.Screens.Device; -public class DeviceLogicalLayoutDialogViewModel : ContentDialogViewModelBase +public partial class DeviceLogicalLayoutDialogViewModel : ContentDialogViewModelBase { private const int LOCALE_NEUTRAL = 0x0000; private const int LOCALE_CUSTOM_DEFAULT = 0x0c00; private const int LOCALE_INVARIANT = 0x007F; - - private RegionInfo? _selectedRegion; + [Notify] private RegionInfo? _selectedRegion; public DeviceLogicalLayoutDialogViewModel(ArtemisDevice device) { @@ -44,12 +44,6 @@ public class DeviceLogicalLayoutDialogViewModel : ContentDialogViewModelBase public ObservableCollection Regions { get; } public bool Applied { get; set; } - public RegionInfo? SelectedRegion - { - get => _selectedRegion; - set => RaiseAndSetIfChanged(ref _selectedRegion, value); - } - public static async Task SelectLogicalLayout(IWindowService windowService, ArtemisDevice device) { await windowService.CreateContentDialog() diff --git a/src/Artemis.UI/Screens/Device/Tabs/InputMappingsTabViewModel.cs b/src/Artemis.UI/Screens/Device/Tabs/InputMappingsTabViewModel.cs index a96395c7e..122029a67 100644 --- a/src/Artemis.UI/Screens/Device/Tabs/InputMappingsTabViewModel.cs +++ b/src/Artemis.UI/Screens/Device/Tabs/InputMappingsTabViewModel.cs @@ -7,18 +7,19 @@ using Artemis.Core.Services; using Artemis.UI.Exceptions; using Artemis.UI.Shared; using HidSharp.Reports.Units; +using PropertyChanged.SourceGenerator; using ReactiveUI; using RGB.NET.Core; using Unit = System.Reactive.Unit; namespace Artemis.UI.Screens.Device; -public class InputMappingsTabViewModel : ActivatableViewModelBase +public partial class InputMappingsTabViewModel : ActivatableViewModelBase { private readonly IInputService _inputService; private readonly IDeviceService _deviceService; private readonly ObservableCollection _selectedLeds; - private ArtemisLed? _selectedLed; + [Notify] private ArtemisLed? _selectedLed; public InputMappingsTabViewModel(ArtemisDevice device, ObservableCollection selectedLeds, IInputService inputService, IDeviceService deviceService) { @@ -49,15 +50,7 @@ public class InputMappingsTabViewModel : ActivatableViewModelBase } public ReactiveCommand DeleteMapping { get; } - public ArtemisDevice Device { get; } - - public ArtemisLed? SelectedLed - { - get => _selectedLed; - set => RaiseAndSetIfChanged(ref _selectedLed, value); - } - public ObservableCollection InputMappings { get; } private void ExecuteDeleteMapping(ArtemisInputMapping inputMapping) diff --git a/src/Artemis.UI/Screens/Plugins/Dialogs/PluginPrerequisitesInstallDialogViewModel.cs b/src/Artemis.UI/Screens/Plugins/Dialogs/PluginPrerequisitesInstallDialogViewModel.cs index 649698e0d..c01733e92 100644 --- a/src/Artemis.UI/Screens/Plugins/Dialogs/PluginPrerequisitesInstallDialogViewModel.cs +++ b/src/Artemis.UI/Screens/Plugins/Dialogs/PluginPrerequisitesInstallDialogViewModel.cs @@ -14,20 +14,21 @@ using Artemis.UI.Shared.Services; using Avalonia.Threading; using FluentAvalonia.Core; using FluentAvalonia.UI.Controls; +using PropertyChanged.SourceGenerator; using ReactiveUI; using ContentDialogButton = Artemis.UI.Shared.Services.Builders.ContentDialogButton; namespace Artemis.UI.Screens.Plugins; -public class PluginPrerequisitesInstallDialogViewModel : ContentDialogViewModelBase +public partial class PluginPrerequisitesInstallDialogViewModel : ContentDialogViewModelBase { - private PluginPrerequisiteViewModel? _activePrerequisite; - private bool _canInstall; - private bool _showFailed; - private bool _showInstall = true; - private bool _showIntro = true; - private bool _showProgress; private CancellationTokenSource? _tokenSource; + [Notify] private PluginPrerequisiteViewModel? _activePrerequisite; + [Notify] private bool _canInstall; + [Notify] private bool _showFailed; + [Notify] private bool _showInstall = true; + [Notify] private bool _showIntro = true; + [Notify] private bool _showProgress; public PluginPrerequisitesInstallDialogViewModel(List subjects, IPrerequisitesVmFactory prerequisitesVmFactory) { @@ -50,43 +51,7 @@ public class PluginPrerequisitesInstallDialogViewModel : ContentDialogViewModelB public ReactiveCommand Install { get; } public ObservableCollection Prerequisites { get; } - - public PluginPrerequisiteViewModel? ActivePrerequisite - { - get => _activePrerequisite; - set => RaiseAndSetIfChanged(ref _activePrerequisite, value); - } - - public bool ShowProgress - { - get => _showProgress; - set => RaiseAndSetIfChanged(ref _showProgress, value); - } - - public bool ShowIntro - { - get => _showIntro; - set => RaiseAndSetIfChanged(ref _showIntro, value); - } - - public bool ShowFailed - { - get => _showFailed; - set => RaiseAndSetIfChanged(ref _showFailed, value); - } - - public bool ShowInstall - { - get => _showInstall; - set => RaiseAndSetIfChanged(ref _showInstall, value); - } - - public bool CanInstall - { - get => _canInstall; - set => RaiseAndSetIfChanged(ref _canInstall, value); - } - + public static async Task Show(IWindowService windowService, List subjects) { await windowService.CreateContentDialog() diff --git a/src/Artemis.UI/Screens/Plugins/Dialogs/PluginPrerequisitesUninstallDialogViewModel.cs b/src/Artemis.UI/Screens/Plugins/Dialogs/PluginPrerequisitesUninstallDialogViewModel.cs index b443de9b1..60264ae54 100644 --- a/src/Artemis.UI/Screens/Plugins/Dialogs/PluginPrerequisitesUninstallDialogViewModel.cs +++ b/src/Artemis.UI/Screens/Plugins/Dialogs/PluginPrerequisitesUninstallDialogViewModel.cs @@ -15,19 +15,20 @@ using Artemis.UI.Shared.Services; using Avalonia.Threading; using FluentAvalonia.Core; using FluentAvalonia.UI.Controls; +using PropertyChanged.SourceGenerator; using ReactiveUI; using ContentDialogButton = Artemis.UI.Shared.Services.Builders.ContentDialogButton; namespace Artemis.UI.Screens.Plugins; -public class PluginPrerequisitesUninstallDialogViewModel : ContentDialogViewModelBase +public partial class PluginPrerequisitesUninstallDialogViewModel : ContentDialogViewModelBase { private readonly IPluginManagementService _pluginManagementService; private readonly List _subjects; private readonly IWindowService _windowService; - private PluginPrerequisiteViewModel? _activePrerequisite; - private bool _canUninstall; private CancellationTokenSource? _tokenSource; + [Notify] private PluginPrerequisiteViewModel? _activePrerequisite; + [Notify] private bool _canUninstall; public PluginPrerequisitesUninstallDialogViewModel(List subjects, IPrerequisitesVmFactory prerequisitesVmFactory, @@ -59,19 +60,7 @@ public class PluginPrerequisitesUninstallDialogViewModel : ContentDialogViewMode public ReactiveCommand Uninstall { get; } public ObservableCollection Prerequisites { get; } - - public PluginPrerequisiteViewModel? ActivePrerequisite - { - get => _activePrerequisite; - set => RaiseAndSetIfChanged(ref _activePrerequisite, value); - } - - public bool CanUninstall - { - get => _canUninstall; - set => RaiseAndSetIfChanged(ref _canUninstall, value); - } - + public static async Task Show(IWindowService windowService, List subjects, string cancelLabel = "Cancel") { await windowService.CreateContentDialog() diff --git a/src/Artemis.UI/Screens/Plugins/Features/PluginFeatureViewModel.cs b/src/Artemis.UI/Screens/Plugins/Features/PluginFeatureViewModel.cs index 2d83d9e6c..bf9831a36 100644 --- a/src/Artemis.UI/Screens/Plugins/Features/PluginFeatureViewModel.cs +++ b/src/Artemis.UI/Screens/Plugins/Features/PluginFeatureViewModel.cs @@ -16,16 +16,17 @@ using Artemis.UI.Shared.Services; using Artemis.UI.Shared.Services.Builders; using Avalonia.Threading; using Material.Icons; +using PropertyChanged.SourceGenerator; using ReactiveUI; namespace Artemis.UI.Screens.Plugins.Features; -public class PluginFeatureViewModel : ActivatableViewModelBase +public partial class PluginFeatureViewModel : ActivatableViewModelBase { private readonly ICoreService _coreService; private readonly IPluginManagementService _pluginManagementService; private readonly IWindowService _windowService; - private bool _enabling; + [Notify] private bool _enabling; public PluginFeatureViewModel(PluginFeatureInfo pluginFeatureInfo, bool showShield, @@ -73,15 +74,8 @@ public class PluginFeatureViewModel : ActivatableViewModelBase public PluginFeatureInfo FeatureInfo { get; } public Exception? LoadException => FeatureInfo.LoadException; - public bool ShowShield { get; } - - public bool Enabling - { - get => _enabling; - set => RaiseAndSetIfChanged(ref _enabling, value); - } - + public bool IsEnabled { get => FeatureInfo.AlwaysEnabled || (FeatureInfo.Instance != null && FeatureInfo.Instance.IsEnabled); diff --git a/src/Artemis.UI/Screens/Plugins/PluginViewModel.cs b/src/Artemis.UI/Screens/Plugins/PluginViewModel.cs index 96ec6e772..c01e2dfc2 100644 --- a/src/Artemis.UI/Screens/Plugins/PluginViewModel.cs +++ b/src/Artemis.UI/Screens/Plugins/PluginViewModel.cs @@ -14,21 +14,22 @@ using Artemis.UI.Shared.Services.Builders; using Avalonia.Controls; using Avalonia.Threading; using Material.Icons; +using PropertyChanged.SourceGenerator; using ReactiveUI; namespace Artemis.UI.Screens.Plugins; -public class PluginViewModel : ActivatableViewModelBase +public partial class PluginViewModel : ActivatableViewModelBase { private readonly ICoreService _coreService; private readonly INotificationService _notificationService; private readonly IPluginManagementService _pluginManagementService; private readonly IWindowService _windowService; - private bool _canInstallPrerequisites; - private bool _canRemovePrerequisites; - private bool _enabling; - private Plugin _plugin; private Window? _settingsWindow; + [Notify] private bool _canInstallPrerequisites; + [Notify] private bool _canRemovePrerequisites; + [Notify] private bool _enabling; + [Notify] private Plugin _plugin; public PluginViewModel(Plugin plugin, ReactiveCommand? reload, @@ -87,34 +88,9 @@ public class PluginViewModel : ActivatableViewModelBase public ReactiveCommand OpenPluginDirectory { get; } public ObservableCollection Platforms { get; } - - public Plugin Plugin - { - get => _plugin; - set => RaiseAndSetIfChanged(ref _plugin, value); - } - - public bool Enabling - { - get => _enabling; - set => RaiseAndSetIfChanged(ref _enabling, value); - } - public string Type => Plugin.GetType().BaseType?.Name ?? Plugin.GetType().Name; public bool IsEnabled => Plugin.IsEnabled; - - public bool CanInstallPrerequisites - { - get => _canInstallPrerequisites; - set => RaiseAndSetIfChanged(ref _canInstallPrerequisites, value); - } - - public bool CanRemovePrerequisites - { - get => _canRemovePrerequisites; - set => RaiseAndSetIfChanged(ref _canRemovePrerequisites, value); - } - + public async Task UpdateEnabled(bool enable) { if (Enabling) diff --git a/src/Artemis.UI/Screens/Plugins/Prerequisites/PluginPrerequisiteViewModel.cs b/src/Artemis.UI/Screens/Plugins/Prerequisites/PluginPrerequisiteViewModel.cs index 58cce5d2e..10b3e4d8e 100644 --- a/src/Artemis.UI/Screens/Plugins/Prerequisites/PluginPrerequisiteViewModel.cs +++ b/src/Artemis.UI/Screens/Plugins/Prerequisites/PluginPrerequisiteViewModel.cs @@ -6,21 +6,20 @@ using System.Threading; using System.Threading.Tasks; using Artemis.Core; using Artemis.UI.Shared; +using PropertyChanged.SourceGenerator; using ReactiveUI; namespace Artemis.UI.Screens.Plugins.Prerequisites; -public class PluginPrerequisiteViewModel : ActivatableViewModelBase +public partial class PluginPrerequisiteViewModel : ActivatableViewModelBase { private readonly ObservableAsPropertyHelper _activeStepNumber; private readonly ObservableAsPropertyHelper _busy; private readonly bool _uninstall; - - private PluginPrerequisiteActionViewModel? _activeAction; - - private bool _installing; - private bool _isMet; - private bool _uninstalling; + [Notify] private PluginPrerequisiteActionViewModel? _activeAction; + [Notify] private bool _installing; + [Notify] private bool _isMet; + [Notify] private bool _uninstalling; public PluginPrerequisiteViewModel(PluginPrerequisite pluginPrerequisite, bool uninstall) { @@ -45,33 +44,7 @@ public class PluginPrerequisiteViewModel : ActivatableViewModelBase } public ObservableCollection Actions { get; } - - public PluginPrerequisiteActionViewModel? ActiveAction - { - get => _activeAction; - set => RaiseAndSetIfChanged(ref _activeAction, value); - } - public PluginPrerequisite PluginPrerequisite { get; } - - public bool Installing - { - get => _installing; - set => RaiseAndSetIfChanged(ref _installing, value); - } - - public bool Uninstalling - { - get => _uninstalling; - set => RaiseAndSetIfChanged(ref _uninstalling, value); - } - - public bool IsMet - { - get => _isMet; - set => RaiseAndSetIfChanged(ref _isMet, value); - } - public bool Busy => _busy.Value; public int ActiveStepNumber => _activeStepNumber.Value; diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/Keyframes/TimelineKeyframeViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/Keyframes/TimelineKeyframeViewModel.cs index 2f99088af..a0d2b5de6 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/Keyframes/TimelineKeyframeViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/Keyframes/TimelineKeyframeViewModel.cs @@ -17,18 +17,19 @@ using Avalonia; using Avalonia.Input; using DynamicData; using DynamicData.Binding; +using PropertyChanged.SourceGenerator; using ReactiveUI; namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Keyframes; -public class TimelineKeyframeViewModel : ActivatableViewModelBase, ITimelineKeyframeViewModel +public partial class TimelineKeyframeViewModel : ActivatableViewModelBase, ITimelineKeyframeViewModel { private readonly IProfileEditorService _profileEditorService; - private bool _canPaste; - private bool _isFlyoutOpen; private ObservableAsPropertyHelper? _isSelected; - private string _timestamp; - private double _x; + [Notify] private bool _canPaste; + [Notify] private bool _isFlyoutOpen; + [Notify] private string _timestamp; + [Notify] private double _x; public TimelineKeyframeViewModel(LayerPropertyKeyframe layerPropertyKeyframe, IProfileEditorService profileEditorService) { @@ -60,31 +61,6 @@ public class TimelineKeyframeViewModel : ActivatableViewModelBase, ITimelineK public LayerPropertyKeyframe LayerPropertyKeyframe { get; } public ObservableCollection EasingViewModels { get; } - - public double X - { - get => _x; - set => RaiseAndSetIfChanged(ref _x, value); - } - - public string Timestamp - { - get => _timestamp; - set => RaiseAndSetIfChanged(ref _timestamp, value); - } - - public bool IsFlyoutOpen - { - get => _isFlyoutOpen; - set => RaiseAndSetIfChanged(ref _isFlyoutOpen, value); - } - - public bool CanPaste - { - get => _canPaste; - set => RaiseAndSetIfChanged(ref _canPaste, value); - } - public void Update() { X = _pixelsPerSecond * LayerPropertyKeyframe.Position.TotalSeconds; diff --git a/src/Artemis.UI/Screens/Root/SplashViewModel.cs b/src/Artemis.UI/Screens/Root/SplashViewModel.cs index 99351a066..dd9622421 100644 --- a/src/Artemis.UI/Screens/Root/SplashViewModel.cs +++ b/src/Artemis.UI/Screens/Root/SplashViewModel.cs @@ -2,12 +2,13 @@ using Artemis.Core; using Artemis.Core.Services; using Artemis.UI.Shared; +using PropertyChanged.SourceGenerator; namespace Artemis.UI.Screens.Root; -public class SplashViewModel : ViewModelBase +public partial class SplashViewModel : ViewModelBase { - private string _status; + [Notify] private string _status; public SplashViewModel(ICoreService coreService, IPluginManagementService pluginManagementService) { @@ -24,13 +25,7 @@ public class SplashViewModel : ViewModelBase } public ICoreService CoreService { get; } - - public string Status - { - get => _status; - set => RaiseAndSetIfChanged(ref _status, value); - } - + private void OnPluginManagementServiceOnPluginManagementLoaded(object? sender, PluginEventArgs args) { Status = "Initializing UI"; diff --git a/src/Artemis.UI/Screens/Scripting/Dialogs/ScriptConfigurationCreateViewModel.cs b/src/Artemis.UI/Screens/Scripting/Dialogs/ScriptConfigurationCreateViewModel.cs index 1977d5109..4cf06a8e4 100644 --- a/src/Artemis.UI/Screens/Scripting/Dialogs/ScriptConfigurationCreateViewModel.cs +++ b/src/Artemis.UI/Screens/Scripting/Dialogs/ScriptConfigurationCreateViewModel.cs @@ -5,15 +5,16 @@ using Artemis.Core.ScriptingProviders; 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.Scripting.Dialogs; -public class ScriptConfigurationCreateViewModel : ContentDialogViewModelBase +public partial class ScriptConfigurationCreateViewModel : ContentDialogViewModelBase { - private string? _scriptName; - private ScriptingProvider _selectedScriptingProvider; + [Notify] private string? _scriptName; + [Notify] private ScriptingProvider _selectedScriptingProvider; public ScriptConfigurationCreateViewModel(IScriptingService scriptingService) { @@ -26,19 +27,6 @@ public class ScriptConfigurationCreateViewModel : ContentDialogViewModelBase public ScriptConfiguration? ScriptConfiguration { get; private set; } public List ScriptingProviders { get; } - - public string? ScriptName - { - get => _scriptName; - set => RaiseAndSetIfChanged(ref _scriptName, value); - } - - public ScriptingProvider SelectedScriptingProvider - { - get => _selectedScriptingProvider; - set => RaiseAndSetIfChanged(ref _selectedScriptingProvider, value); - } - public ReactiveCommand Submit { get; } private void ExecuteSubmit() diff --git a/src/Artemis.UI/Screens/Scripting/Dialogs/ScriptConfigurationEditViewModel.cs b/src/Artemis.UI/Screens/Scripting/Dialogs/ScriptConfigurationEditViewModel.cs index bc0ab2757..c25784fcd 100644 --- a/src/Artemis.UI/Screens/Scripting/Dialogs/ScriptConfigurationEditViewModel.cs +++ b/src/Artemis.UI/Screens/Scripting/Dialogs/ScriptConfigurationEditViewModel.cs @@ -2,14 +2,15 @@ using Artemis.Core.ScriptingProviders; using Artemis.UI.Shared; using FluentAvalonia.UI.Controls; +using PropertyChanged.SourceGenerator; using ReactiveUI; using ReactiveUI.Validation.Extensions; namespace Artemis.UI.Screens.Scripting.Dialogs; -public class ScriptConfigurationEditViewModel : ContentDialogViewModelBase +public partial class ScriptConfigurationEditViewModel : ContentDialogViewModelBase { - private string? _scriptName; + [Notify] private string? _scriptName; public ScriptConfigurationEditViewModel(ScriptConfiguration scriptConfiguration) { @@ -23,12 +24,6 @@ public class ScriptConfigurationEditViewModel : ContentDialogViewModelBase public ScriptConfiguration ScriptConfiguration { get; } public ReactiveCommand Submit { get; } - public string? ScriptName - { - get => _scriptName; - set => RaiseAndSetIfChanged(ref _scriptName, value); - } - private void ExecuteSubmit() { if (ScriptName == null) diff --git a/src/Artemis.UI/Screens/Scripting/ScriptsDialogViewModel.cs b/src/Artemis.UI/Screens/Scripting/ScriptsDialogViewModel.cs index dcd4b4a3f..cbb044bc7 100644 --- a/src/Artemis.UI/Screens/Scripting/ScriptsDialogViewModel.cs +++ b/src/Artemis.UI/Screens/Scripting/ScriptsDialogViewModel.cs @@ -16,19 +16,20 @@ using Artemis.UI.Shared.Services; using Artemis.UI.Shared.Services.Builders; using DynamicData; using DynamicData.Binding; +using PropertyChanged.SourceGenerator; using ReactiveUI; namespace Artemis.UI.Screens.Scripting; -public class ScriptsDialogViewModel : DialogViewModelBase +public partial class ScriptsDialogViewModel : DialogViewModelBase { private readonly Dictionary _providerViewModels = new(); private readonly IScriptingService _scriptingService; private readonly IWindowService _windowService; private ObservableAsPropertyHelper? _hasScripts; - private ReadOnlyObservableCollection _scriptConfigurations; - private IScriptEditorViewModel? _scriptEditorViewModel; - private ScriptConfigurationViewModel? _selectedScript; + [Notify] private ReadOnlyObservableCollection _scriptConfigurations; + [Notify] private IScriptEditorViewModel? _scriptEditorViewModel; + [Notify] private ScriptConfigurationViewModel? _selectedScript; public ScriptsDialogViewModel(IScriptingService scriptingService, IWindowService windowService, IProfileService profileService, IScriptVmFactory scriptVmFactory) { @@ -74,25 +75,6 @@ public class ScriptsDialogViewModel : DialogViewModelBase public List ScriptingProviders { get; } public Profile? Profile { get; } public bool HasScripts => _hasScripts?.Value ?? false; - - public ReadOnlyObservableCollection ScriptConfigurations - { - get => _scriptConfigurations; - set => RaiseAndSetIfChanged(ref _scriptConfigurations, value); - } - - public ScriptConfigurationViewModel? SelectedScript - { - get => _selectedScript; - set => RaiseAndSetIfChanged(ref _selectedScript, value); - } - - public IScriptEditorViewModel? ScriptEditorViewModel - { - get => _scriptEditorViewModel; - set => RaiseAndSetIfChanged(ref _scriptEditorViewModel, value); - } - public ReactiveCommand AddScriptConfiguration { get; } public async Task CanClose() diff --git a/src/Artemis.UI/Screens/Settings/Tabs/PluginsTabViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/PluginsTabViewModel.cs index 6113a20b4..9111aecf6 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/PluginsTabViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Tabs/PluginsTabViewModel.cs @@ -15,16 +15,17 @@ using Artemis.UI.Shared.Services.Builders; using Avalonia.ReactiveUI; using DynamicData; using DynamicData.Binding; +using PropertyChanged.SourceGenerator; using ReactiveUI; namespace Artemis.UI.Screens.Settings; -public class PluginsTabViewModel : RoutableScreen +public partial class PluginsTabViewModel : RoutableScreen { private readonly INotificationService _notificationService; private readonly IPluginManagementService _pluginManagementService; private readonly IWindowService _windowService; - private string? _searchPluginInput; + [Notify] private string? _searchPluginInput; public PluginsTabViewModel(IPluginManagementService pluginManagementService, INotificationService notificationService, IWindowService windowService, ISettingsVmFactory settingsVmFactory) { @@ -62,13 +63,7 @@ public class PluginsTabViewModel : RoutableScreen public ReadOnlyObservableCollection Plugins { get; } public ReactiveCommand ImportPlugin { get; } - - public string? SearchPluginInput - { - get => _searchPluginInput; - set => RaiseAndSetIfChanged(ref _searchPluginInput, value); - } - + public void OpenUrl(string url) { Utilities.OpenUrl(url); diff --git a/src/Artemis.UI/Screens/Settings/Tabs/ReleasesTabViewModel.cs b/src/Artemis.UI/Screens/Settings/Tabs/ReleasesTabViewModel.cs index aeb214465..3373eba8c 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/ReleasesTabViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Tabs/ReleasesTabViewModel.cs @@ -16,13 +16,14 @@ using Artemis.WebClient.Updating; using Avalonia.ReactiveUI; using DynamicData; using DynamicData.Binding; +using PropertyChanged.SourceGenerator; using ReactiveUI; using Serilog; using StrawberryShake; namespace Artemis.UI.Screens.Settings; -public class ReleasesTabViewModel : RoutableHostScreen +public partial class ReleasesTabViewModel : RoutableHostScreen { private readonly ILogger _logger; private readonly IUpdateService _updateService; @@ -30,8 +31,8 @@ public class ReleasesTabViewModel : RoutableHostScreen private readonly INotificationService _notificationService; private readonly IRouter _router; private readonly SourceList _releases; - private bool _loading; - private ReleaseViewModel? _selectedReleaseViewModel; + [Notify(Setter.Private)] private bool _loading; + [Notify] private ReleaseViewModel? _selectedReleaseViewModel; public ReleasesTabViewModel(ILogger logger, IUpdateService updateService, IUpdatingClient updatingClient, IReleaseVmFactory releaseVmFactory, INotificationService notificationService, IRouter router) @@ -61,19 +62,7 @@ public class ReleasesTabViewModel : RoutableHostScreen public ReadOnlyObservableCollection ReleaseViewModels { get; } public string Channel { get; } - - public ReleaseViewModel? SelectedReleaseViewModel - { - get => _selectedReleaseViewModel; - set => RaiseAndSetIfChanged(ref _selectedReleaseViewModel, value); - } - - public bool Loading - { - get => _loading; - private set => RaiseAndSetIfChanged(ref _loading, value); - } - + public async Task GetReleases(CancellationToken cancellationToken) { try diff --git a/src/Artemis.UI/Screens/Settings/Updating/ReleaseDetailsViewModel.cs b/src/Artemis.UI/Screens/Settings/Updating/ReleaseDetailsViewModel.cs index 2d9a1a413..cf3026879 100644 --- a/src/Artemis.UI/Screens/Settings/Updating/ReleaseDetailsViewModel.cs +++ b/src/Artemis.UI/Screens/Settings/Updating/ReleaseDetailsViewModel.cs @@ -12,27 +12,27 @@ using Artemis.UI.Shared.Routing; using Artemis.UI.Shared.Services; using Artemis.UI.Shared.Services.Builders; using Artemis.WebClient.Updating; +using PropertyChanged.SourceGenerator; using ReactiveUI; using Serilog; using StrawberryShake; namespace Artemis.UI.Screens.Settings.Updating; -public class ReleaseDetailsViewModel : RoutableScreen +public partial class ReleaseDetailsViewModel : RoutableScreen { private readonly ObservableAsPropertyHelper _fileSize; private readonly ILogger _logger; private readonly INotificationService _notificationService; private readonly IUpdateService _updateService; private readonly IUpdatingClient _updatingClient; - private bool _installationAvailable; - private bool _installationFinished; - private bool _installationInProgress; - private CancellationTokenSource? _installerCts; - private bool _loading = true; - private IGetReleaseById_PublishedRelease? _release; - private ReleaseInstaller? _releaseInstaller; + [Notify(Setter.Private)] private bool _loading = true; + [Notify] private IGetReleaseById_PublishedRelease? _release; + [Notify] private ReleaseInstaller? _releaseInstaller; + [Notify] private bool _installationAvailable; + [Notify] private bool _installationFinished; + [Notify] private bool _installationInProgress; public ReleaseDetailsViewModel(ILogger logger, IUpdatingClient updatingClient, INotificationService notificationService, IUpdateService updateService) { @@ -67,43 +67,7 @@ public class ReleaseDetailsViewModel : RoutableScreen CancelInstall { get; } public long FileSize => _fileSize.Value; - - public IGetReleaseById_PublishedRelease? Release - { - get => _release; - set => RaiseAndSetIfChanged(ref _release, value); - } - - public ReleaseInstaller? ReleaseInstaller - { - get => _releaseInstaller; - set => RaiseAndSetIfChanged(ref _releaseInstaller, value); - } - - public bool Loading - { - get => _loading; - private set => RaiseAndSetIfChanged(ref _loading, value); - } - - public bool InstallationAvailable - { - get => _installationAvailable; - set => RaiseAndSetIfChanged(ref _installationAvailable, value); - } - - public bool InstallationInProgress - { - get => _installationInProgress; - set => RaiseAndSetIfChanged(ref _installationInProgress, value); - } - - public bool InstallationFinished - { - get => _installationFinished; - set => RaiseAndSetIfChanged(ref _installationFinished, value); - } - + public void NavigateToSource() { if (Release != null) diff --git a/src/Artemis.UI/Screens/Sidebar/ContentDialogs/SidebarCategoryEditViewModel.cs b/src/Artemis.UI/Screens/Sidebar/ContentDialogs/SidebarCategoryEditViewModel.cs index 5096cc2d3..14da6013a 100644 --- a/src/Artemis.UI/Screens/Sidebar/ContentDialogs/SidebarCategoryEditViewModel.cs +++ b/src/Artemis.UI/Screens/Sidebar/ContentDialogs/SidebarCategoryEditViewModel.cs @@ -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 Confirm { get; } private void ExecuteConfirm() diff --git a/src/Artemis.UI/Screens/Sidebar/Dialogs/ModuleActivationRequirementViewModel.cs b/src/Artemis.UI/Screens/Sidebar/Dialogs/ModuleActivationRequirementViewModel.cs index c7844442c..afac99040 100644 --- a/src/Artemis.UI/Screens/Sidebar/Dialogs/ModuleActivationRequirementViewModel.cs +++ b/src/Artemis.UI/Screens/Sidebar/Dialogs/ModuleActivationRequirementViewModel.cs @@ -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(); diff --git a/src/Artemis.UI/Screens/Sidebar/Dialogs/ProfileConfigurationEditViewModel.cs b/src/Artemis.UI/Screens/Sidebar/Dialogs/ProfileConfigurationEditViewModel.cs index 4afdd86de..4edaa16a0 100644 --- a/src/Artemis.UI/Screens/Sidebar/Dialogs/ProfileConfigurationEditViewModel.cs +++ b/src/Artemis.UI/Screens/Sidebar/Dialogs/ProfileConfigurationEditViewModel.cs @@ -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 +public partial class ProfileConfigurationEditViewModel : DialogViewModelBase { private readonly ObservableAsPropertyHelper _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 _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 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 _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 diff --git a/src/Artemis.UI/Screens/Sidebar/SidebarCategoryViewModel.cs b/src/Artemis.UI/Screens/Sidebar/SidebarCategoryViewModel.cs index 13121207b..5b8ad504b 100644 --- a/src/Artemis.UI/Screens/Sidebar/SidebarCategoryViewModel.cs +++ b/src/Artemis.UI/Screens/Sidebar/SidebarCategoryViewModel.cs @@ -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? _isCollapsed; private ObservableAsPropertyHelper? _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 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; diff --git a/src/Artemis.UI/Screens/Sidebar/SidebarScreenViewModel.cs b/src/Artemis.UI/Screens/Sidebar/SidebarScreenViewModel.cs index c85d01a34..356af4b5a 100644 --- a/src/Artemis.UI/Screens/Sidebar/SidebarScreenViewModel.cs +++ b/src/Artemis.UI/Screens/Sidebar/SidebarScreenViewModel.cs @@ -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? screens = null) { @@ -22,15 +23,8 @@ public class SidebarScreenViewModel : ViewModelBase public MaterialIconKind Icon { get; } public string Path { get; } public string RootPath { get; } - public ObservableCollection Screens { get; } - - public bool IsExpanded - { - get => _isExpanded; - set => RaiseAndSetIfChanged(ref _isExpanded, value); - } - + public bool Matches(string? path) { if (path == null) diff --git a/src/Artemis.UI/Screens/Sidebar/SidebarViewModel.cs b/src/Artemis.UI/Screens/Sidebar/SidebarViewModel.cs index f49cc0ec3..d804fa2c4 100644 --- a/src/Artemis.UI/Screens/Sidebar/SidebarViewModel.cs +++ b/src/Artemis.UI/Screens/Sidebar/SidebarViewModel.cs @@ -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 _sidebarCategories = new(new ObservableCollection()); - private SidebarScreenViewModel? _selectedScreen; private bool _updating; + [Notify] private ReadOnlyObservableCollection _sidebarCategories = new(new ObservableCollection()); + [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 SidebarCategories - { - get => _sidebarCategories; - set => RaiseAndSetIfChanged(ref _sidebarCategories, value); - } - public ReactiveCommand AddCategory { get; } private async Task ExecuteAddCategory() diff --git a/src/Artemis.UI/Screens/StartupWizard/StartupWizardViewModel.cs b/src/Artemis.UI/Screens/StartupWizard/StartupWizardViewModel.cs index 8031f0126..8ea9f3cbd 100644 --- a/src/Artemis.UI/Screens/StartupWizard/StartupWizardViewModel.cs +++ b/src/Artemis.UI/Screens/StartupWizard/StartupWizardViewModel.cs @@ -13,21 +13,22 @@ using Artemis.UI.Shared; using Artemis.UI.Shared.Providers; using Artemis.UI.Shared.Services; using DryIoc; +using PropertyChanged.SourceGenerator; using ReactiveUI; namespace Artemis.UI.Screens.StartupWizard; -public class StartupWizardViewModel : DialogViewModelBase +public partial class StartupWizardViewModel : DialogViewModelBase { private readonly IAutoRunProvider? _autoRunProvider; private readonly IProtocolProvider? _protocolProvider; private readonly ISettingsService _settingsService; private readonly IWindowService _windowService; private readonly IDeviceService _deviceService; - private int _currentStep; - private bool _showContinue; - private bool _showFinish; - private bool _showGoBack; + [Notify] private int _currentStep; + [Notify] private bool _showContinue; + [Notify] private bool _showFinish; + [Notify] private bool _showGoBack; public StartupWizardViewModel(IContainer container, ISettingsService settingsService, @@ -90,31 +91,7 @@ public class StartupWizardViewModel : DialogViewModelBase public PluginSetting UIShowOnStartup => _settingsService.GetSetting("UI.ShowOnStartup", true); public PluginSetting UICheckForUpdates => _settingsService.GetSetting("UI.Updating.AutoCheck", true); public PluginSetting UIAutoUpdate => _settingsService.GetSetting("UI.Updating.AutoInstall", true); - - public int CurrentStep - { - get => _currentStep; - set => RaiseAndSetIfChanged(ref _currentStep, value); - } - - public bool ShowContinue - { - get => _showContinue; - set => RaiseAndSetIfChanged(ref _showContinue, value); - } - - public bool ShowGoBack - { - get => _showGoBack; - set => RaiseAndSetIfChanged(ref _showGoBack, value); - } - - public bool ShowFinish - { - get => _showFinish; - set => RaiseAndSetIfChanged(ref _showFinish, value); - } - + private void ExecuteGoBack() { if (CurrentStep > 1) diff --git a/src/Artemis.UI/Screens/SurfaceEditor/ListDeviceViewModel.cs b/src/Artemis.UI/Screens/SurfaceEditor/ListDeviceViewModel.cs index b411e7ab0..075420953 100644 --- a/src/Artemis.UI/Screens/SurfaceEditor/ListDeviceViewModel.cs +++ b/src/Artemis.UI/Screens/SurfaceEditor/ListDeviceViewModel.cs @@ -6,20 +6,20 @@ using Artemis.Core.Services; using Artemis.UI.Screens.Device; using Artemis.UI.Shared; using Artemis.UI.Shared.Services; +using PropertyChanged.SourceGenerator; using ReactiveUI; using RGB.NET.Core; using SkiaSharp; namespace Artemis.UI.Screens.SurfaceEditor; -public class ListDeviceViewModel : ViewModelBase +public partial class ListDeviceViewModel : ViewModelBase { private static readonly Random Random = new(); private readonly IWindowService _windowService; private readonly IDeviceService _deviceService; - - private SKColor _color; - private bool _isSelected; + [Notify] private SKColor _color; + [Notify] private bool _isSelected; public ListDeviceViewModel(ArtemisDevice device, SurfaceEditorViewModel surfaceEditorViewModel, IWindowService windowService, IDeviceService deviceService) { @@ -37,19 +37,7 @@ public class ListDeviceViewModel : ViewModelBase public ArtemisDevice Device { get; } public SurfaceEditorViewModel SurfaceEditorViewModel { get; } public bool CanDetectInput => Device.DeviceType == RGBDeviceType.Keyboard || Device.DeviceType == RGBDeviceType.Mouse; - - public bool IsSelected - { - get => _isSelected; - set => RaiseAndSetIfChanged(ref _isSelected, value); - } - - public SKColor Color - { - get => _color; - set => RaiseAndSetIfChanged(ref _color, value); - } - + private async Task ExecuteDetectInput() { if (!CanDetectInput) diff --git a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceDeviceViewModel.cs b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceDeviceViewModel.cs index ee7380343..47bff74f0 100644 --- a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceDeviceViewModel.cs +++ b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceDeviceViewModel.cs @@ -10,6 +10,7 @@ using Artemis.Core.Services; using Artemis.UI.Screens.Device; using Artemis.UI.Shared; using Artemis.UI.Shared.Services; +using PropertyChanged.SourceGenerator; using ReactiveUI; using RGB.NET.Core; using SkiaSharp; @@ -17,16 +18,16 @@ using Point = Avalonia.Point; namespace Artemis.UI.Screens.SurfaceEditor; -public class SurfaceDeviceViewModel : ActivatableViewModelBase +public partial class SurfaceDeviceViewModel : ActivatableViewModelBase { private readonly IDeviceService _deviceService; private readonly ISettingsService _settingsService; private readonly IWindowService _windowService; private double _dragOffsetX; private double _dragOffsetY; - private bool _isSelected; - private float _x; - private float _y; + [Notify] private bool _isSelected; + [Notify] private float _x; + [Notify] private float _y; public SurfaceDeviceViewModel(ArtemisDevice device, SurfaceEditorViewModel surfaceEditorViewModel, IDeviceService deviceService, ISettingsService settingsService, IWindowService windowService) { @@ -48,29 +49,10 @@ public class SurfaceDeviceViewModel : ActivatableViewModelBase } public ReactiveCommand DetectInput { get; } - public ArtemisDevice Device { get; } public SurfaceEditorViewModel SurfaceEditorViewModel { get; } public bool CanDetectInput => Device.DeviceType == RGBDeviceType.Keyboard || Device.DeviceType == RGBDeviceType.Mouse; - public bool IsSelected - { - get => _isSelected; - set => RaiseAndSetIfChanged(ref _isSelected, value); - } - - public float X - { - get => _x; - set => RaiseAndSetIfChanged(ref _x, value); - } - - public float Y - { - get => _y; - set => RaiseAndSetIfChanged(ref _y, value); - } - public void StartMouseDrag(Point mouseStartPosition) { if (!IsSelected) diff --git a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorViewModel.cs b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorViewModel.cs index aa23a0a90..33b54b2c0 100644 --- a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorViewModel.cs +++ b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorViewModel.cs @@ -13,12 +13,13 @@ using Artemis.UI.Shared; using Artemis.UI.Shared.Routing; using Artemis.UI.Shared.Services; using Avalonia; +using PropertyChanged.SourceGenerator; using ReactiveUI; using SkiaSharp; namespace Artemis.UI.Screens.SurfaceEditor; -public class SurfaceEditorViewModel : RoutableScreen, IMainScreenViewModel +public partial class SurfaceEditorViewModel : RoutableScreen, IMainScreenViewModel { private readonly IDeviceService _deviceService; private readonly IRenderService _renderService; @@ -26,11 +27,11 @@ public class SurfaceEditorViewModel : RoutableScreen, IMainScreenViewModel private readonly ISettingsService _settingsService; private readonly ISurfaceVmFactory _surfaceVmFactory; private readonly IWindowService _windowService; - private bool _colorDevices; - private bool _colorFirstLedOnly; private List? _initialSelection; private double _overlayOpacity; private bool _saving; + [Notify] private bool _colorDevices; + [Notify] private bool _colorFirstLedOnly; public SurfaceEditorViewModel(ICoreService coreService, ISurfaceVmFactory surfaceVmFactory, @@ -74,19 +75,7 @@ public class SurfaceEditorViewModel : RoutableScreen, IMainScreenViewModel } public ViewModelBase? TitleBarViewModel => null; - - public bool ColorDevices - { - get => _colorDevices; - set => RaiseAndSetIfChanged(ref _colorDevices, value); - } - - public bool ColorFirstLedOnly - { - get => _colorFirstLedOnly; - set => RaiseAndSetIfChanged(ref _colorFirstLedOnly, value); - } - + public ObservableCollection SurfaceDeviceViewModels { get; } public ObservableCollection ListDeviceViewModels { get; } diff --git a/src/Artemis.UI/Screens/VisualScripting/CableViewModel.cs b/src/Artemis.UI/Screens/VisualScripting/CableViewModel.cs index 1d44adecc..ccc046d86 100644 --- a/src/Artemis.UI/Screens/VisualScripting/CableViewModel.cs +++ b/src/Artemis.UI/Screens/VisualScripting/CableViewModel.cs @@ -11,23 +11,23 @@ using Avalonia; using Avalonia.Media; using DynamicData; using DynamicData.Binding; +using PropertyChanged.SourceGenerator; using ReactiveUI; namespace Artemis.UI.Screens.VisualScripting; -public class CableViewModel : ActivatableViewModelBase +public partial class CableViewModel : ActivatableViewModelBase { private readonly IPin _from; private readonly NodeScriptViewModel _nodeScriptViewModel; private readonly IPin _to; private ObservableAsPropertyHelper? _cableColor; private ObservableAsPropertyHelper? _connected; - private bool _displayValue; private ObservableAsPropertyHelper? _fromPoint; - - private PinViewModel? _fromViewModel; private ObservableAsPropertyHelper? _toPoint; - private PinViewModel? _toViewModel; + [Notify] private PinViewModel? _fromViewModel; + [Notify] private PinViewModel? _toViewModel; + [Notify] private bool _displayValue; public CableViewModel(NodeScriptViewModel nodeScriptViewModel, IPin from, IPin to, ISettingsService settingsService) { @@ -79,28 +79,8 @@ public class CableViewModel : ActivatableViewModelBase } public PluginSetting AlwaysShowValues { get; } - - public PinViewModel? FromViewModel - { - get => _fromViewModel; - set => RaiseAndSetIfChanged(ref _fromViewModel, value); - } - - public PinViewModel? ToViewModel - { - get => _toViewModel; - set => RaiseAndSetIfChanged(ref _toViewModel, value); - } - - public bool DisplayValue - { - get => _displayValue; - set => RaiseAndSetIfChanged(ref _displayValue, value); - } - public bool Connected => _connected?.Value ?? false; public bool IsFirst => _from.ConnectedTo.FirstOrDefault() == _to; - public Point FromPoint => _fromPoint?.Value ?? new Point(); public Point ToPoint => _toPoint?.Value ?? new Point(); public Color CableColor => _cableColor?.Value ?? new Color(255, 255, 255, 255); diff --git a/src/Artemis.UI/Screens/VisualScripting/DragCableViewModel.cs b/src/Artemis.UI/Screens/VisualScripting/DragCableViewModel.cs index da4fbec78..4e1684bde 100644 --- a/src/Artemis.UI/Screens/VisualScripting/DragCableViewModel.cs +++ b/src/Artemis.UI/Screens/VisualScripting/DragCableViewModel.cs @@ -3,16 +3,16 @@ using Artemis.Core; using Artemis.UI.Screens.VisualScripting.Pins; using Artemis.UI.Shared; using Avalonia; +using PropertyChanged.SourceGenerator; using ReactiveUI; namespace Artemis.UI.Screens.VisualScripting; -public class DragCableViewModel : ActivatableViewModelBase +public partial class DragCableViewModel : ActivatableViewModelBase { - private Point _dragPoint; - private ObservableAsPropertyHelper? _fromPoint; private ObservableAsPropertyHelper? _toPoint; + [Notify] private Point _dragPoint; public DragCableViewModel(PinViewModel pinViewModel) { @@ -35,10 +35,4 @@ public class DragCableViewModel : ActivatableViewModelBase public PinViewModel PinViewModel { get; } public Point FromPoint => _fromPoint?.Value ?? new Point(0, 0); public Point ToPoint => _toPoint?.Value ?? new Point(0, 0); - - public Point DragPoint - { - get => _dragPoint; - set => RaiseAndSetIfChanged(ref _dragPoint, value); - } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/VisualScripting/NodePickerViewModel.cs b/src/Artemis.UI/Screens/VisualScripting/NodePickerViewModel.cs index 816ad4343..582ac7bfb 100644 --- a/src/Artemis.UI/Screens/VisualScripting/NodePickerViewModel.cs +++ b/src/Artemis.UI/Screens/VisualScripting/NodePickerViewModel.cs @@ -11,20 +11,20 @@ using Artemis.UI.Shared.Services.NodeEditor.Commands; using Avalonia; using DynamicData; using DynamicData.Binding; +using PropertyChanged.SourceGenerator; using ReactiveUI; namespace Artemis.UI.Screens.VisualScripting; -public class NodePickerViewModel : ActivatableViewModelBase +public partial class NodePickerViewModel : ActivatableViewModelBase { private readonly INodeEditorService _nodeEditorService; private readonly NodeScript _nodeScript; - - private bool _isVisible; - private Point _position; - private string? _searchText; - private object? _selectedNode; - private IPin? _targetPin; + [Notify] private bool _isVisible; + [Notify] private Point _position; + [Notify] private string? _searchText; + [Notify] private object? _selectedNode; + [Notify] private IPin? _targetPin; public NodePickerViewModel(NodeScript nodeScript, INodeService nodeService, INodeEditorService nodeEditorService) { @@ -67,37 +67,7 @@ public class NodePickerViewModel : ActivatableViewModelBase } public ReadOnlyObservableCollection Categories { get; } - - public bool IsVisible - { - get => _isVisible; - set => RaiseAndSetIfChanged(ref _isVisible, value); - } - - public Point Position - { - get => _position; - set => RaiseAndSetIfChanged(ref _position, value); - } - - public string? SearchText - { - get => _searchText; - set => RaiseAndSetIfChanged(ref _searchText, value); - } - - public IPin? TargetPin - { - get => _targetPin; - set => RaiseAndSetIfChanged(ref _targetPin, value); - } - - public object? SelectedNode - { - get => _selectedNode; - set => RaiseAndSetIfChanged(ref _selectedNode, value); - } - + public void CreateNode(NodeData data) { INode node = data.CreateNode(_nodeScript, null); diff --git a/src/Artemis.UI/Screens/VisualScripting/NodeScriptViewModel.cs b/src/Artemis.UI/Screens/VisualScripting/NodeScriptViewModel.cs index c9b790306..9ffb3b2db 100644 --- a/src/Artemis.UI/Screens/VisualScripting/NodeScriptViewModel.cs +++ b/src/Artemis.UI/Screens/VisualScripting/NodeScriptViewModel.cs @@ -21,11 +21,12 @@ using Avalonia; using Avalonia.Input; using DynamicData; using DynamicData.Binding; +using PropertyChanged.SourceGenerator; using ReactiveUI; namespace Artemis.UI.Screens.VisualScripting; -public class NodeScriptViewModel : ActivatableViewModelBase +public partial class NodeScriptViewModel : ActivatableViewModelBase { public const string CLIPBOARD_DATA_FORMAT = "Artemis.Nodes"; @@ -34,11 +35,10 @@ public class NodeScriptViewModel : ActivatableViewModelBase private readonly SourceList _nodeViewModels; private readonly INodeVmFactory _nodeVmFactory; private readonly Subject _requestedPickerPositionSubject; - - private DragCableViewModel? _dragViewModel; private List? _initialNodeSelection; - private Matrix _panMatrix; - private Point _pastePosition; + [Notify] private DragCableViewModel? _dragViewModel; + [Notify] private Matrix _panMatrix; + [Notify] private Point _pastePosition; public NodeScriptViewModel(NodeScript nodeScript, bool isPreview, INodeVmFactory nodeVmFactory, INodeService nodeService, INodeEditorService nodeEditorService) { @@ -111,25 +111,7 @@ public class NodeScriptViewModel : ActivatableViewModelBase public ReactiveCommand DuplicateSelected { get; } public ReactiveCommand CopySelected { get; } public ReactiveCommand PasteSelected { get; } - - public DragCableViewModel? DragViewModel - { - get => _dragViewModel; - set => RaiseAndSetIfChanged(ref _dragViewModel, value); - } - - public Matrix PanMatrix - { - get => _panMatrix; - set => RaiseAndSetIfChanged(ref _panMatrix, value); - } - - public Point PastePosition - { - get => _pastePosition; - set => RaiseAndSetIfChanged(ref _pastePosition, value); - } - + public void DeleteSelectedNodes() { List toRemove = NodeViewModels.Where(vm => vm.IsSelected && !vm.Node.IsDefaultNode && !vm.Node.IsExitNode).ToList(); diff --git a/src/Artemis.UI/Screens/VisualScripting/NodeViewModel.cs b/src/Artemis.UI/Screens/VisualScripting/NodeViewModel.cs index a033a271f..722bfbf26 100644 --- a/src/Artemis.UI/Screens/VisualScripting/NodeViewModel.cs +++ b/src/Artemis.UI/Screens/VisualScripting/NodeViewModel.cs @@ -16,29 +16,28 @@ using Avalonia; using Avalonia.Layout; using DynamicData; using DynamicData.Binding; +using PropertyChanged.SourceGenerator; using ReactiveUI; namespace Artemis.UI.Screens.VisualScripting; -public class NodeViewModel : ActivatableViewModelBase +public partial class NodeViewModel : ActivatableViewModelBase { private readonly INodeEditorService _nodeEditorService; private readonly IWindowService _windowService; - - private ICustomNodeViewModel? _customNodeViewModel; - private double _dragOffsetX; - private double _dragOffsetY; private ObservableAsPropertyHelper? _hasInputPins; private ObservableAsPropertyHelper? _hasOutputPins; - private bool _isSelected; - private ObservableAsPropertyHelper? _isStaticNode; + private double _dragOffsetX; + private double _dragOffsetY; private double _startX; private double _startY; - private bool _displayCustomViewModelAbove; - private bool _displayCustomViewModelBetween; - private bool _displayCustomViewModelBelow; - private VerticalAlignment _customViewModelVerticalAlignment; + [Notify] private bool _isSelected; + [Notify] private ICustomNodeViewModel? _customNodeViewModel; + [Notify] private bool _displayCustomViewModelAbove; + [Notify] private bool _displayCustomViewModelBetween; + [Notify] private bool _displayCustomViewModelBelow; + [Notify] private VerticalAlignment _customViewModelVerticalAlignment; public NodeViewModel(NodeScriptViewModel nodeScriptViewModel, INode node, INodeVmFactory nodeVmFactory, INodeEditorService nodeEditorService, IWindowService windowService) { @@ -170,43 +169,6 @@ public class NodeViewModel : ActivatableViewModelBase public ReadOnlyObservableCollection OutputPinViewModels { get; } public ReadOnlyObservableCollection OutputPinCollectionViewModels { get; } public ReadOnlyObservableCollection PinViewModels { get; } - - public bool IsSelected - { - get => _isSelected; - set => RaiseAndSetIfChanged(ref _isSelected, value); - } - - public ICustomNodeViewModel? CustomNodeViewModel - { - get => _customNodeViewModel; - set => RaiseAndSetIfChanged(ref _customNodeViewModel, value); - } - - public bool DisplayCustomViewModelAbove - { - get => _displayCustomViewModelAbove; - set => RaiseAndSetIfChanged(ref _displayCustomViewModelAbove, value); - } - - public bool DisplayCustomViewModelBetween - { - get => _displayCustomViewModelBetween; - set => RaiseAndSetIfChanged(ref _displayCustomViewModelBetween, value); - } - - public bool DisplayCustomViewModelBelow - { - get => _displayCustomViewModelBelow; - set => RaiseAndSetIfChanged(ref _displayCustomViewModelBelow, value); - } - - public VerticalAlignment CustomViewModelVerticalAlignment - { - get => _customViewModelVerticalAlignment; - set => RaiseAndSetIfChanged(ref _customViewModelVerticalAlignment, value); - } - public ReactiveCommand ShowBrokenState { get; } public ReactiveCommand DeleteNode { get; } diff --git a/src/Artemis.UI/Screens/VisualScripting/Pins/PinViewModel.cs b/src/Artemis.UI/Screens/VisualScripting/Pins/PinViewModel.cs index 5a29c6301..e45649e09 100644 --- a/src/Artemis.UI/Screens/VisualScripting/Pins/PinViewModel.cs +++ b/src/Artemis.UI/Screens/VisualScripting/Pins/PinViewModel.cs @@ -13,17 +13,18 @@ using Artemis.UI.Shared.Services.NodeEditor.Commands; using Avalonia; using Avalonia.Media; using DynamicData; +using PropertyChanged.SourceGenerator; using ReactiveUI; namespace Artemis.UI.Screens.VisualScripting.Pins; -public abstract class PinViewModel : ActivatableViewModelBase +public abstract partial class PinViewModel : ActivatableViewModelBase { private readonly INodeService _nodeService; - private Color _darkenedPinColor; - private Color _pinColor; - private Point _position; - private ReactiveCommand? _removePin; + [Notify] private Color _darkenedPinColor; + [Notify] private Color _pinColor; + [Notify] private Point _position; + [Notify] private ReactiveCommand? _removePin; protected PinViewModel(IPin pin, NodeScriptViewModel nodeScriptViewModel, INodeService nodeService, INodeEditorService nodeEditorService) { @@ -49,33 +50,7 @@ public abstract class PinViewModel : ActivatableViewModelBase } public IObservableList Connections { get; } - public IPin Pin { get; } - - public Color PinColor - { - get => _pinColor; - set => RaiseAndSetIfChanged(ref _pinColor, value); - } - - public Color DarkenedPinColor - { - get => _darkenedPinColor; - set => RaiseAndSetIfChanged(ref _darkenedPinColor, value); - } - - public Point Position - { - get => _position; - set => RaiseAndSetIfChanged(ref _position, value); - } - - public ReactiveCommand? RemovePin - { - get => _removePin; - set => RaiseAndSetIfChanged(ref _removePin, value); - } - public ReactiveCommand DisconnectPin { get; } public bool IsCompatibleWith(PinViewModel pinViewModel)