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

Data bindings - Simplified getter/setter code

This commit is contained in:
Robert 2021-03-02 21:41:56 +01:00
parent 267e8e6a1e
commit f4ad41cbd4
38 changed files with 86 additions and 89 deletions

View File

@ -6,7 +6,7 @@
internal BoolLayerProperty()
{
KeyframesSupported = false;
RegisterDataBindingProperty(value => value, (_, newValue) => CurrentValue = newValue, new GeneralDataBindingConverter<bool>(), "Value");
RegisterDataBindingProperty(() => CurrentValue, value => CurrentValue = value, new GeneralDataBindingConverter<bool>(), "Value");
}
/// <summary>

View File

@ -23,14 +23,12 @@ namespace Artemis.Core
for (int index = 0; index < CurrentValue.Stops.Count; index++)
{
int stopIndex = index;
DataBindingRegistration<ColorGradient, SKColor> registerDataBindingProperty = RegisterDataBindingProperty(
gradient => gradient.Stops[stopIndex].Color,
(gradient, value) => gradient.Stops[stopIndex].Color = value,
RegisterDataBindingProperty(
() => CurrentValue.Stops[stopIndex].Color,
value => CurrentValue.Stops[stopIndex].Color = value,
new ColorStopDataBindingConverter(),
$"Color #{stopIndex + 1}"
);
registerDataBindingProperty.DisplayName = $"Color #{stopIndex + 1}";
}
}

View File

