From f4ad41cbd45f9b3e73fe8b5ef0762fdf23245daf Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 2 Mar 2021 21:41:56 +0100 Subject: [PATCH] Data bindings - Simplified getter/setter code --- .../Properties/BoolLayerProperty.cs | 2 +- .../Properties/ColorGradientLayerProperty.cs | 8 +++----- .../Properties/FloatLayerProperty.cs | 2 +- .../Properties/FloatRangeLayerProperty.cs | 6 +++--- .../DefaultTypes/Properties/IntLayerProperty.cs | 2 +- .../Properties/IntRangeLayerProperty.cs | 4 ++-- .../Properties/SKColorLayerProperty.cs | 2 +- .../Properties/SKPointLayerProperty.cs | 5 ++--- .../Properties/SKSizeLayerProperty.cs | 4 ++-- .../Models/Profile/DataBindings/DataBinding.cs | 4 ++-- .../DataBindings/DataBindingConverter.cs | 4 ++-- .../DataBindings/DataBindingRegistration.cs | 16 ++++++---------- .../DataBindings/IDataBindingRegistration.cs | 5 +++++ .../Profile/LayerProperties/LayerProperty.cs | 17 +++++++---------- .../Profile/DataBindings/DataBindingEntity.cs | 2 +- .../PropertyInput/BoolPropertyInputView.xaml | 2 +- .../PropertyInput/BoolPropertyInputViewModel.cs | 16 +++++++++++++--- .../PropertyInput/BrushPropertyInputView.xaml | 4 ++-- .../BrushPropertyInputViewModel.cs | 2 +- .../ColorGradientPropertyInputView.xaml | 3 +-- .../ColorGradientPropertyInputViewModel.cs | 2 +- .../PropertyInput/EnumPropertyInputView.xaml | 2 +- .../PropertyInput/EnumPropertyInputViewModel.cs | 2 +- .../PropertyInput/FloatPropertyInputView.xaml | 3 +-- .../FloatPropertyInputViewModel.cs | 4 ++-- .../FloatRangePropertyInputView.xaml | 3 +-- .../FloatRangePropertyInputViewModel.cs | 6 +++--- .../PropertyInput/IntPropertyInputView.xaml | 3 +-- .../PropertyInput/IntPropertyInputViewModel.cs | 4 ++-- .../IntRangePropertyInputView.xaml | 3 +-- .../IntRangePropertyInputViewModel.cs | 6 +++--- .../PropertyInput/SKColorPropertyInputView.xaml | 3 +-- .../SKColorPropertyInputViewModel.cs | 4 ++-- .../PropertyInput/SKPointPropertyInputView.xaml | 3 +-- .../SKPointPropertyInputViewModel.cs | 6 +++--- .../PropertyInput/SKSizePropertyInputView.xaml | 3 +-- .../SKSizePropertyInputViewModel.cs | 6 +++--- src/Artemis.UI/Services/RegistrationService.cs | 2 +- 38 files changed, 86 insertions(+), 89 deletions(-) diff --git a/src/Artemis.Core/DefaultTypes/Properties/BoolLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/BoolLayerProperty.cs index 567ef6002..99a7b614a 100644 --- a/src/Artemis.Core/DefaultTypes/Properties/BoolLayerProperty.cs +++ b/src/Artemis.Core/DefaultTypes/Properties/BoolLayerProperty.cs @@ -6,7 +6,7 @@ internal BoolLayerProperty() { KeyframesSupported = false; - RegisterDataBindingProperty(value => value, (_, newValue) => CurrentValue = newValue, new GeneralDataBindingConverter(), "Value"); + RegisterDataBindingProperty(() => CurrentValue, value => CurrentValue = value, new GeneralDataBindingConverter(), "Value"); } /// diff --git a/src/Artemis.Core/DefaultTypes/Properties/ColorGradientLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/ColorGradientLayerProperty.cs index 39f02c655..931e4d03d 100644 --- a/src/Artemis.Core/DefaultTypes/Properties/ColorGradientLayerProperty.cs +++ b/src/Artemis.Core/DefaultTypes/Properties/ColorGradientLayerProperty.cs @@ -23,14 +23,12 @@ namespace Artemis.Core for (int index = 0; index < CurrentValue.Stops.Count; index++) { int stopIndex = index; - DataBindingRegistration 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}"; } } diff --git a/src/Artemis.Core/DefaultTypes/Properties/FloatLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/FloatLayerProperty.cs index 589244657..cb1a6eae8 100644 --- a/src/Artemis.Core/DefaultTypes/Properties/FloatLayerProperty.cs +++ b/src/Artemis.Core/DefaultTypes/Properties/FloatLayerProperty.cs @@ -5,7 +5,7 @@ { internal FloatLayerProperty() { - RegisterDataBindingProperty(value => value, (_, newValue) => CurrentValue = newValue, new FloatDataBindingConverter(), "Value"); + RegisterDataBindingProperty(() => CurrentValue, value => CurrentValue = value, new FloatDataBindingConverter(), "Value"); } /// diff --git a/src/Artemis.Core/DefaultTypes/Properties/FloatRangeLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/FloatRangeLayerProperty.cs index 74baa44f9..298e824f3 100644 --- a/src/Artemis.Core/DefaultTypes/Properties/FloatRangeLayerProperty.cs +++ b/src/Artemis.Core/DefaultTypes/Properties/FloatRangeLayerProperty.cs @@ -5,9 +5,9 @@ { internal FloatRangeLayerProperty() { - RegisterDataBindingProperty(value => value.Start, (value, newValue) => value.Start = newValue, new FloatDataBindingConverter(), "Start"); - RegisterDataBindingProperty(value => value.End, (value, newValue) => value.End = newValue, new FloatDataBindingConverter(), "End"); - + RegisterDataBindingProperty(() => CurrentValue.Start, value => CurrentValue.Start = value, new FloatDataBindingConverter(), "Start"); + RegisterDataBindingProperty(() => CurrentValue.End, value => CurrentValue.End = value, new FloatDataBindingConverter(), "End"); + CurrentValueSet += OnCurrentValueSet; } diff --git a/src/Artemis.Core/DefaultTypes/Properties/IntLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/IntLayerProperty.cs index 8d1fff755..f69a1bdbc 100644 --- a/src/Artemis.Core/DefaultTypes/Properties/IntLayerProperty.cs +++ b/src/Artemis.Core/DefaultTypes/Properties/IntLayerProperty.cs @@ -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"); } /// diff --git a/src/Artemis.Core/DefaultTypes/Properties/IntRangeLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/IntRangeLayerProperty.cs index 8ca36f876..474fa33e1 100644 --- a/src/Artemis.Core/DefaultTypes/Properties/IntRangeLayerProperty.cs +++ b/src/Artemis.Core/DefaultTypes/Properties/IntRangeLayerProperty.cs @@ -5,8 +5,8 @@ { internal IntRangeLayerProperty() { - RegisterDataBindingProperty(value => value.Start, (value, newValue) => value.Start = newValue, new IntDataBindingConverter(), "Start"); - RegisterDataBindingProperty(value => value.End, (value, newValue) => value.End = newValue, new IntDataBindingConverter(), "End"); + RegisterDataBindingProperty(() => CurrentValue.Start, value => CurrentValue.Start = value, new IntDataBindingConverter(), "Start"); + RegisterDataBindingProperty(() => CurrentValue.End, value => CurrentValue.End = value, new IntDataBindingConverter(), "End"); CurrentValueSet += OnCurrentValueSet; } diff --git a/src/Artemis.Core/DefaultTypes/Properties/SKColorLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/SKColorLayerProperty.cs index e08b9aaf6..46370568a 100644 --- a/src/Artemis.Core/DefaultTypes/Properties/SKColorLayerProperty.cs +++ b/src/Artemis.Core/DefaultTypes/Properties/SKColorLayerProperty.cs @@ -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"); } /// diff --git a/src/Artemis.Core/DefaultTypes/Properties/SKPointLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/SKPointLayerProperty.cs index f32a312c0..3cd654ad9 100644 --- a/src/Artemis.Core/DefaultTypes/Properties/SKPointLayerProperty.cs +++ b/src/Artemis.Core/DefaultTypes/Properties/SKPointLayerProperty.cs @@ -7,9 +7,8 @@ namespace Artemis.Core { internal SKPointLayerProperty() { - RegisterDataBindingProperty(value => value.X, (value, newValue) => value.X = newValue, new FloatDataBindingConverter(), "X"); - RegisterDataBindingProperty(value => value.Y, (value, newValue) => value.Y = newValue, new FloatDataBindingConverter(), "Y"); - + RegisterDataBindingProperty(() => CurrentValue.X, value => CurrentValue = new SKPoint(value, CurrentValue.Y), new FloatDataBindingConverter(), "X"); + RegisterDataBindingProperty(() => CurrentValue.Y, value => CurrentValue = new SKPoint(CurrentValue.X, value), new FloatDataBindingConverter(), "Y"); } /// diff --git a/src/Artemis.Core/DefaultTypes/Properties/SKSizeLayerProperty.cs b/src/Artemis.Core/DefaultTypes/Properties/SKSizeLayerProperty.cs index d018b4fb5..3274c26f9 100644 --- a/src/Artemis.Core/DefaultTypes/Properties/SKSizeLayerProperty.cs +++ b/src/Artemis.Core/DefaultTypes/Properties/SKSizeLayerProperty.cs @@ -7,8 +7,8 @@ namespace Artemis.Core { internal SKSizeLayerProperty() { - RegisterDataBindingProperty(value => value.Height, (value, newValue) => value.Height = newValue, new FloatDataBindingConverter(), "Height"); - RegisterDataBindingProperty(value => value.Width, (value, newValue) => value.Width = newValue, new FloatDataBindingConverter(), "Width"); + RegisterDataBindingProperty(() => CurrentValue.Width, (value) => CurrentValue = new SKSize(value, CurrentValue.Height), new FloatDataBindingConverter(), "Width"); + RegisterDataBindingProperty(() => CurrentValue.Height, (value) => CurrentValue = new SKSize(CurrentValue.Width, value), new FloatDataBindingConverter(), "Height"); } /// diff --git a/src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs b/src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs index 44370e498..4bfbacc48 100644 --- a/src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs +++ b/src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs @@ -272,7 +272,7 @@ namespace Artemis.Core throw new ObjectDisposedException("DataBinding"); // General - DataBindingRegistration? registration = LayerProperty.GetDataBindingRegistration(Entity.TargetExpression); + DataBindingRegistration? registration = LayerProperty.GetDataBindingRegistration(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; diff --git a/src/Artemis.Core/Models/Profile/DataBindings/DataBindingConverter.cs b/src/Artemis.Core/Models/Profile/DataBindings/DataBindingConverter.cs index a7ec330ed..2b3d7eb5a 100644 --- a/src/Artemis.Core/Models/Profile/DataBindings/DataBindingConverter.cs +++ b/src/Artemis.Core/Models/Profile/DataBindings/DataBindingConverter.cs @@ -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); } /// @@ -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(); } /// diff --git a/src/Artemis.Core/Models/Profile/DataBindings/DataBindingRegistration.cs b/src/Artemis.Core/Models/Profile/DataBindings/DataBindingRegistration.cs index e43c28550..78e233fe1 100644 --- a/src/Artemis.Core/Models/Profile/DataBindings/DataBindingRegistration.cs +++ b/src/Artemis.Core/Models/Profile/DataBindings/DataBindingRegistration.cs @@ -8,9 +8,7 @@ namespace Artemis.Core public class DataBindingRegistration : IDataBindingRegistration { internal DataBindingRegistration(LayerProperty layerProperty, DataBindingConverter converter, - Func getter, - Action setter, - string displayName) + Func getter, Action setter, string displayName) { LayerProperty = layerProperty ?? throw new ArgumentNullException(nameof(layerProperty)); Converter = converter ?? throw new ArgumentNullException(nameof(converter)); @@ -32,17 +30,15 @@ namespace Artemis.Core /// /// Gets the function to call to get the value of the property /// - public Func Getter { get; } + public Func Getter { get; } /// /// Gets the action to call to set the value of the property /// - public Action Setter { get; } + public Action Setter { get; } - /// - /// Gets or sets the display name of the data binding registration - /// - public string DisplayName { get; set; } + /// + public string DisplayName { get; } /// /// 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; diff --git a/src/Artemis.Core/Models/Profile/DataBindings/IDataBindingRegistration.cs b/src/Artemis.Core/Models/Profile/DataBindings/IDataBindingRegistration.cs index fb6220951..8e1de1f0a 100644 --- a/src/Artemis.Core/Models/Profile/DataBindings/IDataBindingRegistration.cs +++ b/src/Artemis.Core/Models/Profile/DataBindings/IDataBindingRegistration.cs @@ -5,6 +5,11 @@ /// public interface IDataBindingRegistration { + /// + /// Gets or sets the display name of the data binding registration + /// + string DisplayName { get; } + /// /// Returns the data binding applied using this registration /// diff --git a/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs b/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs index b184f6e24..fe93cbcb3 100644 --- a/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs +++ b/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs @@ -379,21 +379,16 @@ namespace Artemis.Core public bool HasDataBinding => GetAllDataBindingRegistrations().Any(r => r.GetDataBinding() != null); /// - /// 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 /// Note: The expression must exactly match the one used to register the data binding /// - public DataBindingRegistration? GetDataBindingRegistration(Expression> propertyExpression) - { - return GetDataBindingRegistration(propertyExpression.ToString()); - } - - internal DataBindingRegistration? GetDataBindingRegistration(string expression) + public DataBindingRegistration? GetDataBindingRegistration(string identifier) { if (_disposed) throw new ObjectDisposedException("LayerProperty"); IDataBindingRegistration? match = _dataBindingRegistrations.FirstOrDefault(r => r is DataBindingRegistration registration && - registration.Getter.ToString() == expression); + registration.DisplayName == identifier); return (DataBindingRegistration?) match; } @@ -414,13 +409,15 @@ namespace Artemis.Core /// The action to call to set the value of the property /// The converter to use while applying the data binding /// The display name of the data binding property - public DataBindingRegistration RegisterDataBindingProperty(Func getter, Action setter, DataBindingConverter converter, + public DataBindingRegistration RegisterDataBindingProperty(Func getter, Action setter, DataBindingConverter 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 registration = new(this, converter, getter, setter, displayName); + DataBindingRegistration registration = new(this, converter, getter, setter, displayName); _dataBindingRegistrations.Add(registration); return registration; } diff --git a/src/Artemis.Storage/Entities/Profile/DataBindings/DataBindingEntity.cs b/src/Artemis.Storage/Entities/Profile/DataBindings/DataBindingEntity.cs index 0a0dc030c..6dd27b85a 100644 --- a/src/Artemis.Storage/Entities/Profile/DataBindings/DataBindingEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/DataBindings/DataBindingEntity.cs @@ -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; } diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/BoolPropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/BoolPropertyInputView.xaml index 16f480241..ebf357f9e 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/BoolPropertyInputView.xaml +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/BoolPropertyInputView.xaml @@ -1,4 +1,4 @@ - { + private List _registrations; + public BoolPropertyInputViewModel(LayerProperty 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)); + } } } \ No newline at end of file diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputView.xaml index 15c14f988..aa4e288d3 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputView.xaml +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputView.xaml @@ -1,12 +1,12 @@ - diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputViewModel.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputViewModel.cs index d0b5e1b16..20409eb1c 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputViewModel.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputViewModel.cs @@ -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 { diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputView.xaml index 13ea3a9c9..ef17ba34e 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputView.xaml +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputView.xaml @@ -1,9 +1,8 @@ - { diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/EnumPropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/EnumPropertyInputView.xaml index 732d1648f..818914562 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/EnumPropertyInputView.xaml +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/EnumPropertyInputView.xaml @@ -1,4 +1,4 @@ - : PropertyInputViewModel where T : Enum { diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputView.xaml index 3c9bd2105..65e27826f 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputView.xaml +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputView.xaml @@ -1,11 +1,10 @@ - { @@ -13,7 +13,7 @@ namespace Artemis.UI.PropertyInput public FloatPropertyInputViewModel(LayerProperty layerProperty, IProfileEditorService profileEditorService, IModelValidator validator) : base(layerProperty, profileEditorService, validator) { - _registration = layerProperty.GetDataBindingRegistration(value => value); + _registration = layerProperty.GetDataBindingRegistration("Value"); } public bool IsEnabled => _registration.DataBinding == null; diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/FloatRangePropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/FloatRangePropertyInputView.xaml index e88828009..aabe66a33 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/FloatRangePropertyInputView.xaml +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/FloatRangePropertyInputView.xaml @@ -1,9 +1,8 @@ - { @@ -16,8 +16,8 @@ namespace Artemis.UI.PropertyInput IProfileEditorService profileEditorService, IModelValidator validator) : base(layerProperty, profileEditorService, validator) { - _startRegistration = layerProperty.GetDataBindingRegistration(range => range.Start); - _endRegistration = layerProperty.GetDataBindingRegistration(range => range.End); + _startRegistration = layerProperty.GetDataBindingRegistration("Start"); + _endRegistration = layerProperty.GetDataBindingRegistration("End"); } public float Start diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputView.xaml index 14fab93f1..4cae90771 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputView.xaml +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputView.xaml @@ -1,11 +1,10 @@ - { @@ -13,7 +13,7 @@ namespace Artemis.UI.PropertyInput public IntPropertyInputViewModel(LayerProperty layerProperty, IProfileEditorService profileEditorService, IModelValidator validator) : base(layerProperty, profileEditorService, validator) { - _registration = layerProperty.GetDataBindingRegistration(value => value); + _registration = layerProperty.GetDataBindingRegistration("Value"); } public bool IsEnabled => _registration.DataBinding == null; diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/IntRangePropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/IntRangePropertyInputView.xaml index 62e4b8570..40a0e815a 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/IntRangePropertyInputView.xaml +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/IntRangePropertyInputView.xaml @@ -1,9 +1,8 @@ - { @@ -16,8 +16,8 @@ namespace Artemis.UI.PropertyInput IProfileEditorService profileEditorService, IModelValidator validator) : base(layerProperty, profileEditorService, validator) { - _startRegistration = layerProperty.GetDataBindingRegistration(range => range.Start); - _endRegistration = layerProperty.GetDataBindingRegistration(range => range.End); + _startRegistration = layerProperty.GetDataBindingRegistration("Start"); + _endRegistration = layerProperty.GetDataBindingRegistration("End"); } public int Start diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/SKColorPropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/SKColorPropertyInputView.xaml index fdc5a6c1b..6861259bb 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/SKColorPropertyInputView.xaml +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/SKColorPropertyInputView.xaml @@ -1,10 +1,9 @@ - { @@ -11,7 +11,7 @@ namespace Artemis.UI.PropertyInput public SKColorPropertyInputViewModel(LayerProperty layerProperty, IProfileEditorService profileEditorService) : base(layerProperty, profileEditorService) { - _registration = layerProperty.GetDataBindingRegistration(value => value); + _registration = layerProperty.GetDataBindingRegistration("Value"); } public bool IsEnabled => _registration.DataBinding == null; diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputView.xaml index 34e679a0c..1f15efc15 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputView.xaml +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputView.xaml @@ -1,11 +1,10 @@ - diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputViewModel.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputViewModel.cs index 8d7448f8b..ac32cbaf3 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputViewModel.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputViewModel.cs @@ -6,7 +6,7 @@ using FluentValidation; using SkiaSharp; using Stylet; -namespace Artemis.UI.PropertyInput +namespace Artemis.UI.DefaultTypes.PropertyInput { public class SKPointPropertyInputViewModel : PropertyInputViewModel { @@ -16,8 +16,8 @@ namespace Artemis.UI.PropertyInput public SKPointPropertyInputViewModel(LayerProperty layerProperty, IProfileEditorService profileEditorService, IModelValidator validator) : base(layerProperty, profileEditorService, validator) { - _xRegistration = layerProperty.GetDataBindingRegistration(point => point.X); - _yRegistration = layerProperty.GetDataBindingRegistration(point => point.Y); + _xRegistration = layerProperty.GetDataBindingRegistration("X"); + _yRegistration = layerProperty.GetDataBindingRegistration("Y"); } public float X diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputView.xaml index 9cca2e62b..0f5dfc93c 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputView.xaml +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputView.xaml @@ -1,9 +1,8 @@ - { @@ -18,8 +18,8 @@ namespace Artemis.UI.PropertyInput public SKSizePropertyInputViewModel(LayerProperty layerProperty, IProfileEditorService profileEditorService, IModelValidator validator) : base(layerProperty, profileEditorService, validator) { - _widthRegistration = layerProperty.GetDataBindingRegistration(size => size.Width); - _heightRegistration = layerProperty.GetDataBindingRegistration(size => size.Height); + _widthRegistration = layerProperty.GetDataBindingRegistration("Width"); + _heightRegistration = layerProperty.GetDataBindingRegistration("Height"); } // Since SKSize is immutable we need to create properties that replace the SKSize entirely diff --git a/src/Artemis.UI/Services/RegistrationService.cs b/src/Artemis.UI/Services/RegistrationService.cs index ffbdc2958..0d51ce376 100644 --- a/src/Artemis.UI/Services/RegistrationService.cs +++ b/src/Artemis.UI/Services/RegistrationService.cs @@ -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;