UI - Use PropertyChanged.SourceGenerator everywhere else

This commit is contained in:
Robert committed 2023-10-20 20:33:44 +02:00
1 parent d656c6960d
commit 190d797f1a
40 files changed
+223 -934

No files matched your search

@@ -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<object>
public partial class DevicePropertiesViewModel : DialogViewModelBase<object>
{
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<object>
ClearSelectedLeds = ReactiveCommand.Create(ExecuteClearSelectedLeds);
}
public ArtemisDevice Device
{
get => _device;
set => RaiseAndSetIfChanged(ref _device, value);
}
public ObservableCollection<ArtemisLed> SelectedLeds { get; }
public ObservableCollection<ActivatableViewModelBase> Tabs { get; }
public ReactiveCommand<Unit, Unit> ClearSelectedLeds { get; }
@@ -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);
@@ -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<DeviceCategory> _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);
@@ -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<RegionInfo> Regions { get; }
public bool Applied { get; set; }
public RegionInfo? SelectedRegion
{
get => _selectedRegion;
set => RaiseAndSetIfChanged(ref _selectedRegion, value);
}
public static async Task<bool> SelectLogicalLayout(IWindowService windowService, ArtemisDevice device)
{
await windowService.CreateContentDialog()
@@ -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<ArtemisLed> _selectedLeds;
private ArtemisLed? _selectedLed;
[Notify] private ArtemisLed? _selectedLed;
public InputMappingsTabViewModel(ArtemisDevice device, ObservableCollection<ArtemisLed> selectedLeds, IInputService inputService, IDeviceService deviceService)
{
@@ -49,15 +50,7 @@ public class InputMappingsTabViewModel : ActivatableViewModelBase
}
public ReactiveCommand<ArtemisInputMapping, Unit> DeleteMapping { get; }
public ArtemisDevice Device { get; }
public ArtemisLed? SelectedLed
{
get => _selectedLed;
set => RaiseAndSetIfChanged(ref _selectedLed, value);
}
public ObservableCollection<ArtemisInputMapping> InputMappings { get; }
private void ExecuteDeleteMapping(ArtemisInputMapping inputMapping)