Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e804355034 | ||
|
|
34a2990e9d | ||
|
|
24f999d859 | ||
|
|
bfa8fd7d4f | ||
|
|
3da4e0ea84 | ||
|
|
28c9ae94b0 | ||
|
|
1210637f59 | ||
|
|
509d47fb91 | ||
|
|
1b4e39df45 | ||
|
|
8dbf692855 | ||
|
|
7b0af841ab | ||
|
|
d66723d510 | ||
|
|
8963bdb6c0 | ||
|
|
4cd9a851e8 | ||
|
|
77c5d94b74 | ||
|
|
5f7b2911da | ||
|
|
96a2d4f52f | ||
|
|
12cfaaefc6 | ||
|
|
d4cf9d9649 | ||
|
|
e0d290306b | ||
|
|
1d66f9fef0 | ||
|
|
6f7b0386cd | ||
|
|
228217e79b | ||
|
|
06589d6cf8 | ||
|
|
b88bdcb8be | ||
|
|
06f5b818bb | ||
|
|
8a7e8b0262 | ||
|
|
a223ee1610 | ||
|
|
19e9e1d50a | ||
|
|
afe7c4048a | ||
|
|
a0fbf28e42 | ||
|
|
915f93defd | ||
|
|
3e7c7a4a30 | ||
|
|
5db9c09cff | ||
|
|
82be95fb43 | ||
|
|
132e254f25 | ||
|
|
7352f2a0e3 | ||
|
|
a3a930d44c | ||
|
|
ae3328b029 | ||
|
|
c9d2c77340 | ||
|
|
890ed87cf8 | ||
|
|
f6547941bc | ||
|
|
00d380f92e | ||
|
|
d7f25f6ab2 | ||
|
|
ef566be2bf | ||
|
|
c5b73b32b3 | ||
|
|
359a445126 | ||
|
|
a3cddcc75c | ||
|
|
b8a46ac0ef | ||
|
|
3b2adcc941 | ||
|
|
b4058b2ed6 | ||
|
|
18d616050a | ||
|
|
1b6984c378 | ||
|
|
a589aa53a4 | ||
|
|
0793a25ebc | ||
|
|
4a02a02083 | ||
|
|
c929221c60 | ||
|
|
ec98a107e4 | ||
|
|
68327299c0 | ||
|
|
4c7ff20193 | ||
|
|
5b49da745a | ||
|
|
6944180acd | ||
|
|
fbb1146931 | ||
|
|
81ea226e84 | ||
|
|
b0a1c57dd8 | ||
|
|
45625d18e4 | ||
|
|
6d1c8f3ff3 | ||
|
|
fbc080f935 | ||
|
|
9400f742d8 | ||
|
|
6dfd1f4bbf | ||
|
|
96988cd131 | ||
|
|
df80137624 | ||
|
|
03e975b371 | ||
|
|
43f5cb91cd | ||
|
|
be875bdf03 | ||
|
|
7147d670c1 | ||
|
|
390cfdc81b | ||
|
|
62636bd730 |
No files matched your search
@@ -1,7 +1,7 @@
|
||||
<Application x:Class="FileConverter.Application"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
StartupUri="MainWindow.xaml" ShutdownMode="OnMainWindowClose">
|
||||
StartupUri="Windows/MainWindow.xaml" ShutdownMode="OnMainWindowClose">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
|
||||
@@ -18,24 +18,29 @@ namespace FileConverter
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
|
||||
using FileConverter.ConversionJobs;
|
||||
|
||||
public partial class Application : System.Windows.Application
|
||||
{
|
||||
public static readonly Version Version = new Version()
|
||||
private static readonly Version Version = new Version()
|
||||
{
|
||||
Major = 0,
|
||||
Minor = 1,
|
||||
Minor = 3,
|
||||
};
|
||||
|
||||
private readonly List<ConversionJob> conversionJobs = new List<ConversionJob>();
|
||||
|
||||
private bool debugMode;
|
||||
private bool initialized;
|
||||
private bool cancelAutoExit;
|
||||
|
||||
public Application()
|
||||
{
|
||||
this.ConvertionJobs = this.conversionJobs.AsReadOnly();
|
||||
|
||||
this.Initialize();
|
||||
|
||||
if (this.initialized)
|
||||
@@ -45,22 +50,51 @@ namespace FileConverter
|
||||
}
|
||||
}
|
||||
|
||||
public static Version ApplicationVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return Application.Version;
|
||||
}
|
||||
}
|
||||
|
||||
public ReadOnlyCollection<ConversionJob> ConvertionJobs
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public Settings Settings
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool ShowSettings
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool Verbose
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public void CancelAutoExit()
|
||||
{
|
||||
this.cancelAutoExit = true;
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
this.ConvertionJobs = this.conversionJobs.AsReadOnly();
|
||||
// Load settigns.
|
||||
Diagnostics.Log("Retrieve arguments...");
|
||||
this.Settings = new Settings();
|
||||
this.Settings.Load();
|
||||
|
||||
// Retrieve arguments.
|
||||
Diagnostics.Log("Retrieve arguments...");
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
|
||||
@@ -68,17 +102,14 @@ namespace FileConverter
|
||||
if (args.Length <= 1)
|
||||
{
|
||||
this.debugMode = true;
|
||||
System.Array.Resize(ref args, 9);
|
||||
args[1] = "--output-type";
|
||||
args[2] = "Flac";
|
||||
args[3] = @"D:\Projects\FileConverter\TestFiles\Herbie Hancock - Speak Like A Child [RVG Edition].flac";
|
||||
args[3] = @"D:\Projects\FileConverter\TestFiles\01 - Le Bruit Du Bang.wma";
|
||||
args[4] = @"D:\Projects\FileConverter\TestFiles\test\Toccata.wav";
|
||||
args[5] = @"D:\Projects\FileConverter\TestFiles\test\Toccata - Copie (4).wav";
|
||||
args[5] = "--verbose";
|
||||
args[6] = @"D:\Projects\FileConverter\TestFiles\test\Toccata - Copie (3).wav";
|
||||
args[7] = @"D:\Projects\FileConverter\TestFiles\test\Toccata - Copie (2).wav";
|
||||
args[8] = @"D:\Projects\FileConverter\TestFiles\test\Toccata - Copie (5).wav";
|
||||
System.Array.Resize(ref args, 5);
|
||||
args[1] = "--conversion-preset";
|
||||
args[2] = "To Mp3";
|
||||
args[3] = "--verbose";
|
||||
args[4] = @"D:\Test\10 - Get around town (lp version).ogg";
|
||||
|
||||
System.Array.Resize(ref args, 2);
|
||||
args[1] = "--settings";
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -90,8 +121,10 @@ namespace FileConverter
|
||||
|
||||
Diagnostics.Log(string.Empty);
|
||||
|
||||
OutputType outputType = OutputType.None;
|
||||
ConversionPreset conversionPreset = null;
|
||||
List<string> filePaths = new List<string>();
|
||||
|
||||
// Parse arguments.
|
||||
for (int index = 1; index < args.Length; index++)
|
||||
{
|
||||
string argument = args[index];
|
||||
@@ -102,42 +135,34 @@ namespace FileConverter
|
||||
|
||||
switch (parameterTitle)
|
||||
{
|
||||
case "output-type":
|
||||
case "settings":
|
||||
this.ShowSettings = true;
|
||||
return;
|
||||
|
||||
case "apply-settings":
|
||||
Settings.ApplyTemporarySettings();
|
||||
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
|
||||
return;
|
||||
|
||||
case "conversion-preset":
|
||||
if (index >= args.Length - 1)
|
||||
{
|
||||
if (index >= args.Length - 1)
|
||||
{
|
||||
Diagnostics.Log("ERROR ! Invalid format.");
|
||||
return;
|
||||
}
|
||||
|
||||
string outputTypeName = args[index + 1].ToLowerInvariant();
|
||||
switch (outputTypeName)
|
||||
{
|
||||
case "mp3":
|
||||
outputType = OutputType.Mp3;
|
||||
break;
|
||||
|
||||
case "ogg":
|
||||
outputType = OutputType.Ogg;
|
||||
break;
|
||||
|
||||
case "wav":
|
||||
outputType = OutputType.Wav;
|
||||
break;
|
||||
|
||||
case "flac":
|
||||
outputType = OutputType.Flac;
|
||||
break;
|
||||
|
||||
default:
|
||||
Diagnostics.Log("ERROR ! Unknown output type {0}.", outputType);
|
||||
return;
|
||||
}
|
||||
|
||||
index++;
|
||||
continue;
|
||||
MessageBox.Show(string.Format("Invalid format. (code 0x01)"), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
|
||||
return;
|
||||
}
|
||||
|
||||
conversionPreset = Settings.GetPresetFromName(args[index + 1]);
|
||||
if (conversionPreset == null)
|
||||
{
|
||||
MessageBox.Show(string.Format("Invalid conversion preset '{0}'. (code 0x02)", args[index + 1]), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
|
||||
return;
|
||||
}
|
||||
|
||||
index++;
|
||||
continue;
|
||||
|
||||
case "verbose":
|
||||
{
|
||||
this.Verbose = true;
|
||||
@@ -156,23 +181,18 @@ namespace FileConverter
|
||||
}
|
||||
}
|
||||
|
||||
if (outputType == OutputType.None)
|
||||
if (conversionPreset == null)
|
||||
{
|
||||
Diagnostics.Log("ERROR ! Can't retrieve the output type from arguments.");
|
||||
Diagnostics.Log("ERROR ! Can't retrieve the conversion preset from arguments.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create convertion jobs.
|
||||
for (int index = 0; index < filePaths.Count; index++)
|
||||
{
|
||||
ConversionJob conversionJob = new ConversionJob();
|
||||
|
||||
string inputFilePath = filePaths[index];
|
||||
string extension = System.IO.Path.GetExtension(inputFilePath);
|
||||
string outputFilePath = inputFilePath.Substring(0, inputFilePath.Length - extension.Length) + "."
|
||||
+ outputType.ToString().ToLowerInvariant();
|
||||
|
||||
conversionJob.Initialize(outputType, inputFilePath, outputFilePath);
|
||||
ConversionJob conversionJob = ConversionJobFactory.Create(conversionPreset);
|
||||
conversionJob.PrepareConversion(inputFilePath);
|
||||
|
||||
this.conversionJobs.Add(conversionJob);
|
||||
}
|
||||
@@ -185,23 +205,16 @@ namespace FileConverter
|
||||
for (int index = 0; index < this.conversionJobs.Count; index++)
|
||||
{
|
||||
ConversionJob conversionJob = this.conversionJobs[index];
|
||||
if (conversionJob.State != ConversionJob.ConversionState.Ready)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
conversionJob.StartConvertion();
|
||||
|
||||
if (System.IO.File.Exists(conversionJob.OutputFilePath))
|
||||
{
|
||||
Diagnostics.Log("Success!");
|
||||
|
||||
if (this.debugMode)
|
||||
{
|
||||
Diagnostics.Log("Delete file {0}.", conversionJob.OutputFilePath);
|
||||
try
|
||||
{
|
||||
System.IO.File.Delete(conversionJob.OutputFilePath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -222,6 +235,11 @@ namespace FileConverter
|
||||
{
|
||||
System.Threading.Thread.Sleep(3000);
|
||||
|
||||
if (this.cancelAutoExit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<UserControl
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:valueConverters="clr-namespace:FileConverter.ValueConverters" x:Name="userControl"
|
||||
x:Class="FileConverter.Controls.EncodingQualitySliderControl"
|
||||
mc:Ignorable="d" d:DesignWidth="300" Height="50">
|
||||
<UserControl.Resources>
|
||||
<valueConverters:BitrateToString x:Key="BitrateToString"/>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="65"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Slider Grid.Column="0" x:Name="slider" Margin="0,2,0,0" VerticalAlignment="Top" Maximum="245" AutoToolTipPlacement="TopLeft" SmallChange="8" IsSnapToTickEnabled="True" IsSelectionRangeEnabled="True" SelectionStart="115" SelectionEnd="245" Minimum="65" TickPlacement="BottomRight" LargeChange="32" TickFrequency="8" Ticks="65 85 100 115 130 165 175 190 225 245" Foreground="#004B82" />
|
||||
<Label Grid.Column="1" Content="{Binding Value, Converter={StaticResource BitrateToString}, ElementName=slider, Mode=OneWay}" Width="65" />
|
||||
<Label Grid.Column="0" Grid.Row="1" Content="Recommended bitrate range in blue" Foreground="#E5004B82" FontSize="11" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,181 @@
|
||||
// <copyright file="EncodingQualitySliderControl.xaml.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.Controls
|
||||
{
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for EncodingQualitySliderControl.
|
||||
/// </summary>
|
||||
public partial class EncodingQualitySliderControl : UserControl
|
||||
{
|
||||
public static readonly DependencyProperty BitrateProperty = DependencyProperty.Register(
|
||||
"Bitrate",
|
||||
typeof(double),
|
||||
typeof(EncodingQualitySliderControl),
|
||||
new FrameworkPropertyMetadata(new PropertyChangedCallback(EncodingQualitySliderControl.OnBitrateValueChanged), new CoerceValueCallback(EncodingQualitySliderControl.CoerceBitrateValue)));
|
||||
|
||||
public static readonly DependencyProperty EncodingModeProperty = DependencyProperty.Register(
|
||||
"EncodingMode",
|
||||
typeof(EncodingMode),
|
||||
typeof(EncodingQualitySliderControl),
|
||||
new PropertyMetadata(new PropertyChangedCallback(EncodingQualitySliderControl.OnEncodingModeValueChanged)));
|
||||
|
||||
public EncodingQualitySliderControl()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
this.CoerceValue(EncodingQualitySliderControl.BitrateProperty);
|
||||
|
||||
this.slider.ValueChanged += this.Slider_ValueChanged;
|
||||
}
|
||||
|
||||
public EncodingMode EncodingMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return (EncodingMode)this.GetValue(EncodingQualitySliderControl.EncodingModeProperty);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.SetCurrentValue(EncodingQualitySliderControl.EncodingModeProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
public double Bitrate
|
||||
{
|
||||
get
|
||||
{
|
||||
return (double)this.GetValue(EncodingQualitySliderControl.BitrateProperty);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.SetCurrentValue(EncodingQualitySliderControl.BitrateProperty, this.GetNearestTickValue(value));
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnBitrateValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs eventArgs)
|
||||
{
|
||||
EncodingQualitySliderControl encodingQualitySliderControl = sender as EncodingQualitySliderControl;
|
||||
encodingQualitySliderControl.slider.Value = (double)eventArgs.NewValue;
|
||||
}
|
||||
|
||||
private static object CoerceBitrateValue(DependencyObject sender, object basevalue)
|
||||
{
|
||||
EncodingQualitySliderControl encodingQualitySliderControl = sender as EncodingQualitySliderControl;
|
||||
return encodingQualitySliderControl.GetNearestTickValue((double)basevalue);
|
||||
}
|
||||
|
||||
private static void OnEncodingModeValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs eventArgs)
|
||||
{
|
||||
EncodingQualitySliderControl encodingQualitySliderControl = sender as EncodingQualitySliderControl;
|
||||
Slider sliderControl = encodingQualitySliderControl.slider;
|
||||
|
||||
switch (encodingQualitySliderControl.EncodingMode)
|
||||
{
|
||||
case EncodingMode.Mp3VBR:
|
||||
{
|
||||
sliderControl.Minimum = 65;
|
||||
sliderControl.Maximum = 245;
|
||||
sliderControl.SelectionStart = 115;
|
||||
sliderControl.SelectionEnd = 245;
|
||||
sliderControl.Ticks.Clear();
|
||||
sliderControl.Ticks.Add(65);
|
||||
sliderControl.Ticks.Add(85);
|
||||
sliderControl.Ticks.Add(100);
|
||||
sliderControl.Ticks.Add(115);
|
||||
sliderControl.Ticks.Add(130);
|
||||
sliderControl.Ticks.Add(165);
|
||||
sliderControl.Ticks.Add(175);
|
||||
sliderControl.Ticks.Add(190);
|
||||
sliderControl.Ticks.Add(225);
|
||||
sliderControl.Ticks.Add(245);
|
||||
break;
|
||||
}
|
||||
|
||||
case EncodingMode.Mp3CBR:
|
||||
{
|
||||
sliderControl.Minimum = 8;
|
||||
sliderControl.Maximum = 320;
|
||||
sliderControl.SelectionStart = 128;
|
||||
sliderControl.SelectionEnd = 256;
|
||||
sliderControl.Ticks.Clear();
|
||||
sliderControl.Ticks.Add(8);
|
||||
sliderControl.Ticks.Add(16);
|
||||
sliderControl.Ticks.Add(24);
|
||||
sliderControl.Ticks.Add(32);
|
||||
sliderControl.Ticks.Add(40);
|
||||
sliderControl.Ticks.Add(48);
|
||||
sliderControl.Ticks.Add(64);
|
||||
sliderControl.Ticks.Add(80);
|
||||
sliderControl.Ticks.Add(96);
|
||||
sliderControl.Ticks.Add(112);
|
||||
sliderControl.Ticks.Add(128);
|
||||
sliderControl.Ticks.Add(160);
|
||||
sliderControl.Ticks.Add(192);
|
||||
sliderControl.Ticks.Add(224);
|
||||
sliderControl.Ticks.Add(256);
|
||||
sliderControl.Ticks.Add(320);
|
||||
break;
|
||||
}
|
||||
|
||||
case EncodingMode.OggVBR:
|
||||
{
|
||||
sliderControl.Minimum = 32;
|
||||
sliderControl.Maximum = 500;
|
||||
sliderControl.SelectionStart = 80;
|
||||
sliderControl.SelectionEnd = 192;
|
||||
sliderControl.Ticks.Clear();
|
||||
sliderControl.Ticks.Add(32);
|
||||
sliderControl.Ticks.Add(48);
|
||||
sliderControl.Ticks.Add(64);
|
||||
sliderControl.Ticks.Add(80);
|
||||
sliderControl.Ticks.Add(96);
|
||||
sliderControl.Ticks.Add(112);
|
||||
sliderControl.Ticks.Add(128);
|
||||
sliderControl.Ticks.Add(160);
|
||||
sliderControl.Ticks.Add(192);
|
||||
sliderControl.Ticks.Add(224);
|
||||
sliderControl.Ticks.Add(256);
|
||||
sliderControl.Ticks.Add(320);
|
||||
sliderControl.Ticks.Add(500);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
encodingQualitySliderControl.CoerceValue(EncodingQualitySliderControl.BitrateProperty);
|
||||
}
|
||||
|
||||
private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
||||
{
|
||||
if (this.Bitrate == e.NewValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.SetCurrentValue(EncodingQualitySliderControl.BitrateProperty, e.NewValue);
|
||||
}
|
||||
|
||||
private double GetNearestTickValue(double value)
|
||||
{
|
||||
double minimumDifference = float.PositiveInfinity;
|
||||
double nearestTick = value;
|
||||
for (int index = 0; index < this.slider.Ticks.Count; index++)
|
||||
{
|
||||
double tick = this.slider.Ticks[index];
|
||||
double difference = System.Math.Abs(value - tick);
|
||||
if (difference < minimumDifference)
|
||||
{
|
||||
minimumDifference = difference;
|
||||
nearestTick = tick;
|
||||
}
|
||||
}
|
||||
|
||||
return nearestTick;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,265 +0,0 @@
|
||||
// <copyright file="ConversionJob.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
public class ConversionJob : INotifyPropertyChanged
|
||||
{
|
||||
private readonly Regex durationRegex = new Regex(@"Duration:\s*([0-9][0-9]):([0-9][0-9]):([0-9][0-9])\.([0-9][0-9]),.*bitrate:\s*([0-9]+) kb\/s");
|
||||
private readonly Regex progressRegex = new Regex(@"size=\s*([0-9]+)kB\s+time=([0-9][0-9]):([0-9][0-9]):([0-9][0-9]).([0-9][0-9])\s+bitrate=\s*([0-9]+.[0-9])kbits\/s");
|
||||
|
||||
private TimeSpan fileDuration;
|
||||
private TimeSpan actualConvertedDuration;
|
||||
|
||||
private ProcessStartInfo ffmpegProcessStartInfo;
|
||||
|
||||
private float progress;
|
||||
|
||||
private ConversionState state;
|
||||
|
||||
private string exitingMessage;
|
||||
|
||||
public ConversionJob()
|
||||
{
|
||||
this.OutputType = OutputType.None;
|
||||
this.progress = 0f;
|
||||
this.InputFilePath = string.Empty;
|
||||
this.OutputFilePath = string.Empty;
|
||||
this.State = ConversionState.Unknown;
|
||||
this.ExitingMessage = string.Empty;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public enum ConversionState
|
||||
{
|
||||
Unknown,
|
||||
|
||||
Ready,
|
||||
InProgress,
|
||||
Done,
|
||||
Failed,
|
||||
}
|
||||
|
||||
public string InputFilePath
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public string OutputFilePath
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public OutputType OutputType
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ConversionState State
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.state;
|
||||
}
|
||||
|
||||
private set
|
||||
{
|
||||
this.state = value;
|
||||
this.NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.progress;
|
||||
}
|
||||
|
||||
private set
|
||||
{
|
||||
this.progress = value;
|
||||
this.NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string ExitingMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.exitingMessage;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.exitingMessage = value;
|
||||
this.NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialize(OutputType outputType, string inputFileName, string outputFileName)
|
||||
{
|
||||
if (outputType == OutputType.None)
|
||||
{
|
||||
throw new ArgumentException("The output type must be valid.", "outputType");
|
||||
}
|
||||
|
||||
this.OutputType = outputType;
|
||||
this.ffmpegProcessStartInfo = null;
|
||||
|
||||
string applicationDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
string ffmpegPath = string.Format("{0}\\ffmpeg.exe", applicationDirectory);
|
||||
if (!System.IO.File.Exists(ffmpegPath))
|
||||
{
|
||||
Diagnostics.Log("Can't find ffmpeg executable ({0}). Try to reinstall the application.", ffmpegPath);
|
||||
return;
|
||||
}
|
||||
|
||||
this.ffmpegProcessStartInfo = new ProcessStartInfo(ffmpegPath);
|
||||
|
||||
this.ffmpegProcessStartInfo.CreateNoWindow = true;
|
||||
this.ffmpegProcessStartInfo.UseShellExecute = false;
|
||||
this.ffmpegProcessStartInfo.RedirectStandardOutput = true;
|
||||
this.ffmpegProcessStartInfo.RedirectStandardError = true;
|
||||
|
||||
this.InputFilePath = inputFileName;
|
||||
this.OutputFilePath = outputFileName;
|
||||
|
||||
this.State = ConversionState.Ready;
|
||||
}
|
||||
|
||||
public void StartConvertion()
|
||||
{
|
||||
if (this.OutputType == OutputType.None)
|
||||
{
|
||||
throw new Exception("The converter is not initialized.");
|
||||
}
|
||||
|
||||
Diagnostics.Log("Convert file {0} to {1}.", this.InputFilePath, this.OutputFilePath);
|
||||
|
||||
string arguments = string.Empty;
|
||||
switch (this.OutputType)
|
||||
{
|
||||
case OutputType.Mp3:
|
||||
arguments = string.Format("-n -stats -i \"{0}\" -qscale:a 5 \"{1}\"", this.InputFilePath, this.OutputFilePath);
|
||||
break;
|
||||
|
||||
case OutputType.Ogg:
|
||||
arguments = string.Format("-n -stats -i \"{0}\" -acodec libvorbis -qscale:a 5 \"{1}\"", this.InputFilePath, this.OutputFilePath);
|
||||
break;
|
||||
|
||||
case OutputType.Flac:
|
||||
arguments = string.Format("-n -stats -i \"{0}\" \"{1}\"", this.InputFilePath, this.OutputFilePath);
|
||||
break;
|
||||
|
||||
case OutputType.Wav:
|
||||
arguments = string.Format("-n -stats -i \"{0}\" \"{1}\"", this.InputFilePath, this.OutputFilePath);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException("Converter not implemented for output file type " + this.OutputType);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(arguments) || this.ffmpegProcessStartInfo == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.State = ConversionState.InProgress;
|
||||
|
||||
try
|
||||
{
|
||||
Diagnostics.Log(string.Empty);
|
||||
this.ffmpegProcessStartInfo.Arguments = arguments;
|
||||
Diagnostics.Log("Execute command: {0} {1}.", this.ffmpegProcessStartInfo.FileName, this.ffmpegProcessStartInfo.Arguments);
|
||||
using (Process exeProcess = Process.Start(this.ffmpegProcessStartInfo))
|
||||
{
|
||||
using (StreamReader reader = exeProcess.StandardError)
|
||||
{
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
string result = reader.ReadLine();
|
||||
|
||||
this.ParseFFMPEGOutput(result);
|
||||
|
||||
Diagnostics.Log("ffmpeg output: {0}", result);
|
||||
}
|
||||
}
|
||||
|
||||
exeProcess.WaitForExit();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
this.State = ConversionState.Failed;
|
||||
throw;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(this.ExitingMessage))
|
||||
{
|
||||
this.State = ConversionState.Failed;
|
||||
return;
|
||||
}
|
||||
|
||||
this.Progress = 1f;
|
||||
this.State = ConversionState.Done;
|
||||
|
||||
Diagnostics.Log("\nDone!");
|
||||
}
|
||||
|
||||
private void ParseFFMPEGOutput(string input)
|
||||
{
|
||||
Match match = this.durationRegex.Match(input);
|
||||
if (match.Success && match.Groups.Count >= 6)
|
||||
{
|
||||
int hours = int.Parse(match.Groups[1].Value);
|
||||
int minutes = int.Parse(match.Groups[2].Value);
|
||||
int seconds = int.Parse(match.Groups[3].Value);
|
||||
int milliseconds = int.Parse(match.Groups[4].Value);
|
||||
float bitrate = float.Parse(match.Groups[5].Value);
|
||||
this.fileDuration = new TimeSpan(0, hours, minutes, seconds, milliseconds);
|
||||
return;
|
||||
}
|
||||
|
||||
match = this.progressRegex.Match(input);
|
||||
if (match.Success && match.Groups.Count >= 7)
|
||||
{
|
||||
int size = int.Parse(match.Groups[1].Value);
|
||||
int hours = int.Parse(match.Groups[2].Value);
|
||||
int minutes = int.Parse(match.Groups[3].Value);
|
||||
int seconds = int.Parse(match.Groups[4].Value);
|
||||
int milliseconds = int.Parse(match.Groups[5].Value);
|
||||
float bitrate = 0f;
|
||||
float.TryParse(match.Groups[6].Value, out bitrate);
|
||||
|
||||
this.actualConvertedDuration = new TimeSpan(0, hours, minutes, seconds, milliseconds);
|
||||
|
||||
this.Progress = this.actualConvertedDuration.Ticks / (float)this.fileDuration.Ticks;
|
||||
return;
|
||||
}
|
||||
|
||||
if (input.Contains("Exiting."))
|
||||
{
|
||||
this.ExitingMessage = input;
|
||||
}
|
||||
}
|
||||
|
||||
private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
|
||||
{
|
||||
if (this.PropertyChanged != null)
|
||||
{
|
||||
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
// <copyright file="ConversionJob.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ConversionJobs
|
||||
{
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
public class ConversionJob : INotifyPropertyChanged
|
||||
{
|
||||
private float progress = 0f;
|
||||
private ConversionState state = ConversionState.Unknown;
|
||||
private string errorMessage = string.Empty;
|
||||
private string initialInputPath = string.Empty;
|
||||
|
||||
public ConversionJob()
|
||||
{
|
||||
this.State = ConversionState.Unknown;
|
||||
this.ConversionPreset = null;
|
||||
this.InputFilePath = string.Empty;
|
||||
}
|
||||
|
||||
public ConversionJob(ConversionPreset conversionPreset) : this()
|
||||
{
|
||||
if (conversionPreset == null)
|
||||
{
|
||||
throw new ArgumentNullException("conversionPreset");
|
||||
}
|
||||
|
||||
this.ConversionPreset = conversionPreset;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public enum ConversionState
|
||||
{
|
||||
Unknown,
|
||||
|
||||
Ready,
|
||||
InProgress,
|
||||
Done,
|
||||
Failed,
|
||||
}
|
||||
|
||||
public ConversionPreset ConversionPreset
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public string InputFilePath
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public string OutputFilePath
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public ConversionState State
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.state;
|
||||
}
|
||||
|
||||
private set
|
||||
{
|
||||
this.state = value;
|
||||
this.NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.progress;
|
||||
}
|
||||
|
||||
protected set
|
||||
{
|
||||
this.progress = value;
|
||||
this.NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string ErrorMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.errorMessage;
|
||||
}
|
||||
|
||||
private set
|
||||
{
|
||||
this.errorMessage = value;
|
||||
this.NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void PrepareConversion(string inputFilePath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(inputFilePath))
|
||||
{
|
||||
throw new ArgumentNullException("inputFilePath");
|
||||
}
|
||||
|
||||
if (this.ConversionPreset == null)
|
||||
{
|
||||
throw new Exception("The conversion preset must be valid.");
|
||||
}
|
||||
|
||||
this.initialInputPath = inputFilePath;
|
||||
this.InputFilePath = inputFilePath;
|
||||
this.OutputFilePath = this.ConversionPreset.GenerateOutputFilePath(inputFilePath);
|
||||
|
||||
if (!PathHelpers.IsPathValid(this.OutputFilePath))
|
||||
{
|
||||
this.ConvertionFailed("Invalid output path generated by output file path template.");
|
||||
Diagnostics.Log(string.Format("Invalid output path generated: {0} from input: {1}.", this.OutputFilePath, this.InputFilePath));
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.OutputFilePath == this.InputFilePath)
|
||||
{
|
||||
// If the input post conversion action is to move or delete the input file, change its name in order to keep the output name intact.
|
||||
if (this.ConversionPreset.InputPostConversionAction == InputPostConversionAction.MoveInArchiveFolder ||
|
||||
this.ConversionPreset.InputPostConversionAction == InputPostConversionAction.Delete)
|
||||
{
|
||||
string inputExtension = System.IO.Path.GetExtension(this.InputFilePath);
|
||||
string pathWithoutExtension = this.InputFilePath.Substring(0, this.InputFilePath.Length - inputExtension.Length);
|
||||
this.InputFilePath = PathHelpers.GenerateUniquePath(pathWithoutExtension + "_TEMP" + inputExtension);
|
||||
System.IO.File.Move(inputFilePath, this.InputFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
// Create output folder that doesn't exist.
|
||||
{
|
||||
StringBuilder path = new StringBuilder(this.OutputFilePath.Length);
|
||||
foreach (string directory in PathHelpers.GetDirectories(this.OutputFilePath))
|
||||
{
|
||||
path.Append(directory);
|
||||
path.Append('\\');
|
||||
|
||||
if (!System.IO.Directory.Exists(path.ToString()))
|
||||
{
|
||||
try
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(path.ToString());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
this.ConvertionFailed("Invalid output path generated by output file path template.");
|
||||
Diagnostics.Log(string.Format("Can't create directories for path {0}", this.OutputFilePath));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make the output path valid.
|
||||
try
|
||||
{
|
||||
this.OutputFilePath = PathHelpers.GenerateUniquePath(this.OutputFilePath);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
this.ConvertionFailed("Can't generate a valid output filename.");
|
||||
Diagnostics.Log(exception.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
this.Initialize();
|
||||
|
||||
if (this.State == ConversionState.Unknown)
|
||||
{
|
||||
this.State = ConversionState.Ready;
|
||||
}
|
||||
}
|
||||
|
||||
public void StartConvertion()
|
||||
{
|
||||
if (this.ConversionPreset == null)
|
||||
{
|
||||
throw new Exception("The conversion preset must be valid.");
|
||||
}
|
||||
|
||||
if (this.State != ConversionState.Ready)
|
||||
{
|
||||
throw new Exception("Invalid conversion state.");
|
||||
}
|
||||
|
||||
Diagnostics.Log("Convert file {0} to {1}.", this.InputFilePath, this.OutputFilePath);
|
||||
|
||||
this.State = ConversionState.InProgress;
|
||||
|
||||
this.Convert();
|
||||
|
||||
if (this.State != ConversionState.Failed)
|
||||
{
|
||||
this.OnConversionSucceed();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Convert()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void OnConversionSucceed()
|
||||
{
|
||||
Diagnostics.Log("Conversion Succeed!");
|
||||
|
||||
// Apply the input post conversion action.
|
||||
switch (this.ConversionPreset.InputPostConversionAction)
|
||||
{
|
||||
case InputPostConversionAction.None:
|
||||
break;
|
||||
|
||||
case InputPostConversionAction.MoveInArchiveFolder:
|
||||
string basePath = System.IO.Path.GetDirectoryName(this.initialInputPath);
|
||||
string inputFilename = System.IO.Path.GetFileName(this.initialInputPath);
|
||||
string archivePath = basePath + "\\" + this.ConversionPreset.ConversionArchiveFolderName;
|
||||
if (!System.IO.Directory.Exists(archivePath))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(archivePath);
|
||||
}
|
||||
|
||||
string newPath = PathHelpers.GenerateUniquePath(archivePath + "\\" + inputFilename);
|
||||
System.IO.File.Move(this.InputFilePath, newPath);
|
||||
Diagnostics.Log("Input file moved in archive folder: '{0}'", newPath);
|
||||
break;
|
||||
|
||||
case InputPostConversionAction.Delete:
|
||||
System.IO.File.Delete(this.InputFilePath);
|
||||
Diagnostics.Log("Input file deleted: '{0}'", this.initialInputPath);
|
||||
break;
|
||||
}
|
||||
|
||||
Diagnostics.Log(string.Empty);
|
||||
|
||||
this.Progress = 1f;
|
||||
this.State = ConversionState.Done;
|
||||
Diagnostics.Log("Conversion Done!");
|
||||
}
|
||||
|
||||
protected void ConvertionFailed(string exitingMessage)
|
||||
{
|
||||
this.State = ConversionState.Failed;
|
||||
this.ErrorMessage = exitingMessage;
|
||||
}
|
||||
|
||||
protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
|
||||
{
|
||||
if (this.PropertyChanged != null)
|
||||
{
|
||||
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// <copyright file="ConversionJobFactory.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ConversionJobs
|
||||
{
|
||||
public static class ConversionJobFactory
|
||||
{
|
||||
public static ConversionJob Create(ConversionPreset conversionPreset)
|
||||
{
|
||||
ConversionJob conversionJob = new ConversionJob_FFMPEG(conversionPreset);
|
||||
|
||||
return conversionJob;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
// <copyright file="ConversionJob_FFMPEG.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ConversionJobs
|
||||
{
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
public class ConversionJob_FFMPEG : ConversionJob
|
||||
{
|
||||
private readonly Regex durationRegex = new Regex(@"Duration:\s*([0-9][0-9]):([0-9][0-9]):([0-9][0-9])\.([0-9][0-9]),.*bitrate:\s*([0-9]+) kb\/s");
|
||||
private readonly Regex progressRegex = new Regex(@"size=\s*([0-9]+)kB\s+time=([0-9][0-9]):([0-9][0-9]):([0-9][0-9]).([0-9][0-9])\s+bitrate=\s*([0-9]+.[0-9])kbits\/s");
|
||||
|
||||
private TimeSpan fileDuration;
|
||||
private TimeSpan actualConvertedDuration;
|
||||
|
||||
private ProcessStartInfo ffmpegProcessStartInfo;
|
||||
|
||||
public ConversionJob_FFMPEG() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public ConversionJob_FFMPEG(ConversionPreset conversionPreset) : base(conversionPreset)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
if (this.ConversionPreset == null)
|
||||
{
|
||||
throw new Exception("The conversion preset must be valid.");
|
||||
}
|
||||
|
||||
this.ffmpegProcessStartInfo = null;
|
||||
|
||||
string applicationDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
string ffmpegPath = string.Format("{0}\\ffmpeg.exe", applicationDirectory);
|
||||
if (!System.IO.File.Exists(ffmpegPath))
|
||||
{
|
||||
this.ConvertionFailed("Can't find ffmpeg executable. You should try to reinstall the application.");
|
||||
Diagnostics.Log("Can't find ffmpeg executable ({0}). Try to reinstall the application.", ffmpegPath);
|
||||
return;
|
||||
}
|
||||
|
||||
this.ffmpegProcessStartInfo = new ProcessStartInfo(ffmpegPath);
|
||||
|
||||
this.ffmpegProcessStartInfo.CreateNoWindow = true;
|
||||
this.ffmpegProcessStartInfo.UseShellExecute = false;
|
||||
this.ffmpegProcessStartInfo.RedirectStandardOutput = true;
|
||||
this.ffmpegProcessStartInfo.RedirectStandardError = true;
|
||||
|
||||
string arguments = string.Empty;
|
||||
switch (this.ConversionPreset.OutputType)
|
||||
{
|
||||
case OutputType.Wav:
|
||||
{
|
||||
EncodingMode encodingMode = this.ConversionPreset.GetSettingsValue<EncodingMode>("Encoding");
|
||||
string encoderArgs = string.Format("-acodec {0}", this.WAVEncodingToCodecArgument(encodingMode));
|
||||
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Mp3:
|
||||
{
|
||||
string encoderArgs = string.Empty;
|
||||
EncodingMode encodingMode = this.ConversionPreset.GetSettingsValue<EncodingMode>("Encoding");
|
||||
int encodingQuality = this.ConversionPreset.GetSettingsValue<int>("Bitrate");
|
||||
switch (encodingMode)
|
||||
{
|
||||
case EncodingMode.Mp3VBR:
|
||||
encoderArgs = string.Format("-codec:a libmp3lame -q:a {0}", this.MP3VBRBitrateToQualityIndex(encodingQuality));
|
||||
break;
|
||||
|
||||
case EncodingMode.Mp3CBR:
|
||||
encoderArgs = string.Format("-codec:a libmp3lame -b:a {0}k", encodingQuality);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Ogg:
|
||||
{
|
||||
int encodingQuality = this.ConversionPreset.GetSettingsValue<int>("Bitrate");
|
||||
string encoderArgs = string.Format("-codec:a libvorbis -qscale:a {0}", this.OGGVBRBitrateToQualityIndex(encodingQuality));
|
||||
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Flac:
|
||||
arguments = string.Format("-n -stats -i \"{0}\" \"{1}\"", this.InputFilePath, this.OutputFilePath);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException("Converter not implemented for output file type " + this.ConversionPreset.OutputType);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(arguments))
|
||||
{
|
||||
throw new Exception("Invalid ffmpeg process arguments.");
|
||||
}
|
||||
|
||||
this.ffmpegProcessStartInfo.Arguments = arguments;
|
||||
}
|
||||
|
||||
protected override void Convert()
|
||||
{
|
||||
if (this.ConversionPreset == null)
|
||||
{
|
||||
throw new Exception("The conversion preset must be valid.");
|
||||
}
|
||||
|
||||
Diagnostics.Log("Convert file {0} to {1}.", this.InputFilePath, this.OutputFilePath);
|
||||
Diagnostics.Log(string.Empty);
|
||||
Diagnostics.Log("Execute command: {0} {1}.", this.ffmpegProcessStartInfo.FileName, this.ffmpegProcessStartInfo.Arguments);
|
||||
|
||||
try
|
||||
{
|
||||
using (Process exeProcess = Process.Start(this.ffmpegProcessStartInfo))
|
||||
{
|
||||
using (StreamReader reader = exeProcess.StandardError)
|
||||
{
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
string result = reader.ReadLine();
|
||||
|
||||
this.ParseFFMPEGOutput(result);
|
||||
|
||||
Diagnostics.Log("ffmpeg output: {0}", result);
|
||||
}
|
||||
}
|
||||
|
||||
exeProcess.WaitForExit();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
this.ConvertionFailed("Failed to launch FFMPEG process.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private int MP3VBRBitrateToQualityIndex(int bitrate)
|
||||
{
|
||||
switch (bitrate)
|
||||
{
|
||||
case 245:
|
||||
return 0;
|
||||
|
||||
case 225:
|
||||
return 1;
|
||||
|
||||
case 190:
|
||||
return 2;
|
||||
|
||||
case 175:
|
||||
return 3;
|
||||
|
||||
case 165:
|
||||
return 4;
|
||||
|
||||
case 130:
|
||||
return 5;
|
||||
|
||||
case 115:
|
||||
return 6;
|
||||
|
||||
case 100:
|
||||
return 7;
|
||||
|
||||
case 85:
|
||||
return 8;
|
||||
|
||||
case 65:
|
||||
return 9;
|
||||
}
|
||||
|
||||
throw new Exception("Unknown VBR bitrate.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert bitrate in <c>vorbis</c> encoder quality index.
|
||||
/// </summary>
|
||||
/// <param name="bitrate">Wanted bitrate value.</param>
|
||||
/// <returns>The <c>vorbis</c> encoder quality index associated to the given bitrate value.</returns>
|
||||
/// http://wiki.hydrogenaud.io/index.php?title=Recommended_Ogg_Vorbis
|
||||
private int OGGVBRBitrateToQualityIndex(int bitrate)
|
||||
{
|
||||
switch (bitrate)
|
||||
{
|
||||
case 500:
|
||||
return 10;
|
||||
|
||||
case 320:
|
||||
return 9;
|
||||
|
||||
case 256:
|
||||
return 8;
|
||||
|
||||
case 224:
|
||||
return 7;
|
||||
|
||||
case 192:
|
||||
return 6;
|
||||
|
||||
case 160:
|
||||
return 5;
|
||||
|
||||
case 128:
|
||||
return 4;
|
||||
|
||||
case 112:
|
||||
return 3;
|
||||
|
||||
case 96:
|
||||
return 2;
|
||||
|
||||
case 80:
|
||||
return 1;
|
||||
|
||||
case 64:
|
||||
return 0;
|
||||
|
||||
case 48:
|
||||
return -1;
|
||||
|
||||
case 32:
|
||||
return -2;
|
||||
}
|
||||
|
||||
throw new Exception("Unknown VBR bitrate.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert encoding mode setting to <c>ffmpeg</c> argument option.
|
||||
/// </summary>
|
||||
/// <param name="encoding">The encoding mode setting.</param>
|
||||
/// <returns>Returns the <c>ffmpeg</c> argument corresponding to the given encoding mode.</returns>
|
||||
/// https://trac.ffmpeg.org/wiki/audio%20types
|
||||
private string WAVEncodingToCodecArgument(EncodingMode encoding)
|
||||
{
|
||||
switch (encoding)
|
||||
{
|
||||
case EncodingMode.Wav8:
|
||||
return "pcm_s8le";
|
||||
|
||||
case EncodingMode.Wav16:
|
||||
return "pcm_s16le";
|
||||
|
||||
case EncodingMode.Wav24:
|
||||
return "pcm_s24le";
|
||||
|
||||
case EncodingMode.Wav32:
|
||||
return "pcm_s32le";
|
||||
}
|
||||
|
||||
throw new Exception("Unknown Wav encoding.");
|
||||
}
|
||||
|
||||
private void ParseFFMPEGOutput(string input)
|
||||
{
|
||||
Match match = this.durationRegex.Match(input);
|
||||
if (match.Success && match.Groups.Count >= 6)
|
||||
{
|
||||
int hours = int.Parse(match.Groups[1].Value);
|
||||
int minutes = int.Parse(match.Groups[2].Value);
|
||||
int seconds = int.Parse(match.Groups[3].Value);
|
||||
int milliseconds = int.Parse(match.Groups[4].Value);
|
||||
float bitrate = float.Parse(match.Groups[5].Value);
|
||||
this.fileDuration = new TimeSpan(0, hours, minutes, seconds, milliseconds);
|
||||
return;
|
||||
}
|
||||
|
||||
match = this.progressRegex.Match(input);
|
||||
if (match.Success && match.Groups.Count >= 7)
|
||||
{
|
||||
int size = int.Parse(match.Groups[1].Value);
|
||||
int hours = int.Parse(match.Groups[2].Value);
|
||||
int minutes = int.Parse(match.Groups[3].Value);
|
||||
int seconds = int.Parse(match.Groups[4].Value);
|
||||
int milliseconds = int.Parse(match.Groups[5].Value);
|
||||
float bitrate = 0f;
|
||||
float.TryParse(match.Groups[6].Value, out bitrate);
|
||||
|
||||
this.actualConvertedDuration = new TimeSpan(0, hours, minutes, seconds, milliseconds);
|
||||
|
||||
this.Progress = this.actualConvertedDuration.Ticks / (float)this.fileDuration.Ticks;
|
||||
return;
|
||||
}
|
||||
|
||||
if (input.Contains("Exiting."))
|
||||
{
|
||||
this.ConvertionFailed(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,511 @@
|
||||
// <copyright file="ConversionPreset.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
using FileConverter.Annotations;
|
||||
using FileConverter.ValueConverters;
|
||||
|
||||
[XmlRoot]
|
||||
[XmlType]
|
||||
public class ConversionPreset : INotifyPropertyChanged, IDataErrorInfo, IXmlSerializable
|
||||
{
|
||||
private string name;
|
||||
private OutputType outputType;
|
||||
private List<string> inputTypes;
|
||||
private InputPostConversionAction inputPostConversionAction;
|
||||
private ConversionSettings settings = new ConversionSettings();
|
||||
private string outputFileNameTemplate;
|
||||
private FileNameConverter outputFileNameConverter = new FileNameConverter();
|
||||
|
||||
public ConversionPreset()
|
||||
{
|
||||
this.Name = "New Preset";
|
||||
}
|
||||
|
||||
public ConversionPreset(string name, OutputType outputType, string[] inputTypes)
|
||||
{
|
||||
this.Name = name;
|
||||
this.OutputType = outputType;
|
||||
List<string> inputTypeList = new List<string>();
|
||||
inputTypeList.AddRange(inputTypes);
|
||||
this.InputTypes = inputTypeList;
|
||||
|
||||
this.outputFileNameTemplate = "(p)(f)";
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[XmlAttribute]
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.name = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public OutputType OutputType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.outputType;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.outputType = value;
|
||||
this.InitializeDefaultSettings(this.outputType);
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[XmlElement]
|
||||
public List<string> InputTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.inputTypes;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.inputTypes = value;
|
||||
for (int index = 0; index < this.inputTypes.Count; index++)
|
||||
{
|
||||
this.inputTypes[index] = this.inputTypes[index].ToLowerInvariant();
|
||||
}
|
||||
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[XmlElement]
|
||||
public InputPostConversionAction InputPostConversionAction
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.inputPostConversionAction;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.inputPostConversionAction = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[XmlElement("Settings")]
|
||||
public ConversionSetting[] XmlSerializableSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
int index = 0;
|
||||
ConversionSetting[] settings = new ConversionSetting[this.settings.Count];
|
||||
foreach (KeyValuePair<string, string> keyValuePair in this.settings)
|
||||
{
|
||||
settings[index] = new ConversionSetting(keyValuePair);
|
||||
index++;
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
for (int index = 0; index < value.Length; index++)
|
||||
{
|
||||
this.SetSettingsValue(value[index].Key, value[index].Value);
|
||||
}
|
||||
}
|
||||
|
||||
this.OnPropertyChanged("Settings");
|
||||
}
|
||||
}
|
||||
|
||||
[XmlElement]
|
||||
public string OutputFileNameTemplate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.outputFileNameTemplate;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.outputFileNameTemplate = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public string ConversionArchiveFolderName
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Conversion Archives";
|
||||
}
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public IConversionSettings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<string, string> conversionSetting in value)
|
||||
{
|
||||
if (!this.settings.ContainsKey(conversionSetting.Key))
|
||||
{
|
||||
this.settings.Add(conversionSetting.Key, conversionSetting.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.settings[conversionSetting.Key] = conversionSetting.Value;
|
||||
}
|
||||
}
|
||||
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string Error
|
||||
{
|
||||
get
|
||||
{
|
||||
string errorString = this.Validate("Name");
|
||||
if (!string.IsNullOrEmpty(errorString))
|
||||
{
|
||||
return errorString;
|
||||
}
|
||||
|
||||
errorString = this.Validate("OutputFileNameTemplate");
|
||||
if (!string.IsNullOrEmpty(errorString))
|
||||
{
|
||||
return errorString;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public string this[string columnName]
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Validate(columnName);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDeserializationComplete()
|
||||
{
|
||||
for (int index = 0; index < this.InputTypes.Count; index++)
|
||||
{
|
||||
this.InputTypes[index] = this.InputTypes[index].ToLowerInvariant();
|
||||
}
|
||||
}
|
||||
|
||||
public void AddInputType(string inputType)
|
||||
{
|
||||
if (this.inputTypes.Contains(inputType))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.inputTypes.Add(inputType);
|
||||
this.OnPropertyChanged("InputTypes");
|
||||
}
|
||||
|
||||
public void RemoveInputType(string inputType)
|
||||
{
|
||||
if (this.inputTypes.Remove(inputType))
|
||||
{
|
||||
this.OnPropertyChanged("InputTypes");
|
||||
}
|
||||
}
|
||||
|
||||
public string GenerateOutputFilePath(string inputFilePath)
|
||||
{
|
||||
return (string)this.outputFileNameConverter.Convert(new object[] { inputFilePath, this.OutputType, this.OutputFileNameTemplate }, typeof(string), null, null);
|
||||
}
|
||||
|
||||
public void SetSettingsValue(string settingsKey, string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(settingsKey))
|
||||
{
|
||||
throw new ArgumentNullException("key");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
throw new ArgumentNullException("value");
|
||||
}
|
||||
|
||||
if (!this.IsRelevantSetting(settingsKey))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.settings.ContainsKey(settingsKey))
|
||||
{
|
||||
this.settings.Add(settingsKey, value);
|
||||
}
|
||||
|
||||
this.settings[settingsKey] = value;
|
||||
|
||||
this.OnPropertyChanged("Settings");
|
||||
}
|
||||
|
||||
public string GetSettingsValue(string settingsKey)
|
||||
{
|
||||
if (string.IsNullOrEmpty(settingsKey))
|
||||
{
|
||||
throw new ArgumentNullException("key");
|
||||
}
|
||||
|
||||
if (this.settings.ContainsKey(settingsKey))
|
||||
{
|
||||
return this.settings[settingsKey];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public T GetSettingsValue<T>(string settingsKey)
|
||||
{
|
||||
string settingsValue = this.GetSettingsValue(settingsKey);
|
||||
|
||||
Type type = typeof(T);
|
||||
if (type.IsEnum)
|
||||
{
|
||||
return (T)System.Enum.Parse(type, settingsValue);
|
||||
}
|
||||
|
||||
return (T)System.Convert.ChangeType(settingsValue, type);
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private bool IsRelevantSetting(string settingsKey)
|
||||
{
|
||||
switch (this.OutputType)
|
||||
{
|
||||
case OutputType.Wav:
|
||||
switch (settingsKey)
|
||||
{
|
||||
case "Encoding":
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Mp3:
|
||||
switch (settingsKey)
|
||||
{
|
||||
case "Encoding":
|
||||
case "Bitrate":
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Ogg:
|
||||
switch (settingsKey)
|
||||
{
|
||||
case "Bitrate":
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void InitializeDefaultSettings(OutputType outputType)
|
||||
{
|
||||
if (outputType == OutputType.Wav)
|
||||
{
|
||||
this.InitializeSettingsValue("Encoding", "Wav16");
|
||||
}
|
||||
|
||||
if (outputType == OutputType.Mp3)
|
||||
{
|
||||
this.InitializeSettingsValue("Encoding", EncodingMode.Mp3VBR.ToString());
|
||||
this.InitializeSettingsValue("Bitrate", "190");
|
||||
}
|
||||
|
||||
if (outputType == OutputType.Ogg)
|
||||
{
|
||||
this.InitializeSettingsValue("Bitrate", "160");
|
||||
}
|
||||
|
||||
this.OnPropertyChanged("Settings");
|
||||
}
|
||||
|
||||
private void InitializeSettingsValue(string settingsKey, string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(settingsKey))
|
||||
{
|
||||
throw new ArgumentNullException("key");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
throw new ArgumentNullException("value");
|
||||
}
|
||||
|
||||
if (!this.settings.ContainsKey(settingsKey))
|
||||
{
|
||||
this.settings.Add(settingsKey, value);
|
||||
}
|
||||
}
|
||||
|
||||
private string Validate(string propertyName)
|
||||
{
|
||||
// Return error message if there is an error, else return empty or null string.
|
||||
switch (propertyName)
|
||||
{
|
||||
case "Name":
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.Name))
|
||||
{
|
||||
return "The preset name can't be empty.";
|
||||
}
|
||||
|
||||
if (this.Name.Contains(";"))
|
||||
{
|
||||
return "The preset name can't contains the character ';'.";
|
||||
}
|
||||
|
||||
Application application = Application.Current as Application;
|
||||
int? count = application?.Settings?.ConversionPresets?.Count(match => match?.name == this.Name);
|
||||
if (count > 1)
|
||||
{
|
||||
return "The preset name is already used.";
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "OutputFileNameTemplate":
|
||||
{
|
||||
string sampleOutputFilePath = this.GenerateOutputFilePath(FileConverter.Properties.Resources.OuputFileNameTemplateSample);
|
||||
if (string.IsNullOrEmpty(sampleOutputFilePath))
|
||||
{
|
||||
return "The output filename template must produce a non empty result.";
|
||||
}
|
||||
|
||||
if (!PathHelpers.IsPathValid(sampleOutputFilePath))
|
||||
{
|
||||
// Diagnostic to feedback purpose.
|
||||
// Drive letter.
|
||||
if (!PathHelpers.IsPathDriveLetterValid(sampleOutputFilePath))
|
||||
{
|
||||
return "The output filename template must define a root (for example c:\\, use (p) to use the input file path).";
|
||||
}
|
||||
|
||||
// File name.
|
||||
string filename = PathHelpers.GetFileName(sampleOutputFilePath);
|
||||
if (filename == null)
|
||||
{
|
||||
return "The output file name must not be empty (use (f) to use the name of the input file).";
|
||||
}
|
||||
|
||||
char[] invalidFileNameChars = System.IO.Path.GetInvalidFileNameChars();
|
||||
for (int index = 0; index < invalidFileNameChars.Length; index++)
|
||||
{
|
||||
if (filename.Contains(invalidFileNameChars[index]))
|
||||
{
|
||||
return "The output file name must not contains the character '" + invalidFileNameChars[index] + "'.";
|
||||
}
|
||||
}
|
||||
|
||||
// Directory names.
|
||||
string path = sampleOutputFilePath.Substring(3, sampleOutputFilePath.Length - 3 - filename.Length);
|
||||
char[] invalidPathChars = System.IO.Path.GetInvalidPathChars();
|
||||
for (int index = 0; index < invalidPathChars.Length; index++)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return "The output directory name must not be empty (use (d0), (d1), ... to use the name of the parent directories of the input file).";
|
||||
}
|
||||
|
||||
if (path.Contains(invalidPathChars[index]))
|
||||
{
|
||||
return "The output directory name must not contains the character '" + invalidPathChars[index] + "'.";
|
||||
}
|
||||
}
|
||||
|
||||
string[] directories = path.Split('\\');
|
||||
for (int index = 0; index < directories.Length; ++index)
|
||||
{
|
||||
string directoryName = directories[index];
|
||||
if (string.IsNullOrEmpty(directoryName))
|
||||
{
|
||||
return "The output directory name must not be empty (use (d0), (d1), ... to use the name of the parent directories of the input file).";
|
||||
}
|
||||
}
|
||||
|
||||
return "The output filename template is invalid";
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public struct ConversionSetting
|
||||
{
|
||||
public ConversionSetting(KeyValuePair<string, string> keyValuePair)
|
||||
{
|
||||
this.Key = keyValuePair.Key;
|
||||
this.Value = keyValuePair.Value;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public string Key
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public string Value
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// <copyright file="ConversionSettings.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class ConversionSettings : Dictionary<string, string>, IConversionSettings
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
// <copyright file="ConversionSettingsOverride.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public struct ConversionSettingsOverride : IConversionSettings
|
||||
{
|
||||
private string key;
|
||||
private string value;
|
||||
|
||||
public ConversionSettingsOverride(string key, string value)
|
||||
{
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return this.key;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> Values
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
public string this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (key == this.key)
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
throw new KeyNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
|
||||
{
|
||||
yield return new KeyValuePair<string, string>(this.key, this.value);
|
||||
}
|
||||
|
||||
public bool ContainsKey(string key)
|
||||
{
|
||||
return key == this.key;
|
||||
}
|
||||
|
||||
public bool TryGetValue(string key, out string value)
|
||||
{
|
||||
value = null;
|
||||
|
||||
if (key == this.key)
|
||||
{
|
||||
value = this.value;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return this.GetEnumerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// <copyright file="IConversionSettings.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
|
||||
public interface IConversionSettings : IReadOnlyDictionary<string, string>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// <copyright file="EncodingMode.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
public enum EncodingMode
|
||||
{
|
||||
Wav8,
|
||||
Wav16,
|
||||
Wav24,
|
||||
Wav32,
|
||||
|
||||
Mp3VBR,
|
||||
Mp3CBR,
|
||||
|
||||
OggVBR,
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,9 @@
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Resources\ApplicationIcon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Accessibility" />
|
||||
<Reference Include="PresentationUI, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||
@@ -48,7 +51,9 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Printing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
@@ -68,8 +73,58 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Controls\EncodingQualitySliderControl.xaml.cs">
|
||||
<DependentUpon>EncodingQualitySliderControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ConversionJobs\ConversionJobFactory.cs" />
|
||||
<Compile Include="ConversionJobs\ConversionJob_FFMPEG.cs" />
|
||||
<Compile Include="ConversionPreset\ConversionSettingsOverride.cs" />
|
||||
<Compile Include="ConversionPreset\ConversionSettings.cs" />
|
||||
<Compile Include="EncodingMode.cs" />
|
||||
<Compile Include="ConversionPreset\IConversionSettings.cs" />
|
||||
<Compile Include="InputPostConversionAction.cs" />
|
||||
<Compile Include="IXmlSerializable.cs" />
|
||||
<Compile Include="PathHelpers.cs" />
|
||||
<Compile Include="Properties\Resources.en.Designer.cs">
|
||||
<DependentUpon>Resources.en.resx</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<Compile Include="ValueConverters\ApplicationVersionToApplicationName.cs" />
|
||||
<Compile Include="ConversionPreset\ConversionPreset.cs" />
|
||||
<Compile Include="ValueConverters\BitrateToString.cs" />
|
||||
<Compile Include="ValueConverters\FileNameConverter.cs" />
|
||||
<Compile Include="ValueConverters\Generic\BoolToVisibility.cs" />
|
||||
<Compile Include="ValueConverters\ConversionSettingsToString.cs" />
|
||||
<Compile Include="ValueConverters\Generic\BoolInverterConverter.cs" />
|
||||
<Compile Include="ValueConverters\Generic\EqualsConverter.cs" />
|
||||
<Compile Include="ValueConverters\Generic\CollectionContainsElementToBool.cs" />
|
||||
<Compile Include="ValueConverters\Generic\StringToValueType.cs" />
|
||||
<Compile Include="ValueConverters\InputTypesToBool.cs" />
|
||||
<Compile Include="Settings.cs" />
|
||||
<Compile Include="ValueConverters\OutputTypeToVisibility.cs" />
|
||||
<Compile Include="ValueConverters\Generic\StringToEnum.cs" />
|
||||
<Compile Include="ValueConverters\Generic\ValueConverterGroup.cs" />
|
||||
<Compile Include="Windows\DiagnosticsWindow.xaml.cs">
|
||||
<DependentUpon>DiagnosticsWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Windows\ConversionSettingsTemplateSelector.cs" />
|
||||
<Compile Include="Windows\InputExtension.cs" />
|
||||
<Compile Include="Windows\InputExtensionCategory.cs" />
|
||||
<Compile Include="Windows\SettingsWindow.xaml.cs">
|
||||
<DependentUpon>SettingsWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Version.cs" />
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Compile Include="XmlHelpers.cs" />
|
||||
<Page Include="Controls\EncodingQualitySliderControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Windows\DiagnosticsWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Windows\MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
@@ -77,19 +132,26 @@
|
||||
<DependentUpon>Application.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ConversionStateToBrush.cs" />
|
||||
<Compile Include="ConversionJob.cs" />
|
||||
<Compile Include="ValueConverters\ConversionStateToBrush.cs" />
|
||||
<Compile Include="ConversionJobs\ConversionJob.cs" />
|
||||
<Compile Include="Diagnostics.cs" />
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<Compile Include="Windows\MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Page Include="Windows\SettingsWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="OutputType.cs" />
|
||||
<Compile Include="Properties\Annotations.cs" />
|
||||
<Compile Include="Properties\Annotations.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
@@ -101,8 +163,12 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.en.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.en.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="Properties\Settings.settings">
|
||||
@@ -114,8 +180,14 @@
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\ApplicationIcon.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\ApplicationIcon.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
|
||||
@@ -4,5 +4,22 @@
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StyleCop_002ESA1601/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StyleCop_002ESA1602/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SuggestUseVarKeywordEvident/@EntryIndexedValue">DO_NOT_SHOW</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UnusedMember_002ELocal/@EntryIndexedValue">HINT</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/ValueAnalysisMode/@EntryValue">PESSIMISTIC</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ThisQualifier/INSTANCE_MEMBERS_QUALIFY_MEMBERS/@EntryValue">Field, Property, Event, Method</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ABSTRACT_ACCESSORHOLDER_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSOR_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean></wpf:ResourceDictionary>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSOR_ATTRIBUTE_ON_SAME_LINE/@EntryValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSOR_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForBuiltInTypes/@EntryValue">UseExplicitType</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForOtherTypes/@EntryValue">UseExplicitType</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/CSharpVarKeywordUsage/ForSimpleTypes/@EntryValue">UseExplicitType</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderText/@EntryValue">// <copyright file="$FILENAME$" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CBR/@EntryIndexedValue">CBR</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=OGGVBR/@EntryIndexedValue">OGGVBR</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=VBR/@EntryIndexedValue">VBR</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=MethodPropertyEvent/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></s:String>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/UpdatesManger/IsDownloadUpdateDataAllowed/@EntryValue">False</s:Boolean></wpf:ResourceDictionary>
|
||||
@@ -0,0 +1,9 @@
|
||||
// <copyright file="IXmlSerializable.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
public interface IXmlSerializable
|
||||
{
|
||||
void OnDeserializationComplete();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// <copyright file="InputPostConversionAction.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
public enum InputPostConversionAction
|
||||
{
|
||||
None,
|
||||
MoveInArchiveFolder,
|
||||
Delete,
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
<Window
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="FileConverter.MainWindow"
|
||||
xmlns:local="clr-namespace:FileConverter"
|
||||
x:Name="FileConverterMainWindow" Title="{Binding ApplicationName, ElementName=FileConverterMainWindow, Mode=OneWay}" Height="500" Width="950" MinHeight="250" MinWidth="450" WindowStartupLocation="CenterScreen">
|
||||
<Window.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<local:ConversionStateToBrush x:Key="ConversionStateToColor" />
|
||||
</Window.Resources>
|
||||
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="2*" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="100" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Name="Title" Grid.Column="0" Content="Files to convert" VerticalAlignment="Top" Height="30" FontSize="16" FontWeight="Bold"/>
|
||||
<Button Name="SettingsButton" Grid.Column="1" Content="Settings" Margin="0,3" Visibility="Hidden"></Button>
|
||||
</Grid>
|
||||
|
||||
<ScrollViewer x:Name="ScrollViewer" Grid.Row="1" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
|
||||
<ItemsControl Name="ConverterJobsList">
|
||||
<ItemsControl.DataContext>
|
||||
<local:ConversionJob/>
|
||||
</ItemsControl.DataContext>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<DockPanel Background="{Binding State, Converter={StaticResource ConversionStateToColor}, ConverterParameter='Background'}" Margin="0,4">
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="20" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2.5*" MinWidth="300" />
|
||||
<ColumnDefinition Width="*" MinWidth="100" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding OutputFilePath}" FontWeight="Bold" />
|
||||
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Margin="10,0,0,0">
|
||||
<WrapPanel>
|
||||
<TextBlock Text="Converted from " FontSize="11" FontStyle="Italic" />
|
||||
<TextBlock Text="{Binding InputFilePath}" FontSize="11" FontStyle="Italic" />
|
||||
</WrapPanel>
|
||||
<TextBlock Text="{Binding ExitingMessage}" Foreground="{Binding State, Converter={StaticResource ConversionStateToColor}, ConverterParameter='Foreground'}" />
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding State}" FontWeight="Bold" Foreground="{Binding State, Converter={StaticResource ConversionStateToColor}, ConverterParameter='Foreground'}" />
|
||||
|
||||
<ProgressBar Grid.Row="1" Grid.Column="1" Height="18" Width="Auto" Minimum="0" Maximum="1" SmallChange="0.001" Value="{Binding Progress, Mode=OneWay}" Foreground="{Binding State, Converter={StaticResource ConversionStateToColor}, ConverterParameter='Foreground'}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" MinWidth="100" LargeChange="0.1" />
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
|
||||
<Grid Grid.Row="2" Visibility="{Binding VerboseMode, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=FileConverterMainWindow, Mode=OneWay}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Grid.Row="0" Content="Log" VerticalAlignment="Top" Height="30" FontSize="16" FontWeight="Bold" />
|
||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" CanContentScroll="True">
|
||||
<TextBlock Name="Diagnostics" TextWrapping="NoWrap" Text="{Binding Path=(local:Diagnostics.Content), Mode=OneWay}" FontFamily="Consolas" Foreground="#FF272727"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,69 +0,0 @@
|
||||
// <copyright file="MainWindow.xaml.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
|
||||
using FileConverter.Annotations;
|
||||
|
||||
public partial class MainWindow : Window, INotifyPropertyChanged
|
||||
{
|
||||
private bool verboseMode;
|
||||
|
||||
private string applicationName;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
this.ApplicationName = string.Format("File Converter v{0}", Application.Version.ToString());
|
||||
|
||||
Application application = Application.Current as Application;
|
||||
|
||||
this.ConverterJobsList.ItemsSource = application.ConvertionJobs;
|
||||
this.VerboseMode = application.Verbose;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string ApplicationName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.applicationName;
|
||||
}
|
||||
|
||||
private set
|
||||
{
|
||||
this.applicationName = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool VerboseMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.verboseMode;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.verboseMode = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChangedEventHandler handler = this.PropertyChanged;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
// <copyright file="PathHelpers.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
public static class PathHelpers
|
||||
{
|
||||
private static Regex driveLetterRegex = new Regex(@"[a-zA-Z]:\\");
|
||||
private static Regex pathRegex = new Regex(@"^[a-zA-Z]:\\(?:[^\\/:*?""<>|\r\n]+\\)*[^\.\\/:*?""<>|\r\n][^\\/:*?""<>|\r\n]*$");
|
||||
private static Regex filenameRegex = new Regex(@"[^\\]*", RegexOptions.RightToLeft);
|
||||
private static Regex directoryRegex = new Regex(@"(?:([^\\]*)\\)*");
|
||||
|
||||
public static bool IsPathDriveLetterValid(string path)
|
||||
{
|
||||
return PathHelpers.driveLetterRegex.IsMatch(path);
|
||||
}
|
||||
|
||||
public static bool IsPathValid(string path)
|
||||
{
|
||||
return PathHelpers.pathRegex.IsMatch(path);
|
||||
}
|
||||
|
||||
public static string GetFileName(string path)
|
||||
{
|
||||
MatchCollection matchCollection = PathHelpers.filenameRegex.Matches(path);
|
||||
Match filenameMatch = matchCollection.Count > 0 ? matchCollection[0] : null;
|
||||
return filenameMatch?.Groups[0].Value;
|
||||
}
|
||||
|
||||
public static IEnumerable<string> GetDirectories(string path)
|
||||
{
|
||||
MatchCollection matchCollection = PathHelpers.directoryRegex.Matches(path);
|
||||
Match match = matchCollection.Count > 0 ? matchCollection[0] : null;
|
||||
if (match == null || match.Groups.Count < 2)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
Group matchGroup = match.Groups[1];
|
||||
for (int index = 0; index < matchGroup.Captures.Count; index++)
|
||||
{
|
||||
yield return matchGroup.Captures[index].Value;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GenerateUniquePath(string path)
|
||||
{
|
||||
string baseExtension = System.IO.Path.GetExtension(path);
|
||||
string basePath = path.Substring(0, path.Length - baseExtension.Length);
|
||||
int index = 2;
|
||||
while (System.IO.File.Exists(path))
|
||||
{
|
||||
path = string.Format("{0} ({1}){2}", basePath, index, baseExtension);
|
||||
index++;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
public static string GetExtensionCategory(string extension)
|
||||
{
|
||||
switch (extension)
|
||||
{
|
||||
case "aiff":
|
||||
case "ape":
|
||||
case "flac":
|
||||
case "mp3":
|
||||
case "m4a":
|
||||
case "ogg":
|
||||
case "wav":
|
||||
case "wma":
|
||||
return "Audio";
|
||||
|
||||
case "avi":
|
||||
case "mp4":
|
||||
return "Video";
|
||||
}
|
||||
|
||||
return "Misc";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.18444
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace FileConverter.Properties
|
||||
{
|
||||
|
||||
|
||||
namespace FileConverter.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
@@ -22,50 +22,67 @@ namespace FileConverter.Properties
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
public class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FileConverter.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to C:\Data\MyFolder\Default.wav.
|
||||
/// </summary>
|
||||
public static string OuputFileNameTemplateSample {
|
||||
get {
|
||||
return ResourceManager.GetString("OuputFileNameTemplateSample", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to (p): input file path
|
||||
///(f): input filename
|
||||
///(o): output extension type
|
||||
///(i): input extension type
|
||||
///(d0): input parent folder
|
||||
///(d1): input sub parent folder
|
||||
///...
|
||||
///use maj for uppercase version.
|
||||
/// </summary>
|
||||
public static string OutputFilePathTemplateHelp {
|
||||
get {
|
||||
return ResourceManager.GetString("OutputFilePathTemplateHelp", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="OuputFileNameTemplateSample" xml:space="preserve">
|
||||
<value>C:\Music\Artist\Album\Song.wav</value>
|
||||
</data>
|
||||
<data name="OutputFilePathTemplateHelp" xml:space="preserve">
|
||||
<value>(p): input file path
|
||||
(f): input filename
|
||||
(o): output extension type
|
||||
(i): input extension type
|
||||
(d0): input parent folder
|
||||
(d1): input sub parent folder
|
||||
...
|
||||
use maj for uppercase version</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
@@ -60,6 +60,7 @@
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
@@ -68,9 +69,10 @@
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
@@ -85,9 +87,10 @@
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
@@ -109,9 +112,22 @@
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.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>
|
||||
<data name="OuputFileNameTemplateSample" xml:space="preserve">
|
||||
<value>C:\Music\Artist\Album\Song.wav</value>
|
||||
</data>
|
||||
<data name="OutputFilePathTemplateHelp" xml:space="preserve">
|
||||
<value>(p): input file path
|
||||
(f): input filename
|
||||
(o): output extension type
|
||||
(i): input extension type
|
||||
(d0): input parent folder
|
||||
(d1): input sub parent folder
|
||||
...
|
||||
use maj for uppercase version</value>
|
||||
</data>
|
||||
</root>
|
||||
|
After Width: | Height: | Size: 294 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
@@ -0,0 +1,386 @@
|
||||
// <copyright file="Settings.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.Principal;
|
||||
using System.Windows;
|
||||
|
||||
using FileConverter.Annotations;
|
||||
using Microsoft.Win32;
|
||||
|
||||
public class Settings : INotifyPropertyChanged, IDataErrorInfo
|
||||
{
|
||||
private const char PresetSeparator = ';';
|
||||
|
||||
private ObservableCollection<ConversionPreset> conversionPresets = new ObservableCollection<ConversionPreset>();
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public ObservableCollection<ConversionPreset> ConversionPresets
|
||||
{
|
||||
get { return this.conversionPresets; }
|
||||
set { this.conversionPresets = value; }
|
||||
}
|
||||
|
||||
public string Error
|
||||
{
|
||||
get
|
||||
{
|
||||
for (int index = 0; index < this.ConversionPresets.Count; index++)
|
||||
{
|
||||
string error = this.ConversionPresets[index].Error;
|
||||
if (!string.IsNullOrEmpty(error))
|
||||
{
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsInAdmininstratorPrivileges
|
||||
{
|
||||
get
|
||||
{
|
||||
return new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
|
||||
}
|
||||
}
|
||||
|
||||
public string this[string columnName]
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Error;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ApplyTemporarySettings()
|
||||
{
|
||||
// Load temporary settings.
|
||||
string temporaryFilePath = Settings.GetUserSettingsTemporaryFilePath();
|
||||
if (!File.Exists(temporaryFilePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ICollection<ConversionPreset> conversionPresets = new ObservableCollection<ConversionPreset>();
|
||||
XmlHelpers.LoadFromFile("Settings", temporaryFilePath, ref conversionPresets);
|
||||
|
||||
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software\FileConverter");
|
||||
if (registryKey == null)
|
||||
{
|
||||
MessageBox.Show("Can't apply settings in registry. (code 0x03)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
// Compute the registry entries data from settings.
|
||||
Dictionary<string, List<string>> registryEntries = ComputeRegistryEntriesFromConvertionPresets(conversionPresets);
|
||||
|
||||
bool succeed = Settings.ApplyRegistryModifications(registryEntries);
|
||||
|
||||
if (succeed)
|
||||
{
|
||||
// Copy temporary settings file to the real settings file.
|
||||
string userFilePath = Settings.GetUserSettingsFilePath();
|
||||
File.Copy(temporaryFilePath, userFilePath, true);
|
||||
File.Delete(temporaryFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
public ConversionPreset GetPresetFromName(string presetName)
|
||||
{
|
||||
return this.conversionPresets.FirstOrDefault(match => match.Name == presetName);
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
ICollection<ConversionPreset> presets = this.ConversionPresets;
|
||||
presets.Clear();
|
||||
|
||||
string userFilePath = Settings.GetUserSettingsFilePath();
|
||||
if (File.Exists(userFilePath))
|
||||
{
|
||||
XmlHelpers.LoadFromFile<ConversionPreset>("Settings", userFilePath, ref presets);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If user settings doesn't exist, load the default settings.
|
||||
string defaultFilePath = Settings.GetDefaultSettingsFilePath();
|
||||
if (File.Exists(defaultFilePath))
|
||||
{
|
||||
XmlHelpers.LoadFromFile<ConversionPreset>("Settings", defaultFilePath, ref presets);
|
||||
}
|
||||
else
|
||||
{
|
||||
Diagnostics.Log("Default settings not found. You should try to reinstall the application.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
// Save the settings in a temporary files (we'll write the settings file when we'll succeed to write the registry keys).
|
||||
string temporaryFilePath = Settings.GetUserSettingsTemporaryFilePath();
|
||||
XmlHelpers.SaveToFile("Settings", temporaryFilePath, this.ConversionPresets);
|
||||
|
||||
// Compute the registry entries data from settings.
|
||||
Dictionary<string, List<string>> registryEntries = Settings.ComputeRegistryEntriesFromConvertionPresets(this.ConversionPresets);
|
||||
|
||||
// Detect if existing registry configuration need to be modified.
|
||||
bool registryNeedModifications = Settings.IsRegistryNeedModifications(registryEntries);
|
||||
|
||||
if (registryNeedModifications)
|
||||
{
|
||||
// Write the settings in registry.
|
||||
if (Settings.IsInAdmininstratorPrivileges)
|
||||
{
|
||||
// We are in admin mode, write reigstry ...
|
||||
bool succeed = Settings.ApplyRegistryModifications(registryEntries);
|
||||
if (succeed)
|
||||
{
|
||||
// ... and copy temporary settings file to the real settings file.
|
||||
string userFilePath = Settings.GetUserSettingsFilePath();
|
||||
File.Copy(temporaryFilePath, userFilePath, true);
|
||||
File.Delete(temporaryFilePath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Run the application in admin mode in order to perform modifications.
|
||||
Settings.RunSaveInAdminMode();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Copy temporary settings file to the real settings file.
|
||||
string userFilePath = Settings.GetUserSettingsFilePath();
|
||||
File.Copy(temporaryFilePath, userFilePath, true);
|
||||
File.Delete(temporaryFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ApplyRegistryModifications(Dictionary<string, List<string>> registryEntries)
|
||||
{
|
||||
if (!Settings.IsInAdmininstratorPrivileges)
|
||||
{
|
||||
MessageBox.Show("Can't apply settings in registry because the application is not in administrator privileges. (code 0x04)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software\FileConverter", RegistryKeyPermissionCheck.ReadWriteSubTree);
|
||||
if (registryKey == null)
|
||||
{
|
||||
MessageBox.Show("Can't apply settings in registry. (code 0x05)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete previous settings.
|
||||
string[] subKeyNames = registryKey.GetSubKeyNames();
|
||||
for (int index = 0; index < subKeyNames.Length; index++)
|
||||
{
|
||||
try
|
||||
{
|
||||
registryKey.DeleteSubKey(subKeyNames[index]);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Can't apply settings in registry. (code 0x06)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply settings in registry.
|
||||
foreach (KeyValuePair<string, List<string>> registryEntry in registryEntries)
|
||||
{
|
||||
string presets = string.Empty;
|
||||
for (int index = 0; index < registryEntry.Value.Count; index++)
|
||||
{
|
||||
if (index > 0)
|
||||
{
|
||||
presets += ";";
|
||||
}
|
||||
|
||||
presets += registryEntry.Value[index];
|
||||
}
|
||||
|
||||
RegistryKey subKey = null;
|
||||
try
|
||||
{
|
||||
subKey = registryKey.CreateSubKey(registryEntry.Key);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Diagnostics.Log(exception.Message);
|
||||
}
|
||||
|
||||
if (subKey == null)
|
||||
{
|
||||
MessageBox.Show("Can't apply settings in registry. (code 0x07)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
subKey.SetValue("Presets", presets);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Dictionary<string, List<string>> ComputeRegistryEntriesFromConvertionPresets(ICollection<ConversionPreset> conversionPresets)
|
||||
{
|
||||
Dictionary<string, List<string>> registryEntries = new Dictionary<string, List<string>>();
|
||||
|
||||
foreach (ConversionPreset conversionPreset in conversionPresets)
|
||||
{
|
||||
List<string> inputTypes = conversionPreset.InputTypes;
|
||||
for (int inputIndex = 0; inputIndex < inputTypes.Count; inputIndex++)
|
||||
{
|
||||
string inputType = inputTypes[inputIndex].ToLowerInvariant();
|
||||
if (!registryEntries.ContainsKey(inputType))
|
||||
{
|
||||
registryEntries.Add(inputType, new List<string>());
|
||||
}
|
||||
|
||||
registryEntries[inputType].Add(conversionPreset.Name);
|
||||
}
|
||||
}
|
||||
|
||||
return registryEntries;
|
||||
}
|
||||
|
||||
private static string GetDefaultSettingsFilePath()
|
||||
{
|
||||
string path = Assembly.GetEntryAssembly().Location;
|
||||
path = Path.GetDirectoryName(path);
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
path = Path.Combine(path, "Settings.xml");
|
||||
return path;
|
||||
}
|
||||
|
||||
private static string GetUserSettingsFilePath()
|
||||
{
|
||||
string path = Environment.GetEnvironmentVariable("LocalAppData");
|
||||
path = Path.Combine(path, "FileConverter");
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
path = Path.Combine(path, "Settings.user.xml");
|
||||
return path;
|
||||
}
|
||||
|
||||
private static string GetUserSettingsTemporaryFilePath()
|
||||
{
|
||||
string path = Environment.GetEnvironmentVariable("LocalAppData");
|
||||
path = Path.Combine(path, "FileConverter");
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
path = Path.Combine(path, "Settings.temp.xml");
|
||||
return path;
|
||||
}
|
||||
|
||||
private static bool IsRegistryNeedModifications(Dictionary<string, List<string>> registryEntries)
|
||||
{
|
||||
// Compare to registry entries.
|
||||
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software\FileConverter");
|
||||
if (registryKey == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
string[] subKeyNames = registryKey.GetSubKeyNames();
|
||||
if (subKeyNames.Length == registryEntries.Count)
|
||||
{
|
||||
for (int index = 0; index < subKeyNames.Length; index++)
|
||||
{
|
||||
string subKeyName = subKeyNames[index];
|
||||
if (!registryEntries.ContainsKey(subKeyName))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
List<string> presetsList = registryEntries[subKeyName];
|
||||
|
||||
RegistryKey subKey = registryKey.OpenSubKey(subKeyName);
|
||||
if (subKey == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
string presetsString = subKey.GetValue("Presets", string.Empty) as string;
|
||||
string[] presets = presetsString != null ? presetsString.Split(Settings.PresetSeparator) : new string[0];
|
||||
if (presets.Length != presetsList.Count)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int presetIndex = 0; presetIndex < presets.Length; presetIndex++)
|
||||
{
|
||||
if (!presetsList.Contains(presets[presetIndex]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void RunSaveInAdminMode()
|
||||
{
|
||||
ProcessStartInfo processStartInfo = new ProcessStartInfo(Assembly.GetEntryAssembly().Location, "--apply-settings")
|
||||
{
|
||||
UseShellExecute = true,
|
||||
Verb = "runas", // indicates to elevate privileges
|
||||
};
|
||||
|
||||
Process process = new Process
|
||||
{
|
||||
EnableRaisingEvents = true, // enable WaitForExit()
|
||||
StartInfo = processStartInfo
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
process.Start();
|
||||
process.WaitForExit();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Can't apply settings in registry because the application has no administrator privileges. (code 0x08)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
||||
<ConversionPreset Name="To Ogg" OutputType="Ogg">
|
||||
<InputTypes>flac</InputTypes>
|
||||
<InputTypes>ape</InputTypes>
|
||||
<InputTypes>wav</InputTypes>
|
||||
<InputTypes>wma</InputTypes>
|
||||
<InputTypes>m4a</InputTypes>
|
||||
<InputTypes>avi</InputTypes>
|
||||
<InputTypes>mp4</InputTypes>
|
||||
<InputTypes>mp3</InputTypes>
|
||||
<InputTypes>aiff</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="Bitrate" Value="128" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Mp3" OutputType="Mp3">
|
||||
<InputTypes>ogg</InputTypes>
|
||||
<InputTypes>flac</InputTypes>
|
||||
<InputTypes>ape</InputTypes>
|
||||
<InputTypes>wav</InputTypes>
|
||||
<InputTypes>wma</InputTypes>
|
||||
<InputTypes>m4a</InputTypes>
|
||||
<InputTypes>mp4</InputTypes>
|
||||
<InputTypes>avi</InputTypes>
|
||||
<InputTypes>aiff</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="Encoding" Value="Mp3VBR" />
|
||||
<Settings Key="Bitrate" Value="175" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Flac" OutputType="Flac">
|
||||
<InputTypes>ape</InputTypes>
|
||||
<InputTypes>wav</InputTypes>
|
||||
<InputTypes>avi</InputTypes>
|
||||
<InputTypes>mp4</InputTypes>
|
||||
<InputTypes>aiff</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Wav" OutputType="Wav">
|
||||
<InputTypes>ape</InputTypes>
|
||||
<InputTypes>flac</InputTypes>
|
||||
<InputTypes>mp3</InputTypes>
|
||||
<InputTypes>ogg</InputTypes>
|
||||
<InputTypes>wma</InputTypes>
|
||||
<InputTypes>avi</InputTypes>
|
||||
<InputTypes>mp4</InputTypes>
|
||||
<InputTypes>m4a</InputTypes>
|
||||
<InputTypes>aiff</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="Encoding" Value="Wav16" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
</Settings>
|
||||
@@ -0,0 +1,28 @@
|
||||
// <copyright file="ApplicationVersionToApplicationName.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ValueConverters
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
public class ApplicationVersionToApplicationName : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (!(value is FileConverter.Version))
|
||||
{
|
||||
return "File Converter";
|
||||
}
|
||||
|
||||
FileConverter.Version version = (FileConverter.Version)value;
|
||||
|
||||
return string.Format("File Converter v{0}", version.ToString());
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// <copyright file="BitrateToString.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ValueConverters
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
public class BitrateToString : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (!(value is double))
|
||||
{
|
||||
throw new ArgumentException("The value must be a double value.");
|
||||
}
|
||||
|
||||
double bitrate = (double)value;
|
||||
|
||||
return string.Format("{0} kbit/s", bitrate.ToString("0"));
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// <copyright file="ConversionSettingsToString.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ValueConverters
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
public class ConversionSettingsToString : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(value is IConversionSettings))
|
||||
{
|
||||
throw new ArgumentException("The value must be a conversion preset array.");
|
||||
}
|
||||
|
||||
IConversionSettings settings = (IConversionSettings)value;
|
||||
|
||||
string parameterString = parameter as string;
|
||||
if (parameterString == null)
|
||||
{
|
||||
throw new ArgumentException("The parameter must be a string value.");
|
||||
}
|
||||
|
||||
string[] parameters = parameterString.Split(',');
|
||||
if (parameters.Length < 1 || parameters.Length > 2)
|
||||
{
|
||||
throw new ArgumentException("The parameter format must be 'SettingsKey[,DefaultValue]'.");
|
||||
}
|
||||
|
||||
string key = parameters[0];
|
||||
string setting;
|
||||
if (settings.TryGetValue(key, out setting))
|
||||
{
|
||||
return setting;
|
||||
}
|
||||
|
||||
if (parameters.Length >= 2)
|
||||
{
|
||||
return parameters[1];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!(value is string))
|
||||
{
|
||||
throw new ArgumentException("value");
|
||||
}
|
||||
|
||||
string settingsValue = (string)value;
|
||||
|
||||
if (!(parameter is string))
|
||||
{
|
||||
throw new ArgumentException("parameter");
|
||||
}
|
||||
|
||||
string settingsKey = (string)parameter;
|
||||
|
||||
return new ConversionSettingsOverride(settingsKey, settingsValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
// <copyright file="ConversionStateToBrush.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
namespace FileConverter.ValueConverters
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
using FileConverter.ConversionJobs;
|
||||
|
||||
public class ConversionStateToBrush : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
@@ -0,0 +1,81 @@
|
||||
// <copyright file="FileNameConverter.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ValueConverters
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
public class FileNameConverter : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (values == null || values.Length != 3)
|
||||
{
|
||||
throw new ArgumentException("The values must contains the input file path, the output file extension and the ouput file template.");
|
||||
}
|
||||
|
||||
if (!(values[1] is OutputType))
|
||||
{
|
||||
return "Invalid output file extension (argument 1).";
|
||||
}
|
||||
|
||||
string inputFilePath = values[0] as string;
|
||||
OutputType outputFileExtension = (OutputType)values[1];
|
||||
string outputFileTemplate = values[2] as string;
|
||||
|
||||
if (inputFilePath == null)
|
||||
{
|
||||
return "Invalid input file path (argument 0).";
|
||||
}
|
||||
|
||||
string inputExtension = System.IO.Path.GetExtension(inputFilePath).Substring(1);
|
||||
string inputPathWithoutExtension = inputFilePath.Substring(0, inputFilePath.Length - inputExtension.Length - 1);
|
||||
string outputExtension = outputFileExtension.ToString().ToLowerInvariant();
|
||||
|
||||
if (outputFileTemplate == null)
|
||||
{
|
||||
// Default output path.
|
||||
return inputPathWithoutExtension + "." + outputExtension;
|
||||
}
|
||||
|
||||
string fileName = System.IO.Path.GetFileName(inputPathWithoutExtension);
|
||||
string parentDirectory = System.IO.Path.GetDirectoryName(inputPathWithoutExtension);
|
||||
string[] directories = parentDirectory.Split(System.IO.Path.DirectorySeparatorChar);
|
||||
parentDirectory += System.IO.Path.DirectorySeparatorChar;
|
||||
|
||||
// Generate output path from template.
|
||||
string outputPath = outputFileTemplate;
|
||||
|
||||
outputPath = outputPath.Replace("(path)", parentDirectory);
|
||||
outputPath = outputPath.Replace("(p)", parentDirectory);
|
||||
|
||||
outputPath = outputPath.Replace("(filename)", fileName);
|
||||
outputPath = outputPath.Replace("(f)", fileName);
|
||||
outputPath = outputPath.Replace("(F)", fileName.ToUpperInvariant());
|
||||
|
||||
outputPath = outputPath.Replace("(outputext)", outputExtension);
|
||||
outputPath = outputPath.Replace("(o)", outputExtension);
|
||||
outputPath = outputPath.Replace("(O)", outputExtension.ToUpperInvariant());
|
||||
|
||||
outputPath = outputPath.Replace("(inputext)", inputExtension);
|
||||
outputPath = outputPath.Replace("(i)", inputExtension);
|
||||
outputPath = outputPath.Replace("(I)", inputExtension.ToUpperInvariant());
|
||||
|
||||
for (int index = 0; index < directories.Length; index++)
|
||||
{
|
||||
outputPath = outputPath.Replace(string.Format("(d{0})", directories.Length - index - 1), directories[index]);
|
||||
outputPath = outputPath.Replace(string.Format("(D{0})", directories.Length - index - 1), directories[index].ToUpperInvariant());
|
||||
}
|
||||
|
||||
outputPath += "." + outputExtension;
|
||||
|
||||
return outputPath;
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// <copyright file="BoolInverterConverter.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ValueConverters.Generic
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
public class BoolInverterConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (!(value is bool))
|
||||
{
|
||||
throw new System.ArgumentException("The object must be a boolean value.");
|
||||
}
|
||||
|
||||
bool boolValue = (bool)value;
|
||||
|
||||
return !boolValue;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// <copyright file="BoolToVisibility.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ValueConverters.Generic
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
public class BoolToVisibility : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (!(value is bool))
|
||||
{
|
||||
throw new ArgumentException("The value must be a boolean.");
|
||||
}
|
||||
|
||||
bool booleanValue = (bool)value;
|
||||
|
||||
return booleanValue ? "Visible" : "Hidden";
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
// <copyright file="CollectionContainsElementToBool.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ValueConverters.Generic
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
public class CollectionContainsElementToBool : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (values == null || values.Length != 2)
|
||||
{
|
||||
throw new ArgumentException("The values must contains the collection of elements and the researched element.");
|
||||
}
|
||||
|
||||
//// TODO: Make this converter generic.
|
||||
|
||||
if (!(values[0] is ICollection<string>))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool? result = null;
|
||||
if (values[1] is IEnumerable<string>)
|
||||
{
|
||||
ICollection<string> collection = values[0] as ICollection<string>;
|
||||
IEnumerable<string> objectsToFind = values[1] as IEnumerable<string>;
|
||||
|
||||
bool all = true;
|
||||
bool none = true;
|
||||
foreach (string objectToFind in objectsToFind)
|
||||
{
|
||||
bool contains = collection.Contains(objectToFind);
|
||||
all &= contains;
|
||||
none &= !contains;
|
||||
}
|
||||
|
||||
if (all)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
else if (none)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ICollection<string> collection = values[0] as ICollection<string>;
|
||||
string objectToFind = values[1] as string;
|
||||
|
||||
result = collection.Contains(objectToFind);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// <copyright file="EqualsConverter.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ValueConverters.Generic
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
public class EqualsConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return parameter == null;
|
||||
}
|
||||
|
||||
return value.Equals(parameter);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (!(value is bool))
|
||||
{
|
||||
throw new ArgumentException("value");
|
||||
}
|
||||
|
||||
bool equals = (bool)value;
|
||||
if (equals)
|
||||
{
|
||||
return parameter;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// <copyright file="StringToEnum.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ValueConverters.Generic
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
public class StringToEnum : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
string stringValue = value as string;
|
||||
if (value == null)
|
||||
{
|
||||
// TODO default value ?
|
||||
return null;
|
||||
}
|
||||
|
||||
string typeName = parameter as string;
|
||||
if (typeName == null)
|
||||
{
|
||||
throw new ArgumentNullException("parameter", "The parameter must contains the enum type.");
|
||||
}
|
||||
|
||||
Type enumType = Type.GetType(typeName);
|
||||
if (enumType == null)
|
||||
{
|
||||
throw new Exception("Invalid enum type " + typeName + ".");
|
||||
}
|
||||
|
||||
return Enum.Parse(enumType, stringValue);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// <copyright file="StringToValueType.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ValueConverters.Generic
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
public class StringToValueType : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
string typeName = parameter as string;
|
||||
if (typeName == null)
|
||||
{
|
||||
throw new ArgumentNullException("parameter", "The parameter must contains a convertible type.");
|
||||
}
|
||||
|
||||
Type type = Type.GetType(typeName);
|
||||
if (type == null)
|
||||
{
|
||||
throw new Exception("Invalid enum type " + typeName + ".");
|
||||
}
|
||||
|
||||
return System.Convert.ChangeType(value, type);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// <copyright file="ValueConverterGroup.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ValueConverters.Generic
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Data;
|
||||
|
||||
public class ValueConverterGroup : List<IValueConverter>, IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
string[] parameters = null;
|
||||
if (parameter == null)
|
||||
{
|
||||
parameters = new string[this.Count];
|
||||
}
|
||||
else
|
||||
{
|
||||
string parameterString = parameter as string;
|
||||
if (parameterString == null)
|
||||
{
|
||||
throw new ArgumentException("The parameter must be a string value.");
|
||||
}
|
||||
|
||||
parameters = parameterString.Split('|');
|
||||
if (parameters.Length != this.Count)
|
||||
{
|
||||
throw new ArgumentException("The parameter format must be 'Converter1Parameters|Converter2Parameters|...'.");
|
||||
}
|
||||
}
|
||||
|
||||
object result = value;
|
||||
for (int index = 0; index < this.Count; index++)
|
||||
{
|
||||
IValueConverter converter = this[index];
|
||||
result = converter.Convert(result, targetType, parameters[index], culture);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
string parameterString = parameter as string;
|
||||
if (parameterString == null)
|
||||
{
|
||||
throw new ArgumentException("The parameter must be a string value.");
|
||||
}
|
||||
|
||||
string[] parameters = parameterString.Split('|');
|
||||
if (parameters.Length != this.Count)
|
||||
{
|
||||
throw new ArgumentException("The parameter format must be 'Converter1Parameters|Converter2Parameters|...'.");
|
||||
}
|
||||
|
||||
object result = value;
|
||||
for (int index = this.Count - 1; index >= 0; index--)
|
||||
{
|
||||
IValueConverter converter = this[index];
|
||||
result = converter.ConvertBack(result, targetType, parameters[index], culture);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// <copyright file="InputTypesToBool.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ValueConverters
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
public class InputTypesToBool : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
List<string> intputTypes = value as List<string>;
|
||||
if (intputTypes == null)
|
||||
{
|
||||
throw new ArgumentException("The value must be an list of string.");
|
||||
}
|
||||
|
||||
string referenceTypeName = parameter as string;
|
||||
if (string.IsNullOrEmpty(referenceTypeName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return intputTypes.Contains(referenceTypeName);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// <copyright file="OutputTypeToVisibility.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ValueConverters
|
||||
{
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
public class OutputTypeToVisibility : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (!(value is OutputType))
|
||||
{
|
||||
throw new ArgumentException("The value must be an output type enum value.");
|
||||
}
|
||||
|
||||
OutputType outputType = (OutputType)value;
|
||||
|
||||
string referenceTypeName = parameter as string;
|
||||
if (string.IsNullOrEmpty(referenceTypeName))
|
||||
{
|
||||
return "Hidden";
|
||||
}
|
||||
|
||||
OutputType referenceType;
|
||||
if (!Enum.TryParse<OutputType>(referenceTypeName, out referenceType))
|
||||
{
|
||||
return "Hidden";
|
||||
}
|
||||
|
||||
return outputType == referenceType ? "Visible" : "Hidden";
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
// <copyright file="Version.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// <copyright file="ConversionSettingsTemplateSelector.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.Windows
|
||||
{
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
public class ConversionSettingsTemplateSelector : DataTemplateSelector
|
||||
{
|
||||
public DataTemplate DefaultDataTemplate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public DataTemplate WavSettingsDataTemplate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public DataTemplate Mp3SettingsDataTemplate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public DataTemplate OggSettingsDataTemplate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public override DataTemplate SelectTemplate(object item, DependencyObject container)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return this.DefaultDataTemplate;
|
||||
}
|
||||
|
||||
OutputType outputType = (OutputType)item;
|
||||
|
||||
switch (outputType)
|
||||
{
|
||||
case OutputType.Wav:
|
||||
return this.WavSettingsDataTemplate;
|
||||
|
||||
case OutputType.Mp3:
|
||||
return this.Mp3SettingsDataTemplate;
|
||||
|
||||
case OutputType.Ogg:
|
||||
return this.OggSettingsDataTemplate;
|
||||
}
|
||||
|
||||
return this.DefaultDataTemplate;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<Window x:Class="FileConverter.Windows.DiagnosticsWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:FileConverter.Windows"
|
||||
xmlns:fileConverter="clr-namespace:FileConverter"
|
||||
mc:Ignorable="d"
|
||||
Title="Diagnostics" Height="600" Width="800" Icon="/FileConverter;component/Resources/ApplicationIcon.ico">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Grid.Row="0" Content="Logs" VerticalAlignment="Top" Height="30" FontSize="16" FontWeight="Bold" />
|
||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" CanContentScroll="True">
|
||||
<TextBlock Name="Diagnostics" TextWrapping="NoWrap" Text="{Binding Path=(fileConverter:Diagnostics.Content), Mode=OneWay}" FontFamily="Consolas" Foreground="#FF272727"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,17 @@
|
||||
// <copyright file="DiagnosticsWindow.xaml.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.Windows
|
||||
{
|
||||
using System.Windows;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for DiagnosticsWindow.
|
||||
/// </summary>
|
||||
public partial class DiagnosticsWindow : Window
|
||||
{
|
||||
public DiagnosticsWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// <copyright file="InputExtension.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using FileConverter.Annotations;
|
||||
|
||||
public class InputExtension : INotifyPropertyChanged
|
||||
{
|
||||
private string name;
|
||||
|
||||
public InputExtension(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.name = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// <copyright file="InputExtensionCategory.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using FileConverter.Annotations;
|
||||
|
||||
public class InputExtensionCategory : INotifyPropertyChanged
|
||||
{
|
||||
private string name;
|
||||
private List<InputExtension> inputExtensions = new List<InputExtension>();
|
||||
|
||||
public InputExtensionCategory(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.name = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<InputExtension> InputExtensions
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.inputExtensions;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> InputExtensionNames
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (InputExtension inputExtension in this.inputExtensions)
|
||||
{
|
||||
yield return inputExtension.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddExtension(string extension)
|
||||
{
|
||||
InputExtension inputExtension = this.inputExtensions.Find(match => match.Name == extension);
|
||||
if (inputExtension == null)
|
||||
{
|
||||
inputExtension = new InputExtension(extension);
|
||||
this.inputExtensions.Add(inputExtension);
|
||||
this.OnPropertyChanged("InputExtensions");
|
||||
this.OnPropertyChanged("InputExtensionNames");
|
||||
}
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<Window
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:FileConverter"
|
||||
xmlns:valueConverters="clr-namespace:FileConverter.ValueConverters"
|
||||
xmlns:conversionJobs="clr-namespace:FileConverter.ConversionJobs" mc:Ignorable="d" x:Class="FileConverter.MainWindow"
|
||||
x:Name="FileConverterMainWindow" Height="500" Width="950" MinHeight="250" MinWidth="450" WindowStartupLocation="CenterScreen" Icon="/FileConverter;component/Resources/ApplicationIcon.ico">
|
||||
<Window.Resources>
|
||||
<valueConverters:ApplicationVersionToApplicationName x:Key="ApplicationVersionToApplicationName"/>
|
||||
<valueConverters:ConversionStateToBrush x:Key="ConversionStateToColor" />
|
||||
</Window.Resources>
|
||||
<Window.Title>
|
||||
<Binding Converter="{StaticResource ApplicationVersionToApplicationName}" Mode="OneWay" Path="(local:Application.ApplicationVersion)"/>
|
||||
</Window.Title>
|
||||
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition Width="100" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label x:Name="Title" Grid.Column="0" Content="Files to convert" VerticalAlignment="Top" Height="30" FontSize="16" FontWeight="Bold"/>
|
||||
<Button x:Name="DiagnosticsButton" Grid.Column="1" Content="Logs" Margin="3,3" Click="DiagnosticsButton_OnClick"/>
|
||||
<Button x:Name="SettingsButton" Grid.Column="2" Content="Settings" Margin="3,3" Click="SettingsButton_OnClick"/>
|
||||
</Grid>
|
||||
|
||||
<ScrollViewer x:Name="ScrollViewer" Grid.Row="1" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
|
||||
<ItemsControl x:Name="ConverterJobsList">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<DockPanel Background="{Binding State, ConverterParameter=Background, Converter={StaticResource ConversionStateToColor}}" Margin="0,4">
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="20" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2.5*" MinWidth="300" />
|
||||
<ColumnDefinition Width="*" MinWidth="100" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding OutputFilePath}" FontWeight="Bold" />
|
||||
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Margin="10,0,0,0">
|
||||
<WrapPanel>
|
||||
<TextBlock Text="Converted from " FontSize="11" FontStyle="Italic" />
|
||||
<TextBlock Text="{Binding InputFilePath}" FontSize="11" FontStyle="Italic" />
|
||||
</WrapPanel>
|
||||
<TextBlock Text="{Binding ErrorMessage}" Foreground="{Binding State, ConverterParameter=Foreground, Converter={StaticResource ConversionStateToColor}}" />
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding State}" FontWeight="Bold" Foreground="{Binding State, ConverterParameter=Foreground, Converter={StaticResource ConversionStateToColor}}" />
|
||||
|
||||
<ProgressBar Grid.Row="1" Grid.Column="1" Height="18" Width="Auto" Minimum="0" Maximum="1" SmallChange="0.001" Value="{Binding Progress, Mode=OneWay}" Foreground="{Binding State, ConverterParameter=Foreground, Converter={StaticResource ConversionStateToColor}}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" MinWidth="100" LargeChange="0.1" />
|
||||
</Grid>
|
||||
</DockPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
<ItemsControl.DataContext>
|
||||
<conversionJobs:ConversionJob/>
|
||||
</ItemsControl.DataContext>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,98 @@
|
||||
// <copyright file="MainWindow.xaml.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
|
||||
using FileConverter.Annotations;
|
||||
using FileConverter.Windows;
|
||||
|
||||
public partial class MainWindow : Window, INotifyPropertyChanged
|
||||
{
|
||||
private DiagnosticsWindow diagnosticsWindow;
|
||||
private SettingsWindow settingsWindow;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
Application application = Application.Current as Application;
|
||||
|
||||
this.ConverterJobsList.ItemsSource = application.ConvertionJobs;
|
||||
if (application.Verbose)
|
||||
{
|
||||
this.ShowDiagnosticsWindow();
|
||||
}
|
||||
|
||||
if (application.ShowSettings)
|
||||
{
|
||||
this.Hide();
|
||||
|
||||
this.ShowSettingsWindow();
|
||||
this.settingsWindow.OnSettingsWindowHide += this.SettingsWindow_Closed;
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChangedEventHandler handler = this.PropertyChanged;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
private void SettingsButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.ShowSettingsWindow();
|
||||
}
|
||||
|
||||
private void SettingsWindow_Closed(object sender, System.EventArgs e)
|
||||
{
|
||||
this.settingsWindow.OnSettingsWindowHide -= this.SettingsWindow_Closed;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void DiagnosticsButton_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.ShowDiagnosticsWindow();
|
||||
}
|
||||
|
||||
private void ShowDiagnosticsWindow()
|
||||
{
|
||||
if (this.diagnosticsWindow != null && this.diagnosticsWindow.IsVisible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.diagnosticsWindow = new DiagnosticsWindow();
|
||||
}
|
||||
|
||||
Application application = Application.Current as Application;
|
||||
application?.CancelAutoExit();
|
||||
this.diagnosticsWindow.Show();
|
||||
}
|
||||
|
||||
private void ShowSettingsWindow()
|
||||
{
|
||||
if (this.settingsWindow != null && this.settingsWindow.IsVisible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.settingsWindow = new SettingsWindow();
|
||||
}
|
||||
|
||||
Application application = Application.Current as Application;
|
||||
application?.CancelAutoExit();
|
||||
this.settingsWindow.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
<Window
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:FileConverter"
|
||||
xmlns:controls="clr-namespace:FileConverter.Controls"
|
||||
xmlns:valueConverters="clr-namespace:FileConverter.ValueConverters"
|
||||
xmlns:generic="clr-namespace:FileConverter.ValueConverters.Generic"
|
||||
xmlns:windows="clr-namespace:FileConverter.Windows"
|
||||
xmlns:project="clr-namespace:FileConverter.Properties"
|
||||
xmlns:System="clr-namespace:System;assembly=mscorlib" x:Name="window" x:Class="FileConverter.SettingsWindow"
|
||||
Height="600" Width="800" MinHeight="480" MinWidth="640"
|
||||
WindowStartupLocation="CenterScreen" Icon="/FileConverter;component/Resources/ApplicationIcon.ico"
|
||||
Closing="SettingsWindow_OnClosing">
|
||||
<Window.Resources>
|
||||
<valueConverters:FileNameConverter x:Key="FileNameConverter"/>
|
||||
<generic:BoolToVisibility x:Key="BoolToVisibility"/>
|
||||
<valueConverters:InputTypesToBool x:Key="InputTypesToBool"/>
|
||||
<valueConverters:OutputTypeToVisibility x:Key="OutputTypeToVisibility"/>
|
||||
<valueConverters:ApplicationVersionToApplicationName x:Key="ApplicationVersionToApplicationName"/>
|
||||
<generic:CollectionContainsElementToBool x:Key="CollectionContainsElementToBool"/>
|
||||
|
||||
<generic:ValueConverterGroup x:Key="ConversionSettingsToEnum">
|
||||
<valueConverters:ConversionSettingsToString/>
|
||||
<generic:StringToEnum/>
|
||||
</generic:ValueConverterGroup>
|
||||
|
||||
<generic:ValueConverterGroup x:Key="ConversionSettingsEquals">
|
||||
<valueConverters:ConversionSettingsToString/>
|
||||
<generic:EqualsConverter/>
|
||||
</generic:ValueConverterGroup>
|
||||
|
||||
<generic:ValueConverterGroup x:Key="ConversionSettingsToValueType">
|
||||
<valueConverters:ConversionSettingsToString/>
|
||||
<generic:StringToValueType/>
|
||||
</generic:ValueConverterGroup>
|
||||
|
||||
<generic:ValueConverterGroup x:Key="ReferenceToVisibility">
|
||||
<generic:EqualsConverter/>
|
||||
<generic:BoolInverterConverter/>
|
||||
<generic:BoolToVisibility/>
|
||||
</generic:ValueConverterGroup>
|
||||
|
||||
<Style TargetType="{x:Type TextBox}">
|
||||
<Setter Property="Validation.ErrorTemplate">
|
||||
<Setter.Value>
|
||||
<ControlTemplate>
|
||||
<DockPanel LastChildFill="true">
|
||||
<Border Background="#F44336" DockPanel.Dock="right" Margin="5,0,0,0" Width="20" Height="20" CornerRadius="10"
|
||||
ToolTip="{Binding AdornedElement.(Validation.Errors)[0].ErrorContent, ElementName=customAdorner}">
|
||||
<TextBlock Text="!" VerticalAlignment="center" HorizontalAlignment="center" FontWeight="Bold" Foreground="white"/>
|
||||
</Border>
|
||||
<AdornedElementPlaceholder x:Name="customAdorner" VerticalAlignment="Center" >
|
||||
<Border BorderBrush="#F44336" BorderThickness="1" />
|
||||
</AdornedElementPlaceholder>
|
||||
</DockPanel>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<DataTemplate x:Key="EmptyDataTemplate">
|
||||
<StackPanel/>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="WavSettingsDataTemplate">
|
||||
<StackPanel>
|
||||
<DockPanel>
|
||||
<Label Content="Encoding :" />
|
||||
<RadioButton x:Name="WAV8radioButton" Content="8-bits" ToolTip="PCM signed 8-bit little-endian" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=Encoding|Wav8, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" />
|
||||
<RadioButton x:Name="WAV16radioButton" Content="16-bits" ToolTip="PCM signed 16-bit little-endian" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=Encoding|Wav16, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}"/>
|
||||
<RadioButton x:Name="WAV24radioButton" Content="24-bits" ToolTip="PCM signed 24-bit little-endian" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=Encoding|Wav24, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}"/>
|
||||
<RadioButton x:Name="WAV32radioButton" Content="32-bits" ToolTip="PCM signed 32-bit little-endian" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=Encoding|Wav32, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}"/>
|
||||
</DockPanel>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="Mp3SettingsDataTemplate">
|
||||
<StackPanel>
|
||||
<DockPanel>
|
||||
<Label Content="Encoding :" />
|
||||
<RadioButton x:Name="VBRradioButton" Content="VBR" ToolTip="Variable bitrate encoding" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=Encoding|Mp3VBR, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" />
|
||||
<RadioButton x:Name="CBRradioButton" Content="CBR" ToolTip="Constant bitrate encoding" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=Encoding|Mp3CBR, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}"/>
|
||||
</DockPanel>
|
||||
<DockPanel>
|
||||
<Label Content="Quality :" />
|
||||
<controls:EncodingQualitySliderControl x:Name="EncodingQualitySlider"
|
||||
EncodingMode="{Binding SelectedPreset.Settings, ConverterParameter=Encoding|FileConverter.EncodingMode, Converter={StaticResource ConversionSettingsToEnum}, ElementName=window, Mode=OneWay, TargetNullValue=VBR}"
|
||||
Bitrate="{Binding SelectedPreset.Settings, ConverterParameter=Bitrate|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay, TargetNullValue=190}" />
|
||||
</DockPanel>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="OggSettingsDataTemplate">
|
||||
<StackPanel>
|
||||
<DockPanel>
|
||||
<Label Content="Quality :" />
|
||||
<controls:EncodingQualitySliderControl x:Name="EncodingQualitySlider" EncodingMode="OggVBR"
|
||||
Bitrate="{Binding SelectedPreset.Settings, ConverterParameter=Bitrate|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay, TargetNullValue=160}" />
|
||||
</DockPanel>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<windows:ConversionSettingsTemplateSelector x:Key="ConversionSettingsSelector"
|
||||
DefaultDataTemplate="{StaticResource EmptyDataTemplate}"
|
||||
WavSettingsDataTemplate="{StaticResource WavSettingsDataTemplate}"
|
||||
Mp3SettingsDataTemplate="{StaticResource Mp3SettingsDataTemplate}"
|
||||
OggSettingsDataTemplate="{StaticResource OggSettingsDataTemplate}" />
|
||||
</Window.Resources>
|
||||
<Window.Title>
|
||||
<Binding Converter="{StaticResource ApplicationVersionToApplicationName}" Mode="OneWay" Path="(local:Application.ApplicationVersion)"/>
|
||||
</Window.Title>
|
||||
|
||||
<Grid x:Name="grid" Margin="10">
|
||||
<Grid.CommandBindings>
|
||||
<CommandBinding Command="New" CanExecute="CanSaveSettings" />
|
||||
</Grid.CommandBindings>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="48"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="28"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="48"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Image HorizontalAlignment="Left" Height="48" Width="48" VerticalAlignment="Top" Source="..\Resources\ApplicationIcon.png" />
|
||||
<Label Grid.Column="1" Content="Settings" FontSize="20" Margin="4" VerticalAlignment="Center" />
|
||||
<Label Grid.Column="2" HorizontalAlignment="Right" FontStyle="Italic" FontSize="14" VerticalAlignment="Center">
|
||||
<Label.Content>
|
||||
<Binding Path="(local:Application.ApplicationVersion)" Converter="{StaticResource ApplicationVersionToApplicationName}" Mode="OneWay" />
|
||||
</Label.Content>
|
||||
</Label>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="122"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid x:Name="PresetListGrid" Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label Content="Presets" Grid.Row="0" VerticalAlignment="Top" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="{Binding ActualWidth, ElementName=PresetListGrid, Mode=OneWay}" />
|
||||
<ListBox x:Name="PresetList" Grid.Row="1" HorizontalAlignment="Left" IsSynchronizedWithCurrentItem="True" SelectedItem="{Binding SelectedPreset, ElementName=window}" Width="{Binding ActualWidth, ElementName=PresetListGrid, Mode=OneWay}">
|
||||
<ListBox.DataContext>
|
||||
<local:ConversionPreset/>
|
||||
</ListBox.DataContext>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Label Content="{Binding Name}"/>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<DockPanel Grid.Row="2" Margin="0,5,0,0">
|
||||
<Button x:Name="MoveUpPresetButton" Content="^" HorizontalAlignment="Left" Width="25" Margin="0,0,2,0" Click="MovePresetUpButton_Click"/>
|
||||
<Button x:Name="AddPresetButton" Content="+" HorizontalAlignment="Left" Width="25" Margin="2,0" Click="AddPresetButton_Click"/>
|
||||
<Button x:Name="RemovePresetButton" Content="-" HorizontalAlignment="Left" Width="25" Margin="2,0" Click="RemovePresetButton_Click"/>
|
||||
<Button x:Name="MoveDownPresetButton" Content="v" HorizontalAlignment="Left" Width="25" Margin="2,0,0,0" Click="MovePresetDownButton_Click"/>
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- Preset settings -->
|
||||
<GroupBox Header="Preset" Margin="5,5,0,0" Grid.Column="1" Visibility="{Binding SelectedPreset, Converter={StaticResource ReferenceToVisibility}, ElementName=window}">
|
||||
<Grid Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" MaxWidth="240"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label Content="Preset name" Grid.Row="0" HorizontalContentAlignment="Right" Margin="0,0,5,0"/>
|
||||
<TextBox x:Name="PresetNameTextBox" Grid.Row="0" Grid.Column="1" Margin="5,2,25,2" Text="{Binding SelectedPreset.Name, ElementName=window, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" TextWrapping="Wrap" Width="Auto" />
|
||||
|
||||
<GroupBox Grid.Row="1" Grid.Column="0" Header="Input formats" Margin="5">
|
||||
<Grid Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="25"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TreeView x:Name="InputTypesTreeView" ItemsSource="{Binding InputCategories, ElementName=window}" >
|
||||
<TreeView.Resources>
|
||||
<HierarchicalDataTemplate DataType="{x:Type local:InputExtensionCategory}" ItemsSource="{Binding InputExtensions}">
|
||||
<CheckBox Content="{Binding Name}" Height="20" VerticalAlignment="Top" Margin="2" Checked="OnInputTypeCategoryChecked" Unchecked="OnInputTypeCategoryUnchecked" IsThreeState="True" >
|
||||
<CheckBox.IsChecked>
|
||||
<MultiBinding Converter="{StaticResource CollectionContainsElementToBool}" Mode="OneWay">
|
||||
<Binding ElementName="window" Path="SelectedPreset.InputTypes" Mode="OneWay"/>
|
||||
<Binding Path="InputExtensionNames" Mode="OneWay"/>
|
||||
</MultiBinding>
|
||||
</CheckBox.IsChecked>
|
||||
</CheckBox>
|
||||
</HierarchicalDataTemplate>
|
||||
<DataTemplate DataType="{x:Type local:InputExtension}">
|
||||
<CheckBox Content="{Binding Name}" Height="20" VerticalAlignment="Top" Margin="2" Checked="OnInputTypeChecked" Unchecked="OnInputTypeUnchecked">
|
||||
<CheckBox.IsChecked>
|
||||
<MultiBinding Converter="{StaticResource CollectionContainsElementToBool}" Mode="OneWay">
|
||||
<Binding ElementName="window" Path="SelectedPreset.InputTypes" Mode="OneWay"/>
|
||||
<Binding Path="Name" Mode="OneWay"/>
|
||||
</MultiBinding>
|
||||
</CheckBox.IsChecked>
|
||||
</CheckBox>
|
||||
</DataTemplate>
|
||||
</TreeView.Resources>
|
||||
<TreeView.ItemContainerStyle>
|
||||
<Style TargetType="TreeViewItem">
|
||||
<Setter Property="IsExpanded" Value="True" />
|
||||
</Style>
|
||||
</TreeView.ItemContainerStyle>
|
||||
</TreeView>
|
||||
|
||||
<Label Grid.Row="1" Content="Action when conversion succeed"/>
|
||||
<ComboBox Grid.Row="2" x:Name="PostConversionActionComboBox" SelectedItem="{Binding SelectedPreset.InputPostConversionAction, ElementName=window, Mode=TwoWay}" />
|
||||
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Header="Output format" Grid.Row="1" Grid.Column="1" Margin="5">
|
||||
<StackPanel>
|
||||
<ComboBox x:Name="OutputFormats" Margin="5" Height="25" VerticalAlignment="Top" SelectedItem="{Binding SelectedPreset.OutputType, ElementName=window, Mode=TwoWay}"/>
|
||||
|
||||
<ContentControl ContentTemplateSelector="{StaticResource ResourceKey=ConversionSettingsSelector}"
|
||||
Content="{Binding SelectedPreset.OutputType, ElementName=window, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<Separator/>
|
||||
|
||||
<!-- Output file name template -->
|
||||
<Grid Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="23"/>
|
||||
<RowDefinition Height="23"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label Content="File name template" Grid.Row="0" HorizontalContentAlignment="Right" Margin="0,0,5,0"/>
|
||||
<TextBox x:Name="FileNameTemplateTextBox" Grid.Row="0" Grid.Column="1" Margin="5,2,25,2" Text="{Binding SelectedPreset.OutputFileNameTemplate, ElementName=window, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" TextWrapping="Wrap" Width="Auto" ToolTip="{x:Static project:Resources.OutputFilePathTemplateHelp}" />
|
||||
<Label Content="Input example" Grid.Row="1" Grid.Column="0" HorizontalContentAlignment="Right" Margin="0,0,5,0" Foreground="Gray" FontSize="10"/>
|
||||
<TextBlock Text="{x:Static project:Resources.OuputFileNameTemplateSample}" Grid.Row="1" Grid.Column="1" Margin="5,0,5,0" Foreground="Gray" FontSize="10" VerticalAlignment="Center"/>
|
||||
<Label Content="Output" Grid.Row="2" Grid.Column="0" HorizontalContentAlignment="Right" Margin="0,0,5,0" Foreground="Gray" FontSize="10"/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Margin="5,0,5,0" Foreground="Gray" FontSize="10" VerticalAlignment="Center">
|
||||
<TextBlock.Text>
|
||||
<MultiBinding Converter="{StaticResource FileNameConverter}">
|
||||
<Binding Source="{x:Static project:Resources.OuputFileNameTemplateSample}"/>
|
||||
<Binding ElementName="window" Path="SelectedPreset.OutputType" Mode="OneWay"/>
|
||||
<Binding ElementName="window" Path="SelectedPreset.OutputFileNameTemplate" Mode="OneWay"/>
|
||||
</MultiBinding>
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
</Grid>
|
||||
|
||||
<Button x:Name="CloseButton" Grid.Row="2" Content="Close" HorizontalAlignment="Right" Width="100" Margin="0,4,105,0" Click="CloseButton_Click" />
|
||||
<Button x:Name="SaveButton" Grid.Row="2" Content="Save" HorizontalAlignment="Right" Width="100" Margin="0,4,0,0" Click="SaveButton_Click" Command="New"/>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,282 @@
|
||||
// <copyright file="SettingsWindow.xaml.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
using FileConverter.Annotations;
|
||||
using Microsoft.Win32;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for Settings.
|
||||
/// </summary>
|
||||
public partial class SettingsWindow : Window, INotifyPropertyChanged
|
||||
{
|
||||
private ConversionPreset selectedPreset;
|
||||
|
||||
private Settings settings;
|
||||
|
||||
private InputExtensionCategory[] inputCategories;
|
||||
|
||||
public SettingsWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
Application application = Application.Current as Application;
|
||||
this.settings = application.Settings;
|
||||
this.PresetList.ItemsSource = this.settings.ConversionPresets;
|
||||
|
||||
OutputType[] outputTypes = new[]
|
||||
{
|
||||
OutputType.Flac,
|
||||
OutputType.Mp3,
|
||||
OutputType.Ogg,
|
||||
OutputType.Wav,
|
||||
};
|
||||
|
||||
this.OutputFormats.ItemsSource = outputTypes;
|
||||
|
||||
InputPostConversionAction[] postConversionActions = new[]
|
||||
{
|
||||
InputPostConversionAction.None,
|
||||
InputPostConversionAction.MoveInArchiveFolder,
|
||||
InputPostConversionAction.Delete,
|
||||
};
|
||||
|
||||
this.PostConversionActionComboBox.ItemsSource = postConversionActions;
|
||||
|
||||
this.InitializeCompatibleInputExtensions();
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public event System.EventHandler<System.EventArgs> OnSettingsWindowHide;
|
||||
|
||||
public ConversionPreset SelectedPreset
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.selectedPreset;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.selectedPreset = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public InputExtensionCategory[] InputCategories
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.inputCategories;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.inputCategories = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private void OnInputTypeChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.selectedPreset == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CheckBox checkBox = sender as System.Windows.Controls.CheckBox;
|
||||
string inputFormat = (checkBox.Content as string).ToLowerInvariant();
|
||||
|
||||
this.selectedPreset.AddInputType(inputFormat);
|
||||
}
|
||||
|
||||
private void OnInputTypeUnchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.selectedPreset == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CheckBox checkBox = sender as System.Windows.Controls.CheckBox;
|
||||
string inputFormat = (checkBox.Content as string).ToLowerInvariant();
|
||||
|
||||
this.selectedPreset.RemoveInputType(inputFormat);
|
||||
}
|
||||
|
||||
private void OnInputTypeCategoryChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.selectedPreset == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CheckBox checkBox = sender as System.Windows.Controls.CheckBox;
|
||||
string categoryName = checkBox.Content as string;
|
||||
InputExtensionCategory category = System.Array.Find(this.inputCategories, match => match.Name == categoryName);
|
||||
if (category == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string inputExtension in category.InputExtensionNames)
|
||||
{
|
||||
this.selectedPreset.AddInputType(inputExtension);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnInputTypeCategoryUnchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.selectedPreset == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CheckBox checkBox = sender as System.Windows.Controls.CheckBox;
|
||||
string categoryName = checkBox.Content as string;
|
||||
InputExtensionCategory category = System.Array.Find(this.inputCategories, match => match.Name == categoryName);
|
||||
if (category == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string inputExtension in category.InputExtensionNames)
|
||||
{
|
||||
this.selectedPreset.RemoveInputType(inputExtension);
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.HideSettingsWindow();
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// Save changes.
|
||||
Application application = Application.Current as Application;
|
||||
application.Settings.Save();
|
||||
|
||||
this.Hide();
|
||||
|
||||
this.OnSettingsWindowHide?.Invoke(this, new EventArgs());
|
||||
}
|
||||
|
||||
private void AddPresetButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Application application = Application.Current as Application;
|
||||
ConversionPreset newPreset = new ConversionPreset("New preset", OutputType.None, new string[0]);
|
||||
application.Settings.ConversionPresets.Add(newPreset);
|
||||
this.SelectedPreset = newPreset;
|
||||
this.PresetNameTextBox.Focus();
|
||||
this.PresetNameTextBox.SelectAll();
|
||||
}
|
||||
|
||||
private void RemovePresetButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Application application = Application.Current as Application;
|
||||
application.Settings.ConversionPresets.Remove(this.selectedPreset);
|
||||
}
|
||||
|
||||
private void CanSaveSettings(object sender, CanExecuteRoutedEventArgs e)
|
||||
{
|
||||
e.CanExecute = this.settings != null && string.IsNullOrEmpty(this.settings.Error);
|
||||
}
|
||||
|
||||
private void SettingsWindow_OnClosing(object sender, CancelEventArgs e)
|
||||
{
|
||||
e.Cancel = true;
|
||||
|
||||
this.HideSettingsWindow();
|
||||
}
|
||||
|
||||
private void HideSettingsWindow()
|
||||
{
|
||||
// Load previous preset in order to cancel changes.
|
||||
Application application = Application.Current as Application;
|
||||
application.Settings.Load();
|
||||
|
||||
this.Hide();
|
||||
|
||||
this.OnSettingsWindowHide?.Invoke(this, new EventArgs());
|
||||
}
|
||||
|
||||
private void MovePresetUpButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ConversionPreset presetToMove = this.SelectedPreset;
|
||||
if (presetToMove == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int indexOfSelectedPreset = this.settings.ConversionPresets.IndexOf(presetToMove);
|
||||
int newIndexOfSelectedPreset = System.Math.Max(0, indexOfSelectedPreset - 1);
|
||||
|
||||
this.settings.ConversionPresets.Move(indexOfSelectedPreset, newIndexOfSelectedPreset);
|
||||
}
|
||||
|
||||
private void MovePresetDownButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ConversionPreset presetToMove = this.SelectedPreset;
|
||||
if (presetToMove == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int indexOfSelectedPreset = this.settings.ConversionPresets.IndexOf(presetToMove);
|
||||
int newIndexOfSelectedPreset = System.Math.Min(this.settings.ConversionPresets.Count - 1, indexOfSelectedPreset + 1);
|
||||
|
||||
this.settings.ConversionPresets.Move(indexOfSelectedPreset, newIndexOfSelectedPreset);
|
||||
}
|
||||
|
||||
private void InitializeCompatibleInputExtensions()
|
||||
{
|
||||
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software\FileConverter");
|
||||
if (registryKey == null)
|
||||
{
|
||||
MessageBox.Show("Can't retrieve the list of compatible input extensions. (code 0x09)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
string registryValue = registryKey.GetValue("CompatibleInputExtensions") as string;
|
||||
if (registryValue == null)
|
||||
{
|
||||
MessageBox.Show("Can't retrieve the list of compatible input extensions. (code 0x0A)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
string[] compatibleInputExtensions = registryValue.Split(';');
|
||||
|
||||
List<InputExtensionCategory> categories = new List<InputExtensionCategory>();
|
||||
for (int index = 0; index < compatibleInputExtensions.Length; index++)
|
||||
{
|
||||
string compatibleInputExtension = compatibleInputExtensions[index];
|
||||
string extensionCategory = PathHelpers.GetExtensionCategory(compatibleInputExtension);
|
||||
InputExtensionCategory category = categories.Find(match => match.Name == extensionCategory);
|
||||
if (category == null)
|
||||
{
|
||||
category = new InputExtensionCategory(extensionCategory);
|
||||
categories.Add(category);
|
||||
}
|
||||
|
||||
category.AddExtension(compatibleInputExtension);
|
||||
}
|
||||
|
||||
this.InputCategories = categories.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
// <copyright file="XmlHelpers.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
public class XmlHelpers
|
||||
{
|
||||
public static void LoadFromFile<T>(string root, string path, ref ICollection<T> collection)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException("path");
|
||||
}
|
||||
|
||||
XmlRootAttribute xmlRoot = new XmlRootAttribute
|
||||
{
|
||||
ElementName = root
|
||||
};
|
||||
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(List<T>), xmlRoot);
|
||||
|
||||
try
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(path))
|
||||
{
|
||||
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
|
||||
{
|
||||
IgnoreWhitespace = true, IgnoreComments = true
|
||||
};
|
||||
|
||||
using (XmlReader xmlReader = XmlReader.Create(reader, xmlReaderSettings))
|
||||
{
|
||||
List<T> elements = (List<T>)serializer.Deserialize(xmlReader);
|
||||
for (int index = 0; index < elements.Count; index++)
|
||||
{
|
||||
T item = elements[index];
|
||||
|
||||
if (item is IXmlSerializable)
|
||||
{
|
||||
(item as IXmlSerializable).OnDeserializationComplete();
|
||||
}
|
||||
|
||||
collection.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception exception)
|
||||
{
|
||||
Diagnostics.Log("The database of type '" + typeof(T) + "' failed to load the asset. The following exception was raised:\n " + exception.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveToFile<T>(string root, string path, ICollection<T> objectsToSerialize)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<T> list = new List<T>();
|
||||
list.AddRange(objectsToSerialize);
|
||||
|
||||
XmlRootAttribute xmlRoot = new XmlRootAttribute
|
||||
{
|
||||
ElementName = root
|
||||
};
|
||||
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(List<T>), xmlRoot);
|
||||
|
||||
try
|
||||
{
|
||||
using (StreamWriter writer = new StreamWriter(path))
|
||||
{
|
||||
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings
|
||||
{
|
||||
Indent = true, IndentChars = " "
|
||||
};
|
||||
|
||||
using (XmlWriter xmlWriter = XmlWriter.Create(writer, xmlWriterSettings))
|
||||
{
|
||||
serializer.Serialize(xmlWriter, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception exception)
|
||||
{
|
||||
Diagnostics.Log("The database of type '" + typeof(T) + "' failed to load the asset. The following exception was raised:\n " + exception.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
namespace FileConverterExtension
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
@@ -13,11 +16,68 @@ namespace FileConverterExtension
|
||||
using SharpShell.Attributes;
|
||||
using SharpShell.SharpContextMenu;
|
||||
|
||||
/// <summary>
|
||||
/// File converter context menu extension class.
|
||||
/// </summary>
|
||||
[ComVisible(true), Guid("AF9B72B5-F4E4-44B0-A3D9-B55B748EFE90")]
|
||||
[COMServerAssociation(AssociationType.AllFiles)]
|
||||
public class FileConverterExtension : SharpContextMenu
|
||||
{
|
||||
private string fileConverterPath;
|
||||
private RegistryKey fileConverterRegistryKey;
|
||||
private List<PresetDefinition> presetList = new List<PresetDefinition>();
|
||||
private List<string> compatibleInputExtensions = new List<string>();
|
||||
|
||||
private RegistryKey FileConverterRegistryKey
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.fileConverterRegistryKey == null)
|
||||
{
|
||||
this.fileConverterRegistryKey = Registry.CurrentUser.OpenSubKey(@"Software\FileConverter");
|
||||
if (this.fileConverterRegistryKey == null)
|
||||
{
|
||||
throw new Exception("Can't retrieve file converter registry entry.");
|
||||
}
|
||||
}
|
||||
|
||||
return this.fileConverterRegistryKey;
|
||||
}
|
||||
}
|
||||
|
||||
private string FileConverterPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.fileConverterPath))
|
||||
{
|
||||
this.fileConverterPath = this.FileConverterRegistryKey.GetValue("Path") as string;
|
||||
}
|
||||
|
||||
return this.fileConverterPath;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<string> CompatibleInputExtensions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.compatibleInputExtensions != null && this.compatibleInputExtensions.Count > 0)
|
||||
{
|
||||
return this.compatibleInputExtensions;
|
||||
}
|
||||
|
||||
this.compatibleInputExtensions.Clear();
|
||||
string registryValue = this.FileConverterRegistryKey.GetValue("CompatibleInputExtensions") as string;
|
||||
string[] extensions = registryValue.Split(';');
|
||||
for (int index = 0; index < extensions.Length; index++)
|
||||
{
|
||||
this.compatibleInputExtensions.Add(extensions[index]);
|
||||
}
|
||||
|
||||
return this.compatibleInputExtensions;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool CanShowMenu()
|
||||
{
|
||||
@@ -30,22 +90,9 @@ namespace FileConverterExtension
|
||||
}
|
||||
|
||||
extension = extension.Substring(1).ToLowerInvariant();
|
||||
switch (extension)
|
||||
if (this.CompatibleInputExtensions.Contains(extension))
|
||||
{
|
||||
case "mp3":
|
||||
return true;
|
||||
|
||||
case "wav":
|
||||
return true;
|
||||
|
||||
case "ogg":
|
||||
return true;
|
||||
|
||||
case "flac":
|
||||
return true;
|
||||
|
||||
case "wma":
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,80 +101,127 @@ namespace FileConverterExtension
|
||||
|
||||
protected override ContextMenuStrip CreateMenu()
|
||||
{
|
||||
this.RefreshPresetList();
|
||||
|
||||
ContextMenuStrip menu = new ContextMenuStrip();
|
||||
|
||||
ToolStripMenuItem fileConverterItem = new ToolStripMenuItem
|
||||
{
|
||||
Text = "File Converter"
|
||||
Text = "File Converter",
|
||||
Image = Properties.Resources.ApplicationIcon_16x16.ToBitmap(),
|
||||
};
|
||||
|
||||
for (int index = 0; index < this.presetList.Count; index++)
|
||||
{
|
||||
PresetDefinition preset = this.presetList[index];
|
||||
|
||||
ToolStripMenuItem subItem = new ToolStripMenuItem
|
||||
{
|
||||
Text = "To Ogg",
|
||||
Text = preset.Name,
|
||||
Enabled = preset.Enabled
|
||||
};
|
||||
|
||||
fileConverterItem.DropDownItems.Add(subItem);
|
||||
subItem.Click += (sender, args) => this.ConvertFiles(FileType.Ogg);
|
||||
subItem.Click += (sender, args) => this.ConvertFiles(preset.Name);
|
||||
}
|
||||
|
||||
if (this.presetList.Count > 0)
|
||||
{
|
||||
fileConverterItem.DropDownItems.Add(new ToolStripSeparator());
|
||||
}
|
||||
|
||||
{
|
||||
ToolStripMenuItem subItem = new ToolStripMenuItem
|
||||
{
|
||||
Text = "To Mp3",
|
||||
Text = "Settings",
|
||||
};
|
||||
|
||||
fileConverterItem.DropDownItems.Add(subItem);
|
||||
subItem.Click += (sender, args) => this.ConvertFiles(FileType.Mp3);
|
||||
}
|
||||
|
||||
{
|
||||
ToolStripMenuItem subItem = new ToolStripMenuItem
|
||||
{
|
||||
Text = "To Flac",
|
||||
};
|
||||
|
||||
fileConverterItem.DropDownItems.Add(subItem);
|
||||
subItem.Click += (sender, args) => this.ConvertFiles(FileType.Flac);
|
||||
}
|
||||
|
||||
{
|
||||
ToolStripMenuItem subItem = new ToolStripMenuItem
|
||||
{
|
||||
Text = "To Wav",
|
||||
};
|
||||
|
||||
fileConverterItem.DropDownItems.Add(subItem);
|
||||
subItem.Click += (sender, args) => this.ConvertFiles(FileType.Wav);
|
||||
subItem.Click += (sender, args) => this.OpenSettings();
|
||||
}
|
||||
|
||||
menu.Items.Add(fileConverterItem);
|
||||
|
||||
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software\FileConverter");
|
||||
this.fileConverterPath = null;
|
||||
if (registryKey != null)
|
||||
{
|
||||
this.fileConverterPath = registryKey.GetValue("Path") as string;
|
||||
}
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
private void ConvertFiles(FileType ouputType)
|
||||
private void RefreshPresetList()
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.fileConverterPath))
|
||||
// Retrieve selected files extensions.
|
||||
List<string> extensions = new List<string>();
|
||||
foreach (string filePath in this.SelectedItemPaths)
|
||||
{
|
||||
string extension = Path.GetExtension(filePath);
|
||||
if (string.IsNullOrEmpty(extension))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
extension = extension.Substring(1).ToLowerInvariant();
|
||||
if (extensions.Contains(extension))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
extensions.Add(extension);
|
||||
}
|
||||
|
||||
// Compute preset list.
|
||||
this.presetList.Clear();
|
||||
RegistryKey fileConverterKey = this.FileConverterRegistryKey;
|
||||
for (int extensionIndex = 0; extensionIndex < extensions.Count; extensionIndex++)
|
||||
{
|
||||
string extension = extensions[extensionIndex];
|
||||
RegistryKey extensionKey = fileConverterKey.OpenSubKey(extension);
|
||||
if (extensionKey == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string presetsString = extensionKey.GetValue("Presets") as string;
|
||||
if (presetsString == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string[] presets = presetsString.Split(';');
|
||||
|
||||
for (int presetIndex = 0; presetIndex < presets.Length; presetIndex++)
|
||||
{
|
||||
string presetName = presets[presetIndex];
|
||||
PresetDefinition presetDefinition = this.presetList.FirstOrDefault(match => match.Name == presetName);
|
||||
if (presetDefinition == null)
|
||||
{
|
||||
presetDefinition = new PresetDefinition(presetName);
|
||||
this.presetList.Add(presetDefinition);
|
||||
}
|
||||
|
||||
presetDefinition.ExtensionRefCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Update enable states.
|
||||
for (int index = 0; index < this.presetList.Count; index++)
|
||||
{
|
||||
this.presetList[index].Enabled = this.presetList[index].ExtensionRefCount == extensions.Count;
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenSettings()
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.FileConverterPath))
|
||||
{
|
||||
MessageBox.Show(string.Format("Can't retrieve the file converter executable path. You should try to reinstall the application."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!File.Exists(this.fileConverterPath))
|
||||
if (!File.Exists(this.FileConverterPath))
|
||||
{
|
||||
MessageBox.Show(string.Format("Can't find the file converter executable ({0}). You should try to reinstall the application.", this.fileConverterPath));
|
||||
MessageBox.Show(string.Format("Can't find the file converter executable ({0}). You should try to reinstall the application.", this.FileConverterPath));
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessStartInfo processStartInfo = new ProcessStartInfo(this.fileConverterPath);
|
||||
ProcessStartInfo processStartInfo = new ProcessStartInfo(this.FileConverterPath);
|
||||
|
||||
processStartInfo.CreateNoWindow = false;
|
||||
processStartInfo.UseShellExecute = false;
|
||||
@@ -135,8 +229,38 @@ namespace FileConverterExtension
|
||||
|
||||
// Build arguments string.
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.Append("--output-type ");
|
||||
stringBuilder.Append(ouputType.ToString());
|
||||
stringBuilder.Append("--settings");
|
||||
|
||||
processStartInfo.Arguments = stringBuilder.ToString();
|
||||
Process exeProcess = Process.Start(processStartInfo);
|
||||
}
|
||||
|
||||
private void ConvertFiles(string presetName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.FileConverterPath))
|
||||
{
|
||||
MessageBox.Show(string.Format("Can't retrieve the file converter executable path. You should try to reinstall the application."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!File.Exists(this.FileConverterPath))
|
||||
{
|
||||
MessageBox.Show(string.Format("Can't find the file converter executable ({0}). You should try to reinstall the application.", this.FileConverterPath));
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessStartInfo processStartInfo = new ProcessStartInfo(this.FileConverterPath);
|
||||
|
||||
processStartInfo.CreateNoWindow = false;
|
||||
processStartInfo.UseShellExecute = false;
|
||||
processStartInfo.RedirectStandardOutput = false;
|
||||
|
||||
// Build arguments string.
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.Append("--conversion-preset ");
|
||||
stringBuilder.Append(" \"");
|
||||
stringBuilder.Append(presetName);
|
||||
stringBuilder.Append("\"");
|
||||
|
||||
foreach (var filePath in this.SelectedItemPaths)
|
||||
{
|
||||
|
||||
@@ -61,18 +61,35 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FileConverterExtension.cs" />
|
||||
<Compile Include="FileType.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="PresetDefinition.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="FileConverterExtensionKey.snk" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\ApplicationIcon-16x16.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -1,14 +0,0 @@
|
||||
// <copyright file="FileType.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverterExtension
|
||||
{
|
||||
public enum FileType
|
||||
{
|
||||
Undefined,
|
||||
|
||||
Mp3,
|
||||
Ogg,
|
||||
Flac,
|
||||
Wav,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// <copyright file="PresetDefinition.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverterExtension
|
||||
{
|
||||
public class PresetDefinition
|
||||
{
|
||||
public PresetDefinition(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public int ExtensionRefCount
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.0
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace FileConverterExtension.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FileConverterExtension.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon ApplicationIcon_16x16 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ApplicationIcon_16x16", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="ApplicationIcon_16x16" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ApplicationIcon-16x16.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,24 @@
|
||||
<StyleCopSettings Version="105">
|
||||
<Analyzers>
|
||||
<Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
|
||||
<Rules>
|
||||
<Rule Name="ElementsMustBeDocumented">
|
||||
<RuleSettings>
|
||||
<BooleanProperty Name="Enabled">False</BooleanProperty>
|
||||
</RuleSettings>
|
||||
</Rule>
|
||||
<Rule Name="EnumerationItemsMustBeDocumented">
|
||||
<RuleSettings>
|
||||
<BooleanProperty Name="Enabled">False</BooleanProperty>
|
||||
</RuleSettings>
|
||||
</Rule>
|
||||
<Rule Name="PartialElementsMustBeDocumented">
|
||||
<RuleSettings>
|
||||
<BooleanProperty Name="Enabled">False</BooleanProperty>
|
||||
</RuleSettings>
|
||||
</Rule>
|
||||
</Rules>
|
||||
<AnalyzerSettings />
|
||||
</Analyzer>
|
||||
</Analyzers>
|
||||
</StyleCopSettings>
|
||||
@@ -11,14 +11,17 @@
|
||||
<?endif ?>
|
||||
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||
<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="0.1.0" Manufacturer="AAllard" UpgradeCode="e3ca717b-a897-418a-bbef-5c7e35c76e4b">
|
||||
<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="0.3.0" Manufacturer="AAllard" UpgradeCode="e3ca717b-a897-418a-bbef-5c7e35c76e4b">
|
||||
<Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Platform="x64" />
|
||||
|
||||
<Icon Id="icon.ico" SourceFile="..\Resources\ApplicationIcon-256x256.ico"/>
|
||||
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
|
||||
|
||||
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
|
||||
<Media Id="1" Cabinet="CabFile.cab" EmbedCab="yes" />
|
||||
|
||||
<Feature Id="ProductFeature" Title="Installer" Level="1">
|
||||
<ComponentGroupRef Id="ProductComponents" />
|
||||
<ComponentGroupRef Id="ProductComponents" />
|
||||
</Feature>
|
||||
|
||||
<Feature Id="ShellExtensionFeature" Title="ShellExtension" Level="1" AllowAdvertise="no">
|
||||
@@ -27,14 +30,14 @@
|
||||
|
||||
<UIRef Id="WixUI_InstallDir" />
|
||||
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
|
||||
|
||||
<WixVariable Id="WixUILicenseRtf" Value="License.rtf" />
|
||||
<!--<WixVariable Id="WixUIBannerBmp" Value="path\banner.bmp" />
|
||||
<WixVariable Id="WixUIDialogBmp" Value="path\dialog.bmp" />
|
||||
<WixVariable Id="WixUIExclamationIco" Value="path\exclamation.ico" />
|
||||
<WixVariable Id="WixUIInfoIco" Value="path\information.ico" />
|
||||
<WixVariable Id="WixUINewIco" Value="path\new.ico" />
|
||||
<WixVariable Id="WixUIUpIco" Value="path\up.ico" />-->
|
||||
|
||||
<WixVariable Id="WixUILicenseRtf" Value="License.rtf" />
|
||||
<WixVariable Id="WixUIBannerBmp" Value="..\Resources\Installer\Banner.bmp" />
|
||||
<WixVariable Id="WixUIDialogBmp" Value="..\Resources\Installer\UI.bmp" />
|
||||
<WixVariable Id="WixUIExclamationIco" Value="..\Resources\Installer\ErrorIcon.ico" />
|
||||
<WixVariable Id="WixUIInfoIco" Value="..\Resources\Installer\WarningIcon.ico" />
|
||||
<!--<WixVariable Id="WixUINewIco" Value="Icon16x16.ico" />
|
||||
<WixVariable Id="WixUIUpIco" Value="Icon16x16.ico" />-->
|
||||
</Product>
|
||||
|
||||
<Fragment>
|
||||
@@ -57,14 +60,49 @@
|
||||
<Component Guid="{1790B82E-86BC-4B95-AA1D-9859FF3B6CA4}" Win64="$(var.Win64)">
|
||||
<File Source="..\Middleware\ffmpeg.exe" KeyPath="yes" />
|
||||
</Component>
|
||||
<Component Guid="{86AEF5B3-C25B-4662-BAEF-20969D1821A5}" Win64="$(var.Win64)">
|
||||
<File Source="..\Application\FileConverter\Settings.xml" KeyPath="yes" />
|
||||
</Component>
|
||||
<Component Guid="{A5158756-A107-4010-9E2F-3C0333F5A5F6}" Win64="$(var.Win64)">
|
||||
<File Source="..\README.md" KeyPath="yes" />
|
||||
</Component>
|
||||
|
||||
<!-- Registry entries -->
|
||||
<Component Id="RegistryEntries" Guid="{C3EF3D67-0206-4DBD-B2EA-78FF2E290093}">
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter" Action="createAndRemoveOnUninstall">
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter">
|
||||
<RegistryValue Name="Path" Type="string" Value="[INSTALLFOLDER]FileConverter.exe"/>
|
||||
<RegistryValue Name="CompatibleInputExtensions" Type="string" Value="aiff;ape;avi;flac;m4a;mp3;mp4;ogg;wav;wma"/>
|
||||
</RegistryKey>
|
||||
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter\aiff">
|
||||
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Flac;To Wav"/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter\ape">
|
||||
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Flac;To Wav"/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter\avi">
|
||||
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Flac;To Wav"/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter\flac">
|
||||
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Wav"/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter\m4a">
|
||||
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Wav"/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter\mp3">
|
||||
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Wav"/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter\mp4">
|
||||
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Flac;To Wav"/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter\ogg">
|
||||
<RegistryValue Name="Presets" Type="string" Value="To Mp3;To Wav"/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter\wav">
|
||||
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Flac"/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter\wma">
|
||||
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Wav"/>
|
||||
</RegistryKey>
|
||||
</Component>
|
||||
</ComponentGroup>
|
||||
|
||||
@@ -1,8 +1,88 @@
|
||||
# File Converter
|
||||
|
||||
## Description
|
||||
File Converter is a very simple tool who allows you to convert one or several file(s) from one format to another using the context menu in windows explorer.
|
||||
This program use [ffmpeg](https://www.ffmpeg.org/) as file conversion tool.
|
||||
**File Converter** is a very simple tool which allows you to convert one or several file(s) from one format to another using the context menu in windows explorer.
|
||||
This program uses [ffmpeg](https://www.ffmpeg.org/) as file conversion software.
|
||||
|
||||
You can convert files from formats **Aiff, Ape, Avi, Flac, M4a, Mp3, Mp4, Ogg, Wav, Wma** to formats **Mp3, Ogg, Wav, Flac**.
|
||||
|
||||
*Note: If your source file is a video, the conversion to an audio format will extract the audio part of the video.*
|
||||
|
||||
***Remove any previous installation of the application before installing the newer version.***
|
||||
|
||||
This application is under GPL version 3 licence.
|
||||
For more informations check the LICENSE file in your installation folder or the [gnu website](http://www.gnu.org/licenses/gpl.html).
|
||||
|
||||
## Input file post conversion actions
|
||||
|
||||
This actions allow you to chose what you want to do with your input files if the conversion succeed.
|
||||
|
||||
Action | Description
|
||||
----------------------------|------------------------------------------------------------------------------------------------
|
||||
**None** | Don't modify the input file. If the output file name conflict with the input, it will be renamed.
|
||||
**Move in archive folder** | Move the input file in a folder named *Conversion Archives* if the conversion is a success.
|
||||
**Delete** | Delete the input file if the conversion is a success (be careful no warning will be prompted).
|
||||
|
||||
## Output file path template
|
||||
|
||||
This template allow you to define how you want to generate the output file path (depending on the input file path).
|
||||
You have access to the following informations:
|
||||
|
||||
Pattern | Description | Example (with input path: *C:\Music\Artist\Album\Song.wav*)
|
||||
--------|-------------------------------|-----------------------------------------------------------------
|
||||
(p) | Input file path | C:\Music\Artist\Album\
|
||||
(f) | Input file name | Song
|
||||
(o) | Output file format | mp3
|
||||
(i) | Input file format | wav
|
||||
(d0) | Input parent folder name | Album
|
||||
(d1) | Input sub parent folder name | Artist
|
||||
|
||||
*Tips: You can use uppercase to retrieve caps lock informations. Example: (f) -> Default / (F) -> DEFAULT *
|
||||
|
||||
### Examples
|
||||
|
||||
Simple default template (just change the extension):
|
||||
|
||||
Input: C:\Music\Artist\Album\Song.wav
|
||||
Template: (p)(f)
|
||||
Generated output: C:\Music\Artist\Album\Song.mp3
|
||||
|
||||
File name customization:
|
||||
|
||||
Input: C:\Music\Artist\Album\Song.wav
|
||||
Template: (p)(O)_(f) (from (i))
|
||||
Generated output: C:\Music\Artist\Album\MP3_Song (from wav).mp3
|
||||
|
||||
File path customization:
|
||||
|
||||
Input: C:\Music\Artist\Album\Song.wav
|
||||
Template: D:\(o)\(d1)\(f)
|
||||
Generated output: D:\mp3\Artist\Song.mp3
|
||||
|
||||
## Change Log
|
||||
v0.3
|
||||
- New: Possibility to extract audio from videos.
|
||||
- New: Support new input file formats: aiff, m4a, avi, mp4.
|
||||
- New: Quality settings for Mp3 (Encoding mode vbr/cbr and bitrate).
|
||||
- New: Quality settings for Ogg (Bitrate).
|
||||
- New: Quality settings for Wav (bits per sample: 8, 16, 24 or 32).
|
||||
- New: Add output file path template system.
|
||||
- New: Add button to move up or down a preset.
|
||||
- New: Add input files post conversion action (No action, move in archive folder or delete).
|
||||
- New: Add categories on input file extensions.
|
||||
- Fixed: Lose focus of main window don't terminate the application.
|
||||
- Fixed: The application icon now have a correct resolution at any size.
|
||||
- Tech: Add error codes on error messages.
|
||||
|
||||
v0.2
|
||||
- New: Support new input file format: ape.
|
||||
- New: Add notion of conversion preset (in order to customize the conversion possibilities).
|
||||
- New: Add settings window to edit conversion presets.
|
||||
- New: Add application icon.
|
||||
- New: Customize application installer.
|
||||
- New: Add diagnostic window to read the application logs.
|
||||
|
||||
v0.1
|
||||
You can convert files from formats **Mp3, Ogg, Wav, Flac, Wma** to formats **Mp3, Ogg, Wav, Flac**
|
||||
- New: Add decode support for file formats Mp3, Ogg, Wav, Flac, Wma
|
||||
- New: Add encode support for file formats Mp3, Ogg, Wav, Flac
|
||||
- New: UI to visualize the conversion progress
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 294 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
@@ -0,0 +1,159 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
id="Capa_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
width="792px"
|
||||
height="792px"
|
||||
viewBox="0 0 792 792"
|
||||
style="enable-background:new 0 0 792 792;"
|
||||
xml:space="preserve"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="ApplicationIcon.svg"
|
||||
inkscape:export-filename="D:\Users\Adrien.Adrien-PC\Documents\GitHub\FileConverter\Resources\ApplicationIcon.png"
|
||||
inkscape:export-xdpi="8.6400003"
|
||||
inkscape:export-ydpi="8.6400003"><metadata
|
||||
id="metadata3385"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs3383" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1018"
|
||||
id="namedview3381"
|
||||
showgrid="false"
|
||||
showguides="true"
|
||||
inkscape:guide-bbox="true"
|
||||
inkscape:zoom="0.3535534"
|
||||
inkscape:cx="-538.5249"
|
||||
inkscape:cy="-40.831874"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer4"><sodipodi:guide
|
||||
position="21.058654,403.40483"
|
||||
orientation="0,1"
|
||||
id="guide4315" /></sodipodi:namedview><g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer3"
|
||||
inkscape:label="Background"><circle
|
||||
style="opacity:1;fill:#0171bb;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:4;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path4286"
|
||||
cx="389.60046"
|
||||
cy="396.81552"
|
||||
r="250" /></g><g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer4"
|
||||
inkscape:label="Pattern"
|
||||
style="display:inline"><circle
|
||||
style="opacity:1;fill:#004b82;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path4393"
|
||||
cx="388.34808"
|
||||
cy="393.1311"
|
||||
r="185.13635" /><path
|
||||
style="fill:#004b82;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 220.61731,309.04607 333.0473,168.99852 -96.87364,160.51324 C 224.69865,684.45629 144.72119,490.77251 144.24978,434.20397 Z"
|
||||
id="path4397"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="ccccc" /></g><g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer2"
|
||||
inkscape:label="Arrow"
|
||||
style="display:inline"><path
|
||||
style="opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:45;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path4307"
|
||||
sodipodi:type="arc"
|
||||
sodipodi:cx="388.49072"
|
||||
sodipodi:cy="391.00571"
|
||||
sodipodi:rx="164.15593"
|
||||
sodipodi:ry="164.15593"
|
||||
sodipodi:start="0.5814947"
|
||||
sodipodi:end="6.2723665"
|
||||
d="M 525.66641,481.17222 A 164.15593,164.15593 0 0 1 319.54955,539.98317 164.15593,164.15593 0 0 1 230.97218,344.79881 164.15593,164.15593 0 0 1 410.95201,228.39372 164.15593,164.15593 0 0 1 552.63705,389.22977"
|
||||
sodipodi:open="true" /><path
|
||||
style="fill:#ffffff;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 502.05274,388.6363 52.26457,89.16055 48.0834,-89.16055 z"
|
||||
id="path4317"
|
||||
inkscape:connector-curvature="0" /><path
|
||||
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 544.46303,493.53621 -28.0754,-44.18448 -9.52444,19.46287 z"
|
||||
id="path4348"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccc" /></g><g
|
||||
id="g3337"
|
||||
transform="matrix(0.55346595,0,0,0.55346595,167.0343,189.85664)" /><g
|
||||
id="g3351" /><g
|
||||
id="g3353" /><g
|
||||
id="g3355" /><g
|
||||
id="g3357" /><g
|
||||
id="g3359" /><g
|
||||
id="g3361" /><g
|
||||
id="g3363" /><g
|
||||
id="g3365" /><g
|
||||
id="g3367" /><g
|
||||
id="g3369" /><g
|
||||
id="g3371" /><g
|
||||
id="g3373" /><g
|
||||
id="g3375" /><g
|
||||
id="g3377" /><g
|
||||
id="g3379" /><g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
inkscape:label="Files"
|
||||
style="display:inline"><g
|
||||
transform="translate(491.76135,105.01435)"
|
||||
id="g3"
|
||||
style="stroke:#ffffff;stroke-opacity:1;fill:#ffffff;fill-opacity:0.94117647;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none"><g
|
||||
id="g5"
|
||||
style="stroke:#ffffff;stroke-opacity:1;fill:#ffffff;fill-opacity:0.94117647;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none"><path
|
||||
inkscape:connector-curvature="0"
|
||||
d="m -174.15384,386.14314 149.574394,0 c 4.183017,0 7.605485,-3.42247 7.605485,-7.60549 l 0,-129.16619 c 0,-2.15503 -0.887157,-4.18301 -2.408254,-5.57751 l -58.815902,-54.63288 c -1.39404,-1.26743 -3.295411,-2.02798 -5.196783,-2.02798 l -90.75894,0 c -4.18302,0 -7.60548,3.42247 -7.60548,7.60549 l 0,183.79907 c 0,4.18302 3.42246,7.60549 7.60548,7.60549 z m 141.968909,-133.47627 0,0.38028 -51.970517,0 0,-48.67511 51.970517,48.29483 z m -134.363419,-50.32281 67.181935,0 0,58.30857 c 0,4.18302 3.422465,7.60549 7.605481,7.60549 l 59.57645,0 0,102.67405 -134.363866,0 0,-168.58811 z"
|
||||
id="path7"
|
||||
style="stroke:#ffffff;stroke-opacity:1;fill:#ffffff;fill-opacity:0.94117647;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none" /></g></g><g
|
||||
transform="translate(491.76135,105.01435)"
|
||||
id="g9" /><g
|
||||
transform="translate(491.76135,105.01435)"
|
||||
id="g11" /><g
|
||||
transform="translate(491.76135,105.01435)"
|
||||
id="g13" /><g
|
||||
transform="translate(491.76135,105.01435)"
|
||||
id="g15" /><g
|
||||
transform="translate(491.76135,105.01435)"
|
||||
id="g17" /><g
|
||||
transform="translate(491.76135,105.01435)"
|
||||
id="g19" /><g
|
||||
transform="translate(491.76135,105.01435)"
|
||||
id="g21" /><g
|
||||
transform="translate(491.76135,105.01435)"
|
||||
id="g23" /><g
|
||||
transform="translate(491.76135,105.01435)"
|
||||
id="g25" /><g
|
||||
transform="translate(491.76135,105.01435)"
|
||||
id="g27" /><g
|
||||
transform="translate(491.76135,105.01435)"
|
||||
id="g29" /><g
|
||||
transform="translate(491.76135,105.01435)"
|
||||
id="g31" /><g
|
||||
transform="translate(491.76135,105.01435)"
|
||||
id="g33" /><g
|
||||
transform="translate(491.76135,105.01435)"
|
||||
id="g35" /><g
|
||||
transform="translate(491.76135,105.01435)"
|
||||
id="g37" /></g></svg>
|
||||
|
After Width: | Height: | Size: 7.0 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
@@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
id="Capa_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 27.964 27.964"
|
||||
style="enable-background:new 0 0 27.964 27.964;"
|
||||
xml:space="preserve"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="ErrorIcon.svg"><metadata
|
||||
id="metadata44"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs42" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1018"
|
||||
id="namedview40"
|
||||
showgrid="false"
|
||||
inkscape:zoom="33.757688"
|
||||
inkscape:cx="12.891981"
|
||||
inkscape:cy="17.64304"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Capa_1" /><g
|
||||
id="g3"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
transform="matrix(0.96727092,0,0,0.96727092,0.4279787,0.48722445)"><g
|
||||
id="c127_X"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"><path
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
d="M 13.981,0 C 6.261,0 0,6.259 0,13.979 c 0,7.724 6.261,13.984 13.981,13.984 7.725,0 13.983,-6.261 13.983,-13.984 C 27.965,6.259 21.706,0 13.981,0 Z m 0,26.531 c -6.93,0 -12.55,-5.62 -12.55,-12.553 0,-6.93 5.62,-12.548 12.55,-12.548 6.931,0 12.553,5.618 12.553,12.548 0,6.933 -5.622,12.553 -12.553,12.553 z"
|
||||
id="path6"
|
||||
inkscape:connector-curvature="0" /><path
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
d="M 19.994,10.197 17.767,7.97 c 0,0 -3.553,3.783 -3.785,3.783 -0.231,0 -3.785,-3.783 -3.785,-3.783 l -2.228,2.228 c 0,0 3.785,3.472 3.785,3.787 0,0.312 -3.785,3.782 -3.785,3.782 l 2.228,2.226 c 0,0 3.525,-3.784 3.785,-3.784 0.262,0 3.785,3.784 3.785,3.784 l 2.228,-2.226 c 0,0 -3.786,-3.528 -3.786,-3.782 -0.001,-0.263 3.785,-3.788 3.785,-3.788 z"
|
||||
id="path8"
|
||||
inkscape:connector-curvature="0" /></g></g><g
|
||||
id="g10"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
transform="matrix(0.96727092,0,0,0.96727092,0.4279787,0.48722445)" /><g
|
||||
id="g12"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
transform="matrix(0.96727092,0,0,0.96727092,0.4279787,0.48722445)" /><g
|
||||
id="g14"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
transform="matrix(0.96727092,0,0,0.96727092,0.4279787,0.48722445)" /><g
|
||||
id="g16"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
transform="matrix(0.96727092,0,0,0.96727092,0.4279787,0.48722445)" /><g
|
||||
id="g18"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
transform="matrix(0.96727092,0,0,0.96727092,0.4279787,0.48722445)" /><g
|
||||
id="g20"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
transform="matrix(0.96727092,0,0,0.96727092,0.4279787,0.48722445)" /><g
|
||||
id="g22"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
transform="matrix(0.96727092,0,0,0.96727092,0.4279787,0.48722445)" /><g
|
||||
id="g24"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
transform="matrix(0.96727092,0,0,0.96727092,0.4279787,0.48722445)" /><g
|
||||
id="g26"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
transform="matrix(0.96727092,0,0,0.96727092,0.4279787,0.48722445)" /><g
|
||||
id="g28"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
transform="matrix(0.96727092,0,0,0.96727092,0.4279787,0.48722445)" /><g
|
||||
id="g30"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
transform="matrix(0.96727092,0,0,0.96727092,0.4279787,0.48722445)" /><g
|
||||
id="g32"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
transform="matrix(0.96727092,0,0,0.96727092,0.4279787,0.48722445)" /><g
|
||||
id="g34"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
transform="matrix(0.96727092,0,0,0.96727092,0.4279787,0.48722445)" /><g
|
||||
id="g36"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
transform="matrix(0.96727092,0,0,0.96727092,0.4279787,0.48722445)" /><g
|
||||
id="g38"
|
||||
style="fill:#d32f2f;fill-opacity:1;stroke:#d32f2f;stroke-opacity:1"
|
||||
transform="matrix(0.96727092,0,0,0.96727092,0.4279787,0.48722445)" /></svg>
|
||||
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 451 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
id="Capa_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 29.535 29.535"
|
||||
style="enable-background:new 0 0 29.535 29.535;"
|
||||
xml:space="preserve"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="WarningIcon.svg"><metadata
|
||||
id="metadata45"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs43" /><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1018"
|
||||
id="namedview41"
|
||||
showgrid="false"
|
||||
inkscape:zoom="7.9905198"
|
||||
inkscape:cx="-4.6304873"
|
||||
inkscape:cy="14.7675"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Capa_1" /><g
|
||||
id="g3"
|
||||
style="fill:#ffa000;fill-opacity:1"><path
|
||||
style="fill:#ffa000;fill-opacity:1"
|
||||
d="M14.768,0C6.609,0,0,6.609,0,14.768c0,8.155,6.609,14.767,14.768,14.767s14.766-6.612,14.766-14.767 C29.534,6.609,22.927,0,14.768,0z M14.768,27.126c-6.826,0-12.359-5.532-12.359-12.359c0-6.828,5.533-12.362,12.359-12.362 S27.128,7.94,27.128,14.768C27.128,21.594,21.594,27.126,14.768,27.126z"
|
||||
id="path5" /><polygon
|
||||
style="fill:#ffa000;fill-opacity:1"
|
||||
points="16.338,17.962 16.938,5.601 12.625,5.601 13.227,17.962 "
|
||||
id="polygon7" /><path
|
||||
style="fill:#ffa000;fill-opacity:1"
|
||||
d="M14.781,19.323c-1.445,0-2.455,1.011-2.455,2.485c0,1.418,0.982,2.482,2.398,2.482h0.057 c1.473,0,2.428-1.064,2.428-2.482C17.182,20.334,16.227,19.323,14.781,19.323z"
|
||||
id="path9" /></g><g
|
||||
id="g11"
|
||||
style="fill:#ffa000;fill-opacity:1" /><g
|
||||
id="g13"
|
||||
style="fill:#ffa000;fill-opacity:1" /><g
|
||||
id="g15"
|
||||
style="fill:#ffa000;fill-opacity:1" /><g
|
||||
id="g17"
|
||||
style="fill:#ffa000;fill-opacity:1" /><g
|
||||
id="g19"
|
||||
style="fill:#ffa000;fill-opacity:1" /><g
|
||||
id="g21"
|
||||
style="fill:#ffa000;fill-opacity:1" /><g
|
||||
id="g23"
|
||||
style="fill:#ffa000;fill-opacity:1" /><g
|
||||
id="g25"
|
||||
style="fill:#ffa000;fill-opacity:1" /><g
|
||||
id="g27"
|
||||
style="fill:#ffa000;fill-opacity:1" /><g
|
||||
id="g29"
|
||||
style="fill:#ffa000;fill-opacity:1" /><g
|
||||
id="g31"
|
||||
style="fill:#ffa000;fill-opacity:1" /><g
|
||||
id="g33"
|
||||
style="fill:#ffa000;fill-opacity:1" /><g
|
||||
id="g35"
|
||||
style="fill:#ffa000;fill-opacity:1" /><g
|
||||
id="g37"
|
||||
style="fill:#ffa000;fill-opacity:1" /><g
|
||||
id="g39"
|
||||
style="fill:#ffa000;fill-opacity:1" /></svg>
|
||||
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 25 KiB |