diff --git a/src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs b/src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs
index 4bfbacc48..6b560ee52 100644
--- a/src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs
+++ b/src/Artemis.Core/Models/Profile/DataBindings/DataBinding.cs
@@ -63,7 +63,10 @@ namespace Artemis.Core
///
public Easings.Functions EasingFunction { get; set; }
- internal DataBindingEntity Entity { get; }
+ ///
+ /// Gets the data binding entity this data binding uses for persistent storage
+ ///
+ public DataBindingEntity Entity { get; }
///
/// Gets the current value of the data binding
@@ -100,6 +103,25 @@ namespace Artemis.Core
return Registration?.Getter.Method.ReturnType;
}
+ ///
+ /// Releases the unmanaged resources used by the object and optionally releases the managed resources.
+ ///
+ ///
+ /// to release both managed and unmanaged resources;
+ /// to release only unmanaged resources.
+ ///
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ _disposed = true;
+
+ if (Registration != null)
+ Registration.DataBinding = null;
+ DataBindingMode?.Dispose();
+ }
+ }
+
private void ResetEasing(TProperty value)
{
_previousValue = GetInterpolatedValue();
@@ -192,27 +214,6 @@ namespace Artemis.Core
_reapplyValue = true;
}
- #region IDisposable
-
- ///
- /// Releases the unmanaged resources used by the object and optionally releases the managed resources.
- ///
- ///
- /// to release both managed and unmanaged resources;
- /// to release only unmanaged resources.
- ///
- protected virtual void Dispose(bool disposing)
- {
- if (disposing)
- {
- _disposed = true;
-
- if (Registration != null)
- Registration.DataBinding = null;
- DataBindingMode?.Dispose();
- }
- }
-
///
public void Dispose()
{
@@ -220,8 +221,6 @@ namespace Artemis.Core
GC.SuppressFinalize(this);
}
- #endregion
-
#region Mode management
///
@@ -245,6 +244,16 @@ namespace Artemis.Core
ApplyDataBindingMode();
}
+ ///
+ /// Replaces the current data binding mode with one based on the provided data binding mode entity
+ ///
+ /// The data binding mode entity to base the new data binding mode upon
+ public void ApplyDataBindingEntity(IDataBindingModeEntity dataBindingModeEntity)
+ {
+ Entity.DataBindingMode = dataBindingModeEntity;
+ ApplyDataBindingMode();
+ }
+
private void ApplyDataBindingMode()
{
DataBindingMode?.Dispose();
diff --git a/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionGroupViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionGroupViewModel.cs
index 437fe3252..de5822a2c 100644
--- a/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionGroupViewModel.cs
+++ b/src/Artemis.UI/Screens/ProfileEditor/Conditions/DataModelConditionGroupViewModel.cs
@@ -1,6 +1,6 @@
using System;
+using System.Collections.Generic;
using System.Linq;
-using System.Threading.Tasks;
using Artemis.Core;
using Artemis.UI.Extensions;
using Artemis.UI.Ninject.Factories;
@@ -16,7 +16,6 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
private readonly IDataModelConditionsVmFactory _dataModelConditionsVmFactory;
private readonly IProfileEditorService _profileEditorService;
private bool _isEventGroup;
- private bool _isInitialized;
private bool _isRootGroup;
public DataModelConditionGroupViewModel(DataModelConditionGroup dataModelConditionGroup,
@@ -30,12 +29,6 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
_dataModelConditionsVmFactory = dataModelConditionsVmFactory;
Items.CollectionChanged += (_, _) => NotifyOfPropertyChange(nameof(DisplayBooleanOperator));
-
- Execute.PostToUIThread(async () =>
- {
- await Task.Delay(50);
- IsInitialized = true;
- });
}
public ConditionGroupType GroupType { get; }
@@ -63,12 +56,6 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
}
}
- public bool IsInitialized
- {
- get => _isInitialized;
- set => SetAndNotify(ref _isInitialized, value);
- }
-
public bool DisplayBooleanOperator => Items.Count > 1;
public bool DisplayEvaluationResult => GroupType == ConditionGroupType.General && !IsEventGroup;
public string SelectedBooleanOperator => DataModelConditionGroup.BooleanOperator.Humanize();
@@ -132,7 +119,9 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
{
NotifyOfPropertyChange(nameof(SelectedBooleanOperator));
// Remove VMs of effects no longer applied on the layer
- Items.RemoveRange(Items.Where(c => !DataModelConditionGroup.Children.Contains(c.Model)).ToList());
+ List toRemove = Items.Where(c => !DataModelConditionGroup.Children.Contains(c.Model)).ToList();
+ if (toRemove.Any())
+ Items.RemoveRange(toRemove);
foreach (DataModelConditionPart childModel in Model.Children)
{
@@ -169,8 +158,10 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
IsEventGroup = Items.Any(i => i is DataModelConditionEventViewModel);
if (IsEventGroup)
+ {
if (DataModelConditionGroup.BooleanOperator != BooleanOperator.And)
SelectBooleanOperator("And");
+ }
OnUpdated();
}
diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/DataBindingConditionView.xaml b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/DataBindingConditionView.xaml
index f3e1833c6..42e982f8d 100644
--- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/DataBindingConditionView.xaml
+++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/ConditionalDataBinding/DataBindingConditionView.xaml
@@ -6,22 +6,25 @@
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
+
\ No newline at end of file
diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingView.xaml b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingView.xaml
index 327b7ede9..b65593a90 100644
--- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingView.xaml
+++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingView.xaml
@@ -17,7 +17,7 @@
-
+
@@ -33,6 +33,7 @@
+
- Data binding result
+ Result
- Other data bindings not updating?
+ Other bindings not updating?
@@ -134,12 +135,39 @@
+
+
+
+
+
+
+
+
+
-
diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs
index b25710928..593c7144d 100644
--- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs
+++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DataBindingViewModel.cs
@@ -3,6 +3,8 @@ using System.Linq;
using System.Timers;
using Artemis.Core;
using Artemis.Core.Services;
+using Artemis.Storage.Entities.Profile.DataBindings;
+using Artemis.UI.Exceptions;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline;
using Artemis.UI.Shared;
@@ -186,16 +188,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
return;
if (Registration.DataBinding != null && SelectedDataBindingMode == DataBindingModeType.None)
- {
RemoveDataBinding();
- CreateDataBindingModeModeViewModel();
- return;
+ else
+ {
+ if (Registration.DataBinding == null && SelectedDataBindingMode != DataBindingModeType.None)
+ EnableDataBinding();
+
+ Registration.DataBinding!.ChangeDataBindingMode(SelectedDataBindingMode);
}
- if (Registration.DataBinding == null && SelectedDataBindingMode != DataBindingModeType.None)
- EnableDataBinding();
-
- Registration.DataBinding.ChangeDataBindingMode(SelectedDataBindingMode);
CreateDataBindingModeModeViewModel();
_profileEditorService.UpdateSelectedProfileElement();
}
@@ -256,6 +257,33 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
_profileEditorService.UpdateSelectedProfileElement();
}
+ public void CopyDataBinding()
+ {
+ if (Registration.DataBinding != null)
+ JsonClipboard.SetObject(Registration.DataBinding.Entity);
+ }
+
+ public void PasteDataBinding()
+ {
+ if (Registration.DataBinding == null)
+ Registration.LayerProperty.EnableDataBinding(Registration);
+ if (Registration.DataBinding == null)
+ throw new ArtemisUIException("Failed to create a data binding in order to paste");
+
+ DataBindingEntity dataBindingEntity = JsonClipboard.GetData();
+ if (dataBindingEntity == null)
+ return;
+
+ Registration.DataBinding.EasingTime = dataBindingEntity.EasingTime;
+ Registration.DataBinding.EasingFunction = (Easings.Functions) dataBindingEntity.EasingFunction;
+ Registration.DataBinding.ApplyDataBindingEntity(dataBindingEntity.DataBindingMode);
+ CreateDataBindingModeModeViewModel();
+ Update();
+
+
+ _profileEditorService.UpdateSelectedProfileElement();
+ }
+
private void OnFrameRendered(object sender, FrameRenderedEventArgs e)
{
UpdateTestResult();
diff --git a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DirectDataBindingModeView.xaml b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DirectDataBindingModeView.xaml
index f92bcd319..d33ce960e 100644
--- a/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DirectDataBindingModeView.xaml
+++ b/src/Artemis.UI/Screens/ProfileEditor/LayerProperties/DataBindings/DirectDataBinding/DirectDataBindingModeView.xaml
@@ -8,7 +8,7 @@
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
-
+
@@ -32,11 +32,7 @@
Padding="6 4"
Height="22"
Command="{s:Action AddModifier}">
-
-
- ADD MODIFIER
-
-
+ ADD MODIFIER
+ IsEnabled="{Binding SelectedProfileElement, Converter={StaticResource NullToBooleanConverter}}"
+ Visibility="{Binding TimelineVisible, Converter={x:Static s:BoolToVisibilityConverter.Instance}}">