1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Property input - Implemented remaining properties

This commit is contained in:
Robert 2022-06-18 11:45:41 +02:00
parent e1a66f8a7e
commit f89e7d43fe
15 changed files with 147 additions and 57 deletions

View File

@ -23,7 +23,10 @@
<entry key="Artemis.UI.Shared/Styles/Condensed.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
<entry key="Artemis.UI.Shared/Styles/TextBlock.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/DefaultTypes/PropertyInput/BoolPropertyInputView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputView.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
<entry key="Artemis.UI/DefaultTypes/PropertyInput/EnumPropertyInputView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputView.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
<entry key="Artemis.UI/DefaultTypes/PropertyInput/FloatRangePropertyInputView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />

View File

@ -15,8 +15,8 @@
Value="{CompiledBinding InputValue}"
Prefix="{CompiledBinding Prefix}"
Suffix="{CompiledBinding Affix}"
Minimum="{CompiledBinding MinInputValue}"
Maximum="{CompiledBinding MaxInputValue}"
Minimum="{CompiledBinding Min}"
Maximum="{CompiledBinding Max}"
LargeChange="{Binding LayerProperty.PropertyDescription.InputStepSize}"
SimpleNumberFormat="F3"
VerticalAlignment="Center"

View File

@ -13,19 +13,17 @@ public class FloatPropertyInputViewModel : PropertyInputViewModel<float>
{
if (LayerProperty.PropertyDescription.MinInputValue.IsNumber())
{
float minInputValue = Convert.ToSingle(LayerProperty.PropertyDescription.MinInputValue);
this.ValidationRule(vm => vm.InputValue, i => i >= minInputValue, $"Value must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
MinInputValue = minInputValue;
Min = Convert.ToSingle(LayerProperty.PropertyDescription.MinInputValue);
this.ValidationRule(vm => vm.InputValue, i => i >= Min, $"Value must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
}
if (LayerProperty.PropertyDescription.MaxInputValue.IsNumber())
{
float maxInputValue = Convert.ToSingle(LayerProperty.PropertyDescription.MaxInputValue);
this.ValidationRule(vm => vm.InputValue, i => i <= maxInputValue, $"Value must be smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
MaxInputValue = maxInputValue;
Max = Convert.ToSingle(LayerProperty.PropertyDescription.MaxInputValue);
this.ValidationRule(vm => vm.InputValue, i => i <= Max, $"Value must be smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
}
}
public float MinInputValue { get; } = float.MinValue;
public float MaxInputValue { get; } = float.MaxValue;
public float Min { get; } = float.MinValue;
public float Max { get; } = float.MaxValue;
}

View File

@ -2,7 +2,38 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:Artemis.UI.Shared.Controls;assembly=Artemis.UI.Shared"
xmlns:propertyInput="clr-namespace:Artemis.UI.DefaultTypes.PropertyInput"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.DefaultTypes.PropertyInput.FloatRangePropertyInputView">
TODO
x:Class="Artemis.UI.DefaultTypes.PropertyInput.FloatRangePropertyInputView"
x:DataType="propertyInput:FloatRangePropertyInputViewModel">
<StackPanel Orientation="Horizontal" Spacing="5">
<controls:DraggableNumberBox Classes="condensed tooltip-validation-left"
MinWidth="80"
Value="{CompiledBinding Start}"
Prefix="{CompiledBinding Prefix}"
Suffix="{CompiledBinding Affix}"
Minimum="{CompiledBinding End}"
Maximum="{CompiledBinding Max}"
LargeChange="{Binding LayerProperty.PropertyDescription.InputStepSize}"
SimpleNumberFormat="F3"
VerticalAlignment="Center"
ToolTip.Tip="Start"
DragStarted="DraggableNumberBox_OnDragStarted"
DragFinished="DraggableNumberBox_OnDragFinished" />
<TextBlock VerticalAlignment="Center">-</TextBlock>
<controls:DraggableNumberBox Classes="condensed tooltip-validation-left"
MinWidth="80"
Value="{CompiledBinding End}"
Prefix="{CompiledBinding Prefix}"
Suffix="{CompiledBinding Affix}"
Minimum="{CompiledBinding Start}"
Maximum="{CompiledBinding Max}"
LargeChange="{Binding LayerProperty.PropertyDescription.InputStepSize}"
SimpleNumberFormat="F3"
VerticalAlignment="Center"
ToolTip.Tip="End"
DragStarted="DraggableNumberBox_OnDragStarted"
DragFinished="DraggableNumberBox_OnDragFinished" />
</StackPanel>
</UserControl>

View File

@ -1,3 +1,5 @@
using System;
using Artemis.UI.Shared.Controls;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
@ -16,5 +18,15 @@ namespace Artemis.UI.DefaultTypes.PropertyInput
{
AvaloniaXamlLoader.Load(this);
}
private void DraggableNumberBox_OnDragStarted(DraggableNumberBox sender, EventArgs args)
{
ViewModel?.StartPreview();
}
private void DraggableNumberBox_OnDragFinished(DraggableNumberBox sender, EventArgs args)
{
ViewModel?.ApplyPreview();
}
}
}

View File

@ -17,18 +17,14 @@ public class FloatRangePropertyInputViewModel : PropertyInputViewModel<FloatRang
if (LayerProperty.PropertyDescription.MinInputValue.IsNumber())
{
this.ValidationRule(vm => vm.Start, i => i >= Convert.ToSingle(LayerProperty.PropertyDescription.MinInputValue),
$"Start value must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
this.ValidationRule(vm => vm.End, i => i >= Convert.ToSingle(LayerProperty.PropertyDescription.MinInputValue),
$"End value must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
Min = Convert.ToSingle(LayerProperty.PropertyDescription.MinInputValue);
this.ValidationRule(vm => vm.Start, i => i >= Min, $"Start value must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
}
if (LayerProperty.PropertyDescription.MaxInputValue.IsNumber())
{
this.ValidationRule(vm => vm.Start, i => i < Convert.ToSingle(LayerProperty.PropertyDescription.MaxInputValue),
$"Start value must be smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
this.ValidationRule(vm => vm.End, i => i < Convert.ToSingle(LayerProperty.PropertyDescription.MaxInputValue),
$"End value must be smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
Max = Convert.ToSingle(LayerProperty.PropertyDescription.MaxInputValue);
this.ValidationRule(vm => vm.End, i => i < Max, $"End value must be smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
}
}
@ -59,7 +55,9 @@ public class FloatRangePropertyInputViewModel : PropertyInputViewModel<FloatRang
this.RaisePropertyChanged(nameof(End));
}
}
public float Min { get; } = float.MinValue;
public float Max { get; } = float.MaxValue;
protected override void OnInputValueChanged()
{

View File

@ -15,8 +15,8 @@
Value="{CompiledBinding InputValue}"
Prefix="{CompiledBinding Prefix}"
Suffix="{CompiledBinding Affix}"
Minimum="{CompiledBinding MinInputValue}"
Maximum="{CompiledBinding MaxInputValue}"
Minimum="{CompiledBinding Min}"
Maximum="{CompiledBinding Max}"
LargeChange="{Binding LayerProperty.PropertyDescription.InputStepSize}"
SimpleNumberFormat="F1"
VerticalAlignment="Center"

View File

@ -13,19 +13,17 @@ public class IntPropertyInputViewModel : PropertyInputViewModel<int>
{
if (LayerProperty.PropertyDescription.MinInputValue.IsNumber())
{
int minInputValue = Convert.ToInt32(LayerProperty.PropertyDescription.MinInputValue);
this.ValidationRule(vm => vm.InputValue, i => i >= minInputValue, $"Value must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
MinInputValue = minInputValue;
Min = Convert.ToInt32(LayerProperty.PropertyDescription.MinInputValue);
this.ValidationRule(vm => vm.InputValue, i => i >= Min, $"Value must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
}
if (LayerProperty.PropertyDescription.MaxInputValue.IsNumber())
{
int maxInputValue = Convert.ToInt32(LayerProperty.PropertyDescription.MaxInputValue);
this.ValidationRule(vm => vm.InputValue, i => i < maxInputValue, $"Value must be smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
MaxInputValue = maxInputValue;
Max = Convert.ToInt32(LayerProperty.PropertyDescription.MaxInputValue);
this.ValidationRule(vm => vm.InputValue, i => i < Max, $"Value must be smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
}
}
public int MinInputValue { get; } = int.MinValue;
public int MaxInputValue { get; } = int.MaxValue;
public int Min { get; } = int.MinValue;
public int Max { get; } = int.MaxValue;
}

View File

@ -2,7 +2,38 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="clr-namespace:Artemis.UI.Shared.Controls;assembly=Artemis.UI.Shared"
xmlns:propertyInput="clr-namespace:Artemis.UI.DefaultTypes.PropertyInput"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.DefaultTypes.PropertyInput.IntRangePropertyInputView">
TODO
x:Class="Artemis.UI.DefaultTypes.PropertyInput.IntRangePropertyInputView"
x:DataType="propertyInput:IntRangePropertyInputViewModel">
<StackPanel Orientation="Horizontal" Spacing="5">
<controls:DraggableNumberBox Classes="condensed tooltip-validation-left"
MinWidth="80"
Value="{CompiledBinding Start}"
Prefix="{CompiledBinding Prefix}"
Suffix="{CompiledBinding Affix}"
Minimum="{CompiledBinding End}"
Maximum="{CompiledBinding Max}"
LargeChange="{Binding LayerProperty.PropertyDescription.InputStepSize}"
SimpleNumberFormat="F3"
VerticalAlignment="Center"
ToolTip.Tip="Start"
DragStarted="DraggableNumberBox_OnDragStarted"
DragFinished="DraggableNumberBox_OnDragFinished" />
<TextBlock VerticalAlignment="Center">-</TextBlock>
<controls:DraggableNumberBox Classes="condensed tooltip-validation-left"
MinWidth="80"
Value="{CompiledBinding End}"
Prefix="{CompiledBinding Prefix}"
Suffix="{CompiledBinding Affix}"
Minimum="{CompiledBinding Start}"
Maximum="{CompiledBinding Max}"
LargeChange="{Binding LayerProperty.PropertyDescription.InputStepSize}"
SimpleNumberFormat="F3"
VerticalAlignment="Center"
ToolTip.Tip="End"
DragStarted="DraggableNumberBox_OnDragStarted"
DragFinished="DraggableNumberBox_OnDragFinished" />
</StackPanel>
</UserControl>

View File

@ -1,3 +1,5 @@
using System;
using Artemis.UI.Shared.Controls;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
@ -16,5 +18,15 @@ namespace Artemis.UI.DefaultTypes.PropertyInput
{
AvaloniaXamlLoader.Load(this);
}
private void DraggableNumberBox_OnDragStarted(DraggableNumberBox sender, EventArgs args)
{
ViewModel?.StartPreview();
}
private void DraggableNumberBox_OnDragFinished(DraggableNumberBox sender, EventArgs args)
{
ViewModel?.ApplyPreview();
}
}
}

View File

@ -17,18 +17,14 @@ public class IntRangePropertyInputViewModel : PropertyInputViewModel<IntRange>
if (LayerProperty.PropertyDescription.MinInputValue.IsNumber())
{
this.ValidationRule(vm => vm.Start, i => i >= Convert.ToInt32(LayerProperty.PropertyDescription.MinInputValue),
$"Start value must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
this.ValidationRule(vm => vm.End, i => i >= Convert.ToInt32(LayerProperty.PropertyDescription.MinInputValue),
$"End value must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
Min = Convert.ToInt32(LayerProperty.PropertyDescription.MinInputValue);
this.ValidationRule(vm => vm.Start, i => i >= Min, $"Start value must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
}
if (LayerProperty.PropertyDescription.MaxInputValue.IsNumber())
{
this.ValidationRule(vm => vm.Start, i => i < Convert.ToInt32(LayerProperty.PropertyDescription.MaxInputValue),
$"Start value must be smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
this.ValidationRule(vm => vm.End, i => i < Convert.ToInt32(LayerProperty.PropertyDescription.MaxInputValue),
$"End value must be smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
Max = Convert.ToInt32(LayerProperty.PropertyDescription.MaxInputValue);
this.ValidationRule(vm => vm.End, i => i < Max, $"End value must be smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
}
}
@ -60,6 +56,8 @@ public class IntRangePropertyInputViewModel : PropertyInputViewModel<IntRange>
}
}
public int Min { get; } = int.MinValue;
public int Max { get; } = int.MaxValue;
protected override void OnInputValueChanged()
{

View File

@ -13,6 +13,8 @@
Value="{CompiledBinding X}"
Prefix="{CompiledBinding Prefix}"
Suffix="{CompiledBinding Affix}"
Minimum="{CompiledBinding Min}"
Maximum="{CompiledBinding Max}"
LargeChange="{Binding LayerProperty.PropertyDescription.InputStepSize}"
SimpleNumberFormat="F3"
VerticalAlignment="Center"
@ -25,6 +27,8 @@
Value="{CompiledBinding Y}"
Prefix="{CompiledBinding Prefix}"
Suffix="{CompiledBinding Affix}"
Minimum="{CompiledBinding Min}"
Maximum="{CompiledBinding Max}"
LargeChange="{Binding LayerProperty.PropertyDescription.InputStepSize}"
SimpleNumberFormat="F3"
VerticalAlignment="Center"

View File

@ -15,18 +15,16 @@ public class SKPointPropertyInputViewModel : PropertyInputViewModel<SKPoint>
{
if (LayerProperty.PropertyDescription.MinInputValue.IsNumber())
{
this.ValidationRule(vm => vm.X, i => i >= Convert.ToSingle(LayerProperty.PropertyDescription.MinInputValue),
$"X must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
this.ValidationRule(vm => vm.Y, i => i >= Convert.ToSingle(LayerProperty.PropertyDescription.MinInputValue),
$"Y must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
Min = Convert.ToSingle(LayerProperty.PropertyDescription.MinInputValue);
this.ValidationRule(vm => vm.X, i => i >= Min, $"X must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
this.ValidationRule(vm => vm.Y, i => i >= Min, $"Y must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
}
if (LayerProperty.PropertyDescription.MaxInputValue.IsNumber())
{
this.ValidationRule(vm => vm.X, i => i <= Convert.ToSingle(LayerProperty.PropertyDescription.MaxInputValue),
$"X must be equal to or smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
this.ValidationRule(vm => vm.Y, i => i <= Convert.ToSingle(LayerProperty.PropertyDescription.MaxInputValue),
$"Y must be equal to or smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
Max = Convert.ToSingle(LayerProperty.PropertyDescription.MaxInputValue);
this.ValidationRule(vm => vm.X, i => i <= Max, $"X must be equal to or smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
this.ValidationRule(vm => vm.Y, i => i <= Max, $"Y must be equal to or smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
}
}
@ -42,6 +40,8 @@ public class SKPointPropertyInputViewModel : PropertyInputViewModel<SKPoint>
set => InputValue = new SKPoint(X, value);
}
public float Min { get; } = float.MinValue;
public float Max { get; } = float.MaxValue;
protected override void OnInputValueChanged()
{

View File

@ -13,6 +13,8 @@
Value="{CompiledBinding Height}"
Prefix="{CompiledBinding Prefix}"
Suffix="{CompiledBinding Affix}"
Minimum="{CompiledBinding Min}"
Maximum="{CompiledBinding Max}"
LargeChange="{Binding LayerProperty.PropertyDescription.InputStepSize}"
SimpleNumberFormat="F3"
VerticalAlignment="Center"
@ -25,6 +27,8 @@
Value="{CompiledBinding Width}"
Prefix="{CompiledBinding Prefix}"
Suffix="{CompiledBinding Affix}"
Minimum="{CompiledBinding Min}"
Maximum="{CompiledBinding Max}"
LargeChange="{Binding LayerProperty.PropertyDescription.InputStepSize}"
SimpleNumberFormat="F3"
VerticalAlignment="Center"

View File

@ -17,18 +17,16 @@ public class SKSizePropertyInputViewModel : PropertyInputViewModel<SKSize>
{
if (LayerProperty.PropertyDescription.MinInputValue.IsNumber())
{
this.ValidationRule(vm => vm.Width, i => i >= Convert.ToSingle(LayerProperty.PropertyDescription.MinInputValue),
$"Width must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
this.ValidationRule(vm => vm.Height, i => i >= Convert.ToSingle(LayerProperty.PropertyDescription.MinInputValue),
$"Height must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
Min = Convert.ToSingle(LayerProperty.PropertyDescription.MinInputValue);
this.ValidationRule(vm => vm.Width, i => i >= Min, $"Width must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
this.ValidationRule(vm => vm.Height, i => i >= Min, $"Height must be equal to or greater than {LayerProperty.PropertyDescription.MinInputValue}.");
}
if (LayerProperty.PropertyDescription.MaxInputValue.IsNumber())
{
this.ValidationRule(vm => vm.Width, i => i <= Convert.ToSingle(LayerProperty.PropertyDescription.MaxInputValue),
$"Width must be equal to or smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
this.ValidationRule(vm => vm.Height, i => i <= Convert.ToSingle(LayerProperty.PropertyDescription.MaxInputValue),
$"Height must be equal to or smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
Max = Convert.ToSingle(LayerProperty.PropertyDescription.MaxInputValue);
this.ValidationRule(vm => vm.Width, i => i <= Max, $"Width must be equal to or smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
this.ValidationRule(vm => vm.Height, i => i <= Max, $"Height must be equal to or smaller than {LayerProperty.PropertyDescription.MaxInputValue}.");
}
}
@ -45,6 +43,9 @@ public class SKSizePropertyInputViewModel : PropertyInputViewModel<SKSize>
set => InputValue = new SKSize(Width, value);
}
public float Min { get; } = float.MinValue;
public float Max { get; } = float.MaxValue;
protected override void OnInputValueChanged()
{
this.RaisePropertyChanged(nameof(Width));