From 2eb4d615ae890cf43c838ace0b0ff7a7d1cf9db7 Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 16 Sep 2020 20:17:54 +0200 Subject: [PATCH] Plugins - Added timed updates Modules - Added option to disable updates while activation is overridden Display conditions - Added SKColor support Data bindings - Added SKColor support --- src/Artemis.Core/Plugins/Modules/Module.cs | 13 +++- .../Plugins/Modules/ProfileModule.cs | 3 +- .../Plugins/PluginUpdateRegistration.cs | 8 +++ .../Controls/ColorPicker.xaml | 4 +- .../Controls/ColorPicker.xaml.cs | 26 +++++++ .../Converters/ColorToStringConverter.cs | 2 +- .../DataModelDisplayViewModel.cs | 8 ++- .../Input/DataModelStaticView.xaml | 2 +- .../Input/DataModelStaticViewModel.cs | 68 +++++++++++++++++-- .../Shared/DataModelListPropertyViewModel.cs | 4 +- .../Shared/DataModelPropertyViewModel.cs | 29 +------- .../Display/DefaultDataModelDisplayView.xaml | 23 +++++++ .../DefaultDataModelDisplayViewModel.cs | 26 +++++++ .../Services/DataModelUIService.cs | 5 +- .../Interfaces/IDataModelUIService.cs | 2 +- src/Artemis.UI/Artemis.UI.csproj | 13 +++- .../Display/SKColorDataModelDisplayView.xaml | 5 +- .../SKColorDataModelDisplayViewModel.cs | 2 +- .../Input/DoubleDataModelInputView.xaml | 2 +- .../Input/DoubleDataModelInputViewModel.cs | 2 +- .../Input/IntDataModelInputView.xaml | 2 +- .../Input/IntDataModelInputViewModel.cs | 2 +- .../Input/SKColorDataModelInputView.xaml | 20 ++++++ .../Input/SKColorDataModelInputViewModel.cs | 13 ++++ .../Input/StringDataModelInputView.xaml | 2 +- .../Input/StringDataModelInputViewModel.cs | 2 +- .../PropertyInput/BrushPropertyInputView.xaml | 0 .../BrushPropertyInputViewModel.cs | 0 .../ColorGradientPropertyInputView.xaml | 0 .../ColorGradientPropertyInputViewModel.cs | 0 .../PropertyInput/EnumPropertyInputView.xaml | 0 .../EnumPropertyInputViewModel.cs | 0 .../PropertyInput/FloatPropertyInputView.xaml | 0 .../FloatPropertyInputViewModel.cs | 0 .../PropertyInput/IntPropertyInputView.xaml | 0 .../IntPropertyInputViewModel.cs | 0 .../SKColorPropertyInputView.xaml | 0 .../SKColorPropertyInputViewModel.cs | 0 .../SKPointPropertyInputView.xaml | 0 .../SKPointPropertyInputViewModel.cs | 0 .../SKSizePropertyInputView.xaml | 0 .../SKSizePropertyInputViewModel.cs | 0 .../DataBindings/DataBindingView.xaml | 16 ++++- .../DataBindings/DataBindingViewModel.cs | 32 ++++----- .../DataBindingModifierViewModel.cs | 7 ++ .../Debug/Tabs/DataModelDebugView.xaml | 16 +---- .../Services/RegistrationService.cs | 9 +-- .../GeneralModule.cs | 1 + 48 files changed, 269 insertions(+), 100 deletions(-) create mode 100644 src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayView.xaml create mode 100644 src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayViewModel.cs rename src/Artemis.UI/{DataModelVisualization => DefaultTypes/DataModel}/Display/SKColorDataModelDisplayView.xaml (93%) rename src/Artemis.UI/{DataModelVisualization => DefaultTypes/DataModel}/Display/SKColorDataModelDisplayViewModel.cs (74%) rename src/Artemis.UI/{DataModelVisualization => DefaultTypes/DataModel}/Input/DoubleDataModelInputView.xaml (93%) rename src/Artemis.UI/{DataModelVisualization => DefaultTypes/DataModel}/Input/DoubleDataModelInputViewModel.cs (94%) rename src/Artemis.UI/{DataModelVisualization => DefaultTypes/DataModel}/Input/IntDataModelInputView.xaml (93%) rename src/Artemis.UI/{DataModelVisualization => DefaultTypes/DataModel}/Input/IntDataModelInputViewModel.cs (92%) create mode 100644 src/Artemis.UI/DefaultTypes/DataModel/Input/SKColorDataModelInputView.xaml create mode 100644 src/Artemis.UI/DefaultTypes/DataModel/Input/SKColorDataModelInputViewModel.cs rename src/Artemis.UI/{DataModelVisualization => DefaultTypes/DataModel}/Input/StringDataModelInputView.xaml (93%) rename src/Artemis.UI/{DataModelVisualization => DefaultTypes/DataModel}/Input/StringDataModelInputViewModel.cs (90%) rename src/Artemis.UI/{ => DefaultTypes}/PropertyInput/BrushPropertyInputView.xaml (100%) rename src/Artemis.UI/{ => DefaultTypes}/PropertyInput/BrushPropertyInputViewModel.cs (100%) rename src/Artemis.UI/{ => DefaultTypes}/PropertyInput/ColorGradientPropertyInputView.xaml (100%) rename src/Artemis.UI/{ => DefaultTypes}/PropertyInput/ColorGradientPropertyInputViewModel.cs (100%) rename src/Artemis.UI/{ => DefaultTypes}/PropertyInput/EnumPropertyInputView.xaml (100%) rename src/Artemis.UI/{ => DefaultTypes}/PropertyInput/EnumPropertyInputViewModel.cs (100%) rename src/Artemis.UI/{ => DefaultTypes}/PropertyInput/FloatPropertyInputView.xaml (100%) rename src/Artemis.UI/{ => DefaultTypes}/PropertyInput/FloatPropertyInputViewModel.cs (100%) rename src/Artemis.UI/{ => DefaultTypes}/PropertyInput/IntPropertyInputView.xaml (100%) rename src/Artemis.UI/{ => DefaultTypes}/PropertyInput/IntPropertyInputViewModel.cs (100%) rename src/Artemis.UI/{ => DefaultTypes}/PropertyInput/SKColorPropertyInputView.xaml (100%) rename src/Artemis.UI/{ => DefaultTypes}/PropertyInput/SKColorPropertyInputViewModel.cs (100%) rename src/Artemis.UI/{ => DefaultTypes}/PropertyInput/SKPointPropertyInputView.xaml (100%) rename src/Artemis.UI/{ => DefaultTypes}/PropertyInput/SKPointPropertyInputViewModel.cs (100%) rename src/Artemis.UI/{ => DefaultTypes}/PropertyInput/SKSizePropertyInputView.xaml (100%) rename src/Artemis.UI/{ => DefaultTypes}/PropertyInput/SKSizePropertyInputViewModel.cs (100%) diff --git a/src/Artemis.Core/Plugins/Modules/Module.cs b/src/Artemis.Core/Plugins/Modules/Module.cs index 0892e6ab2..946ce40b9 100644 --- a/src/Artemis.Core/Plugins/Modules/Module.cs +++ b/src/Artemis.Core/Plugins/Modules/Module.cs @@ -93,7 +93,13 @@ namespace Artemis.Core.Modules /// Gets whether this module's activation was due to an override, can only be true if is /// true /// - public bool IsActivatedOverride { get; set; } + public bool IsActivatedOverride { get; private set; } + + /// + /// Gets whether this module should update if is true + /// Defaults to true + /// + public bool UpdateDuringActivationOverride { get; protected set; } = true; /// /// A list of activation requirements @@ -180,10 +186,11 @@ namespace Artemis.Core.Modules return false; } - + internal virtual void InternalUpdate(double deltaTime) { - Update(deltaTime); + if (!IsActivatedOverride || UpdateDuringActivationOverride) + Update(deltaTime); } internal virtual void InternalRender(double deltaTime, ArtemisSurface surface, SKCanvas canvas, SKImageInfo canvasInfo) diff --git a/src/Artemis.Core/Plugins/Modules/ProfileModule.cs b/src/Artemis.Core/Plugins/Modules/ProfileModule.cs index 86afbcc0a..498d7475a 100644 --- a/src/Artemis.Core/Plugins/Modules/ProfileModule.cs +++ b/src/Artemis.Core/Plugins/Modules/ProfileModule.cs @@ -141,7 +141,8 @@ namespace Artemis.Core.Modules internal override void InternalUpdate(double deltaTime) { - Update(deltaTime); + if (!IsActivatedOverride || UpdateDuringActivationOverride) + Update(deltaTime); lock (this) { diff --git a/src/Artemis.Core/Plugins/PluginUpdateRegistration.cs b/src/Artemis.Core/Plugins/PluginUpdateRegistration.cs index 010e32511..488c30c72 100644 --- a/src/Artemis.Core/Plugins/PluginUpdateRegistration.cs +++ b/src/Artemis.Core/Plugins/PluginUpdateRegistration.cs @@ -1,5 +1,6 @@ using System; using System.Timers; +using Artemis.Core.Modules; namespace Artemis.Core { @@ -53,6 +54,13 @@ namespace Artemis.Core if (_timer != null) return; + // Don't update during override if that is disabled on the module + if (PluginInfo.Instance is Module module) + { + if (module.IsActivatedOverride && !module.UpdateDuringActivationOverride) + return; + } + _lastEvent = DateTime.Now; _timer = new Timer(Interval.TotalMilliseconds); _timer.Elapsed += TimerOnElapsed; diff --git a/src/Artemis.UI.Shared/Controls/ColorPicker.xaml b/src/Artemis.UI.Shared/Controls/ColorPicker.xaml index 666924607..640f202f0 100644 --- a/src/Artemis.UI.Shared/Controls/ColorPicker.xaml +++ b/src/Artemis.UI.Shared/Controls/ColorPicker.xaml @@ -92,7 +92,7 @@ Placement="Bottom" CustomPopupPlacementCallback="{x:Static materialDesign:CustomPopupPlacementCallbackHelper.LargePopupCallback}" PlacementTarget="{Binding ElementName=ColorCodeTextBox}" - StaysOpen="False" + StaysOpen="{Binding StaysOpen, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PopupAnimation="Fade" IsOpen="{Binding PopupOpen, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"> @@ -101,7 +101,7 @@ - + SetValue(PopupOpenProperty, value); } + public bool StaysOpen + { + get => (bool) GetValue(StaysOpenProperty); + set => SetValue(StaysOpenProperty, value); + } + internal byte ColorOpacity { get => (byte) GetValue(ColorOpacityProperty); @@ -92,6 +101,17 @@ namespace Artemis.UI.Shared colorPicker._inCallback = false; } + private static void StaysOpenPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var colorPicker = (ColorPicker) d; + if (colorPicker._inCallback) + return; + + colorPicker._inCallback = true; + colorPicker.OnPropertyChanged(nameof(PopupOpen)); + colorPicker._inCallback = false; + } + private static void ColorOpacityPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { var colorPicker = (ColorPicker) d; @@ -112,6 +132,12 @@ namespace Artemis.UI.Shared private void UIElement_OnMouseUp(object sender, MouseButtonEventArgs e) { PopupOpen = !PopupOpen; + e.Handled = true; + } + + private void ColorGradient_OnMouseUp(object sender, MouseButtonEventArgs e) + { + e.Handled = true; } } } \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Converters/ColorToStringConverter.cs b/src/Artemis.UI.Shared/Converters/ColorToStringConverter.cs index 0d9a9ccd7..a285b1870 100644 --- a/src/Artemis.UI.Shared/Converters/ColorToStringConverter.cs +++ b/src/Artemis.UI.Shared/Converters/ColorToStringConverter.cs @@ -15,7 +15,7 @@ namespace Artemis.UI.Shared /// public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - return value?.ToString(); + return value?.ToString()?.ToUpper(); } /// diff --git a/src/Artemis.UI.Shared/DataModelVisualization/DataModelDisplayViewModel.cs b/src/Artemis.UI.Shared/DataModelVisualization/DataModelDisplayViewModel.cs index 7a5996ca3..ff07fee4f 100644 --- a/src/Artemis.UI.Shared/DataModelVisualization/DataModelDisplayViewModel.cs +++ b/src/Artemis.UI.Shared/DataModelVisualization/DataModelDisplayViewModel.cs @@ -20,10 +20,12 @@ namespace Artemis.UI.Shared { } - internal override void UpdateValue(object model) + public override void UpdateValue(object model) { DisplayValue = model is T value ? value : default; } + + internal override object InternalGuard => null; } /// @@ -31,9 +33,11 @@ namespace Artemis.UI.Shared /// public abstract class DataModelDisplayViewModel : PropertyChangedBase { + public abstract void UpdateValue(object model); + /// /// Prevents this type being implemented directly, implement instead. /// - internal abstract void UpdateValue(object model); + internal abstract object InternalGuard { get; } } } \ No newline at end of file diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticView.xaml b/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticView.xaml index 6afe0edba..87d3109dd 100644 --- a/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticView.xaml +++ b/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticView.xaml @@ -33,7 +33,7 @@ - + diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticViewModel.cs b/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticViewModel.cs index 7d4e23214..f1352e081 100644 --- a/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticViewModel.cs +++ b/src/Artemis.UI.Shared/DataModelVisualization/Input/DataModelStaticViewModel.cs @@ -1,19 +1,21 @@ using System; +using System.Linq; +using System.Windows; +using System.Windows.Input; using System.Windows.Media; using Artemis.Core; using Artemis.Core.DataModelExpansions; using Artemis.UI.Shared.Services; using Stylet; -// Remove, annoying while working on it -#pragma warning disable 1591 - namespace Artemis.UI.Shared.Input { - public class DataModelStaticViewModel : PropertyChangedBase + public class DataModelStaticViewModel : PropertyChangedBase, IDisposable { private readonly IDataModelUIService _dataModelUIService; + private readonly Window _rootView; private Brush _buttonBrush = new SolidColorBrush(Color.FromRgb(171, 71, 188)); + private DataModelDisplayViewModel _displayViewModel; private DataModelInputViewModel _inputViewModel; private string _placeholder = "Enter a value"; private DataModelPropertyAttribute _targetDescription; @@ -25,6 +27,15 @@ namespace Artemis.UI.Shared.Input { TargetType = targetType; _dataModelUIService = dataModelUIService; + + DisplayViewModel = _dataModelUIService.GetDataModelDisplayViewModel(TargetType, true); + + _rootView = Application.Current.Windows.OfType().SingleOrDefault(x => x.IsActive); + if (_rootView != null) + { + _rootView.MouseUp += RootViewOnMouseUp; + _rootView.KeyUp += RootViewOnKeyUp; + } } public Brush ButtonBrush @@ -39,6 +50,12 @@ namespace Artemis.UI.Shared.Input set => SetAndNotify(ref _transitionIndex, value); } + public DataModelDisplayViewModel DisplayViewModel + { + get => _displayViewModel; + set => SetAndNotify(ref _displayViewModel, value); + } + public DataModelInputViewModel InputViewModel { get => _inputViewModel; @@ -60,7 +77,11 @@ namespace Artemis.UI.Shared.Input public object Value { get => _value; - set => SetAndNotify(ref _value, value); + set + { + if (!SetAndNotify(ref _value, value)) return; + DisplayViewModel?.UpdateValue(_value); + } } public string Placeholder @@ -69,6 +90,19 @@ namespace Artemis.UI.Shared.Input set => SetAndNotify(ref _placeholder, value); } + #region IDisposable + + public void Dispose() + { + if (_rootView != null) + { + _rootView.MouseUp -= RootViewOnMouseUp; + _rootView.KeyUp -= RootViewOnKeyUp; + } + } + + #endregion + public void ActivateInputViewModel() { TransitionIndex = 1; @@ -102,6 +136,30 @@ namespace Artemis.UI.Shared.Input Value = value; } + #region Event handlers + + private void RootViewOnKeyUp(object sender, KeyEventArgs e) + { + if (InputViewModel == null) + return; + + if (e.Key == Key.Escape) + InputViewModel.Cancel(); + else if (e.Key == Key.Enter) + InputViewModel.Submit(); + } + + private void RootViewOnMouseUp(object sender, MouseButtonEventArgs e) + { + if (InputViewModel == null) + return; + + if (sender is FrameworkElement frameworkElement && !frameworkElement.IsDescendantOf(InputViewModel.View)) + InputViewModel.Submit(); + } + + #endregion + #region Events public event EventHandler ValueUpdated; diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListPropertyViewModel.cs b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListPropertyViewModel.cs index 2d3c7292b..f612ec056 100644 --- a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListPropertyViewModel.cs +++ b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelListPropertyViewModel.cs @@ -38,8 +38,8 @@ namespace Artemis.UI.Shared if (DisplayValue == null) return; - if (DisplayViewModel == null && dataModelUIService.RegisteredDataModelDisplays.Any(d => d.SupportedType == DisplayValue.GetType())) - dataModelUIService.GetDataModelDisplayViewModel(DisplayValue.GetType()); + if (DisplayViewModel == null) + DisplayViewModel = dataModelUIService.GetDataModelDisplayViewModel(DisplayValue.GetType(), true); ListType = DisplayValue.GetType(); UpdateDisplayParameters(); diff --git a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelPropertyViewModel.cs b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelPropertyViewModel.cs index 729e3fe67..df82cecd7 100644 --- a/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelPropertyViewModel.cs +++ b/src/Artemis.UI.Shared/DataModelVisualization/Shared/DataModelPropertyViewModel.cs @@ -9,9 +9,6 @@ namespace Artemis.UI.Shared { private object _displayValue; private DataModelDisplayViewModel _displayViewModel; - private bool _showNull; - private bool _showToString; - private bool _showViewModel; internal DataModelPropertyViewModel(DataModel dataModel, DataModelVisualizationViewModel parent, PropertyInfo propertyInfo) : base(dataModel, parent, propertyInfo) { @@ -29,31 +26,13 @@ namespace Artemis.UI.Shared set => SetAndNotify(ref _displayViewModel, value); } - public bool ShowToString - { - get => _showToString; - set => SetAndNotify(ref _showToString, value); - } - - public bool ShowNull - { - get => _showNull; - set => SetAndNotify(ref _showNull, value); - } - - public bool ShowViewModel - { - get => _showViewModel; - set => SetAndNotify(ref _showViewModel, value); - } - public override void Update(IDataModelUIService dataModelUIService) { if (Parent != null && !Parent.IsVisualizationExpanded && !Parent.IsRootViewModel) return; - if (DisplayViewModel == null && dataModelUIService.RegisteredDataModelDisplays.Any(d => d.SupportedType == PropertyInfo.PropertyType)) - dataModelUIService.GetDataModelDisplayViewModel(PropertyInfo.PropertyType); + if (DisplayViewModel == null) + DisplayViewModel = dataModelUIService.GetDataModelDisplayViewModel(PropertyInfo.PropertyType, true); DisplayValue = GetCurrentValue(); UpdateDisplayParameters(); @@ -61,10 +40,6 @@ namespace Artemis.UI.Shared protected void UpdateDisplayParameters() { - ShowToString = DisplayValue != null && DisplayViewModel == null; - ShowNull = DisplayValue == null; - ShowViewModel = DisplayValue != null && DisplayViewModel != null; - DisplayViewModel?.UpdateValue(DisplayValue); } } diff --git a/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayView.xaml b/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayView.xaml new file mode 100644 index 000000000..8c748ffaa --- /dev/null +++ b/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayView.xaml @@ -0,0 +1,23 @@ + + + + + + + diff --git a/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayViewModel.cs b/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayViewModel.cs new file mode 100644 index 000000000..fef262aa4 --- /dev/null +++ b/src/Artemis.UI.Shared/DefaultTypes/DataModel/Display/DefaultDataModelDisplayViewModel.cs @@ -0,0 +1,26 @@ +namespace Artemis.UI.Shared.DefaultTypes.DataModel.Display +{ + public class DefaultDataModelDisplayViewModel : DataModelDisplayViewModel + { + private bool _showNull; + private bool _showToString; + + public bool ShowToString + { + get => _showToString; + set => SetAndNotify(ref _showToString, value); + } + + public bool ShowNull + { + get => _showNull; + set => SetAndNotify(ref _showNull, value); + } + + protected override void OnDisplayValueUpdated() + { + ShowToString = DisplayValue != null; + ShowNull = DisplayValue == null; + } + } +} \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Services/DataModelUIService.cs b/src/Artemis.UI.Shared/Services/DataModelUIService.cs index 280bc4b5f..84ac900a6 100644 --- a/src/Artemis.UI.Shared/Services/DataModelUIService.cs +++ b/src/Artemis.UI.Shared/Services/DataModelUIService.cs @@ -5,6 +5,7 @@ using Artemis.Core; using Artemis.Core.DataModelExpansions; using Artemis.Core.Modules; using Artemis.Core.Services; +using Artemis.UI.Shared.DefaultTypes.DataModel.Display; using Artemis.UI.Shared.Input; using Ninject; using Ninject.Parameters; @@ -158,14 +159,14 @@ namespace Artemis.UI.Shared.Services } } - public DataModelDisplayViewModel GetDataModelDisplayViewModel(Type propertyType) + public DataModelDisplayViewModel GetDataModelDisplayViewModel(Type propertyType, bool fallBackToDefault) { lock (_registeredDataModelDisplays) { var match = _registeredDataModelDisplays.FirstOrDefault(d => d.SupportedType == propertyType); if (match != null) return (DataModelDisplayViewModel) _kernel.Get(match.ViewModelType); - return null; + return !fallBackToDefault ? null : _kernel.Get(); } } diff --git a/src/Artemis.UI.Shared/Services/Interfaces/IDataModelUIService.cs b/src/Artemis.UI.Shared/Services/Interfaces/IDataModelUIService.cs index f9cb711df..198dbb47d 100644 --- a/src/Artemis.UI.Shared/Services/Interfaces/IDataModelUIService.cs +++ b/src/Artemis.UI.Shared/Services/Interfaces/IDataModelUIService.cs @@ -19,7 +19,7 @@ namespace Artemis.UI.Shared.Services void RemoveDataModelInput(DataModelVisualizationRegistration registration); void RemoveDataModelDisplay(DataModelVisualizationRegistration registration); - DataModelDisplayViewModel GetDataModelDisplayViewModel(Type propertyType); + DataModelDisplayViewModel GetDataModelDisplayViewModel(Type propertyType, bool fallBackToDefault = false); DataModelInputViewModel GetDataModelInputViewModel(Type propertyType, DataModelPropertyAttribute description, object initialValue, Action updateCallback); DataModelDynamicViewModel GetDynamicSelectionViewModel(Module module); diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index 1921504c0..b39b8eb18 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -315,10 +315,19 @@ - + Designer - + + Designer + + + Designer + + + Designer + + Designer diff --git a/src/Artemis.UI/DataModelVisualization/Display/SKColorDataModelDisplayView.xaml b/src/Artemis.UI/DefaultTypes/DataModel/Display/SKColorDataModelDisplayView.xaml similarity index 93% rename from src/Artemis.UI/DataModelVisualization/Display/SKColorDataModelDisplayView.xaml rename to src/Artemis.UI/DefaultTypes/DataModel/Display/SKColorDataModelDisplayView.xaml index 6bdee4e53..084f60cef 100644 --- a/src/Artemis.UI/DataModelVisualization/Display/SKColorDataModelDisplayView.xaml +++ b/src/Artemis.UI/DefaultTypes/DataModel/Display/SKColorDataModelDisplayView.xaml @@ -1,10 +1,10 @@ - @@ -16,7 +16,6 @@ - { diff --git a/src/Artemis.UI/DataModelVisualization/Input/DoubleDataModelInputView.xaml b/src/Artemis.UI/DefaultTypes/DataModel/Input/DoubleDataModelInputView.xaml similarity index 93% rename from src/Artemis.UI/DataModelVisualization/Input/DoubleDataModelInputView.xaml rename to src/Artemis.UI/DefaultTypes/DataModel/Input/DoubleDataModelInputView.xaml index 068b5b37d..7daddf3ee 100644 --- a/src/Artemis.UI/DataModelVisualization/Input/DoubleDataModelInputView.xaml +++ b/src/Artemis.UI/DefaultTypes/DataModel/Input/DoubleDataModelInputView.xaml @@ -1,4 +1,4 @@ - { diff --git a/src/Artemis.UI/DataModelVisualization/Input/IntDataModelInputView.xaml b/src/Artemis.UI/DefaultTypes/DataModel/Input/IntDataModelInputView.xaml similarity index 93% rename from src/Artemis.UI/DataModelVisualization/Input/IntDataModelInputView.xaml rename to src/Artemis.UI/DefaultTypes/DataModel/Input/IntDataModelInputView.xaml index 7774f8c08..2a0aa7691 100644 --- a/src/Artemis.UI/DataModelVisualization/Input/IntDataModelInputView.xaml +++ b/src/Artemis.UI/DefaultTypes/DataModel/Input/IntDataModelInputView.xaml @@ -1,4 +1,4 @@ - { diff --git a/src/Artemis.UI/DefaultTypes/DataModel/Input/SKColorDataModelInputView.xaml b/src/Artemis.UI/DefaultTypes/DataModel/Input/SKColorDataModelInputView.xaml new file mode 100644 index 000000000..7553ee0bd --- /dev/null +++ b/src/Artemis.UI/DefaultTypes/DataModel/Input/SKColorDataModelInputView.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Artemis.UI/DefaultTypes/DataModel/Input/SKColorDataModelInputViewModel.cs b/src/Artemis.UI/DefaultTypes/DataModel/Input/SKColorDataModelInputViewModel.cs new file mode 100644 index 000000000..02c1beb5f --- /dev/null +++ b/src/Artemis.UI/DefaultTypes/DataModel/Input/SKColorDataModelInputViewModel.cs @@ -0,0 +1,13 @@ +using Artemis.Core.DataModelExpansions; +using Artemis.UI.Shared; +using SkiaSharp; + +namespace Artemis.UI.DefaultTypes.DataModel.Input +{ + public class SKColorDataModelInputViewModel : DataModelInputViewModel + { + public SKColorDataModelInputViewModel(DataModelPropertyAttribute targetDescription, SKColor initialValue) : base(targetDescription, initialValue) + { + } + } +} \ No newline at end of file diff --git a/src/Artemis.UI/DataModelVisualization/Input/StringDataModelInputView.xaml b/src/Artemis.UI/DefaultTypes/DataModel/Input/StringDataModelInputView.xaml similarity index 93% rename from src/Artemis.UI/DataModelVisualization/Input/StringDataModelInputView.xaml rename to src/Artemis.UI/DefaultTypes/DataModel/Input/StringDataModelInputView.xaml index 834776844..c93e9fbd1 100644 --- a/src/Artemis.UI/DataModelVisualization/Input/StringDataModelInputView.xaml +++ b/src/Artemis.UI/DefaultTypes/DataModel/Input/StringDataModelInputView.xaml @@ -1,4 +1,4 @@ - { diff --git a/src/Artemis.UI/PropertyInput/BrushPropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputView.xaml similarity index 100% rename from src/Artemis.UI/PropertyInput/BrushPropertyInputView.xaml rename to src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputView.xaml diff --git a/src/Artemis.UI/PropertyInput/BrushPropertyInputViewModel.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputViewModel.cs similarity index 100% rename from src/Artemis.UI/PropertyInput/BrushPropertyInputViewModel.cs rename to src/Artemis.UI/DefaultTypes/PropertyInput/BrushPropertyInputViewModel.cs diff --git a/src/Artemis.UI/PropertyInput/ColorGradientPropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputView.xaml similarity index 100% rename from src/Artemis.UI/PropertyInput/ColorGradientPropertyInputView.xaml rename to src/Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputView.xaml diff --git a/src/Artemis.UI/PropertyInput/ColorGradientPropertyInputViewModel.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputViewModel.cs similarity index 100% rename from src/Artemis.UI/PropertyInput/ColorGradientPropertyInputViewModel.cs rename to src/Artemis.UI/DefaultTypes/PropertyInput/ColorGradientPropertyInputViewModel.cs diff --git a/src/Artemis.UI/PropertyInput/EnumPropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/EnumPropertyInputView.xaml similarity index 100% rename from src/Artemis.UI/PropertyInput/EnumPropertyInputView.xaml rename to src/Artemis.UI/DefaultTypes/PropertyInput/EnumPropertyInputView.xaml diff --git a/src/Artemis.UI/PropertyInput/EnumPropertyInputViewModel.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/EnumPropertyInputViewModel.cs similarity index 100% rename from src/Artemis.UI/PropertyInput/EnumPropertyInputViewModel.cs rename to src/Artemis.UI/DefaultTypes/PropertyInput/EnumPropertyInputViewModel.cs diff --git a/src/Artemis.UI/PropertyInput/FloatPropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputView.xaml similarity index 100% rename from src/Artemis.UI/PropertyInput/FloatPropertyInputView.xaml rename to src/Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputView.xaml diff --git a/src/Artemis.UI/PropertyInput/FloatPropertyInputViewModel.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputViewModel.cs similarity index 100% rename from src/Artemis.UI/PropertyInput/FloatPropertyInputViewModel.cs rename to src/Artemis.UI/DefaultTypes/PropertyInput/FloatPropertyInputViewModel.cs diff --git a/src/Artemis.UI/PropertyInput/IntPropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputView.xaml similarity index 100% rename from src/Artemis.UI/PropertyInput/IntPropertyInputView.xaml rename to src/Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputView.xaml diff --git a/src/Artemis.UI/PropertyInput/IntPropertyInputViewModel.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputViewModel.cs similarity index 100% rename from src/Artemis.UI/PropertyInput/IntPropertyInputViewModel.cs rename to src/Artemis.UI/DefaultTypes/PropertyInput/IntPropertyInputViewModel.cs diff --git a/src/Artemis.UI/PropertyInput/SKColorPropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/SKColorPropertyInputView.xaml similarity index 100% rename from src/Artemis.UI/PropertyInput/SKColorPropertyInputView.xaml rename to src/Artemis.UI/DefaultTypes/PropertyInput/SKColorPropertyInputView.xaml diff --git a/src/Artemis.UI/PropertyInput/SKColorPropertyInputViewModel.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/SKColorPropertyInputViewModel.cs similarity index 100% rename from src/Artemis.UI/PropertyInput/SKColorPropertyInputViewModel.cs rename to src/Artemis.UI/DefaultTypes/PropertyInput/SKColorPropertyInputViewModel.cs diff --git a/src/Artemis.UI/PropertyInput/SKPointPropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputView.xaml similarity index 100% rename from src/Artemis.UI/PropertyInput/SKPointPropertyInputView.xaml rename to src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputView.xaml diff --git a/src/Artemis.UI/PropertyInput/SKPointPropertyInputViewModel.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputViewModel.cs similarity index 100% rename from src/Artemis.UI/PropertyInput/SKPointPropertyInputViewModel.cs rename to src/Artemis.UI/DefaultTypes/PropertyInput/SKPointPropertyInputViewModel.cs diff --git a/src/Artemis.UI/PropertyInput/SKSizePropertyInputView.xaml b/src/Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputView.xaml similarity index 100% rename from src/Artemis.UI/PropertyInput/SKSizePropertyInputView.xaml rename to src/Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputView.xaml diff --git a/src/Artemis.UI/PropertyInput/SKSizePropertyInputViewModel.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputViewModel.cs similarity index 100% rename from src/Artemis.UI/PropertyInput/SKSizePropertyInputViewModel.cs rename to src/Artemis.UI/DefaultTypes/PropertyInput/SKSizePropertyInputViewModel.cs diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingView.xaml b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingView.xaml index fc0637bbf..86c5d3f85 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingView.xaml +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingView.xaml @@ -105,10 +105,22 @@ Input - + Output - + diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs index 34c1c4c3a..beccd44bd 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs @@ -13,6 +13,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings { private readonly IDataBindingsVmFactory _dataBindingsVmFactory; private readonly IProfileEditorService _profileEditorService; + private readonly IDataModelUIService _dataModelUIService; private DataBinding _dataBinding; private int _easingTime; private bool _isEasingTimeEnabled; @@ -26,10 +27,12 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings public DataBindingViewModel(DataBindingRegistration registration, IProfileEditorService profileEditorService, + IDataModelUIService dataModelUIService, IDataBindingsVmFactory dataBindingsVmFactory) { Registration = registration; _profileEditorService = profileEditorService; + _dataModelUIService = dataModelUIService; _dataBindingsVmFactory = dataBindingsVmFactory; if (Registration.Member != null) @@ -39,6 +42,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings DataBindingModes = new BindableCollection(EnumUtilities.GetAllValuesAndDescriptions(typeof(DataBindingModeType))); EasingViewModels = new BindableCollection(); + TestInputValue = _dataModelUIService.GetDataModelDisplayViewModel(typeof(TProperty), true); + TestResultValue = _dataModelUIService.GetDataModelDisplayViewModel(typeof(TProperty), true); DataBinding = Registration.DataBinding; @@ -49,6 +54,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings public BindableCollection DataBindingModes { get; } public BindableCollection EasingViewModels { get; } + public DataModelDisplayViewModel TestInputValue { get; } + public DataModelDisplayViewModel TestResultValue { get; } public DataBindingModeType SelectedDataBindingMode { @@ -102,18 +109,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings set => SetAndNotify(ref _dataBinding, value); } - public TProperty TestInputValue - { - get => _testInputValue; - set => SetAndNotify(ref _testInputValue, value); - } - - public TProperty TestResultValue - { - get => _testResultValue; - set => SetAndNotify(ref _testResultValue, value); - } - public void Dispose() { _profileEditorService.ProfilePreviewUpdated -= ProfileEditorServiceOnProfilePreviewUpdated; @@ -222,18 +217,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings { if (DataBinding == null) { - TestInputValue = default; - TestResultValue = default; + TestInputValue.UpdateValue(default); + TestResultValue.UpdateValue(default); return; } - var currentValue = ActiveItem?.GetTestValue() ?? default(TProperty); + var currentValue = Registration.Converter.ConvertFromObject(ActiveItem?.GetTestValue() ?? default(TProperty)); - TestInputValue = Registration.Converter.ConvertFromObject(currentValue); - if (DataBinding != null) - TestResultValue = DataBinding.GetValue(TestInputValue); - else - TestInputValue = default; + TestInputValue.UpdateValue(currentValue); + TestResultValue.UpdateValue(DataBinding != null ? DataBinding.GetValue(currentValue) : default); } private void EnableDataBinding() diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DataBindingModifierViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DataBindingModifierViewModel.cs index 73e129427..c66ca6730 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DataBindingModifierViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DataBindingModifierViewModel.cs @@ -79,11 +79,13 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa private void ParameterSelectionViewModelOnPropertySelected(object sender, DataModelInputDynamicEventArgs e) { Modifier.UpdateParameter(e.DataModelVisualizationViewModel.DataModel, e.DataModelVisualizationViewModel.PropertyPath); + _profileEditorService.UpdateSelectedProfileElement(); } private void StaticInputViewModelOnValueUpdated(object sender, DataModelInputStaticEventArgs e) { Modifier.UpdateParameter(e.Value); + _profileEditorService.UpdateSelectedProfileElement(); } private void Update() @@ -155,6 +157,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa DynamicSelectionViewModel.Dispose(); DynamicSelectionViewModel.PropertySelected -= ParameterSelectionViewModelOnPropertySelected; } + + if (StaticInputViewModel != null) + { + StaticInputViewModel.Dispose(); + } } } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugView.xaml b/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugView.xaml index 6bce31a96..f69d9e7bf 100644 --- a/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugView.xaml +++ b/src/Artemis.UI/Screens/Settings/Debug/Tabs/DataModelDebugView.xaml @@ -97,21 +97,7 @@ - - - + diff --git a/src/Artemis.UI/Services/RegistrationService.cs b/src/Artemis.UI/Services/RegistrationService.cs index 1b036c4df..7261cf312 100644 --- a/src/Artemis.UI/Services/RegistrationService.cs +++ b/src/Artemis.UI/Services/RegistrationService.cs @@ -1,6 +1,6 @@ using Artemis.Core; -using Artemis.UI.DataModelVisualization.Display; -using Artemis.UI.DataModelVisualization.Input; +using Artemis.UI.DefaultTypes.DataModel.Display; +using Artemis.UI.DefaultTypes.DataModel.Input; using Artemis.UI.PropertyInput; using Artemis.UI.Services.Interfaces; using Artemis.UI.Shared.Services; @@ -36,9 +36,10 @@ namespace Artemis.UI.Services if (_registeredBuiltInDataModelInputs) return; - _dataModelUIService.RegisterDataModelInput(Constants.CorePluginInfo, null); - _dataModelUIService.RegisterDataModelInput(Constants.CorePluginInfo, Constants.IntegralNumberTypes); _dataModelUIService.RegisterDataModelInput(Constants.CorePluginInfo, Constants.FloatNumberTypes); + _dataModelUIService.RegisterDataModelInput(Constants.CorePluginInfo, Constants.IntegralNumberTypes); + _dataModelUIService.RegisterDataModelInput(Constants.CorePluginInfo, null); + _dataModelUIService.RegisterDataModelInput(Constants.CorePluginInfo, null); _registeredBuiltInDataModelInputs = true; } diff --git a/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs b/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs index 773256d97..2c2db08cf 100644 --- a/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs +++ b/src/Plugins/Artemis.Plugins.Modules.General/GeneralModule.cs @@ -18,6 +18,7 @@ namespace Artemis.Plugins.Modules.General DisplayName = "General"; DisplayIcon = "AllInclusive"; ExpandsDataModel = true; + ModuleTabs = new List {new ModuleTab("General")}; }