Started implementing logic behind the timeline UI

This commit is contained in:
SpoinkyNL committed 2020-01-05 22:10:37 +01:00
1 parent a6c8d339c0
commit 14065bffef
31 files changed
+501 -408

No files matched your search

@@ -0,0 +1,29 @@
using System;
using System.Linq;
using Stylet;
namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
{
public class PropertyTimelineViewModel : PropertyChangedBase
{
public PropertyTimelineViewModel(LayerPropertiesViewModel layerPropertiesViewModel)
{
LayerPropertiesViewModel = layerPropertiesViewModel;
RailItemViewModels = new BindableCollection<PropertyTrackViewModel>();
}
public LayerPropertiesViewModel LayerPropertiesViewModel { get; }
public double Width { get; set; }
public BindableCollection<PropertyTrackViewModel> RailItemViewModels { get; set; }
public void UpdateEndTime()
{
// End time is the last keyframe + 10 sec
var lastKeyFrame = RailItemViewModels.SelectMany(r => r.KeyframeViewModels).OrderByDescending(t => t.Keyframe.Position).FirstOrDefault();
var endTime = lastKeyFrame?.Keyframe.Position.Add(new TimeSpan(0, 0, 0, 10)) ?? TimeSpan.FromSeconds(10);
Width = endTime.TotalSeconds * LayerPropertiesViewModel.PixelsPerSecond;
}
}
}