mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
UI - Add PropertyChanged.SourceGenerator and use it in the profile editor
This commit is contained in:
1 parent
fb6845be5d
commit
6921561317
24 files changed
+139
-311
No files matched your search
+3
-8
@@ -8,15 +8,16 @@ using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
||||
using DynamicData;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Dialogs;
|
||||
|
||||
public class AddEffectViewModel : ContentDialogViewModelBase
|
||||
public partial class AddEffectViewModel : ContentDialogViewModelBase
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly RenderProfileElement _renderProfileElement;
|
||||
private string? _searchText;
|
||||
[Notify] private string? _searchText;
|
||||
|
||||
public AddEffectViewModel(RenderProfileElement renderProfileElement, IProfileEditorService profileEditorService, ILayerEffectService layerEffectService)
|
||||
{
|
||||
@@ -36,12 +37,6 @@ public class AddEffectViewModel : ContentDialogViewModelBase
|
||||
|
||||
public ReadOnlyObservableCollection<LayerEffectDescriptor> LayerEffectDescriptors { get; }
|
||||
|
||||
public string? SearchText
|
||||
{
|
||||
get => _searchText;
|
||||
set => RaiseAndSetIfChanged(ref _searchText, value);
|
||||
}
|
||||
|
||||
public void AddLayerEffect(LayerEffectDescriptor descriptor)
|
||||
{
|
||||
BaseLayerEffect layerEffect = descriptor.CreateInstance(_renderProfileElement, null);
|
||||
|
||||
@@ -18,11 +18,12 @@ using Artemis.UI.Screens.ProfileEditor.Properties.Timeline;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties;
|
||||
|
||||
public class PropertiesViewModel : ActivatableViewModelBase
|
||||
public partial class PropertiesViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private readonly Dictionary<LayerPropertyGroup, PropertyGroupViewModel> _cachedPropertyViewModels;
|
||||
private readonly IDataBindingVmFactory _dataBindingVmFactory;
|
||||
@@ -32,11 +33,11 @@ public class PropertiesViewModel : ActivatableViewModelBase
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly IWindowService _windowService;
|
||||
private DataBindingViewModel? _backgroundDataBindingViewModel;
|
||||
private DataBindingViewModel? _dataBindingViewModel;
|
||||
private ObservableAsPropertyHelper<ILayerProperty?>? _layerProperty;
|
||||
private ObservableAsPropertyHelper<int>? _pixelsPerSecond;
|
||||
private ObservableAsPropertyHelper<RenderProfileElement?>? _profileElement;
|
||||
private ObservableAsPropertyHelper<bool>? _suspendedEditing;
|
||||
[Notify] private DataBindingViewModel? _dataBindingViewModel;
|
||||
|
||||
/// <inheritdoc />
|
||||
public PropertiesViewModel(IProfileEditorService profileEditorService,
|
||||
@@ -103,13 +104,7 @@ public class PropertiesViewModel : ActivatableViewModelBase
|
||||
public PlaybackViewModel PlaybackViewModel { get; }
|
||||
public TimelineViewModel TimelineViewModel { get; }
|
||||
public ReactiveCommand<Unit, Unit> AddEffect { get; }
|
||||
|
||||
public DataBindingViewModel? DataBindingViewModel
|
||||
{
|
||||
get => _dataBindingViewModel;
|
||||
set => RaiseAndSetIfChanged(ref _dataBindingViewModel, value);
|
||||
}
|
||||
|
||||
|
||||
public RenderProfileElement? ProfileElement => _profileElement?.Value;
|
||||
public ILayerProperty? LayerProperty => _layerProperty?.Value;
|
||||
public bool SuspendedEditing => _suspendedEditing?.Value ?? false;
|
||||
|
||||
@@ -14,18 +14,19 @@ using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services.PropertyInput;
|
||||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties;
|
||||
|
||||
public class PropertyGroupViewModel : PropertyViewModelBase, IDisposable
|
||||
public partial class PropertyGroupViewModel : PropertyViewModelBase, IDisposable
|
||||
{
|
||||
private readonly ILayerPropertyVmFactory _layerPropertyVmFactory;
|
||||
private readonly IPropertyInputService _propertyInputService;
|
||||
private bool _hasChildren;
|
||||
private bool _isExpanded;
|
||||
private bool _isVisible;
|
||||
private ReadOnlyObservableCollection<ILayerPropertyKeyframe> _keyframes = null!;
|
||||
private IDisposable _keyframeSubscription = null!;
|
||||
[Notify] private bool _hasChildren;
|
||||
[Notify] private bool _isExpanded;
|
||||
[Notify] private bool _isVisible;
|
||||
|
||||
public PropertyGroupViewModel(LayerPropertyGroup layerPropertyGroup, ILayerPropertyVmFactory layerPropertyVmFactory, IPropertyInputService propertyInputService)
|
||||
{
|
||||
@@ -78,25 +79,7 @@ public class PropertyGroupViewModel : PropertyViewModelBase, IDisposable
|
||||
|
||||
public TreeGroupViewModel TreeGroupViewModel { get; }
|
||||
public TimelineGroupViewModel TimelineGroupViewModel { get; }
|
||||
|
||||
public bool IsVisible
|
||||
{
|
||||
get => _isVisible;
|
||||
set => RaiseAndSetIfChanged(ref _isVisible, value);
|
||||
}
|
||||
|
||||
public bool IsExpanded
|
||||
{
|
||||
get => _isExpanded;
|
||||
set => RaiseAndSetIfChanged(ref _isExpanded, value);
|
||||
}
|
||||
|
||||
public bool HasChildren
|
||||
{
|
||||
get => _hasChildren;
|
||||
set => RaiseAndSetIfChanged(ref _hasChildren, value);
|
||||
}
|
||||
|
||||
|
||||
public override ReadOnlyObservableCollection<ILayerPropertyKeyframe> Keyframes => _keyframes;
|
||||
|
||||
public List<ILayerPropertyKeyframe> GetAllKeyframes(bool expandedOnly)
|
||||
|
||||
@@ -5,15 +5,16 @@ using Artemis.UI.DryIoc.Factories;
|
||||
using Artemis.UI.Screens.ProfileEditor.Properties.Timeline;
|
||||
using Artemis.UI.Screens.ProfileEditor.Properties.Tree;
|
||||
using DynamicData;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties;
|
||||
|
||||
public class PropertyViewModel : PropertyViewModelBase, IDisposable
|
||||
public partial class PropertyViewModel : PropertyViewModelBase, IDisposable
|
||||
{
|
||||
private readonly SourceList<ILayerPropertyKeyframe> _keyframes;
|
||||
private bool _isExpanded;
|
||||
private bool _isHighlighted;
|
||||
private bool _isVisible;
|
||||
[Notify] private bool _isExpanded;
|
||||
[Notify] private bool _isHighlighted;
|
||||
[Notify] private bool _isVisible;
|
||||
|
||||
public PropertyViewModel(ILayerProperty layerProperty, IPropertyVmFactory propertyVmFactory)
|
||||
{
|
||||
@@ -38,24 +39,6 @@ public class PropertyViewModel : PropertyViewModelBase, IDisposable
|
||||
public ITimelinePropertyViewModel TimelinePropertyViewModel { get; }
|
||||
public override ReadOnlyObservableCollection<ILayerPropertyKeyframe> Keyframes { get; }
|
||||
|
||||
public bool IsVisible
|
||||
{
|
||||
get => _isVisible;
|
||||
set => RaiseAndSetIfChanged(ref _isVisible, value);
|
||||
}
|
||||
|
||||
public bool IsHighlighted
|
||||
{
|
||||
get => _isHighlighted;
|
||||
set => RaiseAndSetIfChanged(ref _isHighlighted, value);
|
||||
}
|
||||
|
||||
public bool IsExpanded
|
||||
{
|
||||
get => _isExpanded;
|
||||
set => RaiseAndSetIfChanged(ref _isExpanded, value);
|
||||
}
|
||||
|
||||
private void LayerPropertyOnVisibilityChanged(object? sender, LayerPropertyEventArgs e)
|
||||
{
|
||||
IsVisible = !LayerProperty.IsHidden;
|
||||
|
||||
+3
-8
@@ -12,11 +12,12 @@ using Artemis.UI.Shared.Services;
|
||||
using Artemis.UI.Shared.Services.Builders;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline.Segments;
|
||||
|
||||
public abstract class TimelineSegmentViewModel : ActivatableViewModelBase
|
||||
public abstract partial class TimelineSegmentViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private static readonly TimeSpan NewSegmentLength = TimeSpan.FromSeconds(2);
|
||||
private readonly Dictionary<ILayerPropertyKeyframe, TimeSpan> _originalKeyframePositions = new();
|
||||
@@ -25,10 +26,10 @@ public abstract class TimelineSegmentViewModel : ActivatableViewModelBase
|
||||
private TimeSpan _initialLength;
|
||||
private int _pixelsPerSecond;
|
||||
private RenderProfileElement? _profileElement;
|
||||
private ReactiveCommand<Unit, Unit>? _removeSegment;
|
||||
private ObservableAsPropertyHelper<bool>? _showAddEnd;
|
||||
private ObservableAsPropertyHelper<bool>? _showAddMain;
|
||||
private ObservableAsPropertyHelper<bool>? _showAddStart;
|
||||
[Notify] private ReactiveCommand<Unit, Unit>? _removeSegment;
|
||||
|
||||
protected TimelineSegmentViewModel(IProfileEditorService profileEditorService, IWindowService windowService)
|
||||
{
|
||||
@@ -96,12 +97,6 @@ public abstract class TimelineSegmentViewModel : ActivatableViewModelBase
|
||||
|
||||
public ReactiveCommand<Unit, Unit> EditTime { get; }
|
||||
|
||||
public ReactiveCommand<Unit, Unit>? RemoveSegment
|
||||
{
|
||||
get => _removeSegment;
|
||||
set => RaiseAndSetIfChanged(ref _removeSegment, value);
|
||||
}
|
||||
|
||||
public void AddStartSegment()
|
||||
{
|
||||
if (_profileElement == null)
|
||||
|
||||
+3
-8
@@ -5,14 +5,15 @@ using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using DynamicData;
|
||||
using DynamicData.Binding;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Timeline;
|
||||
|
||||
public class TimelineGroupViewModel : ActivatableViewModelBase
|
||||
public partial class TimelineGroupViewModel : ActivatableViewModelBase
|
||||
{
|
||||
private ReadOnlyObservableCollection<double> _keyframePositions;
|
||||
private int _pixelsPerSecond;
|
||||
[Notify] private ReadOnlyObservableCollection<double> _keyframePositions;
|
||||
|
||||
public TimelineGroupViewModel(PropertyGroupViewModel propertyGroupViewModel, IProfileEditorService profileEditorService)
|
||||
{
|
||||
@@ -39,10 +40,4 @@ public class TimelineGroupViewModel : ActivatableViewModelBase
|
||||
public PropertyGroupViewModel PropertyGroupViewModel { get; }
|
||||
|
||||
public ObservableCollection<PropertyViewModelBase>? Children => PropertyGroupViewModel.IsExpanded ? PropertyGroupViewModel.Children : null;
|
||||
|
||||
public ReadOnlyObservableCollection<double> KeyframePositions
|
||||
{
|
||||
get => _keyframePositions;
|
||||
set => RaiseAndSetIfChanged(ref _keyframePositions, value);
|
||||
}
|
||||
}
|
||||
+3
-8
@@ -4,16 +4,17 @@ using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Validation.Extensions;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree.ContentDialogs;
|
||||
|
||||
public class LayerEffectRenameViewModel : ContentDialogViewModelBase
|
||||
public partial class LayerEffectRenameViewModel : ContentDialogViewModelBase
|
||||
{
|
||||
private readonly BaseLayerEffect _layerEffect;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private string? _layerEffectName;
|
||||
[Notify] private string? _layerEffectName;
|
||||
|
||||
public LayerEffectRenameViewModel(IProfileEditorService profileEditorService, BaseLayerEffect layerEffect)
|
||||
{
|
||||
@@ -25,12 +26,6 @@ public class LayerEffectRenameViewModel : ContentDialogViewModelBase
|
||||
this.ValidationRule(vm => vm.LayerEffectName, categoryName => !string.IsNullOrWhiteSpace(categoryName), "You must specify a valid name");
|
||||
}
|
||||
|
||||
public string? LayerEffectName
|
||||
{
|
||||
get => _layerEffectName;
|
||||
set => RaiseAndSetIfChanged(ref _layerEffectName, value);
|
||||
}
|
||||
|
||||
public ReactiveCommand<Unit, Unit> Confirm { get; }
|
||||
|
||||
private void ExecuteConfirm()
|
||||
|
||||
+3
-8
@@ -4,14 +4,15 @@ using System.Reactive.Linq;
|
||||
using Artemis.Core.LayerBrushes;
|
||||
using Artemis.UI.Shared;
|
||||
using DynamicData;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
using ReactiveUI;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.Properties.Tree.Dialogs;
|
||||
|
||||
public class LayerBrushPresetViewModel : ContentDialogViewModelBase
|
||||
public partial class LayerBrushPresetViewModel : ContentDialogViewModelBase
|
||||
{
|
||||
private readonly BaseLayerBrush _layerBrush;
|
||||
private string? _searchText;
|
||||
[Notify] private string? _searchText;
|
||||
|
||||
public LayerBrushPresetViewModel(BaseLayerBrush layerBrush)
|
||||
{
|
||||
@@ -31,12 +32,6 @@ public class LayerBrushPresetViewModel : ContentDialogViewModelBase
|
||||
|
||||
public ReadOnlyObservableCollection<ILayerBrushPreset> Presets { get; }
|
||||
|
||||
public string? SearchText
|
||||
{
|
||||
get => _searchText;
|
||||
set => RaiseAndSetIfChanged(ref _searchText, value);
|
||||
}
|
||||
|
||||
public void SelectPreset(ILayerBrushPreset preset)
|
||||
{
|
||||
_layerBrush.BaseProperties?.ResetAllLayerProperties();
|
||||
|
||||
Reference in new issue
Block a user