Profile editor - Changed data binding behaviour in profile editor

This commit is contained in:
SpoinkyNL committed 2020-12-18 00:04:37 +01:00
1 parent 15759c9289
commit c885ae225c
4 files changed
+34 -52

No files matched your search

@@ -84,27 +84,20 @@
<materialDesign:Card Grid.Row="3" Grid.ColumnSpan="2" Margin="0 5 0 0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Margin="10 10 4 0">
Test result
<TextBlock Grid.Row="0" Margin="10 10 0 0">
Data binding result
</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="1" Margin="0 10 10 0" TextAlignment="Right" ToolTip="Click Play to ensure all other data bindings update as well." Cursor="Help">
Other data bindings not updating?
</TextBlock>
<CheckBox Grid.Row="0"
Grid.Column="1"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Margin="0 6 10 0"
Style="{StaticResource MaterialDesignCheckBox}"
ToolTip="Apply the test value to the layer"
IsChecked="{Binding ApplyTestResultToLayer}">
Preview on layer
</CheckBox>
<Separator Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource MaterialDesignLightSeparator}" Margin="0" />
<Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="10 4 10 10">
<Grid.ColumnDefinitions>
@@ -15,7 +15,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
private readonly IDataBindingsVmFactory _dataBindingsVmFactory;
private readonly IProfileEditorService _profileEditorService;
private readonly Timer _updateTimer;
private bool _applyTestResultToLayer;
private int _easingTime;
private bool _isDataBindingEnabled;
private bool _isEasingTimeEnabled;
@@ -68,17 +67,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
get => _isDataBindingEnabled;
set => SetAndNotify(ref _isDataBindingEnabled, value);
}
public bool ApplyTestResultToLayer
{
get => _applyTestResultToLayer;
set
{
if (!SetAndNotify(ref _applyTestResultToLayer, value)) return;
_profileEditorService.UpdateProfilePreview();
}
}
public TimelineEasingViewModel SelectedEasingViewModel
{
get => _selectedEasingViewModel;
@@ -121,7 +110,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
_updateTimer.Start();
_updateTimer.Elapsed += OnUpdateTimerOnElapsed;
Registration.LayerProperty.Updated += LayerPropertyOnUpdated;
CreateDataBindingModeModeViewModel();
Update();
@@ -239,15 +227,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
{
TestResultValue.UpdateValue(Registration.DataBinding != null ? Registration.DataBinding.GetValue(default) : default);
}
if (ApplyTestResultToLayer)
{
// TODO: A bit crappy, the ProfileEditorService should really be doing this
bool playing = ((Parent as Screen)?.Parent as LayerPropertiesViewModel)?.Playing ?? true;
if (!playing)
_profileEditorService.UpdateProfilePreview();
}
_profileEditorService.UpdateProfilePreview();
_updatingTestResult = false;
}
@@ -276,12 +257,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
UpdateTestResult();
}
private void LayerPropertyOnUpdated(object sender, LayerPropertyEventArgs<TLayerProperty> e)
{
if (ApplyTestResultToLayer)
Registration.DataBinding?.Apply();
}
#region IDisposable
/// <inheritdoc />
@@ -289,8 +264,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
{
_updateTimer.Dispose();
_updateTimer.Elapsed -= OnUpdateTimerOnElapsed;
Registration.LayerProperty.Updated -= LayerPropertyOnUpdated;
}
#endregion