mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
UI - Streamlined VM names
This commit is contained in:
parent
cd8656cb0d
commit
eac08050bc
2
src/.idea/.idea.Artemis/.idea/avalonia.xml
generated
2
src/.idea/.idea.Artemis/.idea/avalonia.xml
generated
@ -14,8 +14,10 @@
|
|||||||
<entry key="Artemis.UI.Avalonia/Screens/Sidebar/Views/SidebarProfileConfigurationView.axaml" value="Artemis.UI.Avalonia/Artemis.UI.Avalonia.csproj" />
|
<entry key="Artemis.UI.Avalonia/Screens/Sidebar/Views/SidebarProfileConfigurationView.axaml" value="Artemis.UI.Avalonia/Artemis.UI.Avalonia.csproj" />
|
||||||
<entry key="Artemis.UI.Avalonia/Screens/SidebarView.axaml" value="Artemis.UI.Avalonia/Artemis.UI.Avalonia.csproj" />
|
<entry key="Artemis.UI.Avalonia/Screens/SidebarView.axaml" value="Artemis.UI.Avalonia/Artemis.UI.Avalonia.csproj" />
|
||||||
<entry key="Artemis.UI.Avalonia/Views/MainWindow.axaml" value="Artemis.UI.Avalonia/Artemis.UI.Avalonia.csproj" />
|
<entry key="Artemis.UI.Avalonia/Views/MainWindow.axaml" value="Artemis.UI.Avalonia/Artemis.UI.Avalonia.csproj" />
|
||||||
|
<entry key="Artemis.UI.Shared/Styles/Border.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||||
<entry key="Artemis.UI.Windows/App.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
|
<entry key="Artemis.UI.Windows/App.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
|
||||||
<entry key="Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputView.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
|
<entry key="Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputView.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
|
||||||
|
<entry key="Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||||
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/Properties/Dialogs/AddEffectView.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
|
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/Properties/Dialogs/AddEffectView.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
|
||||||
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/Properties/PropertiesView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/Properties/PropertiesView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||||
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/Properties/Tree/ContentDialogs/LayerEffectRenameView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/Properties/Tree/ContentDialogs/LayerEffectRenameView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
|
||||||
|
|||||||
24
src/Artemis.UI.Shared/Extensions/LayerPropertyExtensions.cs
Normal file
24
src/Artemis.UI.Shared/Extensions/LayerPropertyExtensions.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
using Artemis.Core;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Shared.Extensions;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides utilities when working with layer properties in a UI context.
|
||||||
|
/// </summary>
|
||||||
|
public static class LayerPropertyExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Returns an observable sequence of layer property values starting with the current value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="layerProperty">The layer property to create the sequence of.</param>
|
||||||
|
/// <typeparam name="T">The value type of the layer property.</typeparam>
|
||||||
|
/// <returns>An observable sequence of layer property values starting with the current value.</returns>
|
||||||
|
public static IObservable<T> AsObservable<T>(this LayerProperty<T> layerProperty)
|
||||||
|
{
|
||||||
|
return Observable.FromEventPattern<LayerPropertyEventArgs>(x => layerProperty.Updated += x, x => layerProperty.Updated -= x)
|
||||||
|
.Select(_ => layerProperty.CurrentValue)
|
||||||
|
.StartWith(layerProperty.CurrentValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -7,7 +7,7 @@ namespace Artemis.UI.Shared.LayerBrushes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a view model for a brush configuration window
|
/// Represents a view model for a brush configuration window
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class BrushConfigurationViewModel : ActivatableViewModelBase
|
public abstract class BrushConfigurationViewModel : ValidatableViewModelBase
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of the <see cref="BrushConfigurationViewModel" /> class
|
/// Creates a new instance of the <see cref="BrushConfigurationViewModel" /> class
|
||||||
|
|||||||
@ -8,7 +8,7 @@ namespace Artemis.UI.Shared.LayerEffects;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a view model for an effect configuration window
|
/// Represents a view model for an effect configuration window
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class EffectConfigurationViewModel : ActivatableViewModelBase
|
public abstract class EffectConfigurationViewModel : ValidatableViewModelBase
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of the <see cref="EffectConfigurationViewModel" /> class
|
/// Creates a new instance of the <see cref="EffectConfigurationViewModel" /> class
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace Artemis.UI.Shared
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a view model for a plugin configuration window
|
/// Represents a view model for a plugin configuration window
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class PluginConfigurationViewModel : ViewModelValidationBase, IPluginConfigurationViewModel
|
public abstract class PluginConfigurationViewModel : ValidatableViewModelBase, IPluginConfigurationViewModel
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of the <see cref="PluginConfigurationViewModel" /> class
|
/// Creates a new instance of the <see cref="PluginConfigurationViewModel" /> class
|
||||||
|
|||||||
@ -12,7 +12,7 @@ namespace Artemis.UI.Shared;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the base class for Artemis view models
|
/// Represents the base class for Artemis view models
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class ContentDialogViewModelBase : ReactiveValidationObject, IActivatableViewModel, IDisposable
|
public abstract class ContentDialogViewModelBase : ValidatableViewModelBase, IDisposable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the content dialog that hosts the view model
|
/// Gets the content dialog that hosts the view model
|
||||||
@ -30,13 +30,6 @@ public abstract class ContentDialogViewModelBase : ReactiveValidationObject, IAc
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Implementation of IActivatableViewModel
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
public ViewModelActivator Activator { get; } = new();
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
@ -46,9 +39,35 @@ public abstract class ContentDialogViewModelBase : ReactiveValidationObject, IAc
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the base class for Artemis view models
|
/// Represents the base class for Artemis view models used to drive dialogs
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class ViewModelValidationBase : ReactiveValidationObject
|
public abstract class DialogViewModelBase<TResult> : ValidatableViewModelBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Closes the dialog with the given <paramref name="result" />
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="result">The result of the dialog</param>
|
||||||
|
public void Close(TResult result)
|
||||||
|
{
|
||||||
|
CloseRequested?.Invoke(this, new DialogClosedEventArgs<TResult>(result));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes the dialog without a result
|
||||||
|
/// </summary>
|
||||||
|
public void Cancel()
|
||||||
|
{
|
||||||
|
CancelRequested?.Invoke(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal event EventHandler<DialogClosedEventArgs<TResult>>? CloseRequested;
|
||||||
|
internal event EventHandler? CancelRequested;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the base class for Artemis view models that are interested in validation and the activated event
|
||||||
|
/// </summary>
|
||||||
|
public abstract class ValidatableViewModelBase : ReactiveValidationObject, IActivatableViewModel
|
||||||
{
|
{
|
||||||
private string? _displayName;
|
private string? _displayName;
|
||||||
|
|
||||||
@ -61,6 +80,9 @@ public abstract class ViewModelValidationBase : ReactiveValidationObject
|
|||||||
set => RaiseAndSetIfChanged(ref _displayName, value);
|
set => RaiseAndSetIfChanged(ref _displayName, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public ViewModelActivator Activator { get; } = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// RaiseAndSetIfChanged fully implements a Setter for a read-write property on a ReactiveObject, using
|
/// RaiseAndSetIfChanged fully implements a Setter for a read-write property on a ReactiveObject, using
|
||||||
/// CallerMemberName to raise the notification and the ref to the backing field to set the property.
|
/// CallerMemberName to raise the notification and the ref to the backing field to set the property.
|
||||||
@ -89,6 +111,15 @@ public abstract class ViewModelValidationBase : ReactiveValidationObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the base class for Artemis view models that are interested in the activated event
|
||||||
|
/// </summary>
|
||||||
|
public abstract class ActivatableViewModelBase : ViewModelBase, IActivatableViewModel
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public ViewModelActivator Activator { get; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the base class for Artemis view models
|
/// Represents the base class for Artemis view models
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -132,38 +163,3 @@ public abstract class ViewModelBase : ReactiveObject
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents the base class for Artemis view models that are interested in the activated event
|
|
||||||
/// </summary>
|
|
||||||
public abstract class ActivatableViewModelBase : ViewModelBase, IActivatableViewModel
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public ViewModelActivator Activator { get; } = new();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents the base class for Artemis view models used to drive dialogs
|
|
||||||
/// </summary>
|
|
||||||
public abstract class DialogViewModelBase<TResult> : ActivatableViewModelBase
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Closes the dialog with the given <paramref name="result" />
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="result">The result of the dialog</param>
|
|
||||||
public void Close(TResult result)
|
|
||||||
{
|
|
||||||
CloseRequested?.Invoke(this, new DialogClosedEventArgs<TResult>(result));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Closes the dialog without a result
|
|
||||||
/// </summary>
|
|
||||||
public void Cancel()
|
|
||||||
{
|
|
||||||
CancelRequested?.Invoke(this, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal event EventHandler<DialogClosedEventArgs<TResult>>? CloseRequested;
|
|
||||||
internal event EventHandler? CancelRequested;
|
|
||||||
}
|
|
||||||
@ -6,7 +6,7 @@ namespace Artemis.UI.Extensions;
|
|||||||
|
|
||||||
public static class DataBindingExtensions
|
public static class DataBindingExtensions
|
||||||
{
|
{
|
||||||
public static IObservable<IDataBinding> GetObservable(this IDataBinding dataBinding)
|
public static IObservable<IDataBinding> AsObservable(this IDataBinding dataBinding)
|
||||||
{
|
{
|
||||||
return Observable.FromEventPattern<DataBindingEventArgs>(x => dataBinding.DataBindingEnabled += x, x => dataBinding.DataBindingEnabled -= x)
|
return Observable.FromEventPattern<DataBindingEventArgs>(x => dataBinding.DataBindingEnabled += x, x => dataBinding.DataBindingEnabled -= x)
|
||||||
.Merge(Observable.FromEventPattern<DataBindingEventArgs>(x => dataBinding.DataBindingDisabled += x, x => dataBinding.DataBindingDisabled -= x))
|
.Merge(Observable.FromEventPattern<DataBindingEventArgs>(x => dataBinding.DataBindingDisabled += x, x => dataBinding.DataBindingDisabled -= x))
|
||||||
|
|||||||
@ -30,13 +30,13 @@ public class DataBindingViewModel : ActivatableViewModelBase
|
|||||||
{
|
{
|
||||||
_layerProperty = profileEditorService.LayerProperty.ToProperty(this, vm => vm.LayerProperty).DisposeWith(d);
|
_layerProperty = profileEditorService.LayerProperty.ToProperty(this, vm => vm.LayerProperty).DisposeWith(d);
|
||||||
_nodeScriptViewModel = profileEditorService.LayerProperty
|
_nodeScriptViewModel = profileEditorService.LayerProperty
|
||||||
.Select(p => p != null ? p.BaseDataBinding.GetObservable() : Observable.Never<IDataBinding>())
|
.Select(p => p != null ? p.BaseDataBinding.AsObservable() : Observable.Never<IDataBinding>())
|
||||||
.Switch()
|
.Switch()
|
||||||
.Select(b => b.IsEnabled ? nodeVmFactory.NodeScriptViewModel((NodeScript) b.Script, false) : null)
|
.Select(b => b.IsEnabled ? nodeVmFactory.NodeScriptViewModel((NodeScript) b.Script, false) : null)
|
||||||
.ToProperty(this, vm => vm.NodeScriptViewModel)
|
.ToProperty(this, vm => vm.NodeScriptViewModel)
|
||||||
.DisposeWith(d);
|
.DisposeWith(d);
|
||||||
_dataBindingEnabled = profileEditorService.LayerProperty
|
_dataBindingEnabled = profileEditorService.LayerProperty
|
||||||
.Select(p => p != null ? p.BaseDataBinding.GetObservable() : Observable.Never<IDataBinding>())
|
.Select(p => p != null ? p.BaseDataBinding.AsObservable() : Observable.Never<IDataBinding>())
|
||||||
.Switch()
|
.Switch()
|
||||||
.Select(b => b.IsEnabled)
|
.Select(b => b.IsEnabled)
|
||||||
.ToProperty(this, vm => vm.DataBindingEnabled)
|
.ToProperty(this, vm => vm.DataBindingEnabled)
|
||||||
|
|||||||
@ -31,7 +31,7 @@ internal class TreePropertyViewModel<T> : ActivatableViewModelBase, ITreePropert
|
|||||||
{
|
{
|
||||||
_profileEditorService.Time.Subscribe(t => _time = t).DisposeWith(d);
|
_profileEditorService.Time.Subscribe(t => _time = t).DisposeWith(d);
|
||||||
_isCurrentlySelected = _profileEditorService.LayerProperty.Select(l => l == LayerProperty).ToProperty(this, vm => vm.IsCurrentlySelected).DisposeWith(d);
|
_isCurrentlySelected = _profileEditorService.LayerProperty.Select(l => l == LayerProperty).ToProperty(this, vm => vm.IsCurrentlySelected).DisposeWith(d);
|
||||||
_dataBindingEnabled = LayerProperty.BaseDataBinding.GetObservable().Select(b => b.IsEnabled).ToProperty(this, vm => vm.DataBindingEnabled).DisposeWith(d);
|
_dataBindingEnabled = LayerProperty.BaseDataBinding.AsObservable().Select(b => b.IsEnabled).ToProperty(this, vm => vm.DataBindingEnabled).DisposeWith(d);
|
||||||
|
|
||||||
this.WhenAnyValue(vm => vm.LayerProperty.KeyframesEnabled).Subscribe(_ => this.RaisePropertyChanged(nameof(KeyframesEnabled))).DisposeWith(d);
|
this.WhenAnyValue(vm => vm.LayerProperty.KeyframesEnabled).Subscribe(_ => this.RaisePropertyChanged(nameof(KeyframesEnabled))).DisposeWith(d);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user