1
0
Fork 0
mirror of https://github.com/wagesj45/butterflow-ui.git synced 2025-09-09 03:00:39 -05:00

Saving Configurations to Files

This commit is contained in:
Jordan Wages 2018-07-05 02:00:37 -05:00
commit 50eb034ac9
9 changed files with 133 additions and 19 deletions

View file

@ -11,7 +11,6 @@ namespace butterflow_ui
{
/// <summary> The butterflow options configuration. Contians all the options necessary to run butterflow and process a video. </summary>
[Serializable]
public class OptionsConfiguration : PropertyChangedAlerter
{
#region Members
@ -25,6 +24,7 @@ namespace butterflow_ui
private const FlowFilterType DEFAULT_FLOW_FILTER_TYPE = FlowFilterType.box;
/// <summary> An input interpreter used for converting string values to numeric values. </summary>
[NonSerialized]
private InputInterpreter interpreter = new InputInterpreter();
/// <summary> The aspect ratio used for calculating heights when the aspect ratio is locked. </summary>
private decimal aspectRatio = 0;
@ -394,8 +394,6 @@ namespace butterflow_ui
this.smoothDerivativeStandardDeviation = DEFAULT_SMOOTH_DERIVATIVE_STANDARD_DEVIATION;
this.flowFilterType = DEFAULT_FLOW_FILTER_TYPE;
AddConstantCallProperty("CommandLineOutput");
this.subregions.CollectionChanged += Subregions_CollectionChanged; ;
}
@ -431,6 +429,51 @@ namespace butterflow_ui
OnPropertyChanged("CommandLineOutput");
}
/// <summary> Converts this object to a <seealso cref="OptionsConfigurationFile"/>. </summary>
/// <returns> This object as an OptionsConfigurationFile. </returns>
public OptionsConfigurationFile ToFile()
{
var file = new OptionsConfigurationFile()
{
FastPyramid = this.fastPyramid,
FlowFilterType = this.flowFilterType,
Iterations = this.iterations,
KeepAudio = this.keepAudio,
KeepSubregions = this.keepSubRegions,
Levels = this.levels,
LockAspectRatio = this.lockAspectRatio,
LosslessQuality = this.losslessQuality,
PixelNeighborhood = this.pixelNeighborhood,
PlaybackRate = this.playbackRate,
PyramidScale = this.pyramidScale,
SmoothDerivativeStandardDeviation = this.smoothDerivativeStandardDeviation,
SmoothMotion = this.smoothMotion,
WindowSize = this.windowSize
};
return file;
}
/// <summary> Loads an option configuration file's contents into the <seealso cref="OptionsConfiguration"/>. </summary>
/// <param name="file"> The file to load. </param>
public void LoadFile(OptionsConfigurationFile file)
{
this.FastPyramid = file.FastPyramid;
this.FlowFilterType = file.FlowFilterType;
this.Iterations = file.Iterations.ToString();
this.KeepAudio = file.KeepAudio;
this.KeepSubregions = file.KeepSubregions;
this.Levels = file.Levels.ToString();
this.LockAspectRatio = file.LockAspectRatio;
this.LosslessQuality = file.LosslessQuality;
this.PixelNeighborhood = file.PixelNeighborhood.ToString();
this.PlaybackRate = file.PlaybackRate;
this.PyramidScale = file.PyramidScale.ToString();
this.SmoothDerivativeStandardDeviation = file.SmoothDerivativeStandardDeviation.ToString();
this.SmoothMotion = file.SmoothMotion;
this.WindowSize = file.WindowSize.ToString();
}
/// <summary> Converts this object to a butterflow options. </summary>
/// <returns> This object as a string. </returns>
public string ToButterflowArguments()