@ -5,7 +5,7 @@
{
internal FloatLayerProperty()
{
RegisterDataBindingProperty(value => value, (_, newValue) => CurrentValue = newValue, new FloatDataBindingConverter(), "Value");
RegisterDataBindingProperty(() => CurrentValue, value => CurrentValue = value, new FloatDataBindingConverter(), "Value");
}
/// <summary>

View File

@ -5,9 +5,9 @@
{
internal FloatRangeLayerProperty()
{
RegisterDataBindingProperty(value => value.Start, (value, newValue) => value.Start = newValue, new FloatDataBindingConverter<FloatRange>(), "Start");
RegisterDataBindingProperty(value => value.End, (value, newValue) => value.End = newValue, new FloatDataBindingConverter<FloatRange>(), "End");
RegisterDataBindingProperty(() => CurrentValue.Start, value => CurrentValue.Start = value, new FloatDataBindingConverter<FloatRange>(), "Start");
RegisterDataBindingProperty(() => CurrentValue.End, value => CurrentValue.End = value, new FloatDataBindingConverter<FloatRange>(), "End");
CurrentValueSet += OnCurrentValueSet;
}

View File

@ -7,7 +7,7 @@ namespace Artemis.Core
{
internal IntLayerProperty()
{
RegisterDataBindingProperty(value => value, (_, newValue) => CurrentValue = newValue, new IntDataBindingConverter(), "Value");
RegisterDataBindingProperty(() => CurrentValue, value => CurrentValue = value, new IntDataBindingConverter(), "Value");
}
/// <summary>

View File

@ -5,8 +5,8 @@
{
internal IntRangeLayerProperty()
{
RegisterDataBindingProperty(value => value.Start, (value, newValue) => value.Start = newValue, new IntDataBindingConverter<IntRange>(), "Start");
RegisterDataBindingProperty(value => value.End, (value, newValue) => value.End = newValue, new IntDataBindingConverter<IntRange>(), "End");
RegisterDataBindingProperty(() => CurrentValue.Start, value => CurrentValue.Start = value, new IntDataBindingConverter<IntRange>(), "Start");
RegisterDataBindingProperty(() => CurrentValue.End, value => CurrentValue.End = value, new IntDataBindingConverter<IntRange>(), "End");
CurrentValueSet += OnCurrentValueSet;
}

View File

@ -7,7 +7,7 @@ namespace Artemis.Core
{
internal SKColorLayerProperty()
{
RegisterDataBindingProperty(value => value, (_, newValue) => CurrentValue = newValue, new SKColorDataBindingConverter(), "Value");
RegisterDataBindingProperty(() => CurrentValue, value => CurrentValue = value, new SKColorDataBindingConverter(), "Value");
}
/// <summary>

View File

@ -7,9 +7,8 @@ namespace Artemis.Core
{
internal SKPointLayerProperty()
{
RegisterDataBindingProperty(value => value.X, (value, newValue) => value.X = newValue, new FloatDataBindingConverter<SKPoint>(), "X");
RegisterDataBindingProperty(value => value.Y, (value, newValue) => value.Y = newValue, new FloatDataBindingConverter<SKPoint>(), "Y");
RegisterDataBindingProperty(() => CurrentValue.X, value => CurrentValue = new SKPoint(value, CurrentValue.Y), new FloatDataBindingConverter<SKPoint>(), "X");
RegisterDataBindingProperty(() => CurrentValue.Y, value => CurrentValue = new SKPoint(CurrentValue.X, value), new FloatDataBindingConverter<SKPoint>(), "Y");
}
/// <summary>

View File

@ -7,8 +7,8 @@ namespace Artemis.Core
{
internal SKSizeLayerProperty()
{
RegisterDataBindingProperty(value => value.Height, (value, newValue) => value.Height = newValue, new FloatDataBindingConverter<SKSize>(), "Height");
RegisterDataBindingProperty(value => value.Width, (value, newValue) => value.Width = newValue, new FloatDataBindingConverter<SKSize>(), "Width");
RegisterDataBindingProperty(() => CurrentValue.Width, (value) => CurrentValue = new SKSize(value, CurrentValue.Height), new FloatDataBindingConverter<SKSize>(), "Width");
RegisterDataBindingProperty(() => CurrentValue.Height, (value) => CurrentValue = new SKSize(CurrentValue.Width, value), new FloatDataBindingConverter<SKSize>(), "Height");
}
/// <summary>

View File

@ -272,7 +272,7 @@ namespace Artemis.Core
throw new ObjectDisposedException("DataBinding");
// General
DataBindingRegistration<TLayerProperty, TProperty>? registration = LayerProperty.GetDataBindingRegistration<TProperty>(Entity.TargetExpression);
DataBindingRegistration<TLayerProperty, TProperty>? registration = LayerProperty.GetDataBindingRegistration<TProperty>(Entity.Identifier);
if (registration != null)
ApplyRegistration(registration);
@ -293,7 +293,7 @@ namespace Artemis.Core
// Don't save an invalid state
if (Registration != null)
Entity.TargetExpression = Registration.Getter.ToString();
Entity.Identifier = Registration.DisplayName;
Entity.EasingTime = EasingTime;
Entity.EasingFunction = (int) EasingFunction;

View File

@ -47,7 +47,7 @@ namespace Artemis.Core
{
if (DataBinding?.Registration == null)
throw new ArtemisCoreException("Data binding converter is not yet initialized");
DataBinding.Registration.Setter(DataBinding.LayerProperty.CurrentValue, value);
DataBinding.Registration.Setter(value);
}
/// <summary>
@ -57,7 +57,7 @@ namespace Artemis.Core
{
if (DataBinding?.Registration == null)
throw new ArtemisCoreException("Data binding converter is not yet initialized");
return DataBinding.Registration.Getter(DataBinding.LayerProperty.CurrentValue);
return DataBinding.Registration.Getter();
}
/// <summary>

View File

@ -8,9 +8,7 @@ namespace Artemis.Core
public class DataBindingRegistration<TLayerProperty, TProperty> : IDataBindingRegistration
{
internal DataBindingRegistration(LayerProperty<TLayerProperty> layerProperty, DataBindingConverter<TLayerProperty, TProperty> converter,
Func<TLayerProperty, TProperty> getter,
Action<TLayerProperty, TProperty> setter,
string displayName)
Func<TProperty> getter, Action<TProperty> setter, string displayName)
{
LayerProperty = layerProperty ?? throw new ArgumentNullException(nameof(layerProperty));
Converter = converter ?? throw new ArgumentNullException(nameof(converter));
@ -32,17 +30,15 @@ namespace Artemis.Core
/// <summary>
/// Gets the function to call to get the value of the property
/// </summary>
public Func<TLayerProperty, TProperty> Getter { get; }
public Func<TProperty> Getter { get; }
/// <summary>
/// Gets the action to call to set the value of the property
/// </summary>
public Action<TLayerProperty, TProperty> Setter { get; }
public Action<TProperty> Setter { get; }
/// <summary>
/// Gets or sets the display name of the data binding registration
/// </summary>
public string DisplayName { get; set; }
/// <inheritdoc />
public string DisplayName { get; }
/// <summary>
/// Gets the data binding created using this registration
@ -61,7 +57,7 @@ namespace Artemis.Core
if (DataBinding != null)
return DataBinding;
DataBindingEntity? dataBinding = LayerProperty.Entity.DataBindingEntities.FirstOrDefault(e => e.TargetExpression == Getter.ToString());
DataBindingEntity? dataBinding = LayerProperty.Entity.DataBindingEntities.FirstOrDefault(e => e.Identifier == DisplayName);
if (dataBinding == null)
return null;

View File

@ -5,6 +5,11 @@
/// </summary>
public interface IDataBindingRegistration
{
/// <summary>
/// Gets or sets the display name of the data binding registration
/// </summary>
string DisplayName { get; }
/// <summary>
/// Returns the data binding applied using this registration
/// </summary>

View File

@ -379,21 +379,16 @@ namespace Artemis.Core
public bool HasDataBinding => GetAllDataBindingRegistrations().Any(r => r.GetDataBinding() != null);
/// <summary>
/// Gets a data binding registration by the expression used to register it
/// Gets a data binding registration by the display name used to register it
/// <para>Note: The expression must exactly match the one used to register the data binding</para>
/// </summary>
public DataBindingRegistration<T, TProperty>? GetDataBindingRegistration<TProperty>(Expression<Func<T, TProperty>> propertyExpression)
{
return GetDataBindingRegistration<TProperty>(propertyExpression.ToString());
}
internal DataBindingRegistration<T, TProperty>? GetDataBindingRegistration<TProperty>(string expression)
public DataBindingRegistration<T, TProperty>? GetDataBindingRegistration<TProperty>(string identifier)
{
if (_disposed)
throw new ObjectDisposedException("LayerProperty");
IDataBindingRegistration? match = _dataBindingRegistrations.FirstOrDefault(r => r is DataBindingRegistration<T, TProperty> registration &&
registration.Getter.ToString() == expression);
registration.DisplayName == identifier);
return (DataBindingRegistration<T, TProperty>?) match;
}
@ -414,13 +409,15 @@ namespace Artemis.Core
/// <param name="setter">The action to call to set the value of the property</param>
/// <param name="converter">The converter to use while applying the data binding</param>
/// <param name="displayName">The display name of the data binding property</param>
public DataBindingRegistration<T, TProperty> RegisterDataBindingProperty<TProperty>(Func<T, TProperty> getter, Action<T, TProperty> setter, DataBindingConverter<T, TProperty> converter,
public DataBindingRegistration<T, TProperty> RegisterDataBindingProperty<TProperty>(Func<TProperty> getter, Action<TProperty> setter, DataBindingConverter<T, TProperty> converter,
string displayName)
{
if (_disposed)
throw new ObjectDisposedException("LayerProperty");
if (_dataBindingRegistrations.Any(d => d.DisplayName == displayName))
throw new ArtemisCoreException($"A databinding property named '{displayName}' is already registered.");
DataBindingRegistration<T, TProperty> registration = new(this, converter, getter, setter, displayName);
DataBindingRegistration<T, TProperty> registration = new(this, converter, getter, setter, displayName);
_dataBindingRegistrations.Add(registration);
return registration;
}

View File

@ -4,7 +4,7 @@ namespace Artemis.Storage.Entities.Profile.DataBindings
{
public class DataBindingEntity
{
public string TargetExpression { get; set; }
public string Identifier { get; set; }
public TimeSpan EasingTime { get; set; }
public int EasingFunction { get; set; }

View File

@ -1,4 +1,4 @@
<UserControl x:Class="Artemis.UI.PropertyInput.BoolPropertyInputView"
<UserControl x:Class="Artemis.UI.DefaultTypes.PropertyInput.BoolPropertyInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

View File

@ -1,15 +1,25 @@
using Artemis.Core;
using System.Collections.Generic;
using System.Linq;
using Artemis.Core;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
namespace Artemis.UI.PropertyInput
namespace Artemis.UI.DefaultTypes.PropertyInput
{
public class BoolPropertyInputViewModel : PropertyInputViewModel<bool>
{
private List<IDataBindingRegistration> _registrations;
public BoolPropertyInputViewModel(LayerProperty<bool> layerProperty, IProfileEditorService profileEditorService) : base(layerProperty, profileEditorService)
{
_registrations = layerProperty.GetAllDataBindingRegistrations();
}
public bool IsEnabled => true;
public bool IsEnabled => _registrations.Any(r => r.GetDataBinding() != null);
protected override void OnDataBindingsChanged()
{
NotifyOfPropertyChange(nameof(IsEnabled));
}
}
}

View File

@ -1,12 +1,12 @@
<UserControl x:Class="Artemis.UI.PropertyInput.BrushPropertyInputView"
<UserControl x:Class="Artemis.UI.DefaultTypes.PropertyInput.BrushPropertyInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:propertyInput="clr-namespace:Artemis.UI.PropertyInput"
xmlns:dataTemplateSelectors="clr-namespace:Artemis.UI.DataTemplateSelectors"
xmlns:layerBrush="clr-namespace:Artemis.Core.LayerBrushes;assembly=Artemis.Core"
xmlns:propertyInput="clr-namespace:Artemis.UI.DefaultTypes.PropertyInput"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance {x:Type propertyInput:BrushPropertyInputViewModel}}">

View File

@ -7,7 +7,7 @@ using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
using Stylet;
namespace Artemis.UI.PropertyInput
namespace Artemis.UI.DefaultTypes.PropertyInput
{
public class BrushPropertyInputViewModel : PropertyInputViewModel<LayerBrushReference>
{

View File

@ -1,9 +1,8 @@
<UserControl x:Class="Artemis.UI.PropertyInput.ColorGradientPropertyInputView"
<UserControl x:Class="Artemis.UI.DefaultTypes.PropertyInput.ColorGradientPropertyInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:propertyInput="clr-namespace:Artemis.UI.PropertyInput"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
mc:Ignorable="d"

View File

@ -3,7 +3,7 @@ using Artemis.Core;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
namespace Artemis.UI.PropertyInput
namespace Artemis.UI.DefaultTypes.PropertyInput
{
public class ColorGradientPropertyInputViewModel : PropertyInputViewModel<ColorGradient>
{

View File

@ -1,4 +1,4 @@
<UserControl x:Class="Artemis.UI.PropertyInput.EnumPropertyInputView"
<UserControl x:Class="Artemis.UI.DefaultTypes.PropertyInput.EnumPropertyInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

View File

@ -4,7 +4,7 @@ using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
using Stylet;
namespace Artemis.UI.PropertyInput
namespace Artemis.UI.DefaultTypes.PropertyInput
{
public class EnumPropertyInputViewModel<T> : PropertyInputViewModel<T> where T : Enum
{

View File

@ -1,11 +1,10 @@
<UserControl x:Class="Artemis.UI.PropertyInput.FloatPropertyInputView"
<UserControl x:Class="Artemis.UI.DefaultTypes.PropertyInput.FloatPropertyInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
xmlns:propertyInput="clr-namespace:Artemis.UI.PropertyInput"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"

View File

@ -4,7 +4,7 @@ using Artemis.UI.Shared.Services;
using FluentValidation;
using Stylet;
namespace Artemis.UI.PropertyInput
namespace Artemis.UI.DefaultTypes.PropertyInput
{
public class FloatPropertyInputViewModel : PropertyInputViewModel<float>
{
@ -13,7 +13,7 @@ namespace Artemis.UI.PropertyInput
public FloatPropertyInputViewModel(LayerProperty<float> layerProperty, IProfileEditorService profileEditorService, IModelValidator<FloatPropertyInputViewModel> validator)
: base(layerProperty, profileEditorService, validator)
{
_registration = layerProperty.GetDataBindingRegistration(value => value);
_registration = layerProperty.GetDataBindingRegistration<float>("Value");
}
public bool IsEnabled => _registration.DataBinding == null;

View File

@ -1,9 +1,8 @@
<UserControl x:Class="Artemis.UI.PropertyInput.FloatRangePropertyInputView"
<UserControl x:Class="Artemis.UI.DefaultTypes.PropertyInput.FloatRangePropertyInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.PropertyInput"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
mc:Ignorable="d"

View File

@ -5,7 +5,7 @@ using Artemis.UI.Shared.Services;
using FluentValidation;
using Stylet;
namespace Artemis.UI.PropertyInput
namespace Artemis.UI.DefaultTypes.PropertyInput
{
public class FloatRangePropertyInputViewModel : PropertyInputViewModel<FloatRange>
{
@ -16,8 +16,8 @@ namespace Artemis.UI.PropertyInput
IProfileEditorService profileEditorService,
IModelValidator<FloatRangePropertyInputViewModel> validator) : base(layerProperty, profileEditorService, validator)
{
_startRegistration = layerProperty.GetDataBindingRegistration(range => range.Start);
_endRegistration = layerProperty.GetDataBindingRegistration(range => range.End);
_startRegistration = layerProperty.GetDataBindingRegistration<float>("Start");
_endRegistration = layerProperty.GetDataBindingRegistration<float>("End");
}
public float Start

View File

@ -1,11 +1,10 @@
<UserControl x:Class="Artemis.UI.PropertyInput.IntPropertyInputView"
<UserControl x:Class="Artemis.UI.DefaultTypes.PropertyInput.IntPropertyInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
xmlns:propertyInput="clr-namespace:Artemis.UI.PropertyInput"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"

View File

@ -4,7 +4,7 @@ using Artemis.UI.Shared.Services;
using FluentValidation;
using Stylet;
namespace Artemis.UI.PropertyInput
namespace Artemis.UI.DefaultTypes.PropertyInput
{
public class IntPropertyInputViewModel : PropertyInputViewModel<int>
{
@ -13,7 +13,7 @@ namespace Artemis.UI.PropertyInput
public IntPropertyInputViewModel(LayerProperty<int> layerProperty, IProfileEditorService profileEditorService, IModelValidator<IntPropertyInputViewModel> validator)
: base(layerProperty, profileEditorService, validator)
{
_registration = layerProperty.GetDataBindingRegistration(value => value);
_registration = layerProperty.GetDataBindingRegistration<int>("Value");
}
public bool IsEnabled => _registration.DataBinding == null;

View File

@ -1,9 +1,8 @@
<UserControl x:Class="Artemis.UI.PropertyInput.IntRangePropertyInputView"
<UserControl x:Class="Artemis.UI.DefaultTypes.PropertyInput.IntRangePropertyInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.PropertyInput"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
mc:Ignorable="d"

View File

@ -5,7 +5,7 @@ using Artemis.UI.Shared.Services;
using FluentValidation;
using Stylet;
namespace Artemis.UI.PropertyInput
namespace Artemis.UI.DefaultTypes.PropertyInput
{
public class IntRangePropertyInputViewModel : PropertyInputViewModel<IntRange>
{
@ -16,8 +16,8 @@ namespace Artemis.UI.PropertyInput
IProfileEditorService profileEditorService,
IModelValidator<IntRangePropertyInputViewModel> validator) : base(layerProperty, profileEditorService, validator)
{
_startRegistration = layerProperty.GetDataBindingRegistration(range => range.Start);
_endRegistration = layerProperty.GetDataBindingRegistration(range => range.End);
_startRegistration = layerProperty.GetDataBindingRegistration<int>("Start");
_endRegistration = layerProperty.GetDataBindingRegistration<int>("End");
}
public int Start

View File

@ -1,10 +1,9 @@
<UserControl x:Class="Artemis.UI.PropertyInput.SKColorPropertyInputView"
<UserControl x:Class="Artemis.UI.DefaultTypes.PropertyInput.SKColorPropertyInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:artemis="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
xmlns:propertyInput="clr-namespace:Artemis.UI.PropertyInput"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d"
d:DesignHeight="25" d:DesignWidth="800"

View File

@ -3,7 +3,7 @@ using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
using SkiaSharp;
namespace Artemis.UI.PropertyInput
namespace Artemis.UI.DefaultTypes.PropertyInput
{
public class SKColorPropertyInputViewModel : PropertyInputViewModel<SKColor>
{
@ -11,7 +11,7 @@ namespace Artemis.UI.PropertyInput
public SKColorPropertyInputViewModel(LayerProperty<SKColor> layerProperty, IProfileEditorService profileEditorService) : base(layerProperty, profileEditorService)
{
_registration = layerProperty.GetDataBindingRegistration(value => value);
_registration = layerProperty.GetDataBindingRegistration<SKColor>("Value");
}
public bool IsEnabled => _registration.DataBinding == null;

View File

@ -1,11 +1,10 @@
<UserControl x:Class="Artemis.UI.PropertyInput.SKPointPropertyInputView"
<UserControl x:Class="Artemis.UI.DefaultTypes.PropertyInput.SKPointPropertyInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
xmlns:propertyInput="clr-namespace:Artemis.UI.PropertyInput"
mc:Ignorable="d"
d:DesignHeight="25" d:DesignWidth="800"
d:DataContext="{d:DesignInstance propertyInput:SKPointPropertyInputViewModel}">

View File

@ -6,7 +6,7 @@ using FluentValidation;
using SkiaSharp;
using Stylet;
namespace Artemis.UI.PropertyInput
namespace Artemis.UI.DefaultTypes.PropertyInput
{
public class SKPointPropertyInputViewModel : PropertyInputViewModel<SKPoint>
{
@ -16,8 +16,8 @@ namespace Artemis.UI.PropertyInput
public SKPointPropertyInputViewModel(LayerProperty<SKPoint> layerProperty, IProfileEditorService profileEditorService,
IModelValidator<SKPointPropertyInputViewModel> validator) : base(layerProperty, profileEditorService, validator)
{
_xRegistration = layerProperty.GetDataBindingRegistration(point => point.X);
_yRegistration = layerProperty.GetDataBindingRegistration(point => point.Y);
_xRegistration = layerProperty.GetDataBindingRegistration<float>("X");
_yRegistration = layerProperty.GetDataBindingRegistration<float>("Y");
}
public float X

View File

@ -1,9 +1,8 @@
<UserControl x:Class="Artemis.UI.PropertyInput.SKSizePropertyInputView"
<UserControl x:Class="Artemis.UI.DefaultTypes.PropertyInput.SKSizePropertyInputView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.PropertyInput"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
mc:Ignorable="d"

View File

@ -8,7 +8,7 @@ using Stylet;
// using PropertyChanged;
namespace Artemis.UI.PropertyInput
namespace Artemis.UI.DefaultTypes.PropertyInput
{
public class SKSizePropertyInputViewModel : PropertyInputViewModel<SKSize>
{
@ -18,8 +18,8 @@ namespace Artemis.UI.PropertyInput
public SKSizePropertyInputViewModel(LayerProperty<SKSize> layerProperty, IProfileEditorService profileEditorService,
IModelValidator<SKSizePropertyInputViewModel> validator) : base(layerProperty, profileEditorService, validator)
{
_widthRegistration = layerProperty.GetDataBindingRegistration(size => size.Width);
_heightRegistration = layerProperty.GetDataBindingRegistration(size => size.Height);
_widthRegistration = layerProperty.GetDataBindingRegistration<float>("Width");
_heightRegistration = layerProperty.GetDataBindingRegistration<float>("Height");
}
// Since SKSize is immutable we need to create properties that replace the SKSize entirely

View File

@ -4,9 +4,9 @@ using Artemis.Core.Services;
using Artemis.UI.Controllers;
using Artemis.UI.DefaultTypes.DataModel.Display;
using Artemis.UI.DefaultTypes.DataModel.Input;
using Artemis.UI.DefaultTypes.PropertyInput;
using Artemis.UI.InputProviders;
using Artemis.UI.Ninject;
using Artemis.UI.PropertyInput;
using Artemis.UI.Shared.Services;
using Serilog;