1
0
Fork 0
mirror of https://github.com/wagesj45/butterflow-ui.git synced 2024-12-22 09:12:42 -06:00

Advanced options and documentation

Added a lot of new advanced options and documented a lot of functions and members.
This commit is contained in:
Jordan Wages 2018-07-03 18:59:28 -05:00
parent d0b29f20fd
commit 2e73a77538
10 changed files with 568 additions and 33 deletions

View file

@ -8,6 +8,7 @@ using System.Windows.Controls;
namespace butterflow_ui namespace butterflow_ui
{ {
/// <summary> A butterflowUI option. Contains layout information for use in butterflowUI. </summary>
public class ButterflowOption : ContentControl public class ButterflowOption : ContentControl
{ {
#region Properties #region Properties

View file

@ -6,7 +6,8 @@ using System.Threading.Tasks;
namespace butterflow_ui namespace butterflow_ui
{ {
public class ButterflowSubregion : PropertyChangedAlerter, System.ComponentModel.INotifyPropertyChanged /// <summary> A butterflow video subregion. Represents a snippet of a video on which butterflow will act. </summary>
public class ButterflowSubregion : PropertyChangedAlerter
{ {
#region Members #region Members

View file

@ -5,20 +5,27 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace butterflow_ui namespace butterflow_ui
{ {
/// <summary> A butterflow wrapper. Provides interaction with the butterflow executable. </summary>
public class ButterflowWrapper : PropertyChangedAlerter public class ButterflowWrapper : PropertyChangedAlerter
{ {
#region Members #region Members
/// <summary> The RegEx string for matching probed resolution. </summary>
private const string REGEX_RESOLUTION = @"Resolution\s*:\s(?<Width>\d+)x(?<Height>\d+)";
/// <summary> The RegEx string for matching the probed playback rate.. </summary>
private const string REGEX_RATE = @"Rate\s*:\s(?<Rate>\d+\.\d+) fps";
/// <summary> Full pathname of the butterflow executable file. </summary> /// <summary> Full pathname of the butterflow executable file. </summary>
private Lazy<string> executablePath = new Lazy<string>(() => Path.Combine(Directory.GetCurrentDirectory(), "ThirdPartyCompiled", "butterflow.exe")); private Lazy<string> executablePath = new Lazy<string>(() => Path.Combine(Directory.GetCurrentDirectory(), "ThirdPartyCompiled", "butterflow.exe"));
/// <summary> The console output from butterflow. </summary> /// <summary> The console output from butterflow. </summary>
private string consoleOutput = string.Empty; private string consoleOutput = string.Empty;
/// <summary> Event queue for all listeners interested in ConsoleOutputRecieved events. </summary> /// <summary> Event queue for all listeners interested in ParsedConsoleOutputRecieved events. </summary>
//public event EventHandler<ButterflowConsoleOutputArgs> ConsoleOutputRecieved; public event EventHandler<ButterflowOutputArgs> ParsedConsoleOutputRecieved;
#endregion #endregion
@ -71,35 +78,100 @@ namespace butterflow_ui
process.StartInfo.UseShellExecute = false; process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardOutput = true;
process.EnableRaisingEvents = true; process.EnableRaisingEvents = true;
process.OutputDataReceived += ProcessOutputDataReceived; process.OutputDataReceived += Process_OutputDataReceived; ;
process.Start(); process.Start();
process.BeginOutputReadLine(); process.BeginOutputReadLine();
} }
/// <summary> Process the output data received from the butterflow executable. </summary> /// <summary>
/// <param name="sender"> Source of the event. </param> /// Parses console output and attempts to find known values. If a known value is found, the
/// <param name="e"> Data received event information. </param> /// <seealso cref="ParsedConsoleOutputRecieved"/> event is triggered.
private void ProcessOutputDataReceived(object sender, DataReceivedEventArgs e) /// </summary>
/// <param name="consoleOutput"> The console output from butterflow. </param>
private void ParseConsoleOutput(string consoleOutput)
{ {
this.ConsoleOutput += string.Format("{0}{1}", e.Data, Environment.NewLine); if (string.IsNullOrWhiteSpace(consoleOutput))
//OnConsoleOutputRecieved(e.Data); {
//Ignore null content and just escape.
return;
} }
/// <summary> Executes the console output recieved event handler. </summary> //Test for resolution
/// <param name="output"> The output that has been recieved from butterflow. </param> var regex = new Regex(REGEX_RESOLUTION);
//protected void OnConsoleOutputRecieved(string output) foreach (Match match in regex.Matches(consoleOutput))
//{ {
// if (this.ConsoleOutputRecieved != null) var width = match.Groups["Width"].Value;
// { var height = match.Groups["Height"].Value;
// this.ConsoleOutputRecieved(this, new ButterflowConsoleOutputArgs(output));
// } OnParsedConsoleOutputRecieved(ButterflowOutputType.Width, width, consoleOutput);
//} OnParsedConsoleOutputRecieved(ButterflowOutputType.Height, height, consoleOutput);
}
//Test for playback rate
regex = new Regex(REGEX_RATE);
foreach(Match match in regex.Matches(consoleOutput))
{
var rate = match.Groups["Rate"].Value;
OnParsedConsoleOutputRecieved(ButterflowOutputType.Rate, rate, consoleOutput);
}
}
/// <summary> Executes the parsed console output recieved action. </summary>
/// <param name="outputType"> Type of the output. </param>
/// <param name="value"> The value. </param>
/// <param name="consoleOutput"> The console output from butterflow. </param>
private void OnParsedConsoleOutputRecieved(ButterflowOutputType outputType, string value, string consoleOutput)
{
if (this.ParsedConsoleOutputRecieved != null)
{
this.ParsedConsoleOutputRecieved(this, new ButterflowOutputArgs(outputType, value, consoleOutput));
}
}
/// <summary> Event handler. Called by Process for output data received events. </summary>
/// <param name="sender"> Source of the event. </param>
/// <param name="e"> Data received event information. </param>
private void Process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
this.ConsoleOutput += string.Format("{0}{1}", e.Data, Environment.NewLine);
ParseConsoleOutput(e.Data);
}
#endregion #endregion
#region Subclasses #region Subclasses
/// <summary> Arguments for butterflow output events where a known value of type <seealso cref="ButterflowOutputType"/> can be parsed. </summary>
public class ButterflowOutputArgs : ButterflowConsoleOutputArgs
{
#region Properties
/// <summary> Gets or sets the type of the output detected from butterflow. </summary>
/// <value> The type of the output detected from butterflow. </value>
public ButterflowOutputType OutputType { get; private set; }
/// <summary> Gets or sets the value detected from butterflow. </summary>
/// <value> The value detected from butterflow. </value>
public string Value { get; private set; }
#endregion
/// <summary> Constructor. </summary>
/// <param name="outputType"> The type of the output detected from butterflow. </param>
/// <param name="value"> The value detected from butterflow. </param>
/// <param name="consoleOutput"> The console output. </param>
public ButterflowOutputArgs(ButterflowOutputType outputType, string value, string consoleOutput)
: base(consoleOutput)
{
this.OutputType = outputType;
this.Value = value;
}
}
/// <summary> Arguments for butterflow console output events. </summary>
public class ButterflowConsoleOutputArgs : EventArgs public class ButterflowConsoleOutputArgs : EventArgs
{ {
#region Properties #region Properties
@ -122,6 +194,19 @@ namespace butterflow_ui
#endregion #endregion
} }
/// <summary> Values that represent butterflow output types. </summary>
public enum ButterflowOutputType
{
/// <summary> Video Width. </summary>
Width,
/// <summary> Video Height. </summary>
Height,
/// <summary> Video playback rate. </summary>
Rate,
/// <summary> Video processing progress. </summary>
Progress
}
#endregion #endregion
} }
} }

View file

@ -130,4 +130,22 @@
</Path> </Path>
</Viewbox> </Viewbox>
</ControlTemplate> </ControlTemplate>
<ControlTemplate x:Key="LockedIcon">
<Viewbox>
<Path Fill="#000000">
<Path.Data>
<PathGeometry Figures="M18 10v-4c0-3.313-2.687-6-6-6s-6 2.687-6 6v4h-3v14h18v-14h-3zm-10 0v-4c0-2.206 1.794-4 4-4s4 1.794 4 4v4h-8z" FillRule="NonZero"/>
</Path.Data>
</Path>
</Viewbox>
</ControlTemplate>
<ControlTemplate x:Key="UnlockedIcon">
<Viewbox>
<Path Name="path885" Fill="#000000">
<Path.Data>
<PathGeometry Figures="M12 10v-4c0-3.313-2.687-6-6-6s-6 2.687-6 6v3h2v-3c0-2.206 1.794-4 4-4s4 1.794 4 4v4h-4v14h18v-14h-12z" FillRule="NonZero"/>
</Path.Data>
</Path>
</Viewbox>
</ControlTemplate>
</ResourceDictionary> </ResourceDictionary>

View file

@ -124,7 +124,7 @@ namespace butterflow_ui.Localization {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to More about butterflow.... /// Looks up a localized string similar to butterflow on github....
/// </summary> /// </summary>
public static string AboutButterflowMenu { public static string AboutButterflowMenu {
get { get {
@ -133,7 +133,7 @@ namespace butterflow_ui.Localization {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to More about butterflow-ui.... /// Looks up a localized string similar to butterflow-ui on github....
/// </summary> /// </summary>
public static string AboutButterflowUIMenu { public static string AboutButterflowUIMenu {
get { get {
@ -204,6 +204,24 @@ namespace butterflow_ui.Localization {
} }
} }
/// <summary>
/// Looks up a localized string similar to Use Fast Pyramids.
/// </summary>
public static string FastPyramidsLabel {
get {
return ResourceManager.GetString("FastPyramidsLabel", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to .
/// </summary>
public static string FastPyramidsTooltip {
get {
return ResourceManager.GetString("FastPyramidsTooltip", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Input. /// Looks up a localized string similar to Input.
/// </summary> /// </summary>
@ -249,6 +267,24 @@ namespace butterflow_ui.Localization {
} }
} }
/// <summary>
/// Looks up a localized string similar to Pyramid iterations.
/// </summary>
public static string IterationsLabel {
get {
return ResourceManager.GetString("IterationsLabel", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The number of iterations to use for each pyramid layer..
/// </summary>
public static string IterationsTooltip {
get {
return ResourceManager.GetString("IterationsTooltip", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Renders the output video with the audio from the original video. In unchecked, no sound will be included in the output video.. /// Looks up a localized string similar to Renders the output video with the audio from the original video. In unchecked, no sound will be included in the output video..
/// </summary> /// </summary>
@ -267,6 +303,24 @@ namespace butterflow_ui.Localization {
} }
} }
/// <summary>
/// Looks up a localized string similar to Levels.
/// </summary>
public static string LevelsLabel {
get {
return ResourceManager.GetString("LevelsLabel", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The number of pyramid layers..
/// </summary>
public static string LevelsTooltip {
get {
return ResourceManager.GetString("LevelsTooltip", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Renders the video without lossy compression. The video will not lose any visual quality, but it will result in a very large output file.. /// Looks up a localized string similar to Renders the video without lossy compression. The video will not lose any visual quality, but it will result in a very large output file..
/// </summary> /// </summary>
@ -285,6 +339,24 @@ namespace butterflow_ui.Localization {
} }
} }
/// <summary>
/// Looks up a localized string similar to Pixel Neighborhood.
/// </summary>
public static string PixelNeighborhoodLabel {
get {
return ResourceManager.GetString("PixelNeighborhoodLabel", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Size of the pixel neighborhood..
/// </summary>
public static string PixelNeighborhoodTooltip {
get {
return ResourceManager.GetString("PixelNeighborhoodTooltip", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Controls the new framerate of the output video. This can be set in both absolute and relative terms.. /// Looks up a localized string similar to Controls the new framerate of the output video. This can be set in both absolute and relative terms..
/// </summary> /// </summary>
@ -312,6 +384,24 @@ namespace butterflow_ui.Localization {
} }
} }
/// <summary>
/// Looks up a localized string similar to Pyramid Scale Factor.
/// </summary>
public static string PyramidScaleLabel {
get {
return ResourceManager.GetString("PyramidScaleLabel", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to .
/// </summary>
public static string PyramidScaleTooltip {
get {
return ResourceManager.GetString("PyramidScaleTooltip", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Video Rendering. /// Looks up a localized string similar to Video Rendering.
/// </summary> /// </summary>
@ -348,6 +438,42 @@ namespace butterflow_ui.Localization {
} }
} }
/// <summary>
/// Looks up a localized string similar to Smooth Derivative.
/// </summary>
public static string SmoothDerivativeLabel {
get {
return ResourceManager.GetString("SmoothDerivativeLabel", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Size of the standard deviation used for smooth derivatives..
/// </summary>
public static string SmoothDerivativeTooltip {
get {
return ResourceManager.GetString("SmoothDerivativeTooltip", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Smooth Motion.
/// </summary>
public static string SmoothMotionLabel {
get {
return ResourceManager.GetString("SmoothMotionLabel", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Set to tune for smooth motion. This mode yields artifact-less frames by emphasizing blended frames over warping pixels..
/// </summary>
public static string SmoothMotionTooltip {
get {
return ResourceManager.GetString("SmoothMotionTooltip", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to S. /// Looks up a localized string similar to S.
/// </summary> /// </summary>
@ -410,5 +536,23 @@ namespace butterflow_ui.Localization {
return ResourceManager.GetString("WidthLabel", resourceCulture); return ResourceManager.GetString("WidthLabel", resourceCulture);
} }
} }
/// <summary>
/// Looks up a localized string similar to Window Size.
/// </summary>
public static string WindowSizeLabel {
get {
return ResourceManager.GetString("WindowSizeLabel", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to .
/// </summary>
public static string WindowSizeTooltip {
get {
return ResourceManager.GetString("WindowSizeTooltip", resourceCulture);
}
}
} }
} }

View file

@ -118,10 +118,10 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="AboutButterflowMenu" xml:space="preserve"> <data name="AboutButterflowMenu" xml:space="preserve">
<value>More about butterflow...</value> <value>butterflow on github...</value>
</data> </data>
<data name="AboutButterflowUIMenu" xml:space="preserve"> <data name="AboutButterflowUIMenu" xml:space="preserve">
<value>More about butterflow-ui...</value> <value>butterflow-ui on github...</value>
</data> </data>
<data name="AboutMenu" xml:space="preserve"> <data name="AboutMenu" xml:space="preserve">
<value>About butterflow-ui</value> <value>About butterflow-ui</value>
@ -234,4 +234,52 @@
<data name="_60fpsLabel" xml:space="preserve"> <data name="_60fpsLabel" xml:space="preserve">
<value>60 fps</value> <value>60 fps</value>
</data> </data>
<data name="FastPyramidsLabel" xml:space="preserve">
<value>Use Fast Pyramids</value>
</data>
<data name="FastPyramidsTooltip" xml:space="preserve">
<value />
</data>
<data name="IterationsLabel" xml:space="preserve">
<value>Pyramid iterations</value>
</data>
<data name="IterationsTooltip" xml:space="preserve">
<value>The number of iterations to use for each pyramid layer.</value>
</data>
<data name="LevelsLabel" xml:space="preserve">
<value>Levels</value>
</data>
<data name="LevelsTooltip" xml:space="preserve">
<value>The number of pyramid layers.</value>
</data>
<data name="PixelNeighborhoodLabel" xml:space="preserve">
<value>Pixel Neighborhood</value>
</data>
<data name="PixelNeighborhoodTooltip" xml:space="preserve">
<value>Size of the pixel neighborhood.</value>
</data>
<data name="PyramidScaleLabel" xml:space="preserve">
<value>Pyramid Scale Factor</value>
</data>
<data name="PyramidScaleTooltip" xml:space="preserve">
<value />
</data>
<data name="SmoothDerivativeLabel" xml:space="preserve">
<value>Smooth Derivative</value>
</data>
<data name="SmoothDerivativeTooltip" xml:space="preserve">
<value>Size of the standard deviation used for smooth derivatives.</value>
</data>
<data name="SmoothMotionLabel" xml:space="preserve">
<value>Smooth Motion</value>
</data>
<data name="SmoothMotionTooltip" xml:space="preserve">
<value>Set to tune for smooth motion. This mode yields artifact-less frames by emphasizing blended frames over warping pixels.</value>
</data>
<data name="WindowSizeLabel" xml:space="preserve">
<value>Window Size</value>
</data>
<data name="WindowSizeTooltip" xml:space="preserve">
<value />
</data>
</root> </root>

View file

@ -127,13 +127,37 @@
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="16 " />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<butterflow_ui:ButterflowOption Grid.Column="0" LabelValue="{x:Static loc:Localization.WidthLabel}"> <butterflow_ui:ButterflowOption Grid.Column="0" LabelValue="{x:Static loc:Localization.WidthLabel}">
<TextBox Text="{Binding OptionsConfiguration.Width, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=PropertyChanged}" /> <TextBox Text="{Binding OptionsConfiguration.Width, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=LostFocus}" />
</butterflow_ui:ButterflowOption> </butterflow_ui:ButterflowOption>
<butterflow_ui:ButterflowOption Grid.Column="1" LabelValue="{x:Static loc:Localization.HeightLabel}"> <ToggleButton Grid.Column="1" IsChecked="{Binding OptionsConfiguration.LockAspectRatio, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=PropertyChanged}" BorderThickness="0" Background="{x:Null}">
<TextBox Text="{Binding OptionsConfiguration.Height, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=PropertyChanged}" /> <ToggleButton.Style>
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Content">
<Setter.Value>
<ContentControl HorizontalAlignment="Center" Template="{StaticResource UnlockedIcon}" />
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Content">
<Setter.Value>
<ContentControl HorizontalAlignment="Center" Template="{StaticResource LockedIcon}" />
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</ToggleButton.Style>
</ToggleButton>
<Button BorderThickness="0" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Click="bntVideoStop_Click">
</Button>
<butterflow_ui:ButterflowOption Grid.Column="2" LabelValue="{x:Static loc:Localization.HeightLabel}">
<TextBox Text="{Binding OptionsConfiguration.Height, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=LostFocus}" IsReadOnly="{Binding OptionsConfiguration.LockAspectRatio, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=PropertyChanged}" />
</butterflow_ui:ButterflowOption> </butterflow_ui:ButterflowOption>
</Grid> </Grid>
</butterflow_ui:ButterflowOption> </butterflow_ui:ButterflowOption>
@ -161,6 +185,30 @@
</ListView.ItemTemplate> </ListView.ItemTemplate>
</ListView> </ListView>
</butterflow_ui:ButterflowOption> </butterflow_ui:ButterflowOption>
<butterflow_ui:ButterflowOption DescriptionValue="{x:Static loc:Localization.SmoothMotionTooltip}">
<CheckBox IsChecked="{Binding OptionsConfiguration.SmoothMotion, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=PropertyChanged}" Content="{x:Static loc:Localization.SmoothMotionLabel}" />
</butterflow_ui:ButterflowOption>
<butterflow_ui:ButterflowOption DescriptionValue="{x:Static loc:Localization.FastPyramidsTooltip}">
<CheckBox IsChecked="{Binding OptionsConfiguration.FastPyramid, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=PropertyChanged}" Content="{x:Static loc:Localization.FastPyramidsLabel}" />
</butterflow_ui:ButterflowOption>
<butterflow_ui:ButterflowOption LabelValue="{x:Static loc:Localization.PyramidScaleLabel}" DescriptionValue="{x:Static loc:Localization.PyramidScaleTooltip}">
<TextBox Text="{Binding OptionsConfiguration.PyramidScale, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=LostFocus}" />
</butterflow_ui:ButterflowOption>
<butterflow_ui:ButterflowOption LabelValue="{x:Static loc:Localization.LevelsLabel}" DescriptionValue="{x:Static loc:Localization.LevelsTooltip}">
<TextBox Text="{Binding OptionsConfiguration.PyramidScale, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=LostFocus}" />
</butterflow_ui:ButterflowOption>
<butterflow_ui:ButterflowOption LabelValue="{x:Static loc:Localization.WindowSizeLabel}" DescriptionValue="{x:Static loc:Localization.WindowSizeTooltip}">
<TextBox Text="{Binding OptionsConfiguration.PyramidScale, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=LostFocus}" />
</butterflow_ui:ButterflowOption>
<butterflow_ui:ButterflowOption LabelValue="{x:Static loc:Localization.IterationsLabel}" DescriptionValue="{x:Static loc:Localization.IterationsTooltip}">
<TextBox Text="{Binding OptionsConfiguration.PyramidScale, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=LostFocus}" />
</butterflow_ui:ButterflowOption>
<butterflow_ui:ButterflowOption LabelValue="{x:Static loc:Localization.PixelNeighborhoodLabel}" DescriptionValue="{x:Static loc:Localization.PixelNeighborhoodTooltip}">
<TextBox Text="{Binding OptionsConfiguration.PyramidScale, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=LostFocus}" />
</butterflow_ui:ButterflowOption>
<butterflow_ui:ButterflowOption LabelValue="{x:Static loc:Localization.SmoothDerivativeLabel}" DescriptionValue="{x:Static loc:Localization.SmoothDerivativeTooltip}">
<TextBox Text="{Binding OptionsConfiguration.PyramidScale, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type butterflow_ui:MainWindow}}, UpdateSourceTrigger=LostFocus}" />
</butterflow_ui:ButterflowOption>
</StackPanel> </StackPanel>
</ScrollViewer> </ScrollViewer>
</GroupBox> </GroupBox>

View file

@ -43,9 +43,30 @@ namespace butterflow_ui
/// <summary> Default constructor. </summary> /// <summary> Default constructor. </summary>
public MainWindow() public MainWindow()
{ {
this.ButterflowWrapper.ParsedConsoleOutputRecieved += ButterflowWrapper_ParsedConsoleOutputRecieved;
InitializeComponent(); InitializeComponent();
} }
/// <summary> Butterflow wrapper parsed console output recieved. </summary>
/// <param name="sender"> Source of the event. </param>
/// <param name="e"> The ButterflowOutputArgs to process. </param>
private void ButterflowWrapper_ParsedConsoleOutputRecieved(object sender, ButterflowWrapper.ButterflowOutputArgs e)
{
switch (e.OutputType)
{
case ButterflowWrapper.ButterflowOutputType.Width:
this.OptionsConfiguration.Width = e.Value;
break;
case ButterflowWrapper.ButterflowOutputType.Height:
this.OptionsConfiguration.Height = e.Value;
break;
case ButterflowWrapper.ButterflowOutputType.Progress:
break;
default:
break;
}
}
/// <summary> Event handler. Called by btnFilePicker for click events. </summary> /// <summary> Event handler. Called by btnFilePicker for click events. </summary>
/// <param name="sender"> Source of the event. </param> /// <param name="sender"> Source of the event. </param>
/// <param name="e"> Routed event information. </param> /// <param name="e"> Routed event information. </param>
@ -164,8 +185,8 @@ namespace butterflow_ui
/// <param name="e"> Routed event information. </param> /// <param name="e"> Routed event information. </param>
private void mediaPreview_MediaOpened(object sender, RoutedEventArgs e) private void mediaPreview_MediaOpened(object sender, RoutedEventArgs e)
{ {
this.OptionsConfiguration.Width = this.mediaPreview.NaturalVideoWidth.ToString(); //this.OptionsConfiguration.Width = this.mediaPreview.NaturalVideoWidth.ToString();
this.OptionsConfiguration.Height = this.mediaPreview.NaturalVideoHeight.ToString(); //this.OptionsConfiguration.Height = this.mediaPreview.NaturalVideoHeight.ToString();
} }
/// <summary> Event handler. Called by mediaPreview for media ended events. </summary> /// <summary> Event handler. Called by mediaPreview for media ended events. </summary>

View file

@ -10,7 +10,7 @@ using csmic;
namespace butterflow_ui namespace butterflow_ui
{ {
/// <summary> (Serializable) the options configuration. </summary> /// <summary> The butterflow options configuration. Contians all the options necessary to run butterflow and process a video. </summary>
[Serializable] [Serializable]
public class OptionsConfiguration : PropertyChangedAlerter public class OptionsConfiguration : PropertyChangedAlerter
{ {
@ -18,6 +18,8 @@ namespace butterflow_ui
/// <summary> An interpreter used to ensure numeric input is correctly calculated. </summary> /// <summary> An interpreter used to ensure numeric input is correctly calculated. </summary>
private InputInterpreter interpreter = new InputInterpreter(); private InputInterpreter interpreter = new InputInterpreter();
/// <summary> The aspect ratio used for calculating heights when the aspect ratio is locked. </summary>
private decimal aspectRatio = 0;
private string playbackRate; private string playbackRate;
private bool keepAudio; private bool keepAudio;
@ -25,8 +27,17 @@ namespace butterflow_ui
private int height; private int height;
private bool keepAspectRatio; private bool keepAspectRatio;
private bool losslessQuality; private bool losslessQuality;
private bool smoothMotion;
private bool lockAspectRatio;
private string videoInput; private string videoInput;
private string videoOutput; private string videoOutput;
private bool fastPyramid;
private decimal pyramidScale;
private int levels;
private int windowSize;
private int iterations;
private int pixelNeighborhood;
private decimal smoothDerivativeStandardDeviation;
private ObservableCollection<ButterflowSubregion> subregions = new ObservableCollection<ButterflowSubregion>(); private ObservableCollection<ButterflowSubregion> subregions = new ObservableCollection<ButterflowSubregion>();
#endregion #endregion
@ -73,6 +84,41 @@ namespace butterflow_ui
} }
} }
/// <summary> Gets or sets a value indicating whether the butterflow should be turned toward smooth motion. </summary>
/// <value> True if tuned toward smooth motion, false if not. </value>
public bool SmoothMotion
{
get
{
return this.smoothMotion;
}
set
{
this.smoothMotion = value;
OnPropertyChanged();
}
}
/// <summary> Gets or sets a value indicating whether to lock aspect ratio of the video. </summary>
/// <value> True if locking aspect ratio of the video, false if not. </value>
public bool LockAspectRatio
{
get
{
return this.lockAspectRatio;
}
set
{
if (value)
{
this.aspectRatio = Convert.ToDecimal(this.height) / Convert.ToDecimal(this.width);
}
this.lockAspectRatio = value;
OnPropertyChanged();
}
}
/// <summary> Gets or sets the width of the video output. </summary> /// <summary> Gets or sets the width of the video output. </summary>
/// <value> The width of the video output. </value> /// <value> The width of the video output. </value>
public string Width public string Width
@ -83,9 +129,20 @@ namespace butterflow_ui
} }
set set
{ {
var oldWidth = this.width;
interpreter.Interpret(value); interpreter.Interpret(value);
this.width = interpreter.Int; this.width = interpreter.Int;
OnPropertyChanged(); OnPropertyChanged();
if (this.lockAspectRatio)
{
interpreter.Interpret(string.Format("{0} * {1}", this.aspectRatio, this.width));
this.height = interpreter.Int;
OnPropertyChanged("Height");
}
} }
} }
@ -165,6 +222,117 @@ namespace butterflow_ui
} }
} }
/// <summary> Gets or sets a value indicating whether to use fast pyramids. </summary>
/// <value> True if using fast pyramids, false if not. </value>
public bool FastPyramid
{
get
{
return this.fastPyramid;
}
set
{
this.fastPyramid = value;
OnPropertyChanged();
}
}
/// <summary> Gets or sets the pyramid scale factor. </summary>
/// <value> The pyramid scale factor. </value>
public string PyramidScale
{
get
{
return this.pyramidScale.ToString();
}
set
{
interpreter.Interpret(value);
this.pyramidScale = interpreter.Decimal;
OnPropertyChanged();
}
}
/// <summary> Gets or sets the number of pyramid layers. </summary>
/// <value> The number of pyramid layers. </value>
public string Levels
{
get
{
return this.levels.ToString();
}
set
{
interpreter.Interpret(value);
this.levels = interpreter.Int;
OnPropertyChanged();
}
}
/// <summary> Gets or sets the size of the windowing average. </summary>
/// <value> The size of the windowing average. </value>
public string WindowSize
{
get
{
return this.windowSize.ToString();
}
set
{
interpreter.Interpret(value);
this.windowSize = interpreter.Int;
OnPropertyChanged();
}
}
/// <summary> Gets or sets the number of iterations at each pyramid level. </summary>
/// <value> The number of iterations at each pyramid level. </value>
public string Iterations
{
get
{
return this.iterations.ToString();
}
set
{
interpreter.Interpret(value);
this.iterations = interpreter.Int;
OnPropertyChanged();
}
}
/// <summary> Gets or sets the size of the pixel neighborhood. </summary>
/// <value> The size of the pixel neighborhood. </value>
public string PixelNeighborhood
{
get
{
return this.pixelNeighborhood.ToString();
}
set
{
interpreter.Interpret(value);
this.pixelNeighborhood = interpreter.Int;
OnPropertyChanged();
}
}
/// <summary> Gets or sets the standard deviation of smooth derivatives. </summary>
/// <value> The standard deviation of smooth derivatives. </value>
public string SmoothDerivativeStandardDeviation
{
get
{
return this.smoothDerivativeStandardDeviation.ToString();
}
set
{
interpreter.Interpret(value);
this.smoothDerivativeStandardDeviation = interpreter.Decimal;
OnPropertyChanged();
}
}
/// <summary> Gets or sets the subregions of the video on which to work. </summary> /// <summary> Gets or sets the subregions of the video on which to work. </summary>
/// <value> The subregions of the video. </value> /// <value> The subregions of the video. </value>
public ObservableCollection<ButterflowSubregion> Subregions public ObservableCollection<ButterflowSubregion> Subregions
@ -194,16 +362,16 @@ namespace butterflow_ui
private void SubregionsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) private void SubregionsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{ {
if(e.NewItems != null) if (e.NewItems != null)
{ {
foreach(ButterflowSubregion newItem in e.NewItems) foreach (ButterflowSubregion newItem in e.NewItems)
{ {
newItem.PropertyChanged += SubregionPropertyChanged; newItem.PropertyChanged += SubregionPropertyChanged;
} }
} }
if(e.OldItems != null) if (e.OldItems != null)
{ {
foreach(ButterflowSubregion oldItem in e.OldItems) foreach (ButterflowSubregion oldItem in e.OldItems)
{ {
oldItem.PropertyChanged -= SubregionPropertyChanged; oldItem.PropertyChanged -= SubregionPropertyChanged;
} }

View file

@ -8,6 +8,7 @@ using System.Threading.Tasks;
namespace butterflow_ui namespace butterflow_ui
{ {
/// <summary> A class responsible for implementing the <see cref="INotifyPropertyChanged"/> interface and helper functions. </summary>
public abstract class PropertyChangedAlerter : INotifyPropertyChanged public abstract class PropertyChangedAlerter : INotifyPropertyChanged
{ {
#region Members #region Members