mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Shared UI - Resolved all remaining warnings
UI - Resolved all remaining warnings Layer properties - Fixed DisableKeyframes layer property attribute not being applied
This commit is contained in:
1 parent
931b43aa66
commit
8d901027ee
75 files changed
+810
-562
No files matched your search
+3
-2
@@ -10,7 +10,7 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.ConditionalDataBinding
|
||||
{
|
||||
public class ConditionalDataBindingModeViewModel<TLayerProperty, TProperty> : Conductor<DataBindingConditionViewModel<TLayerProperty, TProperty>>.Collection.AllActive, IDataBindingModeViewModel
|
||||
public sealed class ConditionalDataBindingModeViewModel<TLayerProperty, TProperty> : Conductor<DataBindingConditionViewModel<TLayerProperty, TProperty>>.Collection.AllActive, IDataBindingModeViewModel
|
||||
{
|
||||
private readonly IDataBindingsVmFactory _dataBindingsVmFactory;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
@@ -109,7 +109,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
ConditionalDataBinding.ConditionsUpdated -= ConditionalDataBindingOnConditionsUpdated;
|
||||
|
||||
+12
-7
@@ -10,11 +10,11 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.ConditionalDataBinding
|
||||
{
|
||||
public class DataBindingConditionViewModel<TLayerProperty, TProperty> : Conductor<DataModelConditionGroupViewModel>, IDisposable
|
||||
public sealed class DataBindingConditionViewModel<TLayerProperty, TProperty> : Conductor<DataModelConditionGroupViewModel>, IDisposable
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly IDataModelConditionsVmFactory _dataModelConditionsVmFactory;
|
||||
private readonly IDataModelUIService _dataModelUIService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
|
||||
public DataBindingConditionViewModel(DataBindingCondition<TLayerProperty, TProperty> dataBindingCondition,
|
||||
IProfileEditorService profileEditorService,
|
||||
@@ -44,11 +44,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio
|
||||
ValueViewModel.Value = DataBindingCondition.Value;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
ValueViewModel.Dispose();
|
||||
}
|
||||
|
||||
private void ActiveItemOnUpdated(object sender, EventArgs e)
|
||||
{
|
||||
if (!ActiveItem.GetChildren().Any())
|
||||
@@ -60,5 +55,15 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio
|
||||
DataBindingCondition.Value = (TProperty) Convert.ChangeType(e.Value, typeof(TProperty));
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
ValueViewModel?.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+27
-26
@@ -10,17 +10,17 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
{
|
||||
public class DataBindingViewModel<TLayerProperty, TProperty> : Conductor<IDataBindingModeViewModel>, IDataBindingViewModel
|
||||
public sealed class DataBindingViewModel<TLayerProperty, TProperty> : Conductor<IDataBindingModeViewModel>, IDataBindingViewModel
|
||||
{
|
||||
private readonly IDataBindingsVmFactory _dataBindingsVmFactory;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private readonly Timer _updateTimer;
|
||||
private bool _applyTestResultToLayer;
|
||||
private int _easingTime;
|
||||
private bool _isDataBindingEnabled;
|
||||
private bool _isEasingTimeEnabled;
|
||||
private DataBindingModeType _selectedDataBindingMode;
|
||||
private TimelineEasingViewModel _selectedEasingViewModel;
|
||||
private bool _applyTestResultToLayer;
|
||||
|
||||
private bool _updating;
|
||||
private bool _updatingTestResult;
|
||||
@@ -46,12 +46,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
TestResultValue = dataModelUIService.GetDataModelDisplayViewModel(typeof(TProperty), null, true);
|
||||
}
|
||||
|
||||
protected override void OnInitialActivate()
|
||||
{
|
||||
base.OnInitialActivate();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public DataBindingRegistration<TLayerProperty, TProperty> Registration { get; }
|
||||
|
||||
public BindableCollection<ValueDescription> DataBindingModes { get; }
|
||||
@@ -115,12 +109,10 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
protected override void OnInitialActivate()
|
||||
{
|
||||
_updateTimer.Dispose();
|
||||
_updateTimer.Elapsed -= OnUpdateTimerOnElapsed;
|
||||
|
||||
Registration.LayerProperty.Updated -= LayerPropertyOnUpdated;
|
||||
base.OnInitialActivate();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
@@ -171,18 +163,12 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
EasingTime = (int) Registration.DataBinding.EasingTime.TotalMilliseconds;
|
||||
SelectedEasingViewModel = EasingViewModels.First(vm => vm.EasingFunction == Registration.DataBinding.EasingFunction);
|
||||
IsEasingTimeEnabled = EasingTime > 0;
|
||||
switch (Registration.DataBinding.DataBindingMode)
|
||||
SelectedDataBindingMode = Registration.DataBinding.DataBindingMode switch
|
||||
{
|
||||
case DirectDataBinding<TLayerProperty, TProperty> _:
|
||||
SelectedDataBindingMode = DataBindingModeType.Direct;
|
||||
break;
|
||||
case ConditionalDataBinding<TLayerProperty, TProperty> _:
|
||||
SelectedDataBindingMode = DataBindingModeType.Conditional;
|
||||
break;
|
||||
default:
|
||||
SelectedDataBindingMode = DataBindingModeType.None;
|
||||
break;
|
||||
}
|
||||
DirectDataBinding<TLayerProperty, TProperty> _ => DataBindingModeType.Direct,
|
||||
ConditionalDataBinding<TLayerProperty, TProperty> _ => DataBindingModeType.Conditional,
|
||||
_ => DataBindingModeType.None
|
||||
};
|
||||
|
||||
ActiveItem?.Update();
|
||||
|
||||
@@ -250,7 +236,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
TestResultValue.UpdateValue(Registration.DataBinding != null ? Registration.DataBinding.GetValue(currentValue) : default);
|
||||
}
|
||||
else
|
||||
{
|
||||
TestResultValue.UpdateValue(Registration.DataBinding != null ? Registration.DataBinding.GetValue(default) : default);
|
||||
}
|
||||
|
||||
if (ApplyTestResultToLayer)
|
||||
{
|
||||
@@ -288,11 +276,24 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
UpdateTestResult();
|
||||
}
|
||||
|
||||
private void LayerPropertyOnUpdated(object? sender, LayerPropertyEventArgs<TLayerProperty> e)
|
||||
private void LayerPropertyOnUpdated(object sender, LayerPropertyEventArgs<TLayerProperty> e)
|
||||
{
|
||||
if (ApplyTestResultToLayer)
|
||||
if (ApplyTestResultToLayer)
|
||||
Registration.DataBinding?.Apply();
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
_updateTimer.Dispose();
|
||||
_updateTimer.Elapsed -= OnUpdateTimerOnElapsed;
|
||||
|
||||
Registration.LayerProperty.Updated -= LayerPropertyOnUpdated;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public interface IDataBindingViewModel : IScreen, IDisposable
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings
|
||||
SelectedItemIndex = 0;
|
||||
}
|
||||
|
||||
private void ProfileEditorServiceOnSelectedDataBindingChanged(object? sender, EventArgs e)
|
||||
private void ProfileEditorServiceOnSelectedDataBindingChanged(object sender, EventArgs e)
|
||||
{
|
||||
CreateDataBindingViewModels();
|
||||
}
|
||||
|
||||
+4
-3
@@ -12,7 +12,7 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDataBinding
|
||||
{
|
||||
public class DataBindingModifierViewModel<TLayerProperty, TProperty> : PropertyChangedBase, IDisposable
|
||||
public sealed class DataBindingModifierViewModel<TLayerProperty, TProperty> : PropertyChangedBase, IDisposable
|
||||
{
|
||||
private readonly IDataBindingService _dataBindingService;
|
||||
private readonly IDataModelUIService _dataModelUIService;
|
||||
@@ -161,6 +161,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
DisposeDynamicSelectionViewModel();
|
||||
@@ -193,13 +194,13 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
||||
|
||||
#region Event handlers
|
||||
|
||||
private void DynamicSelectionViewModelOnSwitchToStaticRequested(object? sender, EventArgs e)
|
||||
private void DynamicSelectionViewModelOnSwitchToStaticRequested(object sender, EventArgs e)
|
||||
{
|
||||
Modifier.ParameterType = ProfileRightSideType.Static;
|
||||
Update();
|
||||
}
|
||||
|
||||
private void StaticInputViewModelOnSwitchToDynamicRequested(object? sender, EventArgs e)
|
||||
private void StaticInputViewModelOnSwitchToDynamicRequested(object sender, EventArgs e)
|
||||
{
|
||||
Modifier.ParameterType = ProfileRightSideType.Dynamic;
|
||||
Update();
|
||||
|
||||
+2
-1
@@ -12,7 +12,7 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDataBinding
|
||||
{
|
||||
public class DirectDataBindingModeViewModel<TLayerProperty, TProperty> : Screen, IDataBindingModeViewModel
|
||||
public sealed class DirectDataBindingModeViewModel<TLayerProperty, TProperty> : Screen, IDataBindingModeViewModel
|
||||
{
|
||||
private readonly IDataBindingsVmFactory _dataBindingsVmFactory;
|
||||
private readonly IDataModelUIService _dataModelUIService;
|
||||
@@ -70,6 +70,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.DirectDa
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
TargetSelectionViewModel.PropertySelected -= TargetSelectionViewModelOnPropertySelected;
|
||||
|
||||
@@ -9,7 +9,7 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
{
|
||||
public class LayerPropertyGroupViewModel : PropertyChangedBase, IDisposable
|
||||
public sealed class LayerPropertyGroupViewModel : PropertyChangedBase, IDisposable
|
||||
{
|
||||
private readonly ILayerPropertyVmFactory _layerPropertyVmFactory;
|
||||
private bool _isVisible;
|
||||
@@ -40,9 +40,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
get => _isVisible;
|
||||
set => SetAndNotify(ref _isVisible, value);
|
||||
}
|
||||
|
||||
public bool IsHighlighted => false;
|
||||
|
||||
|
||||
public bool IsExpanded
|
||||
{
|
||||
get => LayerPropertyGroup.ProfileElement.IsPropertyGroupExpanded(LayerPropertyGroup);
|
||||
@@ -53,6 +51,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
TimelineGroupViewModel.Dispose();
|
||||
@@ -64,6 +65,8 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void UpdateOrder(int order)
|
||||
{
|
||||
LayerPropertyGroup.LayerEffect.Order = order;
|
||||
@@ -93,7 +96,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
/// </summary>
|
||||
/// <param name="start">The position at which to start removing keyframes, if null this will start at the first keyframe</param>
|
||||
/// <param name="end">The position at which to start removing keyframes, if null this will end at the last keyframe</param>
|
||||
public virtual void WipeKeyframes(TimeSpan? start, TimeSpan? end)
|
||||
public void WipeKeyframes(TimeSpan? start, TimeSpan? end)
|
||||
{
|
||||
foreach (PropertyChangedBase child in Children)
|
||||
{
|
||||
@@ -139,7 +142,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
{
|
||||
PropertyDescriptionAttribute propertyAttribute = (PropertyDescriptionAttribute) Attribute.GetCustomAttribute(propertyInfo, typeof(PropertyDescriptionAttribute));
|
||||
PropertyGroupDescriptionAttribute groupAttribute = (PropertyGroupDescriptionAttribute) Attribute.GetCustomAttribute(propertyInfo, typeof(PropertyGroupDescriptionAttribute));
|
||||
object? value = propertyInfo.GetValue(LayerPropertyGroup);
|
||||
object value = propertyInfo.GetValue(LayerPropertyGroup);
|
||||
|
||||
// Create VMs for properties on the group
|
||||
if (propertyAttribute != null && value is ILayerProperty layerProperty)
|
||||
|
||||
@@ -7,7 +7,7 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
|
||||
{
|
||||
public class LayerPropertyViewModel : PropertyChangedBase, IDisposable
|
||||
public sealed class LayerPropertyViewModel : PropertyChangedBase, IDisposable
|
||||
{
|
||||
private bool _isVisible;
|
||||
private bool _isHighlighted;
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
{
|
||||
public class TimelineGroupViewModel : PropertyChangedBase, IDisposable
|
||||
public sealed class TimelineGroupViewModel : PropertyChangedBase, IDisposable
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
|
||||
|
||||
+2
-3
@@ -7,11 +7,10 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
{
|
||||
public class TimelineKeyframeViewModel<T> : Screen, ITimelineKeyframeViewModel
|
||||
public sealed class TimelineKeyframeViewModel<T> : Screen, ITimelineKeyframeViewModel
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
|
||||
private BindableCollection<TimelineEasingViewModel> _easingViewModels;
|
||||
private bool _isSelected;
|
||||
private string _timestamp;
|
||||
private double _x;
|
||||
@@ -65,7 +64,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
Timestamp = $"{Math.Floor(LayerPropertyKeyframe.Position.TotalSeconds):00}.{LayerPropertyKeyframe.Position.Milliseconds:000}";
|
||||
}
|
||||
|
||||
private void ProfileEditorServiceOnPixelsPerSecondChanged(object? sender, EventArgs e)
|
||||
private void ProfileEditorServiceOnPixelsPerSecondChanged(object sender, EventArgs e)
|
||||
{
|
||||
Update();
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
{
|
||||
public class TimelinePropertyViewModel<T> : Conductor<TimelineKeyframeViewModel<T>>.Collection.AllActive, ITimelinePropertyViewModel
|
||||
public sealed class TimelinePropertyViewModel<T> : Conductor<TimelineKeyframeViewModel<T>>.Collection.AllActive, ITimelinePropertyViewModel
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private double _width;
|
||||
|
||||
+46
-45
@@ -7,7 +7,6 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Screens.ProfileEditor.Dialogs;
|
||||
using Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline.Dialogs;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
@@ -15,19 +14,19 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
{
|
||||
public class TimelineSegmentViewModel : Screen, IDisposable
|
||||
public sealed class TimelineSegmentViewModel : Screen, IDisposable
|
||||
{
|
||||
private readonly IDialogService _dialogService;
|
||||
private bool _draggingSegment;
|
||||
private bool _segmentEnabled;
|
||||
private TimeSpan _segmentEnd;
|
||||
private TimeSpan _segmentLength;
|
||||
private TimeSpan _segmentStart;
|
||||
private double _segmentStartPosition;
|
||||
private double _segmentWidth;
|
||||
private bool _showDisableButton;
|
||||
private bool _showRepeatButton;
|
||||
private bool _showSegmentName;
|
||||
private TimeSpan _segmentLength;
|
||||
private TimeSpan _segmentStart;
|
||||
private TimeSpan _segmentEnd;
|
||||
private double _segmentWidth;
|
||||
private bool _segmentEnabled;
|
||||
private double _segmentStartPosition;
|
||||
|
||||
public TimelineSegmentViewModel(SegmentViewModelType segment, BindableCollection<LayerPropertyGroupViewModel> layerPropertyGroups,
|
||||
IProfileEditorService profileEditorService, IDialogService dialogService)
|
||||
@@ -139,6 +138,40 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
await _dialogService.ShowDialog<TimelineSegmentDialogViewModel>(new Dictionary<string, object> {{"segment", this}});
|
||||
}
|
||||
|
||||
public void ShiftNextSegment(TimeSpan amount)
|
||||
{
|
||||
if (Segment == SegmentViewModelType.Start)
|
||||
ShiftKeyframes(SelectedProfileElement.Timeline.StartSegmentEndPosition, null, amount);
|
||||
else if (Segment == SegmentViewModelType.Main)
|
||||
ShiftKeyframes(SelectedProfileElement.Timeline.MainSegmentEndPosition, null, amount);
|
||||
else if (Segment == SegmentViewModelType.End)
|
||||
ShiftKeyframes(SelectedProfileElement.Timeline.EndSegmentEndPosition, null, amount);
|
||||
}
|
||||
|
||||
private void WipeKeyframes(TimeSpan? start, TimeSpan? end)
|
||||
{
|
||||
foreach (LayerPropertyGroupViewModel layerPropertyGroupViewModel in LayerPropertyGroups)
|
||||
layerPropertyGroupViewModel.WipeKeyframes(start, end);
|
||||
}
|
||||
|
||||
private void ShiftKeyframes(TimeSpan? start, TimeSpan? end, TimeSpan amount)
|
||||
{
|
||||
foreach (LayerPropertyGroupViewModel layerPropertyGroupViewModel in LayerPropertyGroups)
|
||||
layerPropertyGroupViewModel.ShiftKeyframes(start, end, amount);
|
||||
}
|
||||
|
||||
#region IDIsposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
ProfileEditorService.PixelsPerSecondChanged -= ProfileEditorServiceOnPixelsPerSecondChanged;
|
||||
ProfileEditorService.ProfileElementSelected -= ProfileEditorServiceOnProfileElementSelected;
|
||||
if (SelectedProfileElement != null)
|
||||
SelectedProfileElement.Timeline.PropertyChanged -= TimelineOnPropertyChanged;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Updating
|
||||
|
||||
private void UpdateHeader()
|
||||
@@ -283,7 +316,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
}
|
||||
// If holding down control, round to the closest 50ms
|
||||
else if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
|
||||
{
|
||||
newTime = TimeSpan.FromMilliseconds(Math.Round(newTime.TotalMilliseconds / 50.0) * 50.0);
|
||||
}
|
||||
|
||||
UpdateLength(newTime);
|
||||
}
|
||||
@@ -304,7 +339,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
SelectedProfileElement.Timeline.MainSegmentEndPosition = newTime;
|
||||
else if (Segment == SegmentViewModelType.End)
|
||||
SelectedProfileElement.Timeline.EndSegmentEndPosition = newTime;
|
||||
|
||||
|
||||
if (difference < TimeSpan.Zero)
|
||||
ShiftNextSegment(difference);
|
||||
|
||||
@@ -313,21 +348,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDIsposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
ProfileEditorService.PixelsPerSecondChanged -= ProfileEditorServiceOnPixelsPerSecondChanged;
|
||||
ProfileEditorService.ProfileElementSelected -= ProfileEditorServiceOnProfileElementSelected;
|
||||
if (SelectedProfileElement != null)
|
||||
SelectedProfileElement.Timeline.PropertyChanged -= TimelineOnPropertyChanged;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event handlers
|
||||
|
||||
private void ProfileEditorServiceOnProfileElementSelected(object? sender, RenderProfileElementEventArgs e)
|
||||
private void ProfileEditorServiceOnProfileElementSelected(object sender, RenderProfileElementEventArgs e)
|
||||
{
|
||||
if (e.PreviousRenderProfileElement != null)
|
||||
e.PreviousRenderProfileElement.Timeline.PropertyChanged -= TimelineOnPropertyChanged;
|
||||
@@ -347,34 +370,12 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
NotifyOfPropertyChange(nameof(RepeatSegment));
|
||||
}
|
||||
|
||||
private void ProfileEditorServiceOnPixelsPerSecondChanged(object? sender, EventArgs e)
|
||||
private void ProfileEditorServiceOnPixelsPerSecondChanged(object sender, EventArgs e)
|
||||
{
|
||||
Update();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void ShiftNextSegment(TimeSpan amount)
|
||||
{
|
||||
if (Segment == SegmentViewModelType.Start)
|
||||
ShiftKeyframes(SelectedProfileElement.Timeline.StartSegmentEndPosition, null, amount);
|
||||
else if (Segment == SegmentViewModelType.Main)
|
||||
ShiftKeyframes(SelectedProfileElement.Timeline.MainSegmentEndPosition, null, amount);
|
||||
else if (Segment == SegmentViewModelType.End)
|
||||
ShiftKeyframes(SelectedProfileElement.Timeline.EndSegmentEndPosition, null, amount);
|
||||
}
|
||||
|
||||
private void WipeKeyframes(TimeSpan? start, TimeSpan? end)
|
||||
{
|
||||
foreach (LayerPropertyGroupViewModel layerPropertyGroupViewModel in LayerPropertyGroups)
|
||||
layerPropertyGroupViewModel.WipeKeyframes(start, end);
|
||||
}
|
||||
|
||||
private void ShiftKeyframes(TimeSpan? start, TimeSpan? end, TimeSpan amount)
|
||||
{
|
||||
foreach (LayerPropertyGroupViewModel layerPropertyGroupViewModel in LayerPropertyGroups)
|
||||
layerPropertyGroupViewModel.ShiftKeyframes(start, end, amount);
|
||||
}
|
||||
}
|
||||
|
||||
public enum SegmentViewModelType
|
||||
|
||||
+15
-23
@@ -6,14 +6,13 @@ using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
{
|
||||
public class TimelineViewModel : Screen, IDisposable
|
||||
public sealed class TimelineViewModel : Screen, IDisposable
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private RectangleGeometry _selectionRectangle;
|
||||
@@ -88,7 +87,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
Update();
|
||||
}
|
||||
|
||||
private void ProfileEditorServiceOnProfileElementSelected(object? sender, RenderProfileElementEventArgs e)
|
||||
private void ProfileEditorServiceOnProfileElementSelected(object sender, RenderProfileElementEventArgs e)
|
||||
{
|
||||
if (e.PreviousRenderProfileElement != null)
|
||||
e.PreviousRenderProfileElement.Timeline.PropertyChanged -= TimelineOnPropertyChanged;
|
||||
@@ -98,6 +97,18 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
Update();
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_profileEditorService.PixelsPerSecondChanged -= ProfileEditorServiceOnPixelsPerSecondChanged;
|
||||
_profileEditorService.ProfileElementSelected -= ProfileEditorServiceOnProfileElementSelected;
|
||||
if (_profileEditorService.SelectedProfileElement != null)
|
||||
_profileEditorService.SelectedProfileElement.Timeline.PropertyChanged -= TimelineOnPropertyChanged;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Command handlers
|
||||
|
||||
public void KeyframeMouseDown(object sender, MouseButtonEventArgs e)
|
||||
@@ -105,8 +116,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
// if (e.LeftButton == MouseButtonState.Released)
|
||||
// return;
|
||||
|
||||
ITimelineKeyframeViewModel viewModel = (sender as Ellipse)?.DataContext as ITimelineKeyframeViewModel;
|
||||
if (viewModel == null)
|
||||
if (!((sender as Ellipse)?.DataContext is ITimelineKeyframeViewModel viewModel))
|
||||
return;
|
||||
|
||||
((IInputElement) sender).CaptureMouse();
|
||||
@@ -206,7 +216,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
keyframeViewModel.SaveOffsetToKeyframe(sourceKeyframeViewModel);
|
||||
|
||||
if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
|
||||
{
|
||||
cursorTime = _profileEditorService.SnapToTimeline(
|
||||
cursorTime,
|
||||
TimeSpan.FromMilliseconds(1000f / _profileEditorService.PixelsPerSecond * 5),
|
||||
@@ -214,7 +223,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
false,
|
||||
keyframeViewModels.Where(k => k != sourceKeyframeViewModel).Select(k => k.Position).ToList()
|
||||
);
|
||||
}
|
||||
|
||||
sourceKeyframeViewModel.UpdatePosition(cursorTime);
|
||||
|
||||
@@ -306,15 +314,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
|
||||
int clickedIndex = keyframeViewModels.IndexOf(clicked);
|
||||
if (clickedIndex < selectedIndex)
|
||||
{
|
||||
foreach (ITimelineKeyframeViewModel keyframeViewModel in keyframeViewModels.Skip(clickedIndex).Take(selectedIndex - clickedIndex + 1))
|
||||
keyframeViewModel.IsSelected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (ITimelineKeyframeViewModel keyframeViewModel in keyframeViewModels.Skip(selectedIndex).Take(clickedIndex - selectedIndex + 1))
|
||||
keyframeViewModel.IsSelected = true;
|
||||
}
|
||||
}
|
||||
else if (toggle)
|
||||
{
|
||||
@@ -340,17 +344,5 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Timeline
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_profileEditorService.PixelsPerSecondChanged -= ProfileEditorServiceOnPixelsPerSecondChanged;
|
||||
_profileEditorService.ProfileElementSelected -= ProfileEditorServiceOnProfileElementSelected;
|
||||
if (_profileEditorService.SelectedProfileElement != null)
|
||||
_profileEditorService.SelectedProfileElement.Timeline.PropertyChanged -= TimelineOnPropertyChanged;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+40
-42
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using Artemis.Core;
|
||||
using Artemis.UI.Shared;
|
||||
@@ -8,7 +7,7 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
||||
{
|
||||
public class TreePropertyViewModel<T> : Screen, ITreePropertyViewModel
|
||||
public sealed class TreePropertyViewModel<T> : Screen, ITreePropertyViewModel
|
||||
{
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private PropertyInputViewModel<T> _propertyInputViewModel;
|
||||
@@ -26,7 +25,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
||||
LayerProperty.DataBindingDisabled += LayerPropertyOnDataBindingChange;
|
||||
LayerPropertyViewModel.IsVisible = !LayerProperty.IsHidden;
|
||||
}
|
||||
|
||||
|
||||
public LayerProperty<T> LayerProperty { get; }
|
||||
public LayerPropertyViewModel LayerPropertyViewModel { get; }
|
||||
|
||||
@@ -36,22 +35,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
||||
set => SetAndNotify(ref _propertyInputViewModel, value);
|
||||
}
|
||||
|
||||
public bool HasDataBinding => LayerProperty.HasDataBinding;
|
||||
public double GetDepth()
|
||||
{
|
||||
int depth = 0;
|
||||
LayerPropertyGroup current = LayerProperty.LayerPropertyGroup;
|
||||
while (current != null)
|
||||
{
|
||||
depth++;
|
||||
current = current.Parent;
|
||||
}
|
||||
|
||||
return depth;
|
||||
}
|
||||
|
||||
public bool HasPropertyInputViewModel => PropertyInputViewModel != null;
|
||||
|
||||
public bool KeyframesEnabled
|
||||
{
|
||||
get => LayerProperty.KeyframesEnabled;
|
||||
@@ -66,6 +49,42 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
||||
_profileEditorService.ChangeSelectedDataBinding(LayerProperty);
|
||||
}
|
||||
|
||||
private void ApplyKeyframesEnabled(bool enable)
|
||||
{
|
||||
// If enabling keyframes for the first time, add a keyframe with the current value at the current position
|
||||
if (enable && !LayerProperty.Keyframes.Any())
|
||||
LayerProperty.AddKeyframe(new LayerPropertyKeyframe<T>(
|
||||
LayerProperty.CurrentValue,
|
||||
_profileEditorService.CurrentTime,
|
||||
Easings.Functions.Linear,
|
||||
LayerProperty
|
||||
));
|
||||
// If disabling keyframes, set the base value to the current value
|
||||
else if (!enable && LayerProperty.Keyframes.Any())
|
||||
LayerProperty.BaseValue = LayerProperty.CurrentValue;
|
||||
|
||||
LayerProperty.KeyframesEnabled = enable;
|
||||
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
|
||||
public bool HasDataBinding => LayerProperty.HasDataBinding;
|
||||
|
||||
public double GetDepth()
|
||||
{
|
||||
int depth = 0;
|
||||
LayerPropertyGroup current = LayerProperty.LayerPropertyGroup;
|
||||
while (current != null)
|
||||
{
|
||||
depth++;
|
||||
current = current.Parent;
|
||||
}
|
||||
|
||||
return depth;
|
||||
}
|
||||
|
||||
public bool HasPropertyInputViewModel => PropertyInputViewModel != null;
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public void Dispose()
|
||||
@@ -79,27 +98,6 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
||||
|
||||
#endregion
|
||||
|
||||
private void ApplyKeyframesEnabled(bool enable)
|
||||
{
|
||||
// If enabling keyframes for the first time, add a keyframe with the current value at the current position
|
||||
if (enable && !LayerProperty.Keyframes.Any())
|
||||
{
|
||||
LayerProperty.AddKeyframe(new LayerPropertyKeyframe<T>(
|
||||
LayerProperty.CurrentValue,
|
||||
_profileEditorService.CurrentTime,
|
||||
Easings.Functions.Linear,
|
||||
LayerProperty
|
||||
));
|
||||
}
|
||||
// If disabling keyframes, set the base value to the current value
|
||||
else if (!enable && LayerProperty.Keyframes.Any())
|
||||
LayerProperty.BaseValue = LayerProperty.CurrentValue;
|
||||
|
||||
LayerProperty.KeyframesEnabled = enable;
|
||||
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
|
||||
#region Event handlers
|
||||
|
||||
private void ProfileEditorServiceOnSelectedDataBindingChanged(object sender, EventArgs e)
|
||||
@@ -107,12 +105,12 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.Tree
|
||||
LayerPropertyViewModel.IsHighlighted = _profileEditorService.SelectedDataBinding == LayerProperty;
|
||||
}
|
||||
|
||||
private void LayerPropertyOnVisibilityChanged(object? sender, LayerPropertyEventArgs<T> e)
|
||||
private void LayerPropertyOnVisibilityChanged(object sender, LayerPropertyEventArgs<T> e)
|
||||
{
|
||||
LayerPropertyViewModel.IsVisible = !LayerProperty.IsHidden;
|
||||
}
|
||||
|
||||
private void LayerPropertyOnDataBindingChange(object? sender, LayerPropertyEventArgs<T> e)
|
||||
private void LayerPropertyOnDataBindingChange(object sender, LayerPropertyEventArgs<T> e)
|
||||
{
|
||||
NotifyOfPropertyChange(nameof(HasDataBinding));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user