From 28773e23a9212375a5f58e313f2de149a23668cb Mon Sep 17 00:00:00 2001 From: Dude Guy Date: Fri, 7 Apr 2017 21:25:21 -0400 Subject: [PATCH 1/7] Initial GUI work for shot detection --- ShadowClip/GUI/Converters.cs | 35 ++++++++++++ ShadowClip/GUI/VideoView.xaml | 90 +++++++++++++++++++++---------- ShadowClip/GUI/VideoViewModel.cs | 24 ++++++++- ShadowClip/ShadowClip.csproj | 1 + ShadowClip/services/ShotFinder.cs | 29 ++++++++++ 5 files changed, 150 insertions(+), 29 deletions(-) create mode 100644 ShadowClip/services/ShotFinder.cs diff --git a/ShadowClip/GUI/Converters.cs b/ShadowClip/GUI/Converters.cs index 0bbdbcd..7b7c57d 100644 --- a/ShadowClip/GUI/Converters.cs +++ b/ShadowClip/GUI/Converters.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Windows; @@ -72,6 +73,40 @@ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, } } + public class ShotTime + { + public double Time { get; set; } + public Thickness Margin { get; set; } + } + internal class ShotTimesConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + var none = Enumerable.Empty(); + if (!(values[0] is IEnumerable times)) return none; + if (!(values[1] is TimeSpan duration)) return none; + if (!(values[2] is double width)) return none; + if (duration.Ticks == 0) return none; + + return times.Select(time => + { + var fraction = time / duration.TotalSeconds; + var offset = fraction * width - 4; + + return new ShotTime + { + Margin = new Thickness(offset, 0, 0, 0), + Time = time + }; + }); + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + internal class StateToBoolConverter : ParamConverter { public override object Convert(State state, string parameter) diff --git a/ShadowClip/GUI/VideoView.xaml b/ShadowClip/GUI/VideoView.xaml index 3b7495f..7187a4c 100644 --- a/ShadowClip/GUI/VideoView.xaml +++ b/ShadowClip/GUI/VideoView.xaml @@ -6,12 +6,13 @@ xmlns:cal="http://www.caliburnproject.org" xmlns:gui="clr-namespace:ShadowClip.GUI" mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="300"> + d:DesignHeight="300" d:DesignWidth="700"> + @@ -71,36 +72,69 @@ 4x - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + +