mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Profile editor - Moved layer property input to the Shared UI project
This commit is contained in:
1 parent
a5b66441d9
commit
f1cbfb36e9
71 files changed
+1211
-434
No files matched your search
@@ -0,0 +1,59 @@
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
using Artemis.UI.Shared.PropertyInput;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using FluentValidation;
|
||||
using PropertyChanged;
|
||||
using SkiaSharp;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.PropertyInput
|
||||
{
|
||||
public class SKSizePropertyInputViewModel : PropertyInputViewModel<SKSize>
|
||||
{
|
||||
public SKSizePropertyInputViewModel(LayerProperty<SKSize> layerProperty, IProfileEditorService profileEditorService,
|
||||
IModelValidator<SKSizePropertyInputViewModel> validator) : base(layerProperty, profileEditorService, validator)
|
||||
{
|
||||
}
|
||||
|
||||
// Since SKSize is immutable we need to create properties that replace the SKSize entirely
|
||||
[DependsOn(nameof(InputValue))]
|
||||
public float Width
|
||||
{
|
||||
get => InputValue.Width;
|
||||
set => InputValue = new SKSize(value, Height);
|
||||
}
|
||||
|
||||
[DependsOn(nameof(InputValue))]
|
||||
public float Height
|
||||
{
|
||||
get => InputValue.Height;
|
||||
set => InputValue = new SKSize(Width, value);
|
||||
}
|
||||
|
||||
protected override void OnInputValueChanged()
|
||||
{
|
||||
NotifyOfPropertyChange(nameof(Width));
|
||||
NotifyOfPropertyChange(nameof(Height));
|
||||
}
|
||||
}
|
||||
|
||||
public class SKSizePropertyInputViewModelValidator : AbstractValidator<SKSizePropertyInputViewModel>
|
||||
{
|
||||
public SKSizePropertyInputViewModelValidator()
|
||||
{
|
||||
RuleFor(vm => vm.Width)
|
||||
.LessThanOrEqualTo(vm => ((SKSize) vm.LayerProperty.PropertyDescription.MaxInputValue).Width)
|
||||
.When(vm => vm.LayerProperty.PropertyDescription.MaxInputValue is SKSize);
|
||||
RuleFor(vm => vm.Width)
|
||||
.GreaterThanOrEqualTo(vm => ((SKSize) vm.LayerProperty.PropertyDescription.MaxInputValue).Width)
|
||||
.When(vm => vm.LayerProperty.PropertyDescription.MaxInputValue is SKSize);
|
||||
|
||||
RuleFor(vm => vm.Height)
|
||||
.LessThanOrEqualTo(vm => ((SKSize) vm.LayerProperty.PropertyDescription.MaxInputValue).Height)
|
||||
.When(vm => vm.LayerProperty.PropertyDescription.MaxInputValue is SKSize);
|
||||
RuleFor(vm => vm.Height)
|
||||
.GreaterThanOrEqualTo(vm => ((SKSize) vm.LayerProperty.PropertyDescription.MaxInputValue).Height)
|
||||
.When(vm => vm.LayerProperty.PropertyDescription.MaxInputValue is SKSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user