Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff20b26a03 | ||
|
|
af4c708652 | ||
|
|
7539a7e448 | ||
|
|
beb64eb1de | ||
|
|
585ea47702 | ||
|
|
9dee8067a0 | ||
|
|
6728cdd509 | ||
|
|
2cf4c690be | ||
|
|
560364d320 | ||
|
|
c59ff01a73 | ||
|
|
245411bd8b | ||
|
|
73fface5cb | ||
|
|
c53a886353 | ||
|
|
0abd3da8d6 | ||
|
|
04adacee45 | ||
|
|
f4f4a4c357 | ||
|
|
5c9a931558 | ||
|
|
2161f170fc | ||
|
|
7674071fce | ||
|
|
6a1dc7a847 | ||
|
|
347d34ff28 | ||
|
|
ffc81bc378 | ||
|
|
0fd9e3d801 | ||
|
|
7a4666aa15 | ||
|
|
6594d95120 | ||
|
|
ad051308e1 | ||
|
|
dda464c64e | ||
|
|
7fc4646c19 | ||
|
|
424abe9aa4 | ||
|
|
21b6187812 | ||
|
|
b2501a1a04 | ||
|
|
e8a01c91f2 | ||
|
|
efed37b4dc | ||
|
|
1289db0bfa | ||
|
|
6fdb5f2e7a | ||
|
|
6f4b3f85ba | ||
|
|
0f8bcfab57 | ||
|
|
4718c0a9dc | ||
|
|
63633eb3a5 | ||
|
|
571ee4bec5 | ||
|
|
a735eab698 | ||
|
|
dd4389eb24 | ||
|
|
64f9f66724 | ||
|
|
dac4f092ae | ||
|
|
32514af57c | ||
|
|
d3ea351731 | ||
|
|
b13e2621c9 | ||
|
|
42ccbdb8fa | ||
|
|
939d6db778 | ||
|
|
375e8dbb26 | ||
|
|
f5172223b8 | ||
|
|
250ec2f7d3 | ||
|
|
34138ef00c | ||
|
|
3f9b0a0f32 | ||
|
|
b4061a7bdf | ||
|
|
801e1a415f | ||
|
|
8e6db881ea | ||
|
|
5b975fb463 | ||
|
|
36792c31ab | ||
|
|
07f2f9a2dd | ||
|
|
b6980780a8 | ||
|
|
4f38accc9e | ||
|
|
1d64c778e7 | ||
|
|
9ea7abd160 | ||
|
|
7f27737481 | ||
|
|
54d8c4094e | ||
|
|
4fa0863fe7 | ||
|
|
15bef45d4f | ||
|
|
ee1e04f3ff | ||
|
|
6166bd60d5 | ||
|
|
db86b6c372 | ||
|
|
d2b05c9933 | ||
|
|
386e61fec4 | ||
|
|
c0a1ac18e8 | ||
|
|
c327eae1f6 | ||
|
|
ee791bcc11 | ||
|
|
8990efddda | ||
|
|
3a2950190f | ||
|
|
45162328a9 | ||
|
|
1e05944566 | ||
|
|
f58cc625a1 | ||
|
|
09e60f7fa5 | ||
|
|
5732007afb | ||
|
|
69d06f5cde | ||
|
|
dd1d5da176 | ||
|
|
aad9deb7e6 | ||
|
|
40272e58e4 | ||
|
|
8434b00fe6 | ||
|
|
a6d2786749 | ||
|
|
9d659a0178 | ||
|
|
73cecd2722 | ||
|
|
8ca9734298 | ||
|
|
866844e369 | ||
|
|
8007b723a5 | ||
|
|
673f715ed0 | ||
|
|
43cfa7cd11 | ||
|
|
1f94578556 | ||
|
|
73d3255e76 | ||
|
|
9b0777d54d | ||
|
|
fedd6fa02d | ||
|
|
8343bc3e6c | ||
|
|
e656462c11 | ||
|
|
181578ef62 | ||
|
|
3ee0587d24 | ||
|
|
d4d8e175e8 | ||
|
|
fb15d8e833 | ||
|
|
c6e88b320d | ||
|
|
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 |
No files matched your search
@@ -19,33 +19,33 @@ namespace FileConverter
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
using FileConverter.ConversionJobs;
|
||||
using FileConverter.Diagnostics;
|
||||
using FileConverter.Windows;
|
||||
|
||||
public partial class Application : System.Windows.Application
|
||||
{
|
||||
private static readonly Version Version = new Version()
|
||||
{
|
||||
Major = 0,
|
||||
Minor = 2,
|
||||
Minor = 6,
|
||||
Patch = 0,
|
||||
};
|
||||
|
||||
private readonly List<ConversionJob> conversionJobs = new List<ConversionJob>();
|
||||
|
||||
private bool debugMode;
|
||||
private bool initialized;
|
||||
private int numberOfConversionThread = 1;
|
||||
|
||||
private bool needToRunConversionThread;
|
||||
private bool cancelAutoExit;
|
||||
private UpgradeVersionDescription upgradeVersionDescription = null;
|
||||
|
||||
public Application()
|
||||
{
|
||||
this.ConvertionJobs = this.conversionJobs.AsReadOnly();
|
||||
|
||||
this.Initialize();
|
||||
|
||||
if (this.initialized)
|
||||
{
|
||||
Thread fileConvertionThread = new Thread(this.ConvertFiles);
|
||||
fileConvertionThread.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public static Version ApplicationVersion
|
||||
@@ -65,7 +65,7 @@ namespace FileConverter
|
||||
public Settings Settings
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool ShowSettings
|
||||
@@ -74,6 +74,12 @@ namespace FileConverter
|
||||
set;
|
||||
}
|
||||
|
||||
public bool HideMainWindow
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool Verbose
|
||||
{
|
||||
get;
|
||||
@@ -85,50 +91,110 @@ namespace FileConverter
|
||||
this.cancelAutoExit = true;
|
||||
}
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
base.OnStartup(e);
|
||||
|
||||
this.Initialize();
|
||||
|
||||
if (this.needToRunConversionThread)
|
||||
{
|
||||
Thread fileConvertionThread = new Thread(this.ConvertFiles);
|
||||
fileConvertionThread.Start();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnExit(ExitEventArgs e)
|
||||
{
|
||||
base.OnExit(e);
|
||||
|
||||
Debug.Log("Exit application.");
|
||||
|
||||
if (this.upgradeVersionDescription != null && this.upgradeVersionDescription.NeedToUpgrade)
|
||||
{
|
||||
Debug.Log("A new version of file converter has been found: {0}.", this.upgradeVersionDescription.LatestVersion);
|
||||
|
||||
if (string.IsNullOrEmpty(this.upgradeVersionDescription.InstallerPath))
|
||||
{
|
||||
Debug.LogError("Invalid installer path.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Wait for the end of the installer download.");
|
||||
while (this.upgradeVersionDescription.InstallerDownloadInProgress)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
|
||||
string installerPath = this.upgradeVersionDescription.InstallerPath;
|
||||
if (!System.IO.File.Exists(installerPath))
|
||||
{
|
||||
Debug.LogError("Can't find upgrade installer ({0}). Try to restart the application.", installerPath);
|
||||
return;
|
||||
}
|
||||
|
||||
// Start process.
|
||||
Debug.Log("Start file converter upgrade from version {0} to {1}.", ApplicationVersion, this.upgradeVersionDescription.LatestVersion);
|
||||
|
||||
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(installerPath)
|
||||
{
|
||||
UseShellExecute = true,
|
||||
};
|
||||
|
||||
Debug.Log("Start upgrade process: {0}{1}.", System.IO.Path.GetFileName(startInfo.FileName), startInfo.Arguments);
|
||||
System.Diagnostics.Process process = new System.Diagnostics.Process
|
||||
{
|
||||
StartInfo = startInfo
|
||||
};
|
||||
|
||||
process.Start();
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Release();
|
||||
}
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
// Load settigns.
|
||||
Diagnostics.Log("Retrieve arguments...");
|
||||
this.Settings = new Settings();
|
||||
this.Settings.Load();
|
||||
|
||||
Diagnostics.Debug.Log("File Converter v" + ApplicationVersion.ToString());
|
||||
Diagnostics.Debug.Log("The number of processors on this computer is {0}. Set the default number of conversion threads to {0}", Environment.ProcessorCount);
|
||||
this.numberOfConversionThread = Environment.ProcessorCount;
|
||||
|
||||
// Retrieve arguments.
|
||||
Diagnostics.Log("Retrieve arguments...");
|
||||
Debug.Log("Retrieve arguments...");
|
||||
string[] args = Environment.GetCommandLineArgs();
|
||||
|
||||
#if (DEBUG)
|
||||
if (args.Length <= 1)
|
||||
{
|
||||
this.debugMode = true;
|
||||
System.Array.Resize(ref args, 9);
|
||||
args[1] = "--conversion-preset";
|
||||
args[2] = "To Mp3";
|
||||
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, 2);
|
||||
args[1] = "--settings";
|
||||
////System.Array.Resize(ref args, 5);
|
||||
////args[1] = "--conversion-preset";
|
||||
////args[2] = "To Png";
|
||||
////args[3] = "--verbose";
|
||||
////args[4] = @"D:\Test\images\Mario Big.png";
|
||||
}
|
||||
#endif
|
||||
|
||||
// Log arguments.
|
||||
for (int index = 0; index < args.Length; index++)
|
||||
{
|
||||
string argument = args[index];
|
||||
Diagnostics.Log("Arg{0}: {1}", index, argument);
|
||||
Debug.Log("Arg{0}: {1}", index, argument);
|
||||
}
|
||||
|
||||
Diagnostics.Log(string.Empty);
|
||||
Debug.Log(string.Empty);
|
||||
|
||||
ConversionPreset conversionPreset = null;
|
||||
List<string> filePaths = new List<string>();
|
||||
if (args.Length == 1)
|
||||
{
|
||||
// Diplay help windows to explain that this application is a context menu extension.
|
||||
ApplicationStartHelp applicationStartHelp = new ApplicationStartHelp();
|
||||
applicationStartHelp.Show();
|
||||
this.HideMainWindow = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse arguments.
|
||||
List<string> filePaths = new List<string>();
|
||||
string conversionPresetName = null;
|
||||
for (int index = 1; index < args.Length; index++)
|
||||
{
|
||||
string argument = args[index];
|
||||
@@ -139,9 +205,20 @@ namespace FileConverter
|
||||
|
||||
switch (parameterTitle)
|
||||
{
|
||||
case "post-install-init":
|
||||
Settings.PostInstallationInitialization();
|
||||
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
|
||||
return;
|
||||
|
||||
case "version":
|
||||
Console.Write(ApplicationVersion.ToString());
|
||||
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
|
||||
return;
|
||||
|
||||
case "settings":
|
||||
this.ShowSettings = true;
|
||||
return;
|
||||
this.HideMainWindow = true;
|
||||
break;
|
||||
|
||||
case "apply-settings":
|
||||
Settings.ApplyTemporarySettings();
|
||||
@@ -151,22 +228,15 @@ namespace FileConverter
|
||||
case "conversion-preset":
|
||||
if (index >= args.Length - 1)
|
||||
{
|
||||
MessageBox.Show(string.Format("ERROR ! Invalid format."), "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}'.", args[index + 1]), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Debug.LogError("Invalid format. (code 0x01)");
|
||||
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
|
||||
return;
|
||||
}
|
||||
|
||||
conversionPresetName = args[index + 1];
|
||||
index++;
|
||||
continue;
|
||||
|
||||
|
||||
case "verbose":
|
||||
{
|
||||
this.Verbose = true;
|
||||
@@ -175,7 +245,7 @@ namespace FileConverter
|
||||
break;
|
||||
|
||||
default:
|
||||
Diagnostics.Log("ERROR ! Unknown option {0}.", parameterTitle);
|
||||
Debug.LogError("Unknown application argument: '--{0}'.", parameterTitle);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -185,73 +255,195 @@ namespace FileConverter
|
||||
}
|
||||
}
|
||||
|
||||
if (conversionPreset == null)
|
||||
// Load settigns.
|
||||
Debug.Log("Load settings...");
|
||||
this.Settings = Settings.Load();
|
||||
if (this.Settings == null)
|
||||
{
|
||||
Diagnostics.Log("ERROR ! Can't retrieve the conversion preset from arguments.");
|
||||
Diagnostics.Debug.LogError("The application will now shutdown. If you want to fix the problem yourself please edit or delete the file: C:\\Users\\UserName\\AppData\\Local\\FileConverter\\Settings.user.xml.");
|
||||
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
|
||||
return;
|
||||
}
|
||||
|
||||
// Create convertion jobs.
|
||||
for (int index = 0; index < filePaths.Count; index++)
|
||||
// Check upgrade.
|
||||
if (this.Settings.CheckUpgradeAtStartup)
|
||||
{
|
||||
string inputFilePath = filePaths[index];
|
||||
ConversionJob conversionJob = new ConversionJob(conversionPreset, inputFilePath);
|
||||
this.conversionJobs.Add(conversionJob);
|
||||
long fileTime = Registry.GetValue<long>(Registry.Keys.LastUpdateCheckDate);
|
||||
DateTime lastUpdateDateTime = DateTime.FromFileTime(fileTime);
|
||||
|
||||
TimeSpan durationSinceLastUpdate = DateTime.Now.Subtract(lastUpdateDateTime);
|
||||
if (durationSinceLastUpdate > new TimeSpan(1, 0, 0, 0))
|
||||
{
|
||||
Task<UpgradeVersionDescription> task = Upgrade.Helpers.GetLatestVersionDescriptionAsync(this.OnGetLatestVersionDescription);
|
||||
}
|
||||
}
|
||||
|
||||
this.initialized = true;
|
||||
ConversionPreset conversionPreset = null;
|
||||
if (!string.IsNullOrEmpty(conversionPresetName))
|
||||
{
|
||||
conversionPreset = this.Settings.GetPresetFromName(conversionPresetName);
|
||||
if (conversionPreset == null)
|
||||
{
|
||||
Debug.LogError("Invalid conversion preset '{0}'. (code 0x02)", conversionPresetName);
|
||||
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (conversionPreset != null)
|
||||
{
|
||||
// Create convertion jobs.
|
||||
Debug.Log("Create jobs for conversion preset: '{0}'", conversionPreset.Name);
|
||||
try
|
||||
{
|
||||
for (int index = 0; index < filePaths.Count; index++)
|
||||
{
|
||||
string inputFilePath = filePaths[index];
|
||||
ConversionJob conversionJob = ConversionJobFactory.Create(conversionPreset, inputFilePath);
|
||||
conversionJob.PrepareConversion(inputFilePath);
|
||||
|
||||
this.conversionJobs.Add(conversionJob);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Debug.LogError(exception.Message);
|
||||
throw;
|
||||
}
|
||||
|
||||
this.needToRunConversionThread = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void ConvertFiles()
|
||||
{
|
||||
for (int index = 0; index < this.conversionJobs.Count; index++)
|
||||
Thread[] jobThreads = new Thread[this.numberOfConversionThread];
|
||||
|
||||
while (true)
|
||||
{
|
||||
ConversionJob conversionJob = this.conversionJobs[index];
|
||||
conversionJob.StartConvertion();
|
||||
|
||||
if (System.IO.File.Exists(conversionJob.OutputFilePath))
|
||||
// Compute conversion flags.
|
||||
ConversionFlags conversionFlags = ConversionFlags.None;
|
||||
bool allJobAreFinished = true;
|
||||
for (int jobIndex = 0; jobIndex < this.conversionJobs.Count; jobIndex++)
|
||||
{
|
||||
Diagnostics.Log("Success!");
|
||||
ConversionJob conversionJob = this.conversionJobs[jobIndex];
|
||||
allJobAreFinished &= !(conversionJob.State == ConversionJob.ConversionState.Ready ||
|
||||
conversionJob.State == ConversionJob.ConversionState.InProgress);
|
||||
|
||||
if (this.debugMode)
|
||||
if (conversionJob.State == ConversionJob.ConversionState.InProgress)
|
||||
{
|
||||
Diagnostics.Log("Delete file {0}.", conversionJob.OutputFilePath);
|
||||
try
|
||||
{
|
||||
System.IO.File.Delete(conversionJob.OutputFilePath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
conversionFlags |= conversionJob.StateFlags;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (allJobAreFinished)
|
||||
{
|
||||
Diagnostics.Log("Fail!");
|
||||
}
|
||||
}
|
||||
|
||||
Diagnostics.Log("End of job queue.");
|
||||
|
||||
#if !DEBUG
|
||||
bool allConversionsSucceed = true;
|
||||
for (int index = 0; index < this.conversionJobs.Count; index++)
|
||||
{
|
||||
allConversionsSucceed &= this.conversionJobs[index].State == ConversionJob.ConversionState.Done;
|
||||
}
|
||||
|
||||
if (allConversionsSucceed)
|
||||
{
|
||||
System.Threading.Thread.Sleep(3000);
|
||||
|
||||
if (this.cancelAutoExit)
|
||||
{
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
|
||||
// Start job if possible.
|
||||
for (int jobIndex = 0; jobIndex < this.conversionJobs.Count; jobIndex++)
|
||||
{
|
||||
ConversionJob conversionJob = this.conversionJobs[jobIndex];
|
||||
if (conversionJob.State == ConversionJob.ConversionState.Ready &&
|
||||
conversionJob.CanStartConversion(conversionFlags))
|
||||
{
|
||||
// Find a thread to execute the job.
|
||||
Thread jobThread = null;
|
||||
for (int threadIndex = 0; threadIndex < jobThreads.Length; threadIndex++)
|
||||
{
|
||||
Thread thread = jobThreads[threadIndex];
|
||||
if (thread == null || !thread.IsAlive)
|
||||
{
|
||||
jobThread = new Thread(this.ExecuteConversionJob);
|
||||
jobThreads[threadIndex] = jobThread;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (jobThread != null)
|
||||
{
|
||||
jobThread.Start(conversionJob);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (this.Settings.ExitApplicationWhenConversionsFinished)
|
||||
{
|
||||
bool allConversionsSucceed = true;
|
||||
for (int index = 0; index < this.conversionJobs.Count; index++)
|
||||
{
|
||||
allConversionsSucceed &= this.conversionJobs[index].State == ConversionJob.ConversionState.Done;
|
||||
}
|
||||
|
||||
if (allConversionsSucceed)
|
||||
{
|
||||
System.Threading.Thread.Sleep((int)this.Settings.DurationBetweenEndOfConversionsAndApplicationExit * 1000);
|
||||
|
||||
if (this.cancelAutoExit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ExecuteConversionJob(object parameter)
|
||||
{
|
||||
ConversionJob conversionJob = parameter as ConversionJob;
|
||||
if (conversionJob == null)
|
||||
{
|
||||
throw new System.ArgumentException("The parameter must be a conversion job.", "parameter");
|
||||
}
|
||||
|
||||
if (conversionJob.State != ConversionJob.ConversionState.Ready)
|
||||
{
|
||||
Debug.LogError("Fail to execute conversion job.");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
conversionJob.StartConvertion();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
if (conversionJob.State == ConversionJob.ConversionState.Done && !System.IO.File.Exists(conversionJob.OutputFilePath))
|
||||
{
|
||||
Debug.LogError("Can't find the output file.");
|
||||
}
|
||||
else if (conversionJob.State == ConversionJob.ConversionState.Failed && System.IO.File.Exists(conversionJob.OutputFilePath))
|
||||
{
|
||||
Debug.Log("The conversion job failed but there is an output file that does exists.");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGetLatestVersionDescription(UpgradeVersionDescription upgradeVersionDescription)
|
||||
{
|
||||
if (upgradeVersionDescription == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Registry.SetValue(Registry.Keys.LastUpdateCheckDate, DateTime.Now.ToFileTime());
|
||||
|
||||
if (upgradeVersionDescription.LatestVersion <= ApplicationVersion)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.upgradeVersionDescription = upgradeVersionDescription;
|
||||
(this.MainWindow as MainWindow).OnNewVersionReleased(upgradeVersionDescription);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// <copyright file="EncodingMode.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.Controls
|
||||
{
|
||||
public enum EncodingMode
|
||||
{
|
||||
Wav8,
|
||||
Wav16,
|
||||
Wav24,
|
||||
Wav32,
|
||||
|
||||
Mp3VBR,
|
||||
Mp3CBR,
|
||||
|
||||
OggVBR,
|
||||
|
||||
AacVBR,
|
||||
}
|
||||
}
|
||||
@@ -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,205 @@
|
||||
// <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;
|
||||
}
|
||||
|
||||
case EncodingMode.AacVBR:
|
||||
{
|
||||
sliderControl.Minimum = 16;
|
||||
sliderControl.Maximum = 460;
|
||||
sliderControl.SelectionStart = 96;
|
||||
sliderControl.SelectionEnd = 256;
|
||||
sliderControl.Ticks.Clear();
|
||||
sliderControl.Ticks.Add(16);
|
||||
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(155);
|
||||
sliderControl.Ticks.Add(192);
|
||||
sliderControl.Ticks.Add(224);
|
||||
sliderControl.Ticks.Add(256);
|
||||
sliderControl.Ticks.Add(340);
|
||||
sliderControl.Ticks.Add(460);
|
||||
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,269 +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.ConversionPreset = null;
|
||||
this.progress = 0f;
|
||||
this.InputFilePath = string.Empty;
|
||||
this.OutputFilePath = string.Empty;
|
||||
this.State = ConversionState.Unknown;
|
||||
this.ExitingMessage = string.Empty;
|
||||
}
|
||||
|
||||
public ConversionJob(ConversionPreset conversionPreset, string inputFilePath)
|
||||
{
|
||||
this.ConversionPreset = conversionPreset;
|
||||
this.InputFilePath = inputFilePath;
|
||||
|
||||
string extension = System.IO.Path.GetExtension(inputFilePath);
|
||||
this.OutputFilePath = inputFilePath.Substring(0, inputFilePath.Length - extension.Length) + "." + this.ConversionPreset.OutputType.ToString().ToLowerInvariant();
|
||||
|
||||
this.Initialize();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
private set
|
||||
{
|
||||
this.progress = value;
|
||||
this.NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string ExitingMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.exitingMessage;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.exitingMessage = value;
|
||||
this.NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void StartConvertion()
|
||||
{
|
||||
if (this.ConversionPreset == null)
|
||||
{
|
||||
throw new Exception("The conversion preset must be valid.");
|
||||
}
|
||||
|
||||
Diagnostics.Log("Convert file {0} to {1}.", this.InputFilePath, this.OutputFilePath);
|
||||
|
||||
string arguments = string.Empty;
|
||||
switch (this.ConversionPreset.OutputType)
|
||||
{
|
||||
case OutputType.Mp3:
|
||||
arguments = string.Format("-n -stats -i \"{0}\" -qscale:a 2 \"{1}\"", this.InputFilePath, this.OutputFilePath);
|
||||
break;
|
||||
|
||||
case OutputType.Ogg:
|
||||
arguments = string.Format("-n -stats -i \"{0}\" -acodec libvorbis -qscale:a 2 \"{1}\"", this.InputFilePath, this.OutputFilePath);
|
||||
break;
|
||||
|
||||
case OutputType.Flac:
|
||||
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.ConversionPreset.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 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))
|
||||
{
|
||||
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.State = ConversionState.Ready;
|
||||
}
|
||||
|
||||
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,14 @@
|
||||
// // <copyright file="ConversionFlags.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
namespace FileConverter.ConversionJobs
|
||||
{
|
||||
/// <summary>
|
||||
/// This enum describe the special conversion state that need to be multi-threads prerequisites.
|
||||
/// </summary>
|
||||
[System.Flags]
|
||||
public enum ConversionFlags
|
||||
{
|
||||
None = 0x00,
|
||||
|
||||
CdaExtraction = 0x01,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,354 @@
|
||||
// <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;
|
||||
|
||||
using FileConverter.Diagnostics;
|
||||
|
||||
public class ConversionJob : INotifyPropertyChanged
|
||||
{
|
||||
private float progress = 0f;
|
||||
private ConversionState state = ConversionState.Unknown;
|
||||
private string errorMessage = string.Empty;
|
||||
private string initialInputPath = string.Empty;
|
||||
private string userState = 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 string UserState
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.userState;
|
||||
}
|
||||
|
||||
protected set
|
||||
{
|
||||
this.userState = 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 ConversionFlags StateFlags
|
||||
{
|
||||
get;
|
||||
protected set;
|
||||
}
|
||||
|
||||
protected virtual InputPostConversionAction InputPostConversionAction
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.ConversionPreset == null)
|
||||
{
|
||||
return InputPostConversionAction.None;
|
||||
}
|
||||
|
||||
return this.ConversionPreset.InputPostConversionAction;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool CanStartConversion(ConversionFlags conversionFlags)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void PrepareConversion(string inputFilePath, string outputFilePath = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(inputFilePath))
|
||||
{
|
||||
throw new ArgumentNullException("inputFilePath");
|
||||
}
|
||||
|
||||
if (this.ConversionPreset == null)
|
||||
{
|
||||
throw new Exception("The conversion preset must be valid.");
|
||||
}
|
||||
|
||||
string extension = System.IO.Path.GetExtension(inputFilePath);
|
||||
extension = extension.Substring(1, extension.Length - 1);
|
||||
string extensionCategory = PathHelpers.GetExtensionCategory(extension);
|
||||
if (!PathHelpers.IsOutputTypeCompatibleWithCategory(this.ConversionPreset.OutputType, extensionCategory))
|
||||
{
|
||||
this.ConversionFailed("The input file type is not compatible with the output file type.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.initialInputPath = inputFilePath;
|
||||
this.InputFilePath = inputFilePath;
|
||||
this.OutputFilePath = outputFilePath ?? this.ConversionPreset.GenerateOutputFilePath(inputFilePath);
|
||||
|
||||
if (!PathHelpers.IsPathValid(this.OutputFilePath))
|
||||
{
|
||||
this.ConversionFailed("Invalid output path generated by output file path template.");
|
||||
Debug.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.ConversionFailed("Invalid output path generated by output file path template.");
|
||||
Debug.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.ConversionFailed("Can't generate a valid output filename.");
|
||||
Debug.Log(exception.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
this.Initialize();
|
||||
|
||||
if (this.State == ConversionState.Unknown)
|
||||
{
|
||||
this.State = ConversionState.Ready;
|
||||
}
|
||||
|
||||
Debug.Log("Job initialized: Preset: '{0}' Input: {1} Output: {2}", this.ConversionPreset.Name, this.InputFilePath, this.OutputFilePath);
|
||||
|
||||
this.UserState = "In Queue";
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
Debug.Log("Convert file {0} to {1}.", this.InputFilePath, this.OutputFilePath);
|
||||
|
||||
this.State = ConversionState.InProgress;
|
||||
|
||||
try
|
||||
{
|
||||
this.Convert();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
this.ConversionFailed(exception.Message);
|
||||
}
|
||||
|
||||
if (this.State == ConversionState.Failed)
|
||||
{
|
||||
this.OnConversionFailed();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.OnConversionSucceed();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void Convert()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void OnConversionFailed()
|
||||
{
|
||||
Debug.Log("Conversion Failed.");
|
||||
|
||||
if (System.IO.File.Exists(this.OutputFilePath))
|
||||
{
|
||||
System.IO.File.Delete(this.OutputFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnConversionSucceed()
|
||||
{
|
||||
Debug.Log("Conversion Succeed!");
|
||||
|
||||
// Apply the input post conversion action.
|
||||
switch (this.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);
|
||||
Debug.Log("Input file moved in archive folder: '{0}'", newPath);
|
||||
break;
|
||||
|
||||
case InputPostConversionAction.Delete:
|
||||
System.IO.File.Delete(this.InputFilePath);
|
||||
Debug.Log("Input file deleted: '{0}'", this.initialInputPath);
|
||||
break;
|
||||
}
|
||||
|
||||
Debug.Log(string.Empty);
|
||||
|
||||
this.Progress = 1f;
|
||||
this.State = ConversionState.Done;
|
||||
this.UserState = "Done";
|
||||
Debug.Log("Conversion Done!");
|
||||
}
|
||||
|
||||
protected void ConversionFailed(string exitingMessage)
|
||||
{
|
||||
Debug.Log("Fail: {0}", exitingMessage);
|
||||
|
||||
if (this.State == ConversionState.Failed)
|
||||
{
|
||||
// Already failed, don't override informations.
|
||||
return;
|
||||
}
|
||||
|
||||
this.State = ConversionState.Failed;
|
||||
this.UserState = "Failed";
|
||||
this.ErrorMessage = exitingMessage;
|
||||
}
|
||||
|
||||
protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
|
||||
{
|
||||
if (this.PropertyChanged != null)
|
||||
{
|
||||
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// <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, string inputFilePath)
|
||||
{
|
||||
string extension = System.IO.Path.GetExtension(inputFilePath);
|
||||
extension = extension.ToLowerInvariant().Substring(1, extension.Length - 1);
|
||||
if (extension == "cda")
|
||||
{
|
||||
return new ConversionJob_ExtractCDA(conversionPreset);
|
||||
}
|
||||
|
||||
if (conversionPreset.OutputType == OutputType.Ico)
|
||||
{
|
||||
return new ConversionJob_Ico(conversionPreset);
|
||||
}
|
||||
|
||||
if (PathHelpers.GetExtensionCategory(extension) == PathHelpers.InputCategoryNames.Image)
|
||||
{
|
||||
return new ConversionJob_ImageMagick(conversionPreset);
|
||||
}
|
||||
|
||||
return new ConversionJob_FFMPEG(conversionPreset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
// <copyright file="ConversionJob_ExtractCDA.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ConversionJobs
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
|
||||
using Diagnostics;
|
||||
using Ripper;
|
||||
using WaveLib;
|
||||
using Yeti.MMedia;
|
||||
|
||||
public class ConversionJob_ExtractCDA : ConversionJob
|
||||
{
|
||||
private Ripper.CDDrive cdDrive;
|
||||
private int cdaTrackNumber = -1;
|
||||
private WaveWriter waveWriter;
|
||||
private string intermediateFilePath;
|
||||
private ConversionJob compressionConversionJob;
|
||||
private System.Threading.Thread compressionThread;
|
||||
|
||||
public ConversionJob_ExtractCDA() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public ConversionJob_ExtractCDA(ConversionPreset conversionPreset) : base(conversionPreset)
|
||||
{
|
||||
}
|
||||
|
||||
protected override InputPostConversionAction InputPostConversionAction
|
||||
{
|
||||
get
|
||||
{
|
||||
return InputPostConversionAction.None;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanStartConversion(ConversionFlags conversionFlags)
|
||||
{
|
||||
return (conversionFlags & ConversionFlags.CdaExtraction) == 0;
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
if (this.ConversionPreset == null)
|
||||
{
|
||||
throw new Exception("The conversion preset must be valid.");
|
||||
}
|
||||
|
||||
// Retrieve and check drive letter.
|
||||
string pathDriveLetter = PathHelpers.GetPathDriveLetter(this.InputFilePath);
|
||||
if (pathDriveLetter.Length == 0)
|
||||
{
|
||||
this.ConversionFailed("Can't retrieve input path drive letter.");
|
||||
return;
|
||||
}
|
||||
|
||||
char driveLetter = pathDriveLetter[0];
|
||||
|
||||
this.cdDrive = new Ripper.CDDrive();
|
||||
this.cdDrive.CDRemoved += new EventHandler(this.CdDriveCdRemoved);
|
||||
|
||||
bool driveLetterFound = false;
|
||||
char[] driveLetters = Ripper.CDDrive.GetCDDriveLetters();
|
||||
for (int index = 0; index < driveLetters.Length; index++)
|
||||
{
|
||||
driveLetterFound |= driveLetters[index] == driveLetter;
|
||||
}
|
||||
|
||||
if (!driveLetterFound)
|
||||
{
|
||||
this.ConversionFailed(string.Format("Invalid drive letter {0}.", driveLetter));
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve and track number.
|
||||
try
|
||||
{
|
||||
this.cdaTrackNumber = PathHelpers.GetCDATrackNumber(this.InputFilePath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
this.ConversionFailed(string.Format("Can't retrieve the track number from input path '{0}'.", this.InputFilePath));
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.cdDrive.IsOpened)
|
||||
{
|
||||
this.ConversionFailed(string.Format("CD drive already used."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.cdDrive.Open(driveLetter))
|
||||
{
|
||||
this.ConversionFailed(string.Format("Fail to open cd drive {0}.", driveLetter));
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate intermediate file path.
|
||||
string fileName = Path.GetFileName(this.OutputFilePath);
|
||||
string tempPath = Path.GetTempPath();
|
||||
this.intermediateFilePath = PathHelpers.GenerateUniquePath(tempPath + fileName + ".wav");
|
||||
|
||||
// Sub conversion job (for compression).
|
||||
this.compressionConversionJob = ConversionJobFactory.Create(this.ConversionPreset, this.intermediateFilePath);
|
||||
this.compressionConversionJob.PrepareConversion(this.intermediateFilePath, this.OutputFilePath);
|
||||
this.compressionThread = new Thread(this.CompressAsync);
|
||||
|
||||
this.StateFlags = ConversionFlags.CdaExtraction;
|
||||
}
|
||||
|
||||
protected override void Convert()
|
||||
{
|
||||
if (this.ConversionPreset == null)
|
||||
{
|
||||
throw new Exception("The conversion preset must be valid.");
|
||||
}
|
||||
|
||||
Debug.Log("Starting CDA extraction.");
|
||||
|
||||
this.UserState = "Extraction";
|
||||
|
||||
if (!this.cdDrive.IsCDReady())
|
||||
{
|
||||
this.ConversionFailed(string.Format("CD drive is not ready."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.cdDrive.Refresh())
|
||||
{
|
||||
this.ConversionFailed(string.Format("Can't refresh CD drive data."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.cdDrive.LockCD())
|
||||
{
|
||||
this.ConversionFailed(string.Format("Can't lock cd."));
|
||||
return;
|
||||
}
|
||||
|
||||
WaveFormat waveFormat = new WaveFormat(44100, 16, 2);
|
||||
|
||||
using (Stream waveStream = new FileStream(this.intermediateFilePath, FileMode.Create, FileAccess.Write))
|
||||
using (this.waveWriter = new WaveWriter(waveStream, waveFormat, this.cdDrive.TrackSize(this.cdaTrackNumber)))
|
||||
{
|
||||
this.cdDrive.ReadTrack(this.cdaTrackNumber, this.WriteWaveData, this.CdReadProgress);
|
||||
}
|
||||
|
||||
this.waveWriter = null;
|
||||
|
||||
this.cdDrive.UnLockCD();
|
||||
|
||||
this.cdDrive.Close();
|
||||
|
||||
this.StateFlags = ConversionFlags.None;
|
||||
|
||||
if (!File.Exists(this.intermediateFilePath))
|
||||
{
|
||||
this.ConversionFailed("Extraction failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log("CDA extracted to {0}.", this.intermediateFilePath);
|
||||
Debug.Log(string.Empty);
|
||||
Debug.Log("Start compression.");
|
||||
|
||||
this.UserState = "Conversion";
|
||||
|
||||
this.compressionThread.Start();
|
||||
|
||||
while (this.compressionConversionJob.State != ConversionState.Done &&
|
||||
this.compressionConversionJob.State != ConversionState.Failed)
|
||||
{
|
||||
this.Progress = this.compressionConversionJob.Progress;
|
||||
}
|
||||
|
||||
if (this.compressionConversionJob.State == ConversionState.Failed)
|
||||
{
|
||||
this.ConversionFailed(this.compressionConversionJob.ErrorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log(string.Empty);
|
||||
Debug.Log("Delete intermediate file {0}.", this.intermediateFilePath);
|
||||
|
||||
File.Delete(this.intermediateFilePath);
|
||||
}
|
||||
|
||||
private void WriteWaveData(object sender, DataReadEventArgs eventArgs)
|
||||
{
|
||||
this.waveWriter?.Write(eventArgs.Data, 0, (int)eventArgs.DataSize);
|
||||
}
|
||||
|
||||
private void CdReadProgress(object sender, ReadProgressEventArgs eventArgs)
|
||||
{
|
||||
this.Progress = (float)eventArgs.BytesRead / (float)eventArgs.Bytes2Read;
|
||||
|
||||
eventArgs.CancelRead |= this.State != ConversionState.InProgress;
|
||||
}
|
||||
|
||||
private void CdDriveCdRemoved(object sender, System.EventArgs eventArgs)
|
||||
{
|
||||
this.ConversionFailed("The CD has been ejected.");
|
||||
}
|
||||
|
||||
private void CompressAsync()
|
||||
{
|
||||
this.compressionConversionJob.StartConvertion();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
// <copyright file="ConversionJob_FFMPEG.Converters.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ConversionJobs
|
||||
{
|
||||
using System;
|
||||
|
||||
using FileConverter.Controls;
|
||||
|
||||
public partial class ConversionJob_FFMPEG
|
||||
{
|
||||
/// <summary>
|
||||
/// Convert bitrate in <c>mp3</c> encoder quality index.
|
||||
/// </summary>
|
||||
/// <param name="bitrate">Wanted bitrate value.</param>
|
||||
/// <returns>The <c>mp3</c> encoder quality index associated to the given bitrate value.</returns>
|
||||
/// https://trac.ffmpeg.org/wiki/Encode/MP3
|
||||
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 Ogg 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.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert video quality index to MPEG4 video quality level.
|
||||
/// </summary>
|
||||
/// <param name="quality">The quality index.</param>
|
||||
/// <returns>Returns the H264 constant rate factor.</returns>
|
||||
/// The range of the video quality level is 1-31: where 1 is the highest quality/largest filesize, 31 being the lowest quality/smallest filesize.
|
||||
/// https://trac.ffmpeg.org/wiki/Encode/MPEG-4
|
||||
private int MPEG4QualityToQualityIndex(int quality)
|
||||
{
|
||||
return 31 - quality;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert video quality index to H264 constant rate factor.
|
||||
/// </summary>
|
||||
/// <param name="quality">The quality index.</param>
|
||||
/// <returns>Returns the H264 constant rate factor.</returns>
|
||||
/// The range of the quantizer scale is 0-51: where 0 is lossless, 23 is default, and 51 is worst possible.
|
||||
/// A lower value is a higher quality and a subjectively sane range is 18-28.
|
||||
/// https://trac.ffmpeg.org/wiki/Encode/H.264
|
||||
private int H264QualityToCRF(int quality)
|
||||
{
|
||||
return 51 - quality;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert image quality index to JPG quality index.
|
||||
/// </summary>
|
||||
/// <param name="quality">The quality index.</param>
|
||||
/// <returns>Returns the JPG quality index.</returns>
|
||||
/// The range of the quantizer scale is 1-31: where 1 is better quality, and 31 is worst possible.
|
||||
/// http://superuser.com/questions/318845/improve-quality-of-ffmpeg-created-jpgs
|
||||
private int JPGQualityToQualityIndex(int quality)
|
||||
{
|
||||
return 31 - quality;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert video encoding speed to H264 preset.
|
||||
/// </summary>
|
||||
/// <param name="encodingSpeed">The encoding speed.</param>
|
||||
/// <returns>The H264 preset.</returns>
|
||||
private string H264EncodingSpeedToPreset(string encodingSpeed)
|
||||
{
|
||||
switch (encodingSpeed)
|
||||
{
|
||||
case "Ultra Fast":
|
||||
return "ultrafast";
|
||||
|
||||
case "Super Fast":
|
||||
return "superfast";
|
||||
|
||||
case "Very Fast":
|
||||
return "veryfast";
|
||||
|
||||
case "Faster":
|
||||
return "faster";
|
||||
|
||||
case "Fast":
|
||||
return "fast";
|
||||
|
||||
case "Medium":
|
||||
return "medium";
|
||||
|
||||
case "Slow":
|
||||
return "slow";
|
||||
|
||||
case "Slower":
|
||||
return "slower";
|
||||
|
||||
case "Very Slow":
|
||||
return "veryslow";
|
||||
}
|
||||
|
||||
throw new Exception("Unknown H264 encoding speed.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert bitrate in <c>aac</c> encoder quality index.
|
||||
/// </summary>
|
||||
/// <param name="bitrate">Wanted bitrate value.</param>
|
||||
/// <returns>The <c>aac</c> encoder quality index associated to the given bitrate value.</returns>
|
||||
/// See the file Resources/FFMPEG retro engineering.ods for details.
|
||||
private string AACBitrateToQualityIndex(int bitrate)
|
||||
{
|
||||
switch (bitrate)
|
||||
{
|
||||
case 460:
|
||||
return "3.9";
|
||||
|
||||
case 340:
|
||||
return "3";
|
||||
|
||||
case 256:
|
||||
return "2.2";
|
||||
|
||||
case 224:
|
||||
return "1.9";
|
||||
|
||||
case 192:
|
||||
return "1.6";
|
||||
|
||||
case 155:
|
||||
return "1.3";
|
||||
|
||||
case 128:
|
||||
return "1";
|
||||
|
||||
case 112:
|
||||
return "0.9";
|
||||
|
||||
case 96:
|
||||
return "0.75";
|
||||
|
||||
case 80:
|
||||
return "0.6";
|
||||
|
||||
case 64:
|
||||
return "0.45";
|
||||
|
||||
case 48:
|
||||
return "0.3";
|
||||
|
||||
case 32:
|
||||
return "0.2";
|
||||
|
||||
case 16:
|
||||
return "0.1";
|
||||
}
|
||||
|
||||
throw new Exception("Unknown VBR bitrate.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,404 @@
|
||||
// <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.Globalization;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using FileConverter.Controls;
|
||||
|
||||
public partial 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 virtual string FfmpegPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string applicationDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
||||
return System.IO.Path.Combine(applicationDirectory, "ffmpeg.exe");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
if (this.ConversionPreset == null)
|
||||
{
|
||||
throw new Exception("The conversion preset must be valid.");
|
||||
}
|
||||
|
||||
this.ffmpegProcessStartInfo = null;
|
||||
|
||||
string ffmpegPath = this.FfmpegPath;
|
||||
if (!System.IO.File.Exists(ffmpegPath))
|
||||
{
|
||||
this.ConversionFailed("Can't find ffmpeg executable. You should try to reinstall the application.");
|
||||
Diagnostics.Debug.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.Aac:
|
||||
{
|
||||
// https://trac.ffmpeg.org/wiki/Encode/AAC
|
||||
int audioEncodingBitrate = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.AudioBitrate);
|
||||
string encoderArgs = string.Format("-c:a aac -q:a {0}", this.AACBitrateToQualityIndex(audioEncodingBitrate));
|
||||
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Avi:
|
||||
{
|
||||
// https://trac.ffmpeg.org/wiki/Encode/MPEG-4
|
||||
int videoEncodingQuality = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.VideoQuality);
|
||||
int audioEncodingBitrate = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.AudioBitrate);
|
||||
|
||||
float scaleFactor = this.ConversionPreset.GetSettingsValue<float>(ConversionPreset.ConversionSettingKeys.VideoScale);
|
||||
string scaleArgs = string.Empty;
|
||||
if (Math.Abs(scaleFactor - 1f) >= 0.005f)
|
||||
{
|
||||
scaleArgs = string.Format("scale=iw*{0}:ih*{0}", scaleFactor.ToString("#.##", CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
float rotationAngleInDegrees = this.ConversionPreset.GetSettingsValue<float>(ConversionPreset.ConversionSettingKeys.VideoRotation);
|
||||
string rotationArgs = string.Empty;
|
||||
if (Math.Abs(rotationAngleInDegrees - 0f) >= 0.05f)
|
||||
{
|
||||
// Transpose:
|
||||
// 0: 90 CounterClockwise and vertical flip
|
||||
// 1: 90 Clockwise
|
||||
// 2: 90 CounterClockwise
|
||||
// 3: 90 Clockwise and vertical flip
|
||||
if (Math.Abs(rotationAngleInDegrees - 90f) <= 0.05f)
|
||||
{
|
||||
rotationArgs = "transpose=2";
|
||||
}
|
||||
else if (Math.Abs(rotationAngleInDegrees - 180f) <= 0.05f)
|
||||
{
|
||||
rotationArgs = "vflip,hflip";
|
||||
}
|
||||
else if (Math.Abs(rotationAngleInDegrees - 270f) <= 0.05f)
|
||||
{
|
||||
rotationArgs = "transpose=1";
|
||||
}
|
||||
else
|
||||
{
|
||||
Diagnostics.Debug.LogError("Unsupported rotation: {0}°", rotationAngleInDegrees);
|
||||
}
|
||||
}
|
||||
|
||||
// Build vf args (-vf "scale=..., transpose=...")
|
||||
string transformArgs = string.Empty;
|
||||
if (!string.IsNullOrEmpty(scaleArgs) || !string.IsNullOrEmpty(rotationArgs))
|
||||
{
|
||||
transformArgs = "-vf \"";
|
||||
if (!string.IsNullOrEmpty(scaleArgs))
|
||||
{
|
||||
transformArgs += scaleArgs;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(rotationArgs))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(scaleArgs))
|
||||
{
|
||||
transformArgs += ",";
|
||||
}
|
||||
|
||||
transformArgs += rotationArgs;
|
||||
}
|
||||
|
||||
transformArgs += "\"";
|
||||
}
|
||||
|
||||
// Compute final arguments.
|
||||
string encoderArgs = string.Format("-c:v mpeg4 -vtag xvid -qscale:v {0} -c:a libmp3lame -qscale:a {1} {2}", this.MPEG4QualityToQualityIndex(videoEncodingQuality), this.MP3VBRBitrateToQualityIndex(audioEncodingBitrate), transformArgs);
|
||||
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Flac:
|
||||
{
|
||||
// http://taer-naguur.blogspot.fr/2013/11/flac-audio-encoding-with-ffmpeg.html
|
||||
string encoderArgs = string.Format("-compression_level 12");
|
||||
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Ico:
|
||||
{
|
||||
string encoderArgs = string.Empty;
|
||||
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Jpg:
|
||||
{
|
||||
int encodingQuality = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.ImageQuality);
|
||||
|
||||
float scaleFactor = this.ConversionPreset.GetSettingsValue<float>(ConversionPreset.ConversionSettingKeys.ImageScale);
|
||||
string scaleArgs = string.Empty;
|
||||
if (Math.Abs(scaleFactor - 1f) >= 0.005f)
|
||||
{
|
||||
scaleArgs = string.Format("-vf scale=iw*{0}:ih*{0}", scaleFactor.ToString("#.##", CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
string encoderArgs = string.Format("-q:v {0} {1}", this.JPGQualityToQualityIndex(encodingQuality), scaleArgs);
|
||||
|
||||
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>(ConversionPreset.ConversionSettingKeys.AudioEncodingMode);
|
||||
int encodingQuality = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.AudioBitrate);
|
||||
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.Mkv:
|
||||
case OutputType.Mp4:
|
||||
{
|
||||
// https://trac.ffmpeg.org/wiki/Encode/H.264
|
||||
// https://trac.ffmpeg.org/wiki/Encode/AAC
|
||||
int videoEncodingQuality = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.VideoQuality);
|
||||
string videoEncodingSpeed = this.ConversionPreset.GetSettingsValue<string>(ConversionPreset.ConversionSettingKeys.VideoEncodingSpeed);
|
||||
int audioEncodingBitrate = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.AudioBitrate);
|
||||
|
||||
float scaleFactor = this.ConversionPreset.GetSettingsValue<float>(ConversionPreset.ConversionSettingKeys.VideoScale);
|
||||
string scaleArgs = string.Empty;
|
||||
if (Math.Abs(scaleFactor - 1f) >= 0.005f)
|
||||
{
|
||||
scaleArgs = string.Format("scale=iw*{0}:ih*{0}", scaleFactor.ToString("#.##", CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
float rotationAngleInDegrees = this.ConversionPreset.GetSettingsValue<float>(ConversionPreset.ConversionSettingKeys.VideoRotation);
|
||||
string rotationArgs = string.Empty;
|
||||
if (Math.Abs(rotationAngleInDegrees - 0f) >= 0.05f)
|
||||
{
|
||||
// Transpose:
|
||||
// 0: 90 CounterClockwise and vertical flip
|
||||
// 1: 90 Clockwise
|
||||
// 2: 90 CounterClockwise
|
||||
// 3: 90 Clockwise and vertical flip
|
||||
if (Math.Abs(rotationAngleInDegrees - 90f) <= 0.05f)
|
||||
{
|
||||
rotationArgs = "transpose=2";
|
||||
}
|
||||
else if (Math.Abs(rotationAngleInDegrees - 180f) <= 0.05f)
|
||||
{
|
||||
rotationArgs = "vflip,hflip";
|
||||
}
|
||||
else if (Math.Abs(rotationAngleInDegrees - 270f) <= 0.05f)
|
||||
{
|
||||
rotationArgs = "transpose=1";
|
||||
}
|
||||
else
|
||||
{
|
||||
Diagnostics.Debug.LogError("Unsupported rotation: {0}°", rotationAngleInDegrees);
|
||||
}
|
||||
}
|
||||
|
||||
// Build vf args (-vf "scale=..., transpose=...")
|
||||
string transformArgs = string.Empty;
|
||||
if (!string.IsNullOrEmpty(scaleArgs) || !string.IsNullOrEmpty(rotationArgs))
|
||||
{
|
||||
transformArgs = "-vf \"";
|
||||
if (!string.IsNullOrEmpty(scaleArgs))
|
||||
{
|
||||
transformArgs += scaleArgs;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(rotationArgs))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(scaleArgs))
|
||||
{
|
||||
transformArgs += ",";
|
||||
}
|
||||
|
||||
transformArgs += rotationArgs;
|
||||
}
|
||||
|
||||
transformArgs += "\"";
|
||||
}
|
||||
|
||||
string encoderArgs = string.Format("-c:v libx264 -preset {0} -crf {1} -c:a aac -q:a {2} {3}", this.H264EncodingSpeedToPreset(videoEncodingSpeed), this.H264QualityToCRF(videoEncodingQuality), this.AACBitrateToQualityIndex(audioEncodingBitrate), transformArgs);
|
||||
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Ogg:
|
||||
{
|
||||
int encodingQuality = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.AudioBitrate);
|
||||
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.Png:
|
||||
{
|
||||
float scaleFactor = this.ConversionPreset.GetSettingsValue<float>(ConversionPreset.ConversionSettingKeys.ImageScale);
|
||||
string scaleArgs = string.Empty;
|
||||
if (Math.Abs(scaleFactor - 1f) >= 0.005f)
|
||||
{
|
||||
scaleArgs = string.Format("-vf scale=iw*{0}:ih*{0}", scaleFactor.ToString("#.##", CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
// http://www.howtogeek.com/203979/is-the-png-format-lossless-since-it-has-a-compression-parameter/
|
||||
string encoderArgs = string.Format("-compression_level 100 {0}", scaleArgs);
|
||||
|
||||
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Wav:
|
||||
{
|
||||
EncodingMode encodingMode = this.ConversionPreset.GetSettingsValue<EncodingMode>(ConversionPreset.ConversionSettingKeys.AudioEncodingMode);
|
||||
string encoderArgs = string.Format("-acodec {0}", this.WAVEncodingToCodecArgument(encodingMode));
|
||||
arguments = string.Format("-n -stats -i \"{0}\" {2} \"{1}\"", this.InputFilePath, this.OutputFilePath, encoderArgs);
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
this.UserState = "Conversion";
|
||||
|
||||
Diagnostics.Debug.Log("Execute command: {0} {1}.", this.ffmpegProcessStartInfo.FileName, this.ffmpegProcessStartInfo.Arguments);
|
||||
Diagnostics.Debug.Log(string.Empty);
|
||||
|
||||
try
|
||||
{
|
||||
using (Process exeProcess = Process.Start(this.ffmpegProcessStartInfo))
|
||||
{
|
||||
using (StreamReader reader = exeProcess.StandardError)
|
||||
{
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
string result = reader.ReadLine();
|
||||
|
||||
this.ParseFFMPEGOutput(result);
|
||||
|
||||
Diagnostics.Debug.Log("ffmpeg output: {0}", result);
|
||||
}
|
||||
}
|
||||
|
||||
exeProcess.WaitForExit();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
this.ConversionFailed("Failed to launch FFMPEG process.");
|
||||
throw;
|
||||
}
|
||||
|
||||
Diagnostics.Debug.Log(string.Empty);
|
||||
}
|
||||
|
||||
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.") || input.Contains("Error") || input.Contains("Unsupported dimensions") || input.Contains("No such file or directory"))
|
||||
{
|
||||
this.ConversionFailed(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
// <copyright file="ConversionJob_Ico.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ConversionJobs
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
public class ConversionJob_Ico : ConversionJob
|
||||
{
|
||||
private string intermediateFilePath;
|
||||
private ConversionJob pngConversionJob;
|
||||
private ConversionJob icoConversionJob;
|
||||
|
||||
public ConversionJob_Ico(ConversionPreset conversionPreset) : base(conversionPreset)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
if (this.ConversionPreset == null)
|
||||
{
|
||||
throw new Exception("The conversion preset must be valid.");
|
||||
}
|
||||
|
||||
// Generate intermediate file path.
|
||||
string fileName = Path.GetFileName(this.OutputFilePath);
|
||||
string tempPath = Path.GetTempPath();
|
||||
this.intermediateFilePath = PathHelpers.GenerateUniquePath(tempPath + fileName + ".png");
|
||||
|
||||
// Convert input in png file to send it to ffmpeg for the ico conversion.
|
||||
ConversionPreset intermediatePreset = new ConversionPreset("To compatible image", OutputType.Png, this.ConversionPreset.InputTypes.ToArray());
|
||||
intermediatePreset.SetSettingsValue(ConversionPreset.ConversionSettingKeys.ImageClampSizePowerOf2, "True");
|
||||
intermediatePreset.SetSettingsValue(ConversionPreset.ConversionSettingKeys.ImageMaximumSize, "256");
|
||||
this.pngConversionJob = ConversionJobFactory.Create(intermediatePreset, this.InputFilePath);
|
||||
this.pngConversionJob.PrepareConversion(this.InputFilePath, this.intermediateFilePath);
|
||||
|
||||
// Convert png file into ico.
|
||||
this.icoConversionJob = new ConversionJob_FFMPEG(this.ConversionPreset);
|
||||
this.icoConversionJob.PrepareConversion(this.intermediateFilePath, this.OutputFilePath);
|
||||
}
|
||||
|
||||
protected override void Convert()
|
||||
{
|
||||
if (this.ConversionPreset == null)
|
||||
{
|
||||
throw new Exception("The conversion preset must be valid.");
|
||||
}
|
||||
|
||||
Diagnostics.Debug.Log(string.Empty);
|
||||
Diagnostics.Debug.Log("Convert image to PNG (intermediate format).");
|
||||
this.pngConversionJob.StartConvertion();
|
||||
|
||||
if (this.pngConversionJob.State != ConversionState.Done)
|
||||
{
|
||||
this.ConversionFailed(this.pngConversionJob.ErrorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
Diagnostics.Debug.Log(string.Empty);
|
||||
Diagnostics.Debug.Log("Convert png intermediate image to ICO.");
|
||||
this.icoConversionJob.StartConvertion();
|
||||
|
||||
if (this.icoConversionJob.State != ConversionState.Done)
|
||||
{
|
||||
this.ConversionFailed(this.icoConversionJob.ErrorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
Diagnostics.Debug.Log("Delete intermediate file {0}.", this.intermediateFilePath);
|
||||
|
||||
File.Delete(this.intermediateFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
// <copyright file="ConversionJob_ImageMagick.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ConversionJobs
|
||||
{
|
||||
using System;
|
||||
|
||||
using FileConverter.Diagnostics;
|
||||
using ImageMagick;
|
||||
|
||||
public class ConversionJob_ImageMagick : ConversionJob
|
||||
{
|
||||
public ConversionJob_ImageMagick() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public ConversionJob_ImageMagick(ConversionPreset conversionPreset) : base(conversionPreset)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
if (this.ConversionPreset == null)
|
||||
{
|
||||
throw new Exception("The conversion preset must be valid.");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Convert()
|
||||
{
|
||||
if (this.ConversionPreset == null)
|
||||
{
|
||||
throw new Exception("The conversion preset must be valid.");
|
||||
}
|
||||
|
||||
using (MagickImage image = new MagickImage(this.InputFilePath))
|
||||
{
|
||||
image.Progress += this.Image_Progress;
|
||||
Debug.Log("Load image {0} succeed.", this.InputFilePath);
|
||||
|
||||
float scaleFactor = this.ConversionPreset.GetSettingsValue<float>(ConversionPreset.ConversionSettingKeys.ImageScale);
|
||||
if (Math.Abs(scaleFactor - 1f) >= 0.005f)
|
||||
{
|
||||
Debug.Log("Apply scale factor: {0}%.", scaleFactor * 100);
|
||||
|
||||
image.Scale(new Percentage(scaleFactor * 100f));
|
||||
}
|
||||
|
||||
float rotateAngleInDegrees = this.ConversionPreset.GetSettingsValue<float>(ConversionPreset.ConversionSettingKeys.ImageRotation);
|
||||
if (Math.Abs(rotateAngleInDegrees - 0f) >= 0.05f)
|
||||
{
|
||||
Debug.Log("Apply rotation: {0}°.", rotateAngleInDegrees);
|
||||
|
||||
image.Rotate(rotateAngleInDegrees);
|
||||
}
|
||||
|
||||
bool clampSizeToPowerOf2 = this.ConversionPreset.GetSettingsValue<bool>(ConversionPreset.ConversionSettingKeys.ImageClampSizePowerOf2);
|
||||
if (clampSizeToPowerOf2)
|
||||
{
|
||||
int referenceSize = System.Math.Min(image.Width, image.Height);
|
||||
int size = 2;
|
||||
while (size * 2 < referenceSize)
|
||||
{
|
||||
size *= 2;
|
||||
}
|
||||
|
||||
Debug.Log("Clamp size to the nearest power of 2 size (from {0}x{1} to {2}x{2}).", image.Width, image.Height, size);
|
||||
|
||||
image.Scale(size, size);
|
||||
}
|
||||
|
||||
int maximumSize = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.ImageMaximumSize);
|
||||
if (maximumSize > 0)
|
||||
{
|
||||
int width = System.Math.Min(image.Width, maximumSize);
|
||||
int height = System.Math.Min(image.Height, maximumSize);
|
||||
|
||||
Debug.Log("Clamp size to maximum size of {2}x{2} (from {0}x{1} to {2}x{3}).", image.Width, image.Height, width, height);
|
||||
|
||||
image.Scale(width, height);
|
||||
}
|
||||
|
||||
Debug.Log("Convert image (output: {0}).", this.OutputFilePath);
|
||||
switch (this.ConversionPreset.OutputType)
|
||||
{
|
||||
case OutputType.Png:
|
||||
image.Quality = 100;
|
||||
break;
|
||||
|
||||
case OutputType.Jpg:
|
||||
image.Quality = this.ConversionPreset.GetSettingsValue<int>(ConversionPreset.ConversionSettingKeys.ImageQuality);
|
||||
break;
|
||||
|
||||
default:
|
||||
this.ConversionFailed(string.Format("Unsupported output format {0}.", this.ConversionPreset.OutputType));
|
||||
image.Progress -= this.Image_Progress;
|
||||
return;
|
||||
}
|
||||
|
||||
image.Write(this.OutputFilePath);
|
||||
image.Progress -= this.Image_Progress;
|
||||
}
|
||||
}
|
||||
|
||||
private void Image_Progress(object sender, ProgressEventArgs eventArgs)
|
||||
{
|
||||
this.Progress = (float)eventArgs.Progress.ToDouble() / 100f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
// <copyright file="FileConverter.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
using FileConverter.Annotations;
|
||||
|
||||
[XmlRoot]
|
||||
[XmlType]
|
||||
public class ConversionPreset : INotifyPropertyChanged, IDataErrorInfo
|
||||
{
|
||||
private string name;
|
||||
|
||||
private OutputType outputType;
|
||||
|
||||
private List<string> inputTypes;
|
||||
|
||||
public ConversionPreset()
|
||||
{
|
||||
this.Name = "New Preset";
|
||||
}
|
||||
|
||||
public ConversionPreset(string name, OutputType outputType, string[] inputTypes)
|
||||
{
|
||||
this.Name = name;
|
||||
this.OutputType = outputType;
|
||||
this.InputTypes = new List<string>();
|
||||
this.InputTypes.AddRange(inputTypes);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[XmlAttribute]
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.name = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public OutputType OutputType
|
||||
{
|
||||
get
|
||||
{
|
||||
return outputType;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
outputType = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[XmlElement]
|
||||
public List<string> InputTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
return inputTypes;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
inputTypes = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public ConversionPreset.Setting[] Settings
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public class Setting
|
||||
{
|
||||
}
|
||||
|
||||
public string this[string columnName]
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Validate(columnName);
|
||||
}
|
||||
}
|
||||
|
||||
public string Error
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Validate("Name");
|
||||
}
|
||||
}
|
||||
|
||||
private string Validate(string properyName)
|
||||
{
|
||||
// Return error message if there is an error, else return empty or null string.
|
||||
switch (properyName)
|
||||
{
|
||||
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;
|
||||
if (application?.Settings != null)
|
||||
{
|
||||
int count = application.Settings.ConversionPresets.Count(match => match.name == this.Name);
|
||||
if (count > 1)
|
||||
{
|
||||
return "The preset name is already used.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,739 @@
|
||||
// <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.Controls;
|
||||
using FileConverter.Diagnostics;
|
||||
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 ConversionPreset(string name, ConversionPreset source)
|
||||
{
|
||||
this.Name = name;
|
||||
this.OutputType = source.outputType;
|
||||
List<string> inputTypeList = new List<string>();
|
||||
if (source.inputTypes != null)
|
||||
{
|
||||
inputTypeList.AddRange(source.inputTypes);
|
||||
}
|
||||
|
||||
this.InputTypes = inputTypeList;
|
||||
|
||||
this.outputFileNameTemplate = source.OutputFileNameTemplate;
|
||||
|
||||
foreach (KeyValuePair<string, string> conversionSetting in source.settings)
|
||||
{
|
||||
this.SetSettingsValue(conversionSetting.Key, conversionSetting.Value);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
this.CoerceInputTypes();
|
||||
}
|
||||
}
|
||||
|
||||
[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++)
|
||||
{
|
||||
// Compatibility issues.
|
||||
if (value[index].Key == "Bitrate")
|
||||
{
|
||||
this.SetSettingsValue(ConversionSettingKeys.AudioBitrate, value[index].Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (value[index].Key == "Encoding")
|
||||
{
|
||||
this.SetSettingsValue(ConversionSettingKeys.AudioEncodingMode, value[index].Value);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Load settings.
|
||||
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 Clean()
|
||||
{
|
||||
// Remove unrelevant settings.
|
||||
List<string> settingsToRemove = new List<string>();
|
||||
foreach (string settingsKey in this.settings.Keys)
|
||||
{
|
||||
if (!this.IsRelevantSetting(settingsKey))
|
||||
{
|
||||
settingsToRemove.Add(settingsKey);
|
||||
}
|
||||
}
|
||||
|
||||
for (int index = 0; index < settingsToRemove.Count; index++)
|
||||
{
|
||||
this.settings.Remove(settingsToRemove[index]);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDeserializationComplete()
|
||||
{
|
||||
for (int index = 0; index < this.InputTypes.Count; index++)
|
||||
{
|
||||
this.InputTypes[index] = this.InputTypes[index].ToLowerInvariant();
|
||||
}
|
||||
|
||||
this.CoerceInputTypes();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (settingsValue == null)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
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 void CoerceInputTypes()
|
||||
{
|
||||
if (this.inputTypes == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (int index = 0; index < this.inputTypes.Count; index++)
|
||||
{
|
||||
string inputType = this.inputTypes[index];
|
||||
string inputCategory = PathHelpers.GetExtensionCategory(inputType);
|
||||
if (!PathHelpers.IsOutputTypeCompatibleWithCategory(this.OutputType, inputCategory))
|
||||
{
|
||||
this.RemoveInputType(inputType);
|
||||
index--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsRelevantSetting(string settingsKey)
|
||||
{
|
||||
switch (this.OutputType)
|
||||
{
|
||||
case OutputType.Aac:
|
||||
switch (settingsKey)
|
||||
{
|
||||
case ConversionPreset.ConversionSettingKeys.AudioBitrate:
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Avi:
|
||||
switch (settingsKey)
|
||||
{
|
||||
case ConversionPreset.ConversionSettingKeys.AudioBitrate:
|
||||
case ConversionPreset.ConversionSettingKeys.VideoQuality:
|
||||
case ConversionPreset.ConversionSettingKeys.VideoScale:
|
||||
case ConversionPreset.ConversionSettingKeys.VideoRotation:
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Flac:
|
||||
case OutputType.Ico:
|
||||
break;
|
||||
|
||||
case OutputType.Jpg:
|
||||
switch (settingsKey)
|
||||
{
|
||||
case ConversionPreset.ConversionSettingKeys.ImageQuality:
|
||||
case ConversionPreset.ConversionSettingKeys.ImageScale:
|
||||
case ConversionPreset.ConversionSettingKeys.ImageRotation:
|
||||
case ConversionPreset.ConversionSettingKeys.ImageClampSizePowerOf2:
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Mkv:
|
||||
switch (settingsKey)
|
||||
{
|
||||
case ConversionPreset.ConversionSettingKeys.AudioBitrate:
|
||||
case ConversionPreset.ConversionSettingKeys.VideoQuality:
|
||||
case ConversionPreset.ConversionSettingKeys.VideoScale:
|
||||
case ConversionPreset.ConversionSettingKeys.VideoRotation:
|
||||
case ConversionPreset.ConversionSettingKeys.VideoEncodingSpeed:
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Mp3:
|
||||
switch (settingsKey)
|
||||
{
|
||||
case ConversionPreset.ConversionSettingKeys.AudioEncodingMode:
|
||||
case ConversionPreset.ConversionSettingKeys.AudioBitrate:
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Mp4:
|
||||
switch (settingsKey)
|
||||
{
|
||||
case ConversionPreset.ConversionSettingKeys.AudioBitrate:
|
||||
case ConversionPreset.ConversionSettingKeys.VideoQuality:
|
||||
case ConversionPreset.ConversionSettingKeys.VideoScale:
|
||||
case ConversionPreset.ConversionSettingKeys.VideoRotation:
|
||||
case ConversionPreset.ConversionSettingKeys.VideoEncodingSpeed:
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Ogg:
|
||||
switch (settingsKey)
|
||||
{
|
||||
case ConversionPreset.ConversionSettingKeys.AudioBitrate:
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Png:
|
||||
switch (settingsKey)
|
||||
{
|
||||
case ConversionPreset.ConversionSettingKeys.ImageScale:
|
||||
case ConversionPreset.ConversionSettingKeys.ImageRotation:
|
||||
case ConversionPreset.ConversionSettingKeys.ImageClampSizePowerOf2:
|
||||
case ConversionPreset.ConversionSettingKeys.ImageMaximumSize:
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OutputType.Wav:
|
||||
switch (settingsKey)
|
||||
{
|
||||
case ConversionPreset.ConversionSettingKeys.AudioEncodingMode:
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.LogError("Relevant settings '{1}' are not define for output type {0}.", this.OutputType, settingsKey);
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void InitializeDefaultSettings(OutputType outputType)
|
||||
{
|
||||
switch (outputType)
|
||||
{
|
||||
case OutputType.Aac:
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "128");
|
||||
break;
|
||||
|
||||
case OutputType.Ico:
|
||||
case OutputType.Flac:
|
||||
break;
|
||||
|
||||
case OutputType.Png:
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.ImageScale, "1");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.ImageRotation, "0");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.ImageClampSizePowerOf2, "False");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.ImageMaximumSize, "0");
|
||||
break;
|
||||
|
||||
case OutputType.Jpg:
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.ImageQuality, "90");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.ImageScale, "1");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.ImageRotation, "0");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.ImageClampSizePowerOf2, "False");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.ImageMaximumSize, "0");
|
||||
break;
|
||||
|
||||
case OutputType.Avi:
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoQuality, "20");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoScale, "1");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoRotation, "0");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "190");
|
||||
break;
|
||||
|
||||
case OutputType.Mkv:
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoQuality, "28");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoEncodingSpeed, "Medium");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoScale, "1");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoRotation, "0");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "128");
|
||||
break;
|
||||
|
||||
case OutputType.Mp3:
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioEncodingMode, EncodingMode.Mp3VBR.ToString(), true);
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "190");
|
||||
break;
|
||||
|
||||
case OutputType.Mp4:
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoQuality, "28");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoEncodingSpeed, "Medium");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoScale, "1");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.VideoRotation, "0");
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "128");
|
||||
break;
|
||||
|
||||
case OutputType.Ogg:
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioBitrate, "160");
|
||||
break;
|
||||
|
||||
case OutputType.Wav:
|
||||
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.AudioEncodingMode, EncodingMode.Wav16.ToString(), true);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new System.Exception("Missing default settings for type " + outputType);
|
||||
}
|
||||
|
||||
this.OnPropertyChanged("Settings");
|
||||
}
|
||||
|
||||
private void InitializeSettingsValue(string settingsKey, string value, bool force = false)
|
||||
{
|
||||
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);
|
||||
}
|
||||
else if (force)
|
||||
{
|
||||
this.settings[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;
|
||||
}
|
||||
}
|
||||
|
||||
public struct ConversionSettingKeys
|
||||
{
|
||||
public const string AudioEncodingMode = "AudioEncodingMode";
|
||||
public const string AudioBitrate = "AudioBitrate";
|
||||
public const string ImageQuality = "ImageQuality";
|
||||
public const string ImageScale = "ImageScale";
|
||||
public const string ImageRotation = "ImageRotation";
|
||||
public const string ImageClampSizePowerOf2 = "ImageClampSizePowerOf2";
|
||||
public const string ImageMaximumSize = "ImageMaximumSize";
|
||||
public const string VideoQuality = "VideoQuality";
|
||||
public const string VideoEncodingSpeed = "VideoEncodingSpeed";
|
||||
public const string VideoScale = "VideoScale";
|
||||
public const string VideoRotation = "VideoRotation";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
// <copyright file="Diagnostics.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.Text;
|
||||
|
||||
public static class Diagnostics
|
||||
{
|
||||
private static List<string> logMessages = new List<string>();
|
||||
private static StringBuilder workingStringBuilder = new StringBuilder();
|
||||
|
||||
public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
|
||||
|
||||
public static string Content
|
||||
{
|
||||
get
|
||||
{
|
||||
workingStringBuilder.Clear();
|
||||
for (int index = 0; index < logMessages.Count; index++)
|
||||
{
|
||||
workingStringBuilder.AppendLine(logMessages[index]);
|
||||
}
|
||||
|
||||
return workingStringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Log(string message, params object[] arguments)
|
||||
{
|
||||
Diagnostics.logMessages.Add(string.Format(message, arguments));
|
||||
|
||||
if (StaticPropertyChanged != null)
|
||||
{
|
||||
StaticPropertyChanged(null, new PropertyChangedEventArgs("Content"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
// <copyright file="Debug.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.Diagnostics
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
public static class Debug
|
||||
{
|
||||
private static string diagnosticsFolderPath;
|
||||
private static Dictionary<int, DiagnosticsData> diagnosticsDataById = new Dictionary<int, DiagnosticsData>();
|
||||
private static int threadCount = 0;
|
||||
|
||||
static Debug()
|
||||
{
|
||||
string path = PathHelpers.GetUserDataFolderPath();
|
||||
|
||||
// Delete old diagnostics folder (1 day).
|
||||
DateTime expirationDate = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0));
|
||||
string[] diagnosticsDirectories = Directory.GetDirectories(path, "Diagnostics.*");
|
||||
for (int index = 0; index < diagnosticsDirectories.Length; index++)
|
||||
{
|
||||
string directory = diagnosticsDirectories[index];
|
||||
DateTime creationTime = Directory.GetCreationTime(directory);
|
||||
if (creationTime < expirationDate)
|
||||
{
|
||||
Directory.Delete(directory, true);
|
||||
}
|
||||
}
|
||||
|
||||
Debug.diagnosticsFolderPath = Path.Combine(path, "Diagnostics." + Process.GetCurrentProcess().Id);
|
||||
Debug.diagnosticsFolderPath = PathHelpers.GenerateUniquePath(Debug.diagnosticsFolderPath);
|
||||
Directory.CreateDirectory(Debug.diagnosticsFolderPath);
|
||||
}
|
||||
|
||||
public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged;
|
||||
|
||||
public static DiagnosticsData[] Data
|
||||
{
|
||||
get
|
||||
{
|
||||
return Debug.diagnosticsDataById.Values.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Log(string message, params object[] arguments)
|
||||
{
|
||||
DiagnosticsData diagnosticsData;
|
||||
|
||||
int threadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
|
||||
lock (Debug.diagnosticsDataById)
|
||||
{
|
||||
if (!Debug.diagnosticsDataById.TryGetValue(threadId, out diagnosticsData))
|
||||
{
|
||||
diagnosticsData = new DiagnosticsData(Debug.threadCount > 0 ? string.Format("Thread {0}", Debug.threadCount) : "Application");
|
||||
diagnosticsData.Initialize(Debug.diagnosticsFolderPath, threadId);
|
||||
Debug.diagnosticsDataById.Add(threadId, diagnosticsData);
|
||||
Debug.threadCount++;
|
||||
|
||||
StaticPropertyChanged?.Invoke(null, new PropertyChangedEventArgs("Data"));
|
||||
}
|
||||
}
|
||||
|
||||
diagnosticsData.Log(message, arguments);
|
||||
}
|
||||
|
||||
public static void LogError(string message, params object[] arguments)
|
||||
{
|
||||
string log = string.Format(message, arguments);
|
||||
|
||||
MessageBox.Show(log, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
|
||||
Debug.Log("Error: " + message, arguments);
|
||||
}
|
||||
|
||||
public static void Release()
|
||||
{
|
||||
Debug.Log("Diagnostics manager released correctly.");
|
||||
|
||||
foreach (KeyValuePair<int, DiagnosticsData> kvp in Debug.diagnosticsDataById)
|
||||
{
|
||||
kvp.Value.Release();
|
||||
}
|
||||
|
||||
Debug.diagnosticsDataById.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
// <copyright file="DiagnosticsData.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.Diagnostics
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
using FileConverter.Annotations;
|
||||
|
||||
public class DiagnosticsData : INotifyPropertyChanged
|
||||
{
|
||||
private List<string> logMessages = new List<string>();
|
||||
private StringBuilder stringBuilder = new StringBuilder();
|
||||
private System.IO.TextWriter logFileWriter;
|
||||
private string name;
|
||||
|
||||
public DiagnosticsData(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
this.LogMessages = new ReadOnlyCollection<string>(this.logMessages);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
private set
|
||||
{
|
||||
this.name = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string Content
|
||||
{
|
||||
get
|
||||
{
|
||||
this.stringBuilder.Clear();
|
||||
for (int index = 0; index < this.LogMessages.Count; index++)
|
||||
{
|
||||
this.stringBuilder.AppendLine(this.LogMessages[index]);
|
||||
}
|
||||
|
||||
return this.stringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public ReadOnlyCollection<string> LogMessages
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public void Initialize(string diagnosticsFolderPath, int id)
|
||||
{
|
||||
string path = Path.Combine(diagnosticsFolderPath, string.Format("Diagnostics{0}.log", id));
|
||||
path = PathHelpers.GenerateUniquePath(path);
|
||||
this.logFileWriter = new StreamWriter(File.Open(path, FileMode.Create));
|
||||
|
||||
this.Log("{0} {1}\n", System.DateTime.Now.ToLongDateString(), System.DateTime.Now.ToLongTimeString());
|
||||
}
|
||||
|
||||
public void Release()
|
||||
{
|
||||
this.logFileWriter.Close();
|
||||
this.logFileWriter = null;
|
||||
}
|
||||
|
||||
public void Log(string message, params object[] arguments)
|
||||
{
|
||||
string log = string.Format(message, arguments);
|
||||
|
||||
this.logMessages.Add(log);
|
||||
this.logFileWriter.WriteLine(log);
|
||||
this.logFileWriter.Flush();
|
||||
|
||||
this.OnPropertyChanged("Content");
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChangedEventHandler handler = this.PropertyChanged;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,16 +42,29 @@
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Resources\ApplicationIcon-256x256.ico</ApplicationIcon>
|
||||
<ApplicationIcon>Resources\ApplicationIcon.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Accessibility" />
|
||||
<Reference Include="Magick.NET-Q16-AnyCPU, Version=7.0.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Magick.NET-Q16-AnyCPU.7.0.0.0101\lib\net40-client\Magick.NET-Q16-AnyCPU.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Markdown.Xaml">
|
||||
<HintPath>..\..\Middleware\Markdown.Xaml.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationUI, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||
<Reference Include="ReachFramework" />
|
||||
<Reference Include="Ripper, Version=1.0.5806.33932, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\Middleware\Ripper.dll</HintPath>
|
||||
</Reference>
|
||||
<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" />
|
||||
@@ -65,24 +78,84 @@
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="yeti.mmedia">
|
||||
<HintPath>..\..\Middleware\yeti.mmedia.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="Application.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Controls\EncodingQualitySliderControl.xaml.cs">
|
||||
<DependentUpon>EncodingQualitySliderControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ConversionJobs\ConversionFlags.cs" />
|
||||
<Compile Include="ConversionJobs\ConversionJob_ExtractCDA.cs" />
|
||||
<Compile Include="ConversionJobs\ConversionJobFactory.cs" />
|
||||
<Compile Include="ConversionJobs\ConversionJob_FFMPEG.Converters.cs" />
|
||||
<Compile Include="ConversionJobs\ConversionJob_FFMPEG.cs" />
|
||||
<Compile Include="ConversionJobs\ConversionJob_Ico.cs" />
|
||||
<Compile Include="ConversionJobs\ConversionJob_ImageMagick.cs" />
|
||||
<Compile Include="ConversionPreset\ConversionSettingsOverride.cs" />
|
||||
<Compile Include="ConversionPreset\ConversionSettings.cs" />
|
||||
<Compile Include="Diagnostics\DiagnosticsData.cs" />
|
||||
<Compile Include="Controls\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="Registry.cs" />
|
||||
<Compile Include="Settings.Settings.cs" />
|
||||
<Compile Include="Upgrade\Helpers.cs" />
|
||||
<Compile Include="Upgrade\UpgradeVersionDescription.cs" />
|
||||
<Compile Include="ValueConverters\ApplicationVersionToApplicationName.cs" />
|
||||
<Compile Include="ConversionPreset.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\DoubleToTimeString.cs" />
|
||||
<Compile Include="ValueConverters\Generic\EqualsConverter.cs" />
|
||||
<Compile Include="ValueConverters\Generic\CollectionContainsElementToBool.cs" />
|
||||
<Compile Include="ValueConverters\Generic\FormatStringConverter.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\ApplicationStartHelp.xaml.cs">
|
||||
<DependentUpon>ApplicationStartHelp.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<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" />
|
||||
<Compile Include="Windows\UpgradeWindow.xaml.cs">
|
||||
<DependentUpon>UpgradeWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="XmlHelpers.cs" />
|
||||
<Page Include="Controls\EncodingQualitySliderControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Windows\ApplicationStartHelp.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Windows\DiagnosticsWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -96,8 +169,8 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ValueConverters\ConversionStateToBrush.cs" />
|
||||
<Compile Include="ConversionJob.cs" />
|
||||
<Compile Include="Diagnostics.cs" />
|
||||
<Compile Include="ConversionJobs\ConversionJob.cs" />
|
||||
<Compile Include="Diagnostics\Debug.cs" />
|
||||
<Compile Include="Windows\MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
@@ -106,12 +179,19 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Windows\UpgradeWindow.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>
|
||||
@@ -123,10 +203,15 @@
|
||||
<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="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
@@ -140,11 +225,20 @@
|
||||
<Resource Include="Resources\ApplicationIcon.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\ApplicationIcon-16x16.ico" />
|
||||
<Resource Include="Resources\ApplicationIcon-256x256.ico" />
|
||||
<Resource Include="Resources\ApplicationIcon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\DownloadIcon.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\ContextMenuScreenshot.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy /Y "$(SolutionDir)Middleware\ffmpeg.exe" "$(TargetDir)ffmpeg.exe"
|
||||
copy /Y "$(ProjectDir)Settings.default.xml" "$(TargetDir)Settings.default.xml"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- 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>
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,17 @@ namespace FileConverter
|
||||
public enum OutputType
|
||||
{
|
||||
None,
|
||||
Mp3,
|
||||
Ogg,
|
||||
|
||||
Aac,
|
||||
Avi,
|
||||
Flac,
|
||||
Ico,
|
||||
Jpg,
|
||||
Mkv,
|
||||
Mp3,
|
||||
Mp4,
|
||||
Ogg,
|
||||
Png,
|
||||
Wav,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
// <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 cdaTrackNumberRegex = new Regex(@"[a-zA-Z]:\\Track([0-9]+)\.cda");
|
||||
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 string GetPathDriveLetter(string path)
|
||||
{
|
||||
return PathHelpers.driveLetterRegex.Match(path).Groups[0].Value;
|
||||
}
|
||||
|
||||
public static int GetCDATrackNumber(string path)
|
||||
{
|
||||
Match match = PathHelpers.cdaTrackNumberRegex.Match(path);
|
||||
string stringNumber = match.Groups[1].Value;
|
||||
return int.Parse(stringNumber);
|
||||
}
|
||||
|
||||
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 "aac":
|
||||
case "aiff":
|
||||
case "ape":
|
||||
case "cda":
|
||||
case "flac":
|
||||
case "mp3":
|
||||
case "m4a":
|
||||
case "ogg":
|
||||
case "wav":
|
||||
case "wma":
|
||||
return InputCategoryNames.Audio;
|
||||
|
||||
case "avi":
|
||||
case "bik":
|
||||
case "3gp":
|
||||
case "flv":
|
||||
case "m4v":
|
||||
case "mp4":
|
||||
case "mov":
|
||||
case "mkv":
|
||||
case "webm":
|
||||
case "wmv":
|
||||
return InputCategoryNames.Video;
|
||||
|
||||
case "bmp":
|
||||
case "exr":
|
||||
case "ico":
|
||||
case "jpg":
|
||||
case "jpeg":
|
||||
case "png":
|
||||
case "psd":
|
||||
case "tga":
|
||||
case "tiff":
|
||||
case "svg":
|
||||
case "xcf":
|
||||
return InputCategoryNames.Image;
|
||||
}
|
||||
|
||||
return InputCategoryNames.Misc;
|
||||
}
|
||||
|
||||
public static bool IsOutputTypeCompatibleWithCategory(OutputType outputType, string category)
|
||||
{
|
||||
if (category == InputCategoryNames.Misc)
|
||||
{
|
||||
// Misc category contains unsorted input extensions, so we consider that they are compatible to be tolerant.
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (outputType)
|
||||
{
|
||||
case OutputType.Aac:
|
||||
case OutputType.Flac:
|
||||
case OutputType.Mp3:
|
||||
case OutputType.Ogg:
|
||||
case OutputType.Wav:
|
||||
return category == InputCategoryNames.Audio || category == InputCategoryNames.Video;
|
||||
|
||||
case OutputType.Avi:
|
||||
case OutputType.Mkv:
|
||||
case OutputType.Mp4:
|
||||
return category == InputCategoryNames.Video;
|
||||
|
||||
case OutputType.Ico:
|
||||
case OutputType.Png:
|
||||
case OutputType.Jpg:
|
||||
return category == InputCategoryNames.Image;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetUserDataFolderPath()
|
||||
{
|
||||
string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData);
|
||||
path = System.IO.Path.Combine(path, "FileConverter");
|
||||
|
||||
if (!System.IO.Directory.Exists(path))
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
public static class InputCategoryNames
|
||||
{
|
||||
public const string Audio = "Audio";
|
||||
public const string Video = "Video";
|
||||
public const string Image = "Image";
|
||||
public const string Misc = "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,127 @@ 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 90° counter clockwise rotation.
|
||||
/// </summary>
|
||||
public static string NinetyDegreesRotationTooltip {
|
||||
get {
|
||||
return ResourceManager.GetString("NinetyDegreesRotationTooltip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to 180° rotation.
|
||||
/// </summary>
|
||||
public static string OneEightyDegreesRotationTooltip {
|
||||
get {
|
||||
return ResourceManager.GetString("OneEightyDegreesRotationTooltip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to C:\Music\Artist\Album\Song.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
|
||||
///
|
||||
///Special paths:
|
||||
///(p:d): my documents path
|
||||
///(p:m): my music path
|
||||
///(p:v): my videos path
|
||||
///(p:p): my pictures path.
|
||||
/// </summary>
|
||||
public static string OutputFilePathTemplateHelp {
|
||||
get {
|
||||
return ResourceManager.GetString("OutputFilePathTemplateHelp", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to 90° clockwise rotation.
|
||||
/// </summary>
|
||||
public static string TwoSeventyDegreesRotationTooltip {
|
||||
get {
|
||||
return ResourceManager.GetString("TwoSeventyDegreesRotationTooltip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Define the ratio 'file size' versus 'video quality'. A lower value will give you a smaller file, a greater value give you a better video quality..
|
||||
/// </summary>
|
||||
public static string VideoEncodingQualityTooltip {
|
||||
get {
|
||||
return ResourceManager.GetString("VideoEncodingQualityTooltip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Define the ratio 'file size' versus 'compression duration'. A slow compression will give you a smaller file (for the same video quality) than a faster compression..
|
||||
/// </summary>
|
||||
public static string VideoEncodingSpeedTooltip {
|
||||
get {
|
||||
return ResourceManager.GetString("VideoEncodingSpeedTooltip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to No rotation.
|
||||
/// </summary>
|
||||
public static string ZeroDegreesRotationTooltip {
|
||||
get {
|
||||
return ResourceManager.GetString("ZeroDegreesRotationTooltip", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
<?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="NinetyDegreesRotationTooltip" xml:space="preserve">
|
||||
<value>90° counter clockwise rotation</value>
|
||||
</data>
|
||||
<data name="OneEightyDegreesRotationTooltip" xml:space="preserve">
|
||||
<value>180° rotation</value>
|
||||
</data>
|
||||
<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
|
||||
|
||||
Special paths:
|
||||
(p:d): my documents path
|
||||
(p:m): my music path
|
||||
(p:v): my videos path
|
||||
(p:p): my pictures path</value>
|
||||
</data>
|
||||
<data name="TwoSeventyDegreesRotationTooltip" xml:space="preserve">
|
||||
<value>90° clockwise rotation</value>
|
||||
</data>
|
||||
<data name="VideoEncodingQualityTooltip" xml:space="preserve">
|
||||
<value>Define the ratio 'file size' versus 'video quality'. A lower value will give you a smaller file, a greater value give you a better video quality.</value>
|
||||
</data>
|
||||
<data name="VideoEncodingSpeedTooltip" xml:space="preserve">
|
||||
<value>Define the ratio 'file size' versus 'compression duration'. A slow compression will give you a smaller file (for the same video quality) than a faster compression.</value>
|
||||
</data>
|
||||
<data name="ZeroDegreesRotationTooltip" xml:space="preserve">
|
||||
<value>No rotation</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,46 @@
|
||||
<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="NinetyDegreesRotationTooltip" xml:space="preserve">
|
||||
<value>90° counter clockwise rotation</value>
|
||||
</data>
|
||||
<data name="OneEightyDegreesRotationTooltip" xml:space="preserve">
|
||||
<value>180° rotation</value>
|
||||
</data>
|
||||
<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
|
||||
|
||||
Special paths:
|
||||
(p:d): my documents path
|
||||
(p:m): my music path
|
||||
(p:v): my videos path
|
||||
(p:p): my pictures path</value>
|
||||
</data>
|
||||
<data name="TwoSeventyDegreesRotationTooltip" xml:space="preserve">
|
||||
<value>90° clockwise rotation</value>
|
||||
</data>
|
||||
<data name="VideoEncodingQualityTooltip" xml:space="preserve">
|
||||
<value>Define the ratio 'file size' versus 'video quality'. A lower value will give you a smaller file, a greater value give you a better video quality.</value>
|
||||
</data>
|
||||
<data name="VideoEncodingSpeedTooltip" xml:space="preserve">
|
||||
<value>Define the ratio 'file size' versus 'compression duration'. A slow compression will give you a smaller file (for the same video quality) than a faster compression.</value>
|
||||
</data>
|
||||
<data name="ZeroDegreesRotationTooltip" xml:space="preserve">
|
||||
<value>No rotation</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,203 @@
|
||||
// <copyright file="Registry.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.Serialization;
|
||||
|
||||
public class Registry : IDisposable
|
||||
{
|
||||
private static Registry instance;
|
||||
|
||||
private Dictionary<string, string> registryEntries = new Dictionary<string, string>();
|
||||
|
||||
~Registry()
|
||||
{
|
||||
this.Dispose();
|
||||
Registry.instance = null;
|
||||
}
|
||||
|
||||
[XmlElement("Entry")]
|
||||
public Entry[] SerializableEntries
|
||||
{
|
||||
get
|
||||
{
|
||||
Entry[] entries = new Entry[this.registryEntries.Count];
|
||||
int index = 0;
|
||||
foreach (KeyValuePair<string, string> kvp in this.registryEntries)
|
||||
{
|
||||
if (kvp.Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
entries[index] = new Entry(kvp.Key, kvp.Value);
|
||||
index++;
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.registryEntries.Clear();
|
||||
for (int index = 0; index < value.Length; index++)
|
||||
{
|
||||
Entry entry = value[index];
|
||||
if (entry.Key == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.registryEntries.ContainsKey(entry.Key))
|
||||
{
|
||||
Diagnostics.Debug.Log("Ignore registry entry {0}.", entry.Key);
|
||||
continue;
|
||||
}
|
||||
|
||||
this.registryEntries.Add(entry.Key, entry.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Registry Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Registry.instance == null)
|
||||
{
|
||||
Registry.Load();
|
||||
}
|
||||
|
||||
return Registry.instance;
|
||||
}
|
||||
}
|
||||
|
||||
public static T GetValue<T>(string key)
|
||||
{
|
||||
Registry registry = Registry.Instance;
|
||||
|
||||
string stringValue;
|
||||
if (!registry.registryEntries.TryGetValue(key, out stringValue))
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
object value = System.Convert.ChangeType(stringValue, typeof(T));
|
||||
return (T)value;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Diagnostics.Debug.LogError("Can't convert registry value: {0}.", exception.Message);
|
||||
}
|
||||
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public static void SetValue<T>(string key, T value)
|
||||
{
|
||||
Registry registry = Registry.Instance;
|
||||
|
||||
if (!registry.registryEntries.ContainsKey(key))
|
||||
{
|
||||
registry.registryEntries.Add(key, null);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
string stringValue = (string)System.Convert.ChangeType(value, typeof(string));
|
||||
registry.registryEntries[key] = stringValue;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Diagnostics.Debug.LogError("Can't convert registry value: {0}.", exception.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// SAVE
|
||||
string registryFilePath = Registry.GetUserRegistryFilePath();
|
||||
|
||||
try
|
||||
{
|
||||
XmlHelpers.SaveToFile("Registry", registryFilePath, this);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Diagnostics.Debug.LogError("Fail to save registry. {0}", exception.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Load()
|
||||
{
|
||||
string registryFilePath = Registry.GetUserRegistryFilePath();
|
||||
if (!File.Exists(registryFilePath))
|
||||
{
|
||||
Registry.instance = new Registry();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Registry.instance = null;
|
||||
XmlHelpers.LoadFromFile<Registry>("Registry", registryFilePath, out Registry.instance);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Registry.instance = new Registry();
|
||||
Diagnostics.Debug.LogError("Fail to load registry. {0}", exception.Message);
|
||||
while (exception.InnerException != null)
|
||||
{
|
||||
exception = exception.InnerException;
|
||||
Diagnostics.Debug.LogError("Inner exception: {0}", exception.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetUserRegistryFilePath()
|
||||
{
|
||||
string path = PathHelpers.GetUserDataFolderPath();
|
||||
path = Path.Combine(path, "Registry.xml");
|
||||
return path;
|
||||
}
|
||||
|
||||
[XmlRoot("Entry")]
|
||||
public struct Entry
|
||||
{
|
||||
public Entry(string key, string value)
|
||||
{
|
||||
this.Key = key;
|
||||
this.Value = value;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public string Key
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[XmlText]
|
||||
public string Value
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Keys
|
||||
{
|
||||
public static readonly string LastUpdateCheckDate = "LastUpdateCheckDate";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 294 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
@@ -0,0 +1,112 @@
|
||||
// <copyright file="Settings.Settings.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
public partial class Settings : IXmlSerializable
|
||||
{
|
||||
public const int Version = 1;
|
||||
|
||||
private bool exitApplicationWhenConversionsFinished = true;
|
||||
private float durationBetweenEndOfConversionsAndApplicationExit = 3f;
|
||||
private ObservableCollection<ConversionPreset> conversionPresets = new ObservableCollection<ConversionPreset>();
|
||||
private bool checkUpgradeAtStartup = true;
|
||||
|
||||
[XmlAttribute]
|
||||
public int SerializationVersion
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = Version;
|
||||
|
||||
[XmlIgnore]
|
||||
public ObservableCollection<ConversionPreset> ConversionPresets
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.conversionPresets;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.conversionPresets = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[XmlElement]
|
||||
public bool ExitApplicationWhenConversionsFinished
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.exitApplicationWhenConversionsFinished;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.exitApplicationWhenConversionsFinished = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[XmlElement]
|
||||
public float DurationBetweenEndOfConversionsAndApplicationExit
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.durationBetweenEndOfConversionsAndApplicationExit;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.durationBetweenEndOfConversionsAndApplicationExit = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[XmlElement("ConversionPreset")]
|
||||
public ConversionPreset[] SerializableConversionPresets
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.ConversionPresets.ToArray();
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
for (int index = 0; index < value.Length; index++)
|
||||
{
|
||||
this.ConversionPresets.Add(value[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[XmlElement]
|
||||
public bool CheckUpgradeAtStartup
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.checkUpgradeAtStartup;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.checkUpgradeAtStartup = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDeserializationComplete()
|
||||
{
|
||||
this.DurationBetweenEndOfConversionsAndApplicationExit = System.Math.Max(0, System.Math.Min(10, this.DurationBetweenEndOfConversionsAndApplicationExit));
|
||||
|
||||
for (int index = 0; index < this.ConversionPresets.Count; index++)
|
||||
{
|
||||
this.ConversionPresets[index].OnDeserializationComplete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,28 +4,45 @@ 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 System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using Microsoft.Win32;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
using FileConverter.Annotations;
|
||||
using Microsoft.Win32;
|
||||
|
||||
public class Settings : INotifyPropertyChanged, IDataErrorInfo
|
||||
[XmlRoot]
|
||||
[XmlType]
|
||||
public partial class Settings : INotifyPropertyChanged, IDataErrorInfo
|
||||
{
|
||||
private const char PresetSeparator = ';';
|
||||
|
||||
private ObservableCollection<ConversionPreset> conversionPresets = new ObservableCollection<ConversionPreset>();
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[XmlIgnore]
|
||||
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
|
||||
@@ -34,53 +51,172 @@ namespace FileConverter
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<ConversionPreset> ConversionPresets
|
||||
[XmlIgnore]
|
||||
public string this[string columnName]
|
||||
{
|
||||
get { return this.conversionPresets; }
|
||||
set { this.conversionPresets = value; }
|
||||
get
|
||||
{
|
||||
return this.Error;
|
||||
}
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
public static void ApplyTemporarySettings()
|
||||
{
|
||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
// Load temporary settings.
|
||||
string temporaryFilePath = Settings.GetUserSettingsTemporaryFilePath();
|
||||
if (!File.Exists(temporaryFilePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Settings settings = null;
|
||||
XmlHelpers.LoadFromFile("Settings", temporaryFilePath, out settings);
|
||||
|
||||
RegistryKey registryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\FileConverter");
|
||||
if (registryKey == null)
|
||||
{
|
||||
Diagnostics.Debug.LogError("Can't apply settings in registry. (code 0x03)");
|
||||
return;
|
||||
}
|
||||
|
||||
// Compute the registry entries data from settings.
|
||||
Dictionary<string, List<string>> registryEntries = ComputeRegistryEntriesFromConvertionPresets(settings.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 static void PostInstallationInitialization()
|
||||
{
|
||||
Settings defaultSettings = null;
|
||||
|
||||
// Load the default settings.
|
||||
string defaultFilePath = Settings.GetDefaultSettingsFilePath();
|
||||
if (File.Exists(defaultFilePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
XmlHelpers.LoadFromFile<Settings>("Settings", defaultFilePath, out defaultSettings);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Diagnostics.Debug.LogError("Fail to load file converter default settings. {0}", exception.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Diagnostics.Debug.LogError("Default settings not found at path {0}. You should try to reinstall the application.", defaultFilePath);
|
||||
}
|
||||
|
||||
// Load user settings if exists.
|
||||
Settings userSettings = null;
|
||||
string userFilePath = Settings.GetUserSettingsFilePath();
|
||||
if (File.Exists(userFilePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
XmlHelpers.LoadFromFile<Settings>("Settings", userFilePath, out userSettings);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
System.IO.File.Delete(userFilePath);
|
||||
}
|
||||
|
||||
if (userSettings != null && userSettings.SerializationVersion != Version)
|
||||
{
|
||||
Diagnostics.Debug.Log("File converter settings has been imported from version {0} to version {1}.", userSettings.SerializationVersion, Version);
|
||||
userSettings.SerializationVersion = Version;
|
||||
}
|
||||
}
|
||||
|
||||
Settings settings = userSettings != null ? userSettings.Merge(defaultSettings) : defaultSettings;
|
||||
settings.Save();
|
||||
}
|
||||
|
||||
public static Settings Load()
|
||||
{
|
||||
Settings settings = null;
|
||||
string userFilePath = Settings.GetUserSettingsFilePath();
|
||||
if (File.Exists(userFilePath))
|
||||
{
|
||||
Settings userSettings = null;
|
||||
try
|
||||
{
|
||||
XmlHelpers.LoadFromFile<Settings>("Settings", userFilePath, out userSettings);
|
||||
settings = userSettings;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBoxResult messageBoxResult =
|
||||
MessageBox.Show(
|
||||
"Can't load file converter user settings. Do you want to fall back to default settings ?",
|
||||
"Error",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Exclamation);
|
||||
|
||||
if (messageBoxResult == MessageBoxResult.Yes)
|
||||
{
|
||||
System.IO.File.Delete(userFilePath);
|
||||
return Settings.Load();
|
||||
}
|
||||
else if (messageBoxResult == MessageBoxResult.No)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (userSettings != null && userSettings.SerializationVersion != Version)
|
||||
{
|
||||
Diagnostics.Debug.Log("File converter settings has been imported from version {0} to version {1}.", userSettings.SerializationVersion, Version);
|
||||
userSettings.SerializationVersion = Version;
|
||||
userSettings.Save();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load the default settings.
|
||||
string defaultFilePath = Settings.GetDefaultSettingsFilePath();
|
||||
if (File.Exists(defaultFilePath))
|
||||
{
|
||||
Settings defaultSettings = null;
|
||||
try
|
||||
{
|
||||
XmlHelpers.LoadFromFile<Settings>("Settings", defaultFilePath, out defaultSettings);
|
||||
settings = defaultSettings;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Diagnostics.Debug.LogError("Fail to load file converter default settings. {0}", exception.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Diagnostics.Debug.LogError("Default settings not found at path {0}. You should try to reinstall the application.", defaultFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
this.Clean();
|
||||
|
||||
// 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);
|
||||
XmlHelpers.SaveToFile("Settings", temporaryFilePath, this);
|
||||
|
||||
// Compute the registry entries data from settings.
|
||||
Dictionary<string, List<string>> registryEntries = Settings.ComputeRegistryEntriesFromConvertionPresets(this.ConversionPresets);
|
||||
@@ -93,7 +229,7 @@ namespace FileConverter
|
||||
// Write the settings in registry.
|
||||
if (Settings.IsInAdmininstratorPrivileges)
|
||||
{
|
||||
// We are in admin mode, write reigstry ...
|
||||
// We are in admin mode, write registry ...
|
||||
bool succeed = Settings.ApplyRegistryModifications(registryEntries);
|
||||
if (succeed)
|
||||
{
|
||||
@@ -118,36 +254,11 @@ namespace FileConverter
|
||||
}
|
||||
}
|
||||
|
||||
public static void ApplyTemporarySettings()
|
||||
public void Clean()
|
||||
{
|
||||
// Load temporary settings.
|
||||
string temporaryFilePath = Settings.GetUserSettingsTemporaryFilePath();
|
||||
if (!File.Exists(temporaryFilePath))
|
||||
for (int index = 0; index < this.ConversionPresets.Count; index++)
|
||||
{
|
||||
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.", "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);
|
||||
this.ConversionPresets[index].Clean();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,14 +266,14 @@ namespace FileConverter
|
||||
{
|
||||
if (!Settings.IsInAdmininstratorPrivileges)
|
||||
{
|
||||
MessageBox.Show("Can't apply settings in registry because the application is not in administrator privileges.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
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);
|
||||
RegistryKey registryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\FileConverter", RegistryKeyPermissionCheck.ReadWriteSubTree);
|
||||
if (registryKey == null)
|
||||
{
|
||||
MessageBox.Show("Can't apply settings in registry (ErrorCode=1).", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show("Can't apply settings in registry. (code 0x05)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -174,9 +285,9 @@ namespace FileConverter
|
||||
{
|
||||
registryKey.DeleteSubKey(subKeyNames[index]);
|
||||
}
|
||||
catch (Exception exception)
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Can't apply settings in registry (ErrorCode=2).", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show("Can't apply settings in registry. (code 0x06)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -202,12 +313,12 @@ namespace FileConverter
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Diagnostics.Log(exception.Message);
|
||||
Diagnostics.Debug.Log(exception.Message);
|
||||
}
|
||||
|
||||
if (subKey == null)
|
||||
{
|
||||
MessageBox.Show("Can't apply settings in registry (ErrorCode=3).", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show("Can't apply settings in registry. (code 0x07)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -249,34 +360,20 @@ namespace FileConverter
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
path = Path.Combine(path, "Settings.xml");
|
||||
path = Path.Combine(path, "Settings.default.xml");
|
||||
return path;
|
||||
}
|
||||
|
||||
private static string GetUserSettingsFilePath()
|
||||
{
|
||||
string path = Environment.GetEnvironmentVariable("LocalAppData");
|
||||
path = Path.Combine(path, "FileConverter");
|
||||
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
string path = PathHelpers.GetUserDataFolderPath();
|
||||
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);
|
||||
}
|
||||
|
||||
string path = PathHelpers.GetUserDataFolderPath();
|
||||
path = Path.Combine(path, "Settings.temp.xml");
|
||||
return path;
|
||||
}
|
||||
@@ -284,7 +381,7 @@ namespace FileConverter
|
||||
private static bool IsRegistryNeedModifications(Dictionary<string, List<string>> registryEntries)
|
||||
{
|
||||
// Compare to registry entries.
|
||||
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software\FileConverter");
|
||||
RegistryKey registryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\FileConverter");
|
||||
if (registryKey == null)
|
||||
{
|
||||
return true;
|
||||
@@ -318,7 +415,7 @@ namespace FileConverter
|
||||
|
||||
for (int presetIndex = 0; presetIndex < presets.Length; presetIndex++)
|
||||
{
|
||||
if (!presetsList.Contains(presets[presetIndex]))
|
||||
if (presetsList[presetIndex] != presets[presetIndex])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -352,36 +449,38 @@ namespace FileConverter
|
||||
process.Start();
|
||||
process.WaitForExit();
|
||||
}
|
||||
catch (Exception exception)
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Can't apply settings in registry because the application has no administrator privileges.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
MessageBox.Show("Can't apply settings in registry because the application has no administrator privileges. (code 0x08)", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public string this[string columnName]
|
||||
[NotifyPropertyChangedInvocator]
|
||||
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Error;
|
||||
}
|
||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public string Error
|
||||
private Settings Merge(Settings settings)
|
||||
{
|
||||
get
|
||||
if (settings == null)
|
||||
{
|
||||
for (int index = 0; index < this.ConversionPresets.Count; index++)
|
||||
return this;
|
||||
}
|
||||
|
||||
for (int index = 0; index < settings.conversionPresets.Count; index++)
|
||||
{
|
||||
ConversionPreset conversionPreset = settings.conversionPresets[index];
|
||||
if (this.conversionPresets.Any(match => match.Name == conversionPreset.Name))
|
||||
{
|
||||
string error = this.ConversionPresets[index].Error;
|
||||
if (!string.IsNullOrEmpty(error))
|
||||
{
|
||||
return error;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
this.conversionPresets.Add(conversionPreset);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,355 @@
|
||||
<?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" SerializationVersion="1">
|
||||
<ExitApplicationWhenConversionsFinished>true</ExitApplicationWhenConversionsFinished>
|
||||
<DurationBetweenEndOfConversionsAndApplicationExit>3</DurationBetweenEndOfConversionsAndApplicationExit>
|
||||
<ConversionPreset Name="To Mkv" OutputType="Mkv">
|
||||
<InputTypes>3gp</InputTypes>
|
||||
<InputTypes>avi</InputTypes>
|
||||
<InputTypes>bik</InputTypes>
|
||||
<InputTypes>flv</InputTypes>
|
||||
<InputTypes>m4v</InputTypes>
|
||||
<InputTypes>mkv</InputTypes>
|
||||
<InputTypes>mov</InputTypes>
|
||||
<InputTypes>mp4</InputTypes>
|
||||
<InputTypes>webm</InputTypes>
|
||||
<InputTypes>wmv</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="VideoQuality" Value="30" />
|
||||
<Settings Key="VideoEncodingSpeed" Value="Medium" />
|
||||
<Settings Key="VideoScale" Value="1" />
|
||||
<Settings Key="VideoRotation" Value="0" />
|
||||
<Settings Key="AudioBitrate" Value="155" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Mp4" OutputType="Mp4">
|
||||
<InputTypes>avi</InputTypes>
|
||||
<InputTypes>bik</InputTypes>
|
||||
<InputTypes>flv</InputTypes>
|
||||
<InputTypes>mkv</InputTypes>
|
||||
<InputTypes>mov</InputTypes>
|
||||
<InputTypes>mp4</InputTypes>
|
||||
<InputTypes>3gp</InputTypes>
|
||||
<InputTypes>webm</InputTypes>
|
||||
<InputTypes>wmv</InputTypes>
|
||||
<InputTypes>m4v</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="VideoQuality" Value="30" />
|
||||
<Settings Key="VideoEncodingSpeed" Value="Medium" />
|
||||
<Settings Key="VideoScale" Value="1" />
|
||||
<Settings Key="VideoRotation" Value="0" />
|
||||
<Settings Key="AudioBitrate" Value="155" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Mp4 (low quality)" OutputType="Mp4">
|
||||
<InputTypes>avi</InputTypes>
|
||||
<InputTypes>bik</InputTypes>
|
||||
<InputTypes>flv</InputTypes>
|
||||
<InputTypes>mkv</InputTypes>
|
||||
<InputTypes>mov</InputTypes>
|
||||
<InputTypes>mp4</InputTypes>
|
||||
<InputTypes>3gp</InputTypes>
|
||||
<InputTypes>webm</InputTypes>
|
||||
<InputTypes>wmv</InputTypes>
|
||||
<InputTypes>m4v</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="VideoQuality" Value="20" />
|
||||
<Settings Key="VideoEncodingSpeed" Value="Medium" />
|
||||
<Settings Key="VideoScale" Value="1" />
|
||||
<Settings Key="VideoRotation" Value="0" />
|
||||
<Settings Key="AudioBitrate" Value="96" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Mp4 (rotate left)" OutputType="Mp4">
|
||||
<InputTypes>avi</InputTypes>
|
||||
<InputTypes>bik</InputTypes>
|
||||
<InputTypes>flv</InputTypes>
|
||||
<InputTypes>mkv</InputTypes>
|
||||
<InputTypes>mov</InputTypes>
|
||||
<InputTypes>mp4</InputTypes>
|
||||
<InputTypes>3gp</InputTypes>
|
||||
<InputTypes>webm</InputTypes>
|
||||
<InputTypes>wmv</InputTypes>
|
||||
<InputTypes>m4v</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="VideoQuality" Value="30" />
|
||||
<Settings Key="VideoEncodingSpeed" Value="Medium" />
|
||||
<Settings Key="VideoScale" Value="1" />
|
||||
<Settings Key="VideoRotation" Value="90" />
|
||||
<Settings Key="AudioBitrate" Value="155" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Mp4 (rotate right)" OutputType="Mp4">
|
||||
<InputTypes>avi</InputTypes>
|
||||
<InputTypes>bik</InputTypes>
|
||||
<InputTypes>flv</InputTypes>
|
||||
<InputTypes>mkv</InputTypes>
|
||||
<InputTypes>mov</InputTypes>
|
||||
<InputTypes>mp4</InputTypes>
|
||||
<InputTypes>3gp</InputTypes>
|
||||
<InputTypes>webm</InputTypes>
|
||||
<InputTypes>wmv</InputTypes>
|
||||
<InputTypes>m4v</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="VideoQuality" Value="30" />
|
||||
<Settings Key="VideoEncodingSpeed" Value="Medium" />
|
||||
<Settings Key="VideoScale" Value="1" />
|
||||
<Settings Key="VideoRotation" Value="270" />
|
||||
<Settings Key="AudioBitrate" Value="155" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Avi" OutputType="Avi">
|
||||
<InputTypes>avi</InputTypes>
|
||||
<InputTypes>bik</InputTypes>
|
||||
<InputTypes>flv</InputTypes>
|
||||
<InputTypes>mkv</InputTypes>
|
||||
<InputTypes>mov</InputTypes>
|
||||
<InputTypes>mp4</InputTypes>
|
||||
<InputTypes>3gp</InputTypes>
|
||||
<InputTypes>webm</InputTypes>
|
||||
<InputTypes>wmv</InputTypes>
|
||||
<InputTypes>m4v</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="VideoQuality" Value="27" />
|
||||
<Settings Key="VideoScale" Value="1" />
|
||||
<Settings Key="VideoRotation" Value="0" />
|
||||
<Settings Key="AudioBitrate" Value="190" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Ogg" OutputType="Ogg">
|
||||
<InputTypes>aac</InputTypes>
|
||||
<InputTypes>aiff</InputTypes>
|
||||
<InputTypes>ape</InputTypes>
|
||||
<InputTypes>flac</InputTypes>
|
||||
<InputTypes>m4a</InputTypes>
|
||||
<InputTypes>mp3</InputTypes>
|
||||
<InputTypes>wma</InputTypes>
|
||||
<InputTypes>avi</InputTypes>
|
||||
<InputTypes>bik</InputTypes>
|
||||
<InputTypes>flv</InputTypes>
|
||||
<InputTypes>mkv</InputTypes>
|
||||
<InputTypes>mov</InputTypes>
|
||||
<InputTypes>mp4</InputTypes>
|
||||
<InputTypes>wav</InputTypes>
|
||||
<InputTypes>3gp</InputTypes>
|
||||
<InputTypes>webm</InputTypes>
|
||||
<InputTypes>wmv</InputTypes>
|
||||
<InputTypes>m4v</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioBitrate" Value="160" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Flac" OutputType="Flac">
|
||||
<InputTypes>avi</InputTypes>
|
||||
<InputTypes>bik</InputTypes>
|
||||
<InputTypes>flv</InputTypes>
|
||||
<InputTypes>mkv</InputTypes>
|
||||
<InputTypes>mov</InputTypes>
|
||||
<InputTypes>mp4</InputTypes>
|
||||
<InputTypes>wav</InputTypes>
|
||||
<InputTypes>ape</InputTypes>
|
||||
<InputTypes>3gp</InputTypes>
|
||||
<InputTypes>webm</InputTypes>
|
||||
<InputTypes>wmv</InputTypes>
|
||||
<InputTypes>wma</InputTypes>
|
||||
<InputTypes>m4v</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Wav" OutputType="Wav">
|
||||
<InputTypes>aac</InputTypes>
|
||||
<InputTypes>aiff</InputTypes>
|
||||
<InputTypes>ape</InputTypes>
|
||||
<InputTypes>flac</InputTypes>
|
||||
<InputTypes>m4a</InputTypes>
|
||||
<InputTypes>mp3</InputTypes>
|
||||
<InputTypes>ogg</InputTypes>
|
||||
<InputTypes>wma</InputTypes>
|
||||
<InputTypes>avi</InputTypes>
|
||||
<InputTypes>bik</InputTypes>
|
||||
<InputTypes>flv</InputTypes>
|
||||
<InputTypes>mkv</InputTypes>
|
||||
<InputTypes>mov</InputTypes>
|
||||
<InputTypes>mp4</InputTypes>
|
||||
<InputTypes>3gp</InputTypes>
|
||||
<InputTypes>webm</InputTypes>
|
||||
<InputTypes>wmv</InputTypes>
|
||||
<InputTypes>m4v</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioEncodingMode" Value="Wav16" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Mp3" OutputType="Mp3">
|
||||
<InputTypes>aac</InputTypes>
|
||||
<InputTypes>aiff</InputTypes>
|
||||
<InputTypes>ape</InputTypes>
|
||||
<InputTypes>flac</InputTypes>
|
||||
<InputTypes>m4a</InputTypes>
|
||||
<InputTypes>ogg</InputTypes>
|
||||
<InputTypes>wma</InputTypes>
|
||||
<InputTypes>avi</InputTypes>
|
||||
<InputTypes>bik</InputTypes>
|
||||
<InputTypes>flv</InputTypes>
|
||||
<InputTypes>mkv</InputTypes>
|
||||
<InputTypes>mov</InputTypes>
|
||||
<InputTypes>mp4</InputTypes>
|
||||
<InputTypes>wav</InputTypes>
|
||||
<InputTypes>3gp</InputTypes>
|
||||
<InputTypes>webm</InputTypes>
|
||||
<InputTypes>wmv</InputTypes>
|
||||
<InputTypes>m4v</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioEncodingMode" Value="Mp3VBR" />
|
||||
<Settings Key="AudioBitrate" Value="190" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Aac" OutputType="Aac">
|
||||
<InputTypes>aiff</InputTypes>
|
||||
<InputTypes>ape</InputTypes>
|
||||
<InputTypes>m4a</InputTypes>
|
||||
<InputTypes>mp3</InputTypes>
|
||||
<InputTypes>ogg</InputTypes>
|
||||
<InputTypes>wma</InputTypes>
|
||||
<InputTypes>avi</InputTypes>
|
||||
<InputTypes>bik</InputTypes>
|
||||
<InputTypes>flv</InputTypes>
|
||||
<InputTypes>mkv</InputTypes>
|
||||
<InputTypes>mov</InputTypes>
|
||||
<InputTypes>mp4</InputTypes>
|
||||
<InputTypes>wav</InputTypes>
|
||||
<InputTypes>flac</InputTypes>
|
||||
<InputTypes>3gp</InputTypes>
|
||||
<InputTypes>webm</InputTypes>
|
||||
<InputTypes>wmv</InputTypes>
|
||||
<InputTypes>m4v</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioBitrate" Value="128" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="Extract CDA to Flac" OutputType="Flac">
|
||||
<InputTypes>cda</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<OutputFileNameTemplate>(p:m)CDA Extraction\(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="Extract CDA to Ogg" OutputType="Ogg">
|
||||
<InputTypes>cda</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioBitrate" Value="192" />
|
||||
<OutputFileNameTemplate>(p:m)CDA Extraction\(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="Extract CDA to Mp3" OutputType="Mp3">
|
||||
<InputTypes>cda</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioEncodingMode" Value="Mp3VBR" />
|
||||
<Settings Key="AudioBitrate" Value="225" />
|
||||
<OutputFileNameTemplate>(p:m)CDA Extraction\(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Png" OutputType="Png">
|
||||
<InputTypes>bmp</InputTypes>
|
||||
<InputTypes>exr</InputTypes>
|
||||
<InputTypes>ico</InputTypes>
|
||||
<InputTypes>jpg</InputTypes>
|
||||
<InputTypes>jpeg</InputTypes>
|
||||
<InputTypes>png</InputTypes>
|
||||
<InputTypes>psd</InputTypes>
|
||||
<InputTypes>svg</InputTypes>
|
||||
<InputTypes>tga</InputTypes>
|
||||
<InputTypes>tiff</InputTypes>
|
||||
<InputTypes>xcf</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="ImageScale" Value="1" />
|
||||
<Settings Key="ImageRotation" Value="0" />
|
||||
<Settings Key="ImageClampSizePowerOf2" Value="False" />
|
||||
<Settings Key="ImageMaximumSize" Value="0" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To small Png (25%)" OutputType="Png">
|
||||
<InputTypes>bmp</InputTypes>
|
||||
<InputTypes>exr</InputTypes>
|
||||
<InputTypes>ico</InputTypes>
|
||||
<InputTypes>jpg</InputTypes>
|
||||
<InputTypes>jpeg</InputTypes>
|
||||
<InputTypes>png</InputTypes>
|
||||
<InputTypes>psd</InputTypes>
|
||||
<InputTypes>svg</InputTypes>
|
||||
<InputTypes>tga</InputTypes>
|
||||
<InputTypes>tiff</InputTypes>
|
||||
<InputTypes>xcf</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="ImageScale" Value="0,25" />
|
||||
<Settings Key="ImageRotation" Value="0" />
|
||||
<Settings Key="ImageClampSizePowerOf2" Value="False" />
|
||||
<Settings Key="ImageMaximumSize" Value="0" />
|
||||
<OutputFileNameTemplate>(p)(f)-small</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Png (rotate left)" OutputType="Png">
|
||||
<InputTypes>bmp</InputTypes>
|
||||
<InputTypes>exr</InputTypes>
|
||||
<InputTypes>ico</InputTypes>
|
||||
<InputTypes>jpg</InputTypes>
|
||||
<InputTypes>jpeg</InputTypes>
|
||||
<InputTypes>png</InputTypes>
|
||||
<InputTypes>psd</InputTypes>
|
||||
<InputTypes>svg</InputTypes>
|
||||
<InputTypes>tga</InputTypes>
|
||||
<InputTypes>tiff</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="ImageScale" Value="1" />
|
||||
<Settings Key="ImageRotation" Value="90" />
|
||||
<Settings Key="ImageClampSizePowerOf2" Value="False" />
|
||||
<Settings Key="ImageMaximumSize" Value="0" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Png (rotate right)" OutputType="Png">
|
||||
<InputTypes>bmp</InputTypes>
|
||||
<InputTypes>exr</InputTypes>
|
||||
<InputTypes>ico</InputTypes>
|
||||
<InputTypes>jpg</InputTypes>
|
||||
<InputTypes>jpeg</InputTypes>
|
||||
<InputTypes>png</InputTypes>
|
||||
<InputTypes>psd</InputTypes>
|
||||
<InputTypes>svg</InputTypes>
|
||||
<InputTypes>tga</InputTypes>
|
||||
<InputTypes>tiff</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="ImageScale" Value="1" />
|
||||
<Settings Key="ImageRotation" Value="270" />
|
||||
<Settings Key="ImageClampSizePowerOf2" Value="False" />
|
||||
<Settings Key="ImageMaximumSize" Value="0" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Jpg" OutputType="Jpg">
|
||||
<InputTypes>bmp</InputTypes>
|
||||
<InputTypes>exr</InputTypes>
|
||||
<InputTypes>ico</InputTypes>
|
||||
<InputTypes>jpg</InputTypes>
|
||||
<InputTypes>jpeg</InputTypes>
|
||||
<InputTypes>png</InputTypes>
|
||||
<InputTypes>psd</InputTypes>
|
||||
<InputTypes>svg</InputTypes>
|
||||
<InputTypes>tga</InputTypes>
|
||||
<InputTypes>tiff</InputTypes>
|
||||
<InputTypes>xcf</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="ImageQuality" Value="40" />
|
||||
<Settings Key="ImageScale" Value="1" />
|
||||
<Settings Key="ImageRotation" Value="0" />
|
||||
<Settings Key="ImageClampSizePowerOf2" Value="False" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Ico" OutputType="Ico">
|
||||
<InputTypes>bmp</InputTypes>
|
||||
<InputTypes>exr</InputTypes>
|
||||
<InputTypes>ico</InputTypes>
|
||||
<InputTypes>jpg</InputTypes>
|
||||
<InputTypes>jpeg</InputTypes>
|
||||
<InputTypes>png</InputTypes>
|
||||
<InputTypes>psd</InputTypes>
|
||||
<InputTypes>svg</InputTypes>
|
||||
<InputTypes>tga</InputTypes>
|
||||
<InputTypes>tiff</InputTypes>
|
||||
<InputTypes>xcf</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<CheckUpgradeAtStartup>true</CheckUpgradeAtStartup>
|
||||
</Settings>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?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>Wav</InputTypes>
|
||||
<InputTypes>Flac</InputTypes>
|
||||
<InputTypes>Wma</InputTypes>
|
||||
<InputTypes>Mp3</InputTypes>
|
||||
<InputTypes>Ape</InputTypes>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Mp3" OutputType="Mp3">
|
||||
<InputTypes>Flac</InputTypes>
|
||||
<InputTypes>Ogg</InputTypes>
|
||||
<InputTypes>Wav</InputTypes>
|
||||
<InputTypes>Wma</InputTypes>
|
||||
<InputTypes>Ape</InputTypes>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Flac" OutputType="Flac">
|
||||
<InputTypes>Wav</InputTypes>
|
||||
<InputTypes>Ape</InputTypes>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Wav" OutputType="Wav">
|
||||
<InputTypes>Flac</InputTypes>
|
||||
<InputTypes>Mp3</InputTypes>
|
||||
<InputTypes>Ogg</InputTypes>
|
||||
<InputTypes>Wma</InputTypes>
|
||||
<InputTypes>Ape</InputTypes>
|
||||
</ConversionPreset>
|
||||
</Settings>
|
||||
@@ -0,0 +1,130 @@
|
||||
// <copyright file="Helpers.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.Upgrade
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
public static class Helpers
|
||||
{
|
||||
#if DEBUG
|
||||
private const string BaseURI = "https://raw.githubusercontent.com/Tichau/FileConverter/development/";
|
||||
#else
|
||||
private const string BaseURI = "https://raw.githubusercontent.com/Tichau/FileConverter/master/";
|
||||
#endif
|
||||
|
||||
private static WebClient webClient = new WebClient();
|
||||
|
||||
public delegate void OnUpgradeOperationCompletedEventHandler(UpgradeVersionDescription upgradeVersionDescription);
|
||||
|
||||
public static async Task<UpgradeVersionDescription> GetLatestVersionDescriptionAsync(OnUpgradeOperationCompletedEventHandler onGetCompleteDelegate = null)
|
||||
{
|
||||
Uri uri = new Uri(Helpers.BaseURI + "version.xml");
|
||||
Stream stream = await Helpers.webClient.OpenReadTaskAsync(uri);
|
||||
|
||||
UpgradeVersionDescription upgradeVersionDescription = null;
|
||||
try
|
||||
{
|
||||
XmlRootAttribute xmlRoot = new XmlRootAttribute
|
||||
{
|
||||
ElementName = "Version"
|
||||
};
|
||||
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(UpgradeVersionDescription), xmlRoot);
|
||||
|
||||
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
|
||||
{
|
||||
IgnoreWhitespace = true,
|
||||
IgnoreComments = true
|
||||
};
|
||||
|
||||
using (XmlReader xmlReader = XmlReader.Create(stream, xmlReaderSettings))
|
||||
{
|
||||
upgradeVersionDescription = (UpgradeVersionDescription)serializer.Deserialize(xmlReader);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Diagnostics.Debug.LogError("Error while retrieving change log.");
|
||||
return null;
|
||||
}
|
||||
|
||||
onGetCompleteDelegate?.Invoke(upgradeVersionDescription);
|
||||
|
||||
return upgradeVersionDescription;
|
||||
}
|
||||
|
||||
public static async Task<string> GetChangeLogAsync(UpgradeVersionDescription upgradeVersionDescription, OnUpgradeOperationCompletedEventHandler onGetCompleteDelegate = null)
|
||||
{
|
||||
if (upgradeVersionDescription == null)
|
||||
{
|
||||
throw new ArgumentNullException("upgradeVersionDescription");
|
||||
}
|
||||
|
||||
Uri uri = new Uri(Helpers.BaseURI + "CHANGELOG.md");
|
||||
Stream stream = await Helpers.webClient.OpenReadTaskAsync(uri);
|
||||
try
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(stream))
|
||||
{
|
||||
upgradeVersionDescription.ChangeLog = reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Diagnostics.Debug.LogError("Error while retrieving change log.");
|
||||
return null;
|
||||
}
|
||||
|
||||
onGetCompleteDelegate?.Invoke(upgradeVersionDescription);
|
||||
|
||||
return upgradeVersionDescription.ChangeLog;
|
||||
}
|
||||
|
||||
public static void DownloadInstallerAsync(UpgradeVersionDescription upgradeVersionDescription)
|
||||
{
|
||||
Thread thread = new Thread(Helpers.DownloadInstallerAsync);
|
||||
thread.Start(upgradeVersionDescription);
|
||||
}
|
||||
|
||||
private static void DownloadInstallerAsync(object parameter)
|
||||
{
|
||||
UpgradeVersionDescription upgradeVersionDescription = parameter as UpgradeVersionDescription;
|
||||
|
||||
if (upgradeVersionDescription == null)
|
||||
{
|
||||
throw new ArgumentNullException("upgradeVersionDescription");
|
||||
}
|
||||
|
||||
Uri uri = new Uri(upgradeVersionDescription.InstallerURL);
|
||||
|
||||
string fileName = "FileConverter-setup.msi";
|
||||
Regex retrieveFileNameRegex = new Regex("/([^/]*)");
|
||||
MatchCollection matchCollection = retrieveFileNameRegex.Matches(upgradeVersionDescription.InstallerURL);
|
||||
if (matchCollection.Count > 0)
|
||||
{
|
||||
Match match = matchCollection[matchCollection.Count - 1];
|
||||
if (match.Groups.Count > 1)
|
||||
{
|
||||
fileName = match.Groups[1].Value;
|
||||
}
|
||||
}
|
||||
|
||||
string tempPath = System.IO.Path.GetTempPath();
|
||||
string installerPath = System.IO.Path.Combine(tempPath, fileName);
|
||||
|
||||
upgradeVersionDescription.InstallerPath = installerPath;
|
||||
upgradeVersionDescription.InstallerDownloadInProgress = true;
|
||||
|
||||
Helpers.webClient.DownloadFile(uri, installerPath);
|
||||
|
||||
upgradeVersionDescription.InstallerDownloadInProgress = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// <copyright file="UpgradeVersionDescription.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System.Xml.Serialization;
|
||||
|
||||
public class UpgradeVersionDescription
|
||||
{
|
||||
[XmlElement("Latest")]
|
||||
public Version LatestVersion
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[XmlElement("URL")]
|
||||
public string InstallerURL
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public string ChangeLog
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public string InstallerPath
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public bool InstallerDownloadInProgress
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public bool NeedToUpgrade
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// <copyright file="ApplicationVersionToApplicationName.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;
|
||||
@@ -10,12 +10,12 @@ namespace FileConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (!(value is Version))
|
||||
if (!(value is FileConverter.Version))
|
||||
{
|
||||
return "File Converter";
|
||||
}
|
||||
|
||||
Version version = (Version)value;
|
||||
FileConverter.Version version = (FileConverter.Version)value;
|
||||
|
||||
return string.Format("File Converter v{0}", version.ToString());
|
||||
}
|
||||
|
||||
@@ -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,97 @@
|
||||
// <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());
|
||||
|
||||
string myDocumentsFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + "\\";
|
||||
outputPath = outputPath.Replace("(p:d)", myDocumentsFolder);
|
||||
outputPath = outputPath.Replace("(p:documents)", myDocumentsFolder);
|
||||
|
||||
string myMusicFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyMusic) + "\\";
|
||||
outputPath = outputPath.Replace("(p:m)", myMusicFolder);
|
||||
outputPath = outputPath.Replace("(p:music)", myMusicFolder);
|
||||
|
||||
string myVideoFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyVideos) + "\\";
|
||||
outputPath = outputPath.Replace("(p:v)", myVideoFolder);
|
||||
outputPath = outputPath.Replace("(p:videos)", myVideoFolder);
|
||||
|
||||
string myPictureFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyPictures) + "\\";
|
||||
outputPath = outputPath.Replace("(p:p)", myPictureFolder);
|
||||
outputPath = outputPath.Replace("(p:pictures)", myPictureFolder);
|
||||
|
||||
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,32 @@
|
||||
// <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.");
|
||||
}
|
||||
|
||||
string stringParameter = parameter as string;
|
||||
|
||||
string falseResult = stringParameter ?? "Hidden";
|
||||
|
||||
bool booleanValue = (bool)value;
|
||||
|
||||
return booleanValue ? "Visible" : falseResult;
|
||||
}
|
||||
|
||||
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,28 @@
|
||||
// <copyright file="DoubleToTimeString.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 DoubleToTimeString : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (!(value is double))
|
||||
{
|
||||
throw new ArgumentException("The value must be a boolean.");
|
||||
}
|
||||
|
||||
double doubleValue = (double)value;
|
||||
|
||||
return string.Format("{0} second{1}", doubleValue.ToString("0.#"), doubleValue >= 2 ? "s" : string.Empty);
|
||||
}
|
||||
|
||||
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,32 @@
|
||||
// <copyright file="FormatStringConverter.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 FormatStringConverter : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (values == null)
|
||||
{
|
||||
throw new ArgumentException("The values must not be null.");
|
||||
}
|
||||
|
||||
string format = parameter as string;
|
||||
if (format == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return string.Format(format, values);
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// <copyright file="InputTypesToBool.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter
|
||||
namespace FileConverter.ValueConverters
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -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,19 +1,92 @@
|
||||
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
|
||||
{
|
||||
public struct Version
|
||||
using System.Xml.Serialization;
|
||||
|
||||
public struct Version : System.IComparable<Version>
|
||||
{
|
||||
[XmlAttribute]
|
||||
public int Major;
|
||||
|
||||
[XmlAttribute]
|
||||
public int Minor;
|
||||
|
||||
[XmlAttribute]
|
||||
public int Patch;
|
||||
|
||||
public static bool operator !=(Version a, Version b)
|
||||
{
|
||||
return a.CompareTo(b) != 0;
|
||||
}
|
||||
|
||||
public static bool operator ==(Version a, Version b)
|
||||
{
|
||||
return a.CompareTo(b) == 0;
|
||||
}
|
||||
|
||||
public static bool operator <=(Version a, Version b)
|
||||
{
|
||||
return a.CompareTo(b) <= 0;
|
||||
}
|
||||
|
||||
public static bool operator >=(Version a, Version b)
|
||||
{
|
||||
return a.CompareTo(b) >= 0;
|
||||
}
|
||||
|
||||
public static bool operator <(Version a, Version b)
|
||||
{
|
||||
return a.CompareTo(b) < 0;
|
||||
}
|
||||
|
||||
public static bool operator >(Version a, Version b)
|
||||
{
|
||||
return a.CompareTo(b) > 0;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0}.{1}", this.Major, this.Minor);
|
||||
if (this.Patch == 0)
|
||||
{
|
||||
return string.Format("{0}.{1}", this.Major, this.Minor);
|
||||
}
|
||||
|
||||
return string.Format("{0}.{1}.{2}", this.Major, this.Minor, this.Patch);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is Version))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Version other = (Version)obj;
|
||||
|
||||
return this.Major == other.Major && this.Minor == other.Minor && this.Patch == other.Patch;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public int CompareTo(Version other)
|
||||
{
|
||||
if (this.Major == other.Major && this.Minor == other.Minor && this.Patch == other.Patch)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (this.Major > other.Major ||
|
||||
(this.Major == other.Major && this.Minor > other.Minor) ||
|
||||
(this.Major == other.Major && this.Minor == other.Minor && this.Patch > other.Patch))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<Window x:Class="FileConverter.Windows.ApplicationStartHelp"
|
||||
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"
|
||||
xmlns:valueConverters="clr-namespace:FileConverter.ValueConverters"
|
||||
mc:Ignorable="d"
|
||||
Height="480" Width="640" Icon="/FileConverter;component/Resources/ApplicationIcon.ico" WindowStartupLocation="CenterScreen" WindowStyle="ToolWindow" ResizeMode="NoResize">
|
||||
<Window.Resources>
|
||||
<valueConverters:ApplicationVersionToApplicationName x:Key="ApplicationVersionToApplicationName"/>
|
||||
</Window.Resources>
|
||||
<Window.Title>
|
||||
<Binding Converter="{StaticResource ApplicationVersionToApplicationName}" Mode="OneWay" Path="(fileConverter:Application.ApplicationVersion)"/>
|
||||
</Window.Title>
|
||||
<StackPanel Margin="5">
|
||||
<TextBlock Margin="0,0,0,4" Text="File Converter is a shell extension." TextWrapping="Wrap" FontWeight="Bold" FontSize="13.333"/>
|
||||
<TextBlock Text="That means it is integrated into the Windows explorer." TextWrapping="Wrap"/>
|
||||
<TextBlock Text="To use File Converter please open the explorer and right-click on any file you like to bring up the context menu where you will find File Converter commands (see the readme file to see the list of compatible file formats)." TextWrapping="Wrap" />
|
||||
<Image Margin="0,7,0,7" HorizontalAlignment="Left" Height="Auto" VerticalAlignment="Top" Width="Auto" Source="/FileConverter;component/Resources/ContextMenuScreenshot.png" Stretch="None"/>
|
||||
<Button Content="Ok" Height="28" Click="OkButton_Click"/>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
@@ -0,0 +1,29 @@
|
||||
// <copyright file="ApplicationStartHelp.xaml.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.Windows
|
||||
{
|
||||
using System;
|
||||
using System.Windows;
|
||||
|
||||
public partial class ApplicationStartHelp : Window
|
||||
{
|
||||
public ApplicationStartHelp()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
public static FileConverter.Version ApplicationVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return FileConverter.Application.ApplicationVersion;
|
||||
}
|
||||
}
|
||||
|
||||
private void OkButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
Dispatcher.BeginInvoke((Action)(() => Application.Current.Shutdown()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
// <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 AviSettingsDataTemplate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public DataTemplate WavSettingsDataTemplate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public DataTemplate Mp3SettingsDataTemplate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public DataTemplate Mp4SettingsDataTemplate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public DataTemplate OggSettingsDataTemplate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public DataTemplate AacSettingsDataTemplate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public DataTemplate JpgSettingsDataTemplate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public DataTemplate PngSettingsDataTemplate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public DataTemplate MkvSettingsDataTemplate
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public override DataTemplate SelectTemplate(object item, DependencyObject container)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return this.DefaultDataTemplate;
|
||||
}
|
||||
|
||||
OutputType outputType = (OutputType)item;
|
||||
|
||||
switch (outputType)
|
||||
{
|
||||
case OutputType.Aac:
|
||||
return this.AacSettingsDataTemplate;
|
||||
|
||||
case OutputType.Avi:
|
||||
return this.AviSettingsDataTemplate;
|
||||
|
||||
case OutputType.Jpg:
|
||||
return this.JpgSettingsDataTemplate;
|
||||
|
||||
case OutputType.Mkv:
|
||||
return this.MkvSettingsDataTemplate;
|
||||
|
||||
case OutputType.Mp3:
|
||||
return this.Mp3SettingsDataTemplate;
|
||||
|
||||
case OutputType.Mp4:
|
||||
return this.Mp4SettingsDataTemplate;
|
||||
|
||||
case OutputType.Ogg:
|
||||
return this.OggSettingsDataTemplate;
|
||||
|
||||
case OutputType.Png:
|
||||
return this.PngSettingsDataTemplate;
|
||||
|
||||
case OutputType.Wav:
|
||||
return this.WavSettingsDataTemplate;
|
||||
}
|
||||
|
||||
return this.DefaultDataTemplate;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,16 +5,29 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:FileConverter.Windows"
|
||||
xmlns:fileConverter="clr-namespace:FileConverter"
|
||||
xmlns:diagnostics="clr-namespace:FileConverter.Diagnostics"
|
||||
mc:Ignorable="d"
|
||||
Title="Diagnostics" Height="600" Width="800" Icon="/FileConverter;component/Resources/ApplicationIcon-16x16.ico">
|
||||
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>
|
||||
|
||||
<TabControl Grid.Row="1" Margin="5" ItemsSource="{Binding Path=(diagnostics:Debug.Data), Mode=OneWay}">
|
||||
<TabControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}"/>
|
||||
</DataTemplate>
|
||||
</TabControl.ItemTemplate>
|
||||
<TabControl.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" CanContentScroll="True">
|
||||
<TextBlock Name="Diagnostics" TextWrapping="NoWrap" Text="{Binding Content}" FontFamily="Consolas" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.CanContentScroll="False"/>
|
||||
</ScrollViewer>
|
||||
</DataTemplate>
|
||||
</TabControl.ContentTemplate>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -1,27 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
// <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.xaml
|
||||
/// Interaction logic for DiagnosticsWindow.
|
||||
/// </summary>
|
||||
public partial class DiagnosticsWindow : Window
|
||||
{
|
||||
public DiagnosticsWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
<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:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:FileConverter"
|
||||
x:Name="FileConverterMainWindow" Height="500" Width="950" MinHeight="250" MinWidth="450" WindowStartupLocation="CenterScreen" Icon="/FileConverter;component/Resources/ApplicationIcon-16x16.ico">
|
||||
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>
|
||||
<local:ApplicationVersionToApplicationName x:Key="ApplicationVersionToApplicationName"/>
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
|
||||
<local:ConversionStateToBrush x:Key="ConversionStateToColor" />
|
||||
<valueConverters:ApplicationVersionToApplicationName x:Key="ApplicationVersionToApplicationName"/>
|
||||
<valueConverters:ConversionStateToBrush x:Key="ConversionStateToColor" />
|
||||
</Window.Resources>
|
||||
<Window.Title>
|
||||
<Binding Converter="{StaticResource ApplicationVersionToApplicationName}" Mode="OneWay" Path="(local:Application.ApplicationVersion)"/>
|
||||
@@ -26,19 +27,16 @@
|
||||
<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="DiagnosticsButton" Grid.Column="1" Content="Logs" Margin="3,3" Click="DiagnosticsButton_OnClick"/>
|
||||
<Button Name="SettingsButton" Grid.Column="2" Content="Settings" Margin="3,3" Click="SettingsButton_OnClick"/>
|
||||
<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 Name="ConverterJobsList">
|
||||
<ItemsControl.DataContext>
|
||||
<local:ConversionJob/>
|
||||
</ItemsControl.DataContext>
|
||||
<ItemsControl x:Name="ConverterJobsList">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<DockPanel Background="{Binding State, Converter={StaticResource ConversionStateToColor}, ConverterParameter='Background'}" Margin="0,4">
|
||||
<DockPanel Background="{Binding State, ConverterParameter=Background, Converter={StaticResource ConversionStateToColor}}" Margin="0,4">
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="20" />
|
||||
@@ -56,16 +54,19 @@
|
||||
<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'}" />
|
||||
<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, Converter={StaticResource ConversionStateToColor}, ConverterParameter='Foreground'}" />
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding UserState}" 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, Converter={StaticResource ConversionStateToColor}, ConverterParameter='Foreground'}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" MinWidth="100" LargeChange="0.1" />
|
||||
<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>
|
||||
|
||||
@@ -11,10 +11,9 @@ namespace FileConverter
|
||||
|
||||
public partial class MainWindow : Window, INotifyPropertyChanged
|
||||
{
|
||||
private bool verboseMode;
|
||||
|
||||
private DiagnosticsWindow diagnosticsWindow;
|
||||
private SettingsWindow settingsWindow;
|
||||
private UpgradeWindow upgradeWindow;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
@@ -23,6 +22,12 @@ namespace FileConverter
|
||||
Application application = Application.Current as Application;
|
||||
|
||||
this.ConverterJobsList.ItemsSource = application.ConvertionJobs;
|
||||
|
||||
if (application.HideMainWindow)
|
||||
{
|
||||
this.Hide();
|
||||
}
|
||||
|
||||
if (application.Verbose)
|
||||
{
|
||||
this.ShowDiagnosticsWindow();
|
||||
@@ -30,15 +35,19 @@ namespace FileConverter
|
||||
|
||||
if (application.ShowSettings)
|
||||
{
|
||||
this.Hide();
|
||||
|
||||
this.ShowSettingsWindow();
|
||||
this.settingsWindow.Deactivated += this.SettingsWindow_Closed;
|
||||
this.settingsWindow.OnSettingsWindowHide += this.SettingsWindow_Closed;
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
|
||||
public void OnNewVersionReleased(UpgradeVersionDescription upgradeVersionDescription)
|
||||
{
|
||||
this.ShowUpgradeWindow();
|
||||
this.upgradeWindow.VersionDescription = upgradeVersionDescription;
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
@@ -56,7 +65,7 @@ namespace FileConverter
|
||||
|
||||
private void SettingsWindow_Closed(object sender, System.EventArgs e)
|
||||
{
|
||||
settingsWindow.Deactivated -= this.SettingsWindow_Closed;
|
||||
this.settingsWindow.OnSettingsWindowHide -= this.SettingsWindow_Closed;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
@@ -96,5 +105,21 @@ namespace FileConverter
|
||||
application?.CancelAutoExit();
|
||||
this.settingsWindow.Show();
|
||||
}
|
||||
|
||||
private void ShowUpgradeWindow()
|
||||
{
|
||||
if (this.upgradeWindow != null && this.upgradeWindow.IsVisible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.upgradeWindow = new UpgradeWindow();
|
||||
}
|
||||
|
||||
Application application = Application.Current as Application;
|
||||
application?.CancelAutoExit();
|
||||
this.upgradeWindow.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,44 @@
|
||||
<Window x:Name="window" x:Class="FileConverter.SettingsWindow"
|
||||
<Window
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:FileConverter"
|
||||
Height="370" Width="520" MinHeight="370" MinWidth="440"
|
||||
WindowStartupLocation="CenterScreen" Icon="/FileConverter;component/Resources/ApplicationIcon-16x16.ico">
|
||||
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"
|
||||
MinWidth="640" MinHeight="480"
|
||||
Width="900" Height="675"
|
||||
WindowStartupLocation="CenterScreen" Icon="/FileConverter;component/Resources/ApplicationIcon.ico"
|
||||
Closing="SettingsWindow_OnClosing">
|
||||
<Window.Resources>
|
||||
<local:InputTypesToBool x:Key="InputTypesToBool"/>
|
||||
<local:ApplicationVersionToApplicationName x:Key="ApplicationVersionToApplicationName"/>
|
||||
<generic:DoubleToTimeString x:Key="DoubleToTimeString"/>
|
||||
<valueConverters:FileNameConverter x:Key="FileNameConverter"/>
|
||||
<generic:BoolToVisibility x:Key="BoolToVisibility"/>
|
||||
<valueConverters:ApplicationVersionToApplicationName x:Key="ApplicationVersionToApplicationName"/>
|
||||
<generic:CollectionContainsElementToBool x:Key="CollectionContainsElementToBool"/>
|
||||
<generic:FormatStringConverter x:Key="FormatStringConverter"/>
|
||||
|
||||
<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">
|
||||
@@ -13,10 +46,10 @@
|
||||
<ControlTemplate>
|
||||
<DockPanel LastChildFill="true">
|
||||
<Border Background="#F44336" DockPanel.Dock="right" Margin="5,0,0,0" Width="20" Height="20" CornerRadius="10"
|
||||
ToolTip="{Binding ElementName=customAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
|
||||
ToolTip="{Binding AdornedElement.(Validation.Errors)[0].ErrorContent, ElementName=customAdorner}">
|
||||
<TextBlock Text="!" VerticalAlignment="center" HorizontalAlignment="center" FontWeight="Bold" Foreground="white"/>
|
||||
</Border>
|
||||
<AdornedElementPlaceholder Name="customAdorner" VerticalAlignment="Center" >
|
||||
<AdornedElementPlaceholder x:Name="customAdorner" VerticalAlignment="Center" >
|
||||
<Border BorderBrush="#F44336" BorderThickness="1" />
|
||||
</AdornedElementPlaceholder>
|
||||
</DockPanel>
|
||||
@@ -24,22 +57,317 @@
|
||||
</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=AudioEncodingMode|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=AudioEncodingMode|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=AudioEncodingMode|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=AudioEncodingMode|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=AudioEncodingMode|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=AudioEncodingMode|Mp3CBR, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}"/>
|
||||
</DockPanel>
|
||||
<DockPanel>
|
||||
<Label Content="Quality :" />
|
||||
<controls:EncodingQualitySliderControl x:Name="EncodingQualitySlider"
|
||||
EncodingMode="{Binding SelectedPreset.Settings, ConverterParameter=AudioEncodingMode|FileConverter.Controls.EncodingMode, Converter={StaticResource ConversionSettingsToEnum}, ElementName=window, Mode=OneWay, TargetNullValue=VBR}"
|
||||
Bitrate="{Binding SelectedPreset.Settings, ConverterParameter=AudioBitrate|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=AudioBitrate|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay, TargetNullValue=160}" />
|
||||
</DockPanel>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="AacSettingsDataTemplate">
|
||||
<StackPanel>
|
||||
<DockPanel>
|
||||
<Label Content="Quality :" />
|
||||
<controls:EncodingQualitySliderControl x:Name="EncodingQualitySlider" EncodingMode="AacVBR"
|
||||
Bitrate="{Binding SelectedPreset.Settings, ConverterParameter=AudioBitrate|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay, TargetNullValue=128}" />
|
||||
</DockPanel>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="AviSettingsDataTemplate">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<DockPanel Grid.Row="0" Grid.Column="0">
|
||||
<Label Content="Video" FontWeight="Bold" />
|
||||
<Label Content="(Xvid)" FontWeight="Light" Foreground="#004B82" />
|
||||
</DockPanel>
|
||||
|
||||
<Label Content="Quality :" Grid.Row="1" Grid.Column="0" ToolTip="{x:Static project:Resources.VideoEncodingQualityTooltip}" HorizontalContentAlignment="Right"/>
|
||||
<Slider x:Name="QualitySlider" Grid.Row="1" Grid.Column="1" Value="{Binding SelectedPreset.Settings, ConverterParameter=VideoQuality|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay}"
|
||||
Margin="0,2,0,0" VerticalAlignment="Top" AutoToolTipPlacement="TopLeft" IsSnapToTickEnabled="True" IsSelectionRangeEnabled="True" SelectionStart="20" SelectionEnd="28" Minimum="0" Maximum="30" TickPlacement="BottomRight" SmallChange="1" LargeChange="5" TickFrequency="1" Foreground="#004B82" />
|
||||
|
||||
<!-- Scale -->
|
||||
<Label Content="Scale :" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right"/>
|
||||
<Grid Grid.Row="2" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="60"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Slider x:Name="ScaleSlider" Grid.Column="0" Value="{Binding SelectedPreset.Settings, ConverterParameter=VideoScale|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay}" Margin="0,2,0,0" VerticalAlignment="Top" IsSnapToTickEnabled="True" Minimum="0.075" Maximum="2" SmallChange="0.075" LargeChange="0.25" TickPlacement="BottomRight" Ticks="0.075 0.125 0.25 0.5 0.75 1 1.25 1.5 1.75 2" Foreground="#004B82"/>
|
||||
<Label Grid.Column="1">
|
||||
<Label.Content>
|
||||
<MultiBinding Converter="{StaticResource FormatStringConverter}" Mode="OneWay">
|
||||
<MultiBinding.ConverterParameter>{0:P0}</MultiBinding.ConverterParameter>
|
||||
<Binding ElementName="ScaleSlider" Path="Value" Mode="OneWay"/>
|
||||
</MultiBinding>
|
||||
</Label.Content>
|
||||
</Label>
|
||||
</Grid>
|
||||
|
||||
<!--Rotate-->
|
||||
<Label Content="Rotate :" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Right"/>
|
||||
<StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal">
|
||||
<RadioButton Content="None" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=VideoRotation|0, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" ToolTip="{x:Static project:Resources.ZeroDegreesRotationTooltip}" Margin="0,7,7,7"/>
|
||||
<RadioButton Content="90°" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=VideoRotation|90, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" ToolTip="{x:Static project:Resources.NinetyDegreesRotationTooltip}" Margin="7"/>
|
||||
<RadioButton Content="180°" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=VideoRotation|180, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" ToolTip="{x:Static project:Resources.OneEightyDegreesRotationTooltip}" Margin="7"/>
|
||||
<RadioButton Content="270°" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=VideoRotation|270, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" ToolTip="{x:Static project:Resources.TwoSeventyDegreesRotationTooltip}" Margin="7"/>
|
||||
</StackPanel>
|
||||
|
||||
<DockPanel Grid.Row="4" Grid.Column="0" >
|
||||
<Label Content="Audio" FontWeight="Bold" />
|
||||
<Label Content="(Mp3)" FontWeight="Light" Foreground="#004B82" />
|
||||
</DockPanel>
|
||||
|
||||
<Label Content="Quality :" Grid.Row="5" Grid.Column="0" HorizontalContentAlignment="Right"/>
|
||||
<controls:EncodingQualitySliderControl Grid.Row="5" Grid.Column="1" x:Name="EncodingQualitySlider" EncodingMode="Mp3VBR"
|
||||
Bitrate="{Binding SelectedPreset.Settings, ConverterParameter=AudioBitrate|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="MkvSettingsDataTemplate">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<DockPanel Grid.Row="0" Grid.Column="0">
|
||||
<Label Content="Video" FontWeight="Bold" />
|
||||
<Label Content="(H.264)" FontWeight="Light" Foreground="#004B82" />
|
||||
</DockPanel>
|
||||
|
||||
<Label Content="Quality :" Grid.Row="1" Grid.Column="0" ToolTip="{x:Static project:Resources.VideoEncodingQualityTooltip}" HorizontalContentAlignment="Right"/>
|
||||
<Slider x:Name="QualitySlider" Grid.Row="1" Grid.Column="1" Value="{Binding SelectedPreset.Settings, ConverterParameter=VideoQuality|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay}"
|
||||
Margin="0,2,0,0" VerticalAlignment="Top" AutoToolTipPlacement="TopLeft" IsSnapToTickEnabled="True" IsSelectionRangeEnabled="True" SelectionStart="20" SelectionEnd="33" Minimum="0" Maximum="51" TickPlacement="BottomRight" SmallChange="1" LargeChange="6" TickFrequency="1" Foreground="#004B82" />
|
||||
|
||||
<Label Content="Encoding speed :" Grid.Row="2" Grid.Column="0" ToolTip="{x:Static project:Resources.VideoEncodingSpeedTooltip}" HorizontalContentAlignment="Right"/>
|
||||
<ComboBox Grid.Row="2" Grid.Column="1" SelectedValue="{Binding SelectedPreset.Settings, ConverterParameter=VideoEncodingSpeed|System.String, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay, TargetNullValue=veryslow}">
|
||||
<System:String>Ultra Fast</System:String>
|
||||
<System:String>Super Fast</System:String>
|
||||
<System:String>Very Fast</System:String>
|
||||
<System:String>Faster</System:String>
|
||||
<System:String>Fast</System:String>
|
||||
<System:String>Medium</System:String>
|
||||
<System:String>Slow</System:String>
|
||||
<System:String>Slower</System:String>
|
||||
<System:String>Very Slow</System:String>
|
||||
</ComboBox>
|
||||
|
||||
<Label Content="Scale :" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Right"/>
|
||||
<Grid Grid.Row="3" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="60"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Slider x:Name="ScaleSlider" Grid.Column="0" Value="{Binding SelectedPreset.Settings, ConverterParameter=VideoScale|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay}" Margin="0,2,0,0" VerticalAlignment="Top" IsSnapToTickEnabled="True" Minimum="0.075" Maximum="2" SmallChange="0.075" LargeChange="0.25" TickPlacement="BottomRight" Ticks="0.075 0.125 0.25 0.5 0.75 1 1.25 1.5 1.75 2" Foreground="#004B82"/>
|
||||
<Label Grid.Column="1">
|
||||
<Label.Content>
|
||||
<MultiBinding Converter="{StaticResource FormatStringConverter}" Mode="OneWay">
|
||||
<MultiBinding.ConverterParameter>{0:P1}</MultiBinding.ConverterParameter>
|
||||
<Binding ElementName="ScaleSlider" Path="Value" Mode="OneWay"/>
|
||||
</MultiBinding>
|
||||
</Label.Content>
|
||||
</Label>
|
||||
</Grid>
|
||||
|
||||
<!--Rotate-->
|
||||
<Label Content="Rotate :" Grid.Row="4" Grid.Column="0" HorizontalAlignment="Right"/>
|
||||
<StackPanel Grid.Row="4" Grid.Column="1" Orientation="Horizontal">
|
||||
<RadioButton Content="None" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=VideoRotation|0, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" ToolTip="{x:Static project:Resources.ZeroDegreesRotationTooltip}" Margin="0,7,7,7"/>
|
||||
<RadioButton Content="90°" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=VideoRotation|90, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" ToolTip="{x:Static project:Resources.NinetyDegreesRotationTooltip}" Margin="7"/>
|
||||
<RadioButton Content="180°" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=VideoRotation|180, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" ToolTip="{x:Static project:Resources.OneEightyDegreesRotationTooltip}" Margin="7"/>
|
||||
<RadioButton Content="270°" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=VideoRotation|270, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" ToolTip="{x:Static project:Resources.TwoSeventyDegreesRotationTooltip}" Margin="7"/>
|
||||
</StackPanel>
|
||||
|
||||
<DockPanel Grid.Row="5" Grid.Column="0" >
|
||||
<Label Content="Audio" FontWeight="Bold" />
|
||||
<Label Content="(AAC)" FontWeight="Light" Foreground="#004B82" />
|
||||
</DockPanel>
|
||||
|
||||
<Label Content="Quality :" Grid.Row="6" Grid.Column="0" HorizontalContentAlignment="Right"/>
|
||||
<controls:EncodingQualitySliderControl Grid.Row="6" Grid.Column="1" x:Name="EncodingQualitySlider" EncodingMode="AacVBR"
|
||||
Bitrate="{Binding SelectedPreset.Settings, ConverterParameter=AudioBitrate|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay, TargetNullValue=128}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="JpgSettingsDataTemplate">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<!--Quality-->
|
||||
<Label Content="Quality :" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right"/>
|
||||
<Slider Grid.Row="0" Grid.Column="1" x:Name="QualitySlider" Value="{Binding SelectedPreset.Settings, ConverterParameter=ImageQuality|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay, TargetNullValue=25}"
|
||||
Margin="0,2,0,0" VerticalAlignment="Top" AutoToolTipPlacement="TopLeft" IsSnapToTickEnabled="True" IsSelectionRangeEnabled="True" SelectionStart="30" SelectionEnd="100" Minimum="0" Maximum="100" TickPlacement="BottomRight" SmallChange="5" LargeChange="15" TickFrequency="5" Foreground="#004B82" />
|
||||
<!--Scale-->
|
||||
<Label Content="Scale :" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right"/>
|
||||
<Grid Grid.Row="1" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="60"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Slider x:Name="ScaleSlider" Grid.Column="0" Value="{Binding SelectedPreset.Settings, ConverterParameter=ImageScale|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay}" Margin="0,2,0,0" VerticalAlignment="Top" IsSnapToTickEnabled="True" Minimum="0.075" Maximum="16" SmallChange="0.075" LargeChange="0.25" TickPlacement="BottomRight" Ticks="0.075 0.125 0.25 0.5 0.75 1 1.25 1.5 1.75 2 3 4 6 8 12 16" Foreground="#004B82"/>
|
||||
<Label Grid.Column="1">
|
||||
<Label.Content>
|
||||
<MultiBinding Converter="{StaticResource FormatStringConverter}" Mode="OneWay">
|
||||
<MultiBinding.ConverterParameter>{0:P1}</MultiBinding.ConverterParameter>
|
||||
<Binding ElementName="ScaleSlider" Path="Value" Mode="OneWay"/>
|
||||
</MultiBinding>
|
||||
</Label.Content>
|
||||
</Label>
|
||||
<CheckBox Grid.Row="1" Grid.Column="0" Content="Clamp to lowest power of 2 size" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=ImageClampSizePowerOf2|System.Boolean, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
<!--Rotate-->
|
||||
<Label Content="Rotate :" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right"/>
|
||||
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal">
|
||||
<RadioButton Content="None" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=ImageRotation|0, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" ToolTip="{x:Static project:Resources.ZeroDegreesRotationTooltip}" Margin="0,7,7,7"/>
|
||||
<RadioButton Content="90°" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=ImageRotation|90, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" ToolTip="{x:Static project:Resources.NinetyDegreesRotationTooltip}" Margin="7"/>
|
||||
<RadioButton Content="180°" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=ImageRotation|180, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" ToolTip="{x:Static project:Resources.OneEightyDegreesRotationTooltip}" Margin="7"/>
|
||||
<RadioButton Content="270°" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=ImageRotation|270, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" ToolTip="{x:Static project:Resources.TwoSeventyDegreesRotationTooltip}" Margin="7"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="PngSettingsDataTemplate">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<!--Scale-->
|
||||
<Label Content="Scale :" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right"/>
|
||||
<Grid Grid.Row="0" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="60"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Slider x:Name="ScaleSlider" Grid.Column="0" Value="{Binding SelectedPreset.Settings, ConverterParameter=ImageScale|System.Double, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay}" Margin="0,2,0,0" VerticalAlignment="Top" IsSnapToTickEnabled="True" Minimum="0.075" Maximum="16" SmallChange="0.075" LargeChange="0.25" TickPlacement="BottomRight" Ticks="0.075 0.125 0.25 0.5 0.75 1 1.25 1.5 1.75 2 3 4 6 8 12 16" Foreground="#004B82"/>
|
||||
<Label Grid.Column="1">
|
||||
<Label.Content>
|
||||
<MultiBinding Converter="{StaticResource FormatStringConverter}" Mode="OneWay">
|
||||
<MultiBinding.ConverterParameter>{0:P1}</MultiBinding.ConverterParameter>
|
||||
<Binding ElementName="ScaleSlider" Path="Value" Mode="OneWay"/>
|
||||
</MultiBinding>
|
||||
</Label.Content>
|
||||
</Label>
|
||||
|
||||
<CheckBox Grid.Row="1" Grid.Column="0" Content="Clamp to lowest power of 2 size" Margin="5" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=ImageClampSizePowerOf2|System.Boolean, Converter={StaticResource ConversionSettingsToValueType}, ElementName=window, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
<!--Rotate-->
|
||||
<Label Content="Rotate :" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right"/>
|
||||
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal">
|
||||
<RadioButton Content="None" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=ImageRotation|0, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" ToolTip="{x:Static project:Resources.ZeroDegreesRotationTooltip}" Margin="0,7,7,7"/>
|
||||
<RadioButton Content="90°" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=ImageRotation|90, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" ToolTip="{x:Static project:Resources.NinetyDegreesRotationTooltip}" Margin="7"/>
|
||||
<RadioButton Content="180°" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=ImageRotation|180, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" ToolTip="{x:Static project:Resources.OneEightyDegreesRotationTooltip}" Margin="7"/>
|
||||
<RadioButton Content="270°" IsChecked="{Binding SelectedPreset.Settings, ConverterParameter=ImageRotation|270, Converter={StaticResource ConversionSettingsEquals}, ElementName=window, Mode=TwoWay}" ToolTip="{x:Static project:Resources.TwoSeventyDegreesRotationTooltip}" Margin="7"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<windows:ConversionSettingsTemplateSelector x:Key="ConversionSettingsSelector"
|
||||
DefaultDataTemplate="{StaticResource EmptyDataTemplate}"
|
||||
AacSettingsDataTemplate="{StaticResource AacSettingsDataTemplate}"
|
||||
AviSettingsDataTemplate="{StaticResource AviSettingsDataTemplate}"
|
||||
JpgSettingsDataTemplate="{StaticResource JpgSettingsDataTemplate}"
|
||||
MkvSettingsDataTemplate="{StaticResource MkvSettingsDataTemplate}"
|
||||
Mp3SettingsDataTemplate="{StaticResource Mp3SettingsDataTemplate}"
|
||||
Mp4SettingsDataTemplate="{StaticResource MkvSettingsDataTemplate}"
|
||||
OggSettingsDataTemplate="{StaticResource OggSettingsDataTemplate}"
|
||||
PngSettingsDataTemplate="{StaticResource PngSettingsDataTemplate}"
|
||||
WavSettingsDataTemplate="{StaticResource WavSettingsDataTemplate}" />
|
||||
</Window.Resources>
|
||||
<Window.Title>
|
||||
<Binding Converter="{StaticResource ApplicationVersionToApplicationName}" Mode="OneWay" Path="(local:Application.ApplicationVersion)"/>
|
||||
</Window.Title>
|
||||
|
||||
<Grid Margin="10">
|
||||
<Grid.CommandBindings>
|
||||
<Grid x:Name="MainGrid" Margin="10">
|
||||
<Grid.CommandBindings>
|
||||
<CommandBinding Command="New" CanExecute="CanSaveSettings" />
|
||||
</Grid.CommandBindings>
|
||||
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="48"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="{Binding Height, ElementName=ApplicationSettingsPanel, Mode=OneWay}"/>
|
||||
<RowDefinition Height="28"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Header -->
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="48"/>
|
||||
@@ -48,72 +376,165 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Image HorizontalAlignment="Left" Height="48" Width="48" VerticalAlignment="Top" Source="..\Resources\ApplicationIcon.png" />
|
||||
<Label Content="Settings" FontSize="20" Margin="4" Grid.Column="1" VerticalAlignment="Center" />
|
||||
<Label HorizontalAlignment="Right" FontStyle="Italic" FontSize="14" Grid.Column="2" VerticalAlignment="Center">
|
||||
<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 Converter="{StaticResource ApplicationVersionToApplicationName}" Mode="OneWay" Path="(local:Application.ApplicationVersion)"/>
|
||||
<Binding Path="(local:Application.ApplicationVersion)" Converter="{StaticResource ApplicationVersionToApplicationName}" Mode="OneWay" />
|
||||
</Label.Content>
|
||||
</Label>
|
||||
</Grid>
|
||||
|
||||
<!-- Conversion presets settings -->
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="3.5*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Content="Presets" Margin="0,5,0,0" VerticalAlignment="Top" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Width="100" Grid.ColumnSpan="2"/>
|
||||
<ListBox Name="PresetList" HorizontalAlignment="Left" Margin="0,36,0,0" Width="100" Grid.ColumnSpan="2"
|
||||
Grid.Column="0" IsSynchronizedWithCurrentItem="True" SelectedItem="{Binding SelectedPreset, ElementName=window}">
|
||||
<ItemsControl.DataContext>
|
||||
<local:ConversionPreset/>
|
||||
</ItemsControl.DataContext>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Label Content="{Binding Name}"/>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ListBox>
|
||||
<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" HorizontalAlignment="Center">
|
||||
<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">
|
||||
<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="*"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
<ColumnDefinition Width="*" MaxWidth="240"/>
|
||||
<ColumnDefinition Width="2.5*"/>
|
||||
</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 Name="PresetNameTextBox" Grid.Row="0" Grid.Column="1" Margin="5,2,25,2" Text="{Binding SelectedPreset.Name, Mode=TwoWay, ElementName=window, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" TextWrapping="Wrap" Width="Auto" />
|
||||
<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">
|
||||
<StackPanel>
|
||||
<CheckBox Content="Ape" Height="20" VerticalAlignment="Top" Margin="2" Checked="ToggleButton_OnChecked" Unchecked="ToggleButton_OnUnchecked" IsChecked="{Binding SelectedPreset.InputTypes, Converter={StaticResource InputTypesToBool}, ConverterParameter='Ape', ElementName=window, Mode=OneWay}"/>
|
||||
<CheckBox Content="Flac" Height="20" VerticalAlignment="Top" Margin="2" Checked="ToggleButton_OnChecked" Unchecked="ToggleButton_OnUnchecked" IsChecked="{Binding SelectedPreset.InputTypes, Converter={StaticResource InputTypesToBool}, ConverterParameter='Flac', ElementName=window, Mode=OneWay}"/>
|
||||
<CheckBox Content="Mp3" Height="20" VerticalAlignment="Top" Margin="2" Checked="ToggleButton_OnChecked" Unchecked="ToggleButton_OnUnchecked" IsChecked="{Binding SelectedPreset.InputTypes, Converter={StaticResource InputTypesToBool}, ConverterParameter='Mp3', ElementName=window, Mode=OneWay}"/>
|
||||
<CheckBox Content="Ogg" Height="20" VerticalAlignment="Top" Margin="2" Checked="ToggleButton_OnChecked" Unchecked="ToggleButton_OnUnchecked" IsChecked="{Binding SelectedPreset.InputTypes, Converter={StaticResource InputTypesToBool}, ConverterParameter='Ogg', ElementName=window, Mode=OneWay}"/>
|
||||
<CheckBox Content="Wav" Height="20" VerticalAlignment="Top" Margin="2" Checked="ToggleButton_OnChecked" Unchecked="ToggleButton_OnUnchecked" IsChecked="{Binding SelectedPreset.InputTypes, Converter={StaticResource InputTypesToBool}, ConverterParameter='Wav', ElementName=window, Mode=OneWay}"/>
|
||||
<CheckBox Content="Wma" Height="20" VerticalAlignment="Top" Margin="2" Checked="ToggleButton_OnChecked" Unchecked="ToggleButton_OnUnchecked" IsChecked="{Binding SelectedPreset.InputTypes, Converter={StaticResource InputTypesToBool}, ConverterParameter='Wma', ElementName=window, Mode=OneWay}"/>
|
||||
</StackPanel>
|
||||
<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">
|
||||
<ComboBox Name="OutputFormats" Grid.Row="1" Grid.Column="1" Margin="5" Height="25" VerticalAlignment="Top" SelectedItem="{Binding SelectedPreset.OutputType, ElementName=window, Mode=TwoWay}">
|
||||
</ComboBox>
|
||||
<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 Name="AddPresetButton" Grid.Row="2" Content="+" HorizontalAlignment="Left" Width="28" Margin="18,4,0,0" Click="AddPresetButton_Click"/>
|
||||
<Button Name="RemovePresetButton" Grid.Row="2" Content="-" HorizontalAlignment="Left" Width="28" Margin="54,4,0,0" Click="RemovePresetButton_Click"/>
|
||||
|
||||
<Button Name="CloseButton" Grid.Row="2" Content="Close" HorizontalAlignment="Right" Width="100" Margin="0,4,105,0" Click="CloseButton_Click" />
|
||||
<Button Name="SaveButton" Grid.Row="2" Content="Save" HorizontalAlignment="Right" Width="100" Margin="0,4,0,0" Click="SaveButton_Click" Command="New"/>
|
||||
<!-- Application settings -->
|
||||
<StackPanel x:Name="ApplicationSettingsPanel" Grid.Row="2" Margin="5,10,5,5">
|
||||
<CheckBox x:Name="QuitAtEndCheckBox" Content="Automatically exit when all conversions finished" IsChecked="{Binding ApplicationSettings.ExitApplicationWhenConversionsFinished, ElementName=window, Mode=TwoWay}" />
|
||||
<DockPanel Margin="40,0,0,5" Visibility="{Binding IsChecked, Converter={StaticResource BoolToVisibility}, ConverterParameter=Collapsed, ElementName=QuitAtEndCheckBox}">
|
||||
<Label Content="Waiting duration :"/>
|
||||
<Slider x:Name="DurationBeforeQuitSlider" Value="{Binding ApplicationSettings.DurationBetweenEndOfConversionsAndApplicationExit, ElementName=window, Mode=TwoWay}" Minimum="0" Maximum="10" SmallChange="0.1" IsSnapToTickEnabled="True" Width="250" TickFrequency="0.1"/>
|
||||
<Label Content="{Binding Value, Converter={StaticResource DoubleToTimeString}, ElementName=DurationBeforeQuitSlider}"/>
|
||||
</DockPanel>
|
||||
<CheckBox Content="Automatically check for updates when File Converter starts" IsChecked="{Binding ApplicationSettings.CheckUpgradeAtStartup, ElementName=window, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
|
||||
<Button x:Name="CloseButton" Grid.Row="3" Content="Close" HorizontalAlignment="Right" Width="100" Margin="0,4,105,0" Click="CloseButton_Click" />
|
||||
<Button x:Name="SaveButton" Grid.Row="3" Content="Save" HorizontalAlignment="Right" Width="100" Margin="0,4,0,0" Click="SaveButton_Click" Command="New"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -2,16 +2,20 @@
|
||||
|
||||
namespace FileConverter
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
using FileConverter.Annotations;
|
||||
using Microsoft.Win32;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for Settings.xaml
|
||||
/// Interaction logic for Settings.
|
||||
/// </summary>
|
||||
public partial class SettingsWindow : Window, INotifyPropertyChanged
|
||||
{
|
||||
@@ -19,27 +23,49 @@ namespace FileConverter
|
||||
|
||||
private Settings settings;
|
||||
|
||||
private InputExtensionCategory[] inputCategories;
|
||||
|
||||
public SettingsWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
Application application = Application.Current as Application;
|
||||
settings = application.Settings;
|
||||
this.PresetList.ItemsSource = settings.ConversionPresets;
|
||||
this.ApplicationSettings = application.Settings;
|
||||
this.PresetList.ItemsSource = this.settings.ConversionPresets;
|
||||
|
||||
OutputType[] outputTypes = new[]
|
||||
{
|
||||
OutputType.Flac,
|
||||
OutputType.Mp3,
|
||||
OutputType.Ogg,
|
||||
OutputType.Wav,
|
||||
OutputType.Mp3,
|
||||
OutputType.Aac,
|
||||
OutputType.Flac,
|
||||
OutputType.Wav,
|
||||
OutputType.Mkv,
|
||||
OutputType.Mp4,
|
||||
OutputType.Avi,
|
||||
OutputType.Ico,
|
||||
OutputType.Jpg,
|
||||
OutputType.Png,
|
||||
};
|
||||
|
||||
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
|
||||
@@ -49,8 +75,54 @@ namespace FileConverter
|
||||
|
||||
set
|
||||
{
|
||||
if (this.selectedPreset != null)
|
||||
{
|
||||
this.selectedPreset.PropertyChanged -= this.SelectedPresetPropertyChanged;
|
||||
}
|
||||
|
||||
this.selectedPreset = value;
|
||||
|
||||
if (this.selectedPreset != null)
|
||||
{
|
||||
this.selectedPreset.PropertyChanged += this.SelectedPresetPropertyChanged;
|
||||
}
|
||||
|
||||
this.OnPropertyChanged();
|
||||
this.OnPropertyChanged("InputCategories");
|
||||
}
|
||||
}
|
||||
|
||||
public Settings ApplicationSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.settings = value;
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<InputExtensionCategory> InputCategories
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.inputCategories == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
for (int index = 0; index < this.inputCategories.Length; index++)
|
||||
{
|
||||
InputExtensionCategory category = this.inputCategories[index];
|
||||
if (this.SelectedPreset == null || PathHelpers.IsOutputTypeCompatibleWithCategory(this.SelectedPreset.OutputType, category.Name))
|
||||
{
|
||||
yield return category;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,23 +132,15 @@ namespace FileConverter
|
||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private void ToggleButton_OnChecked(object sender, RoutedEventArgs e)
|
||||
private void SelectedPresetPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (this.selectedPreset == null)
|
||||
if (e.PropertyName == "OutputType")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CheckBox checkBox = sender as System.Windows.Controls.CheckBox;
|
||||
string inputFormat = checkBox.Content as string;
|
||||
|
||||
if (!this.selectedPreset.InputTypes.Contains(inputFormat))
|
||||
{
|
||||
this.selectedPreset.InputTypes.Add(inputFormat);
|
||||
this.OnPropertyChanged("InputCategories");
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleButton_OnUnchecked(object sender, RoutedEventArgs e)
|
||||
private void OnInputTypeChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.selectedPreset == null)
|
||||
{
|
||||
@@ -84,18 +148,79 @@ namespace FileConverter
|
||||
}
|
||||
|
||||
CheckBox checkBox = sender as System.Windows.Controls.CheckBox;
|
||||
string inputFormat = checkBox.Content as string;
|
||||
if (!checkBox.IsVisible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.selectedPreset.InputTypes.Remove(inputFormat);
|
||||
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;
|
||||
if (!checkBox.IsVisible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// Load previous preset in order to cancel changes.
|
||||
Application application = Application.Current as Application;
|
||||
application.Settings.Load();
|
||||
|
||||
this.Hide();
|
||||
this.HideSettingsWindow();
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||
@@ -105,12 +230,31 @@ namespace FileConverter
|
||||
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]);
|
||||
string presetName = "New preset";
|
||||
int index = 1;
|
||||
while (application.Settings.ConversionPresets.Any(match => match.Name == presetName))
|
||||
{
|
||||
index++;
|
||||
presetName = string.Format("New preset ({0})", index);
|
||||
}
|
||||
|
||||
ConversionPreset newPreset = null;
|
||||
if (this.SelectedPreset != null)
|
||||
{
|
||||
newPreset = new ConversionPreset(presetName, this.SelectedPreset);
|
||||
}
|
||||
else
|
||||
{
|
||||
newPreset = new ConversionPreset(presetName, OutputType.Mkv, new string[0]);
|
||||
}
|
||||
|
||||
application.Settings.ConversionPresets.Add(newPreset);
|
||||
this.SelectedPreset = newPreset;
|
||||
this.PresetNameTextBox.Focus();
|
||||
@@ -127,5 +271,88 @@ namespace FileConverter
|
||||
{
|
||||
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 = 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 = Microsoft.Win32.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();
|
||||
this.OnPropertyChanged("InputCategories");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<Window x:Name="window" x:Class="FileConverter.Windows.UpgradeWindow"
|
||||
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"
|
||||
xmlns:valueConverters="clr-namespace:FileConverter.ValueConverters"
|
||||
xmlns:xaml="clr-namespace:Markdown.Xaml;assembly=Markdown.Xaml"
|
||||
mc:Ignorable="d"
|
||||
Title="File Converter Updates"
|
||||
WindowStartupLocation="CenterScreen" Icon="/FileConverter;component/Resources/ApplicationIcon.ico"
|
||||
MinHeight="300" MinWidth="450"
|
||||
Height="450" Width="450" WindowStyle="ToolWindow">
|
||||
<Window.Resources>
|
||||
<valueConverters:ApplicationVersionToApplicationName x:Key="ApplicationVersionToApplicationName"/>
|
||||
|
||||
<Style TargetType="FlowDocument" x:Key="DocumentStyle">
|
||||
<Setter Property="FontFamily" Value="Segoe UI" />
|
||||
<Setter Property="TextAlignment" Value="Left" />
|
||||
<Setter Property="Foreground" Value="#786C71" />
|
||||
<Setter Property="Background" Value="White" />
|
||||
<Setter Property="LineHeight" Value="9"/>
|
||||
<Setter Property="FontSize" Value="13" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="PageHeader" TargetType="Paragraph">
|
||||
<Setter Property="FontSize" Value="24" />
|
||||
<Setter Property="Foreground" Value="#1E6BB8" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SubHeader"
|
||||
TargetType="Paragraph">
|
||||
<Setter Property="FontSize"
|
||||
Value="20" />
|
||||
<Setter Property="Foreground"
|
||||
Value="#DF3900" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="SubHeaderSecondary"
|
||||
TargetType="Paragraph">
|
||||
<Setter Property="FontSize"
|
||||
Value="20" />
|
||||
<Setter Property="Foreground"
|
||||
Value="#DF3900" />
|
||||
</Style>
|
||||
|
||||
<xaml:Markdown x:Key="Markdown"
|
||||
DocumentStyle="{StaticResource DocumentStyle}"
|
||||
Heading1Style="{StaticResource PageHeader}"
|
||||
Heading2Style="{StaticResource SubHeader}"
|
||||
Heading3Style="{StaticResource SubHeaderSecondary}"/>
|
||||
|
||||
<xaml:TextToFlowDocumentConverter x:Key="TextToFlowDocumentConverter" Markdown="{StaticResource Markdown}"/>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<!--<RowDefinition Height="{Binding Height, ElementName=ApplicationSettingsPanel, Mode=OneWay}"/>-->
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Margin="5"
|
||||
Text="An update for File Converter is available. It is strongly recommended that you install it as soon as possible!" TextWrapping="Wrap"/>
|
||||
|
||||
<!--<Label Grid.Row="1" Margin="5"
|
||||
Content="{Binding VersionDescription.LatestVersion, Converter={StaticResource ApplicationVersionToApplicationName}, ElementName=window}" FontWeight="Bold" FontSize="14.667"/>-->
|
||||
|
||||
<FlowDocumentScrollViewer Grid.Row="2" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||
Document="{Binding ReleaseNote, Converter={StaticResource TextToFlowDocumentConverter}, ElementName=window}"/>
|
||||
|
||||
<Button Background="WhiteSmoke" Grid.Row="3" Padding="10,5,10,5" Margin="5" HorizontalContentAlignment="Left" Click="OnInstallButtonClick" >
|
||||
<Button.Content>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="64"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Source="/FileConverter;component/Resources/DownloadIcon.png" Stretch="Fill"/>
|
||||
<Grid Grid.Column="1" Margin="10,0,0,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label Grid.Row="0" Content="Install when I exit File Converter" FontSize="14.667"/>
|
||||
<TextBlock Grid.Row="1" Text="The update will be downloaded in background, and installed once you exit File Converter." TextWrapping="Wrap" FontSize="10.667"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Button.Content>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,80 @@
|
||||
// <copyright file="UpgradeWindow.xaml.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.Windows
|
||||
{
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
using FileConverter.Annotations;
|
||||
using FileConverter.Upgrade;
|
||||
|
||||
public partial class UpgradeWindow : Window, INotifyPropertyChanged
|
||||
{
|
||||
private UpgradeVersionDescription upgradeVersionDescription;
|
||||
private string releaseNoteContent;
|
||||
|
||||
public UpgradeWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public UpgradeVersionDescription VersionDescription
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.upgradeVersionDescription;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.upgradeVersionDescription = value;
|
||||
|
||||
Task<string> task = Helpers.GetChangeLogAsync(this.upgradeVersionDescription, this.OnChangeLogRetrieved);
|
||||
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string ReleaseNote
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.releaseNoteContent))
|
||||
{
|
||||
return "###Downloading change log ...";
|
||||
}
|
||||
|
||||
return this.releaseNoteContent;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.releaseNoteContent = value;
|
||||
|
||||
this.OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
private void OnChangeLogRetrieved(UpgradeVersionDescription versionDescription)
|
||||
{
|
||||
this.ReleaseNote = versionDescription.ChangeLog;
|
||||
}
|
||||
|
||||
private void OnInstallButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.upgradeVersionDescription.NeedToUpgrade = true;
|
||||
Helpers.DownloadInstallerAsync(this.upgradeVersionDescription);
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Documents;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
// <copyright file="XmlHelpers.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
using FileConverter;
|
||||
|
||||
public class XmlHelpers
|
||||
namespace FileConverter
|
||||
{
|
||||
public static void LoadFromFile<T>(string root, string path, ref ICollection<T> collection)
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
public class XmlHelpers
|
||||
{
|
||||
if (string.IsNullOrEmpty(path))
|
||||
public static void LoadFromFile<T>(string root, string path, out T deserializedObject)
|
||||
{
|
||||
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))
|
||||
using (XmlReader xmlReader = XmlReader.Create(reader, new XmlReaderSettings { IgnoreWhitespace = true, IgnoreComments = true }))
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
List<T> elements = (List<T>)serializer.Deserialize(xmlReader);
|
||||
foreach (T element in elements)
|
||||
throw new ArgumentNullException("path");
|
||||
}
|
||||
|
||||
XmlRootAttribute xmlRoot = new XmlRootAttribute
|
||||
{
|
||||
ElementName = root
|
||||
};
|
||||
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(T), xmlRoot);
|
||||
|
||||
try
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(path))
|
||||
{
|
||||
collection.Add(element);
|
||||
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
|
||||
{
|
||||
IgnoreWhitespace = true,
|
||||
IgnoreComments = true
|
||||
};
|
||||
|
||||
using (XmlReader xmlReader = XmlReader.Create(reader, xmlReaderSettings))
|
||||
{
|
||||
deserializedObject = (T)serializer.Deserialize(xmlReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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))
|
||||
using (XmlWriter xmlWriter = XmlWriter.Create(writer, new XmlWriterSettings { Indent = true, IndentChars = " " }))
|
||||
catch (System.Exception)
|
||||
{
|
||||
serializer.Serialize(xmlWriter, list);
|
||||
throw;
|
||||
}
|
||||
|
||||
IXmlSerializable xmlSerializableObject = deserializedObject as IXmlSerializable;
|
||||
if (xmlSerializableObject != null)
|
||||
{
|
||||
xmlSerializableObject.OnDeserializationComplete();
|
||||
}
|
||||
}
|
||||
catch (System.Exception exception)
|
||||
|
||||
public static void SaveToFile<T>(string root, string path, T objectToSerialize)
|
||||
{
|
||||
Diagnostics.Log("The database of type '" + typeof(T) + "' failed to load the asset. The following exception was raised:\n " + exception.Message);
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
throw new ArgumentNullException("path");
|
||||
}
|
||||
|
||||
if (objectToSerialize == null)
|
||||
{
|
||||
throw new ArgumentNullException("objectToSerialize");
|
||||
}
|
||||
|
||||
XmlRootAttribute xmlRoot = new XmlRootAttribute
|
||||
{
|
||||
ElementName = root
|
||||
};
|
||||
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(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, objectToSerialize);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception exception)
|
||||
{
|
||||
Diagnostics.Debug.LogError("Fail to save asset of type '" + typeof(T) + "'. The following exception was raised:\n " + exception.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Magick.NET-Q16-AnyCPU" version="7.0.0.0101" targetFramework="net45" />
|
||||
</packages>
|
||||
@@ -16,6 +16,9 @@ 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
|
||||
@@ -23,6 +26,7 @@ namespace FileConverterExtension
|
||||
private string fileConverterPath;
|
||||
private RegistryKey fileConverterRegistryKey;
|
||||
private List<PresetDefinition> presetList = new List<PresetDefinition>();
|
||||
private List<string> compatibleInputExtensions = new List<string>();
|
||||
|
||||
private RegistryKey FileConverterRegistryKey
|
||||
{
|
||||
@@ -54,6 +58,27 @@ namespace FileConverterExtension
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
foreach (string filePath in this.SelectedItemPaths)
|
||||
@@ -65,15 +90,9 @@ namespace FileConverterExtension
|
||||
}
|
||||
|
||||
extension = extension.Substring(1).ToLowerInvariant();
|
||||
switch (extension)
|
||||
if (this.CompatibleInputExtensions.Contains(extension))
|
||||
{
|
||||
case "ape":
|
||||
case "mp3":
|
||||
case "wav":
|
||||
case "ogg":
|
||||
case "flac":
|
||||
case "wma":
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +133,7 @@ namespace FileConverterExtension
|
||||
{
|
||||
ToolStripMenuItem subItem = new ToolStripMenuItem
|
||||
{
|
||||
Text = "Settings",
|
||||
Text = "Configure presets...",
|
||||
};
|
||||
|
||||
fileConverterItem.DropDownItems.Add(subItem);
|
||||
|
||||
@@ -46,8 +46,9 @@
|
||||
</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="SharpShell">
|
||||
<HintPath>..\..\Middleware\SharpShell\SharpShell.dll</HintPath>
|
||||
<Reference Include="SharpShell, Version=2.2.0.0, Culture=neutral, PublicKeyToken=f14dc899472fe6fb, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\SharpShell.2.2.0.0\lib\net40\SharpShell.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
@@ -62,7 +63,9 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="FileConverterExtension.cs" />
|
||||
<Compile Include="PresetDefinition.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<ExcludeFromStyleCop>true</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
@@ -80,10 +83,11 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<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>
|
||||
|
||||
@@ -4,9 +4,6 @@ namespace FileConverterExtension
|
||||
{
|
||||
public class PresetDefinition
|
||||
{
|
||||
public bool Enabled;
|
||||
public int ExtensionRefCount;
|
||||
|
||||
public PresetDefinition(string name)
|
||||
{
|
||||
this.Name = name;
|
||||
@@ -17,5 +14,17 @@ namespace FileConverterExtension
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public int ExtensionRefCount
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 1.1 KiB 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>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="SharpShell" version="2.2.0.0" targetFramework="net45" />
|
||||
</packages>
|
||||
@@ -0,0 +1,71 @@
|
||||
# Change Log
|
||||
|
||||
## Version 0.6
|
||||
- New: Possibility to encode videos using H.264 video codec and AAC audio codec in a mp4 container (more portable than mkv).
|
||||
- New: Support new image input file formats: psd, tga, svg and exr.
|
||||
- New: Support new video input file format: m4v.
|
||||
- New: Possibility to rotate images and videos.
|
||||
- New: Remove restriction on image size to convert to ico file format (it is now possible to convert all images to ico).
|
||||
- New: Add "Clamp to power of 2 size" option in image conversion.
|
||||
- New: Support input images encoded in 16 bits or 32 bits per color channel.
|
||||
- Fixed: Issue where the installer detects the utilisation of the extension dll in explorer, ask the user to restart it and fail to do it.
|
||||
- Fixed: Issue where it is impossible to delete a conversion preset defined in default settings.
|
||||
- Fixed: Issue where the Windows context menu does not contain user preset after an application upgrade.
|
||||
- Fixed: Issue where some registry keys remain after file converter uninstallation.
|
||||
- Fixed: Issue where aac bitrate was not saved.
|
||||
- Fixed: Issue where settings serialization version was not updated.
|
||||
- Change: Allow the user to scale images until 1600% size (useful to scale pixel art images).
|
||||
|
||||
## Version 0.5
|
||||
- New: Software update system. The application now checks if a new version of File Converter is available.
|
||||
- New: Possibility to scale images and videos.
|
||||
- New: Possibility to encode videos (avi output file format) using Xvid video codec and Mp3 audio codec.
|
||||
- New: Support new video input file formats: 3gp, webm and wmv.
|
||||
- New: Add a help window to explain how file converter works when you launch it without using the context menu.
|
||||
- Fixed: Problem to convert images when accentuated characters were present in their path.
|
||||
- Tech: Update ffmpeg version (aac encoding is not anymore experimental).
|
||||
|
||||
## Version 0.4
|
||||
- New: Possibility to encode videos (mkv output file format) using H.264 video codec and AAC audio codec.
|
||||
- New: Possibility to extract Audio CD content.
|
||||
- New: Possibility to encode audio in aac format.
|
||||
- New: Possibility to encode images (png, jpg and ico formats).
|
||||
- New: Support new audio input file format: aac
|
||||
- New: Support new video input file formats: bik, flv, mov, mkv
|
||||
- New: Support new image input file formats: bmp, tiff, png, jpg and ico.
|
||||
- New: Multi-thread conversion (file converter will now start multiple conversions at the time depending on your number of cores).
|
||||
- New: Copy the currently selected preset when clicking on the add preset button.
|
||||
- New: Add "My Documents", "My Music", "My Videos" and "My Pictures" folder to output file name generator.
|
||||
- New: Possibility to choose if the application quit after succeeded conversions.
|
||||
- Fixed: Reordering presets does not update the registry.
|
||||
- Fixed: Merge default settings with user settings to prevent errors when upgrading the application.
|
||||
- Tech: Handle incorrect user settings case.
|
||||
- Tech: Improve diagnostics system (compatibility with logs from multiple threads, dump files in AppData folder and error messages).
|
||||
- Tech: Update ffmpeg version.
|
||||
|
||||
## Version 0.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.
|
||||
|
||||
## Version 0.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.
|
||||
|
||||
## Version 0.1
|
||||
- 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
|
||||
@@ -1,40 +1,54 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileConverter", "FileConverter.csproj", "{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}"
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.24720.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileConverter", "Application\FileConverter\FileConverter.csproj", "{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}"
|
||||
EndProject
|
||||
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Installer", "..\..\Installer\Installer.wixproj", "{F14673DF-DF38-44B4-AB1D-99A59182C24C}"
|
||||
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Installer", "Installer\Installer.wixproj", "{F14673DF-DF38-44B4-AB1D-99A59182C24C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileConverterExtension", "..\FileConverterExtension\FileConverterExtension.csproj", "{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FileConverterExtension", "Application\FileConverterExtension\FileConverterExtension.csproj", "{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Release|x64.Build.0 = Release|Any CPU
|
||||
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{D27A76D2-43E4-43CC-9DA3-334B0B46F4E5}.Release|x86.Build.0 = Release|Any CPU
|
||||
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Debug|x64.Build.0 = Debug|x64
|
||||
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Debug|x86.Build.0 = Debug|x86
|
||||
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Release|x64.ActiveCfg = Release|x64
|
||||
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Release|x64.Build.0 = Release|x64
|
||||
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Release|x86.ActiveCfg = Release|x86
|
||||
{F14673DF-DF38-44B4-AB1D-99A59182C24C}.Release|x86.Build.0 = Release|x86
|
||||
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Release|x64.Build.0 = Release|Any CPU
|
||||
{0C44CA69-42D6-4357-BDFD-83069D1ABA2F}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
@@ -4,12 +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>
|
||||
<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></wpf:ResourceDictionary>
|
||||
<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>
|
||||
@@ -1,30 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<?if $(var.Platform) = x64 ?>
|
||||
<?define Win64 = "yes" ?>
|
||||
<?else ?>
|
||||
<?define Win64 = "no" ?>
|
||||
<?endif ?>
|
||||
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||
<Fragment>
|
||||
<DirectoryRef Id="INSTALLFOLDER">
|
||||
<Component Id="FileConverterExtension.dll" Guid="{FEF385C4-C43F-44F9-92E2-06578A8BD96E}" Win64="$(var.Win64)">
|
||||
<Class Id="{AF9B72B5-F4E4-44B0-A3D9-B55B748EFE90}" Context="InprocServer32" Description="FileConverterExtension.FileConverterExtension" ThreadingModel="both" ForeignServer="mscoree.dll">
|
||||
<ProgId Id="FileConverterExtension.FileConverterExtension" Description="FileConverterExtension.FileConverterExtension" />
|
||||
</Class>
|
||||
<File Id="FileConverterExtension.dll" KeyPath="yes" Source="..\Application\FileConverterExtension\bin\$(var.Configuration)\FileConverterExtension.dll" />
|
||||
<RegistryValue Root="HKCR" Key="*\shellex\ContextMenuHandlers\FileConverterExtension" Value="{af9b72b5-f4e4-44b0-a3d9-b55b748efe90}" Type="string" Action="write" />
|
||||
<RegistryValue Root="HKCR" Key="CLSID\{AF9B72B5-F4E4-44B0-A3D9-B55B748EFE90}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}" Value="" Type="string" Action="write" />
|
||||
<RegistryValue Root="HKCR" Key="CLSID\{AF9B72B5-F4E4-44B0-A3D9-B55B748EFE90}\InprocServer32\1.0.0.0" Name="Class" Value="FileConverterExtension.FileConverterExtension" Type="string" Action="write" />
|
||||
<RegistryValue Root="HKCR" Key="CLSID\{AF9B72B5-F4E4-44B0-A3D9-B55B748EFE90}\InprocServer32\1.0.0.0" Name="Assembly" Value="FileConverterExtension, Version=1.0.0.0, Culture=neutral, PublicKeyToken=15400b1c4b948c8a" Type="string" Action="write" />
|
||||
<RegistryValue Root="HKCR" Key="CLSID\{AF9B72B5-F4E4-44B0-A3D9-B55B748EFE90}\InprocServer32\1.0.0.0" Name="RuntimeVersion" Value="v4.0.30319" Type="string" Action="write" />
|
||||
<RegistryValue Root="HKCR" Key="CLSID\{AF9B72B5-F4E4-44B0-A3D9-B55B748EFE90}\InprocServer32\1.0.0.0" Name="CodeBase" Value="file:///[#FileConverterExtension.dll]" Type="string" Action="write" />
|
||||
<RegistryValue Root="HKCR" Key="CLSID\{AF9B72B5-F4E4-44B0-A3D9-B55B748EFE90}\InprocServer32" Name="Class" Value="FileConverterExtension.FileConverterExtension" Type="string" Action="write" />
|
||||
<RegistryValue Root="HKCR" Key="CLSID\{AF9B72B5-F4E4-44B0-A3D9-B55B748EFE90}\InprocServer32" Name="Assembly" Value="FileConverterExtension, Version=1.0.0.0, Culture=neutral, PublicKeyToken=15400b1c4b948c8a" Type="string" Action="write" />
|
||||
<RegistryValue Root="HKCR" Key="CLSID\{AF9B72B5-F4E4-44B0-A3D9-B55B748EFE90}\InprocServer32" Name="RuntimeVersion" Value="v4.0.30319" Type="string" Action="write" />
|
||||
<RegistryValue Root="HKCR" Key="CLSID\{AF9B72B5-F4E4-44B0-A3D9-B55B748EFE90}\InprocServer32" Name="CodeBase" Value="file:///[#FileConverterExtension.dll]" Type="string" Action="write" />
|
||||
</Component>
|
||||
</DirectoryRef>
|
||||
</Fragment>
|
||||
</Wix>
|
||||
@@ -1 +0,0 @@
|
||||
"C:\Program Files (x86)\Wix Toolset v3.9\bin\Heat.exe" file "..\Application\FileConverterExtension\bin\Release\FileConverterExtension.dll" -dr INSTALLFOLDER -srd -gg -sfrag -suid -out "Extension.wxs" -b "..\Application\FileConverterExtension\bin\Release\"
|
||||
@@ -30,7 +30,6 @@
|
||||
<IntermediateOutputPath>obj\$(Platform)\$(Configuration)\</IntermediateOutputPath>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Extension.wxs" />
|
||||
<Compile Include="Product.wxs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -49,6 +48,9 @@
|
||||
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(WixTargetsPath)" />
|
||||
<!--
|
||||
To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
||||
@@ -10,26 +10,36 @@
|
||||
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
|
||||
<?endif ?>
|
||||
|
||||
<!-- Upgrade documentation: http://wixtoolset.org/documentation/manual/v3/howtos/updates/major_upgrade.html -->
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||
<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="0.2.0" Manufacturer="AAllard" UpgradeCode="e3ca717b-a897-418a-bbef-5c7e35c76e4b">
|
||||
<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="0.6" 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"/>
|
||||
<Icon Id="icon.ico" SourceFile="..\Resources\ApplicationIcon.ico"/>
|
||||
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
|
||||
|
||||
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
|
||||
<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />
|
||||
|
||||
<Media Id="1" Cabinet="CabFile.cab" EmbedCab="yes" />
|
||||
|
||||
<Feature Id="ProductFeature" Title="Installer" Level="1">
|
||||
<ComponentGroupRef Id="ProductComponents" />
|
||||
</Feature>
|
||||
|
||||
<Feature Id="ShellExtensionFeature" Title="ShellExtension" Level="1" AllowAdvertise="no">
|
||||
<ComponentRef Id="FileConverterExtension.dll" />
|
||||
</Feature>
|
||||
<CustomAction Id="InstallShell" FileKey="srm.exe" ExeCommand='install "[INSTALLFOLDER]\FileConverterExtension.dll" -codebase' Execute="deferred" Return="check" Impersonate="no" />
|
||||
<CustomAction Id="UninstallShell" FileKey="srm.exe" ExeCommand='uninstall "[INSTALLFOLDER]\FileConverterExtension.dll"' Execute="deferred" Return="check" Impersonate="no" />
|
||||
<CustomAction Id='PostInstallInit' FileKey='FileConverter.exe' ExeCommand='--post-install-init' Return='asyncNoWait' />
|
||||
|
||||
<InstallExecuteSequence>
|
||||
<Custom Action="InstallShell" After="InstallFiles">NOT Installed</Custom>
|
||||
<Custom Action="UninstallShell" Before="RemoveFiles">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")</Custom>
|
||||
<Custom Action="PostInstallInit" After="InstallFinalize">NOT Installed</Custom>
|
||||
</InstallExecuteSequence>
|
||||
|
||||
<UIRef Id="WixUI_InstallDir" />
|
||||
<Property Id="MSIUSEREALADMINDETECTION" Value="1" />
|
||||
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
|
||||
<Property Id="MSIRESTARTMANAGERCONTROL" Value="Disable" /> <!-- This avoid an issue where the installer detect the utilisation of the extension dll in explorer and then, ask to the user to restart these applications. The restart fails. -->
|
||||
|
||||
<WixVariable Id="WixUILicenseRtf" Value="License.rtf" />
|
||||
<WixVariable Id="WixUIBannerBmp" Value="..\Resources\Installer\Banner.bmp" />
|
||||
@@ -50,46 +60,58 @@
|
||||
|
||||
<Fragment>
|
||||
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
|
||||
<!-- Resources -->
|
||||
<Component Guid="{9BF0AC45-A586-41C9-BA93-6048B46DA65F}" Win64="$(var.Win64)">
|
||||
<File Id="SharpShell.dll" KeyPath="yes" Source="..\Middleware\SharpShell\SharpShell.dll" />
|
||||
<!-- Application -->
|
||||
<Component Guid="{142FBD60-90A7-4753-95CE-7B2A2E20B785}" Win64="$(var.Win64)">
|
||||
<File Id="FileConverter.exe" Source="$(var.FileConverter.TargetPath)" KeyPath="yes" />
|
||||
</Component>
|
||||
|
||||
<!-- Extension -->
|
||||
<Component Guid="{AA5EA6F7-C443-488B-8E48-7CF000B9AD2A}" Win64="$(var.Win64)">
|
||||
<File Source="$(var.FileConverter.TargetPath)" KeyPath="yes" />
|
||||
<File Id="FileConverterExtension.dll" KeyPath="yes" Source="..\Application\FileConverterExtension\bin\$(var.Configuration)\FileConverterExtension.dll" />
|
||||
</Component>
|
||||
<Component Guid="{9BF0AC45-A586-41C9-BA93-6048B46DA65F}" Win64="$(var.Win64)">
|
||||
<File Id="SharpShell.dll" KeyPath="yes" Source="..\packages\SharpShell.2.2.0.0\lib\net40\SharpShell.dll" />
|
||||
</Component>
|
||||
<Component Guid="{EC580BEF-F962-42BD-B46D-4E4C126F2641}" Win64="$(var.Win64)">
|
||||
<File Id="srm.exe" Source="..\packages\SharpShellTools.2.2.0.0\lib\srm.exe" KeyPath="yes" />
|
||||
</Component>
|
||||
|
||||
<!-- Third parties -->
|
||||
<Component Guid="{1790B82E-86BC-4B95-AA1D-9859FF3B6CA4}" Win64="$(var.Win64)">
|
||||
<File Source="..\Middleware\ffmpeg.exe" KeyPath="yes" />
|
||||
</Component>
|
||||
<Component Guid="{C59B7F72-D8D6-47A3-B1D9-515CBC9FCE6F}" Win64="$(var.Win64)">
|
||||
<File Id="Magick.NET.dll" KeyPath="yes" Source="..\Application\FileConverter\bin\$(var.Configuration)\Magick.NET-Q16-AnyCPU.dll" />
|
||||
</Component>
|
||||
<Component Guid="{E1B1C09C-B089-40D8-859B-0E55F640CAE1}" Win64="$(var.Win64)">
|
||||
<File Id="Markdown.Xaml.dll" KeyPath="yes" Source="..\Middleware\Markdown.Xaml.dll" />
|
||||
</Component>
|
||||
<Component Guid="{55CD0B47-D5B0-4F0C-A54E-3E11DF345B48}" Win64="$(var.Win64)">
|
||||
<File Id="Ripper.dll" KeyPath="yes" Source="..\Middleware\Ripper.dll" />
|
||||
</Component>
|
||||
<Component Guid="{3CE6CF1B-431C-41FD-8381-3F73EDAF7B8A}" Win64="$(var.Win64)">
|
||||
<File Id="yeti.mmedia.dll" KeyPath="yes" Source="..\Middleware\yeti.mmedia.dll" />
|
||||
</Component>
|
||||
|
||||
<!-- Configuration and documentation -->
|
||||
<Component Guid="{86AEF5B3-C25B-4662-BAEF-20969D1821A5}" Win64="$(var.Win64)">
|
||||
<File Source="..\Application\FileConverter\Settings.xml" KeyPath="yes" />
|
||||
<File Source="..\Application\FileConverter\Settings.default.xml" KeyPath="yes" />
|
||||
</Component>
|
||||
<Component Guid="{A5158756-A107-4010-9E2F-3C0333F5A5F6}" Win64="$(var.Win64)">
|
||||
<File Source="..\README.md" KeyPath="yes" />
|
||||
</Component>
|
||||
<Component Guid="{B57DCB2B-3520-4430-98CB-41B58F530D75}" Win64="$(var.Win64)">
|
||||
<File Source="..\CHANGELOG.md" KeyPath="yes" />
|
||||
</Component>
|
||||
<Component Guid="{6378238B-E44F-414B-A7AE-7E72CFA8616D}" Win64="$(var.Win64)">
|
||||
<File Source="..\LICENSE.md" KeyPath="yes" />
|
||||
</Component>
|
||||
|
||||
<!-- Registry entries -->
|
||||
<Component Id="RegistryEntries" Guid="{C3EF3D67-0206-4DBD-B2EA-78FF2E290093}">
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter" Action="createAndRemoveOnUninstall">
|
||||
<RegistryValue Name="Path" Type="string" Value="[INSTALLFOLDER]FileConverter.exe"/>
|
||||
</RegistryKey>
|
||||
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter\ape" Action="createAndRemoveOnUninstall">
|
||||
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Flac;To Wav"/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter\flac" Action="createAndRemoveOnUninstall">
|
||||
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Wav"/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter\mp3" Action="createAndRemoveOnUninstall">
|
||||
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Wav"/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter\ogg" Action="createAndRemoveOnUninstall">
|
||||
<RegistryValue Name="Presets" Type="string" Value="To Mp3;To Wav"/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter\wav" Action="createAndRemoveOnUninstall">
|
||||
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Flac"/>
|
||||
</RegistryKey>
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter\wma" Action="createAndRemoveOnUninstall">
|
||||
<RegistryValue Name="Presets" Type="string" Value="To Ogg;To Mp3;To Wav"/>
|
||||
<RegistryValue Name="CompatibleInputExtensions" Type="string" Value="3gp;aac;aiff;ape;avi;bik;bmp;cda;exr;flac;flv;ico;jpg;jpeg;m4a;m4v;mkv;mov;mp3;mp4;ogg;png;psd;svg;tga;tiff;wav;webm;wma;wmv"/>
|
||||
</RegistryKey>
|
||||
</Component>
|
||||
</ComponentGroup>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="SharpShellTools" version="2.2.0.0" />
|
||||
</packages>
|
||||
@@ -1,11 +1,11 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
# GNU GENERAL PUBLIC LICENSE
|
||||
## Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
## Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
@@ -68,7 +68,7 @@ patents cannot be used to render the program non-free.
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
## TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
@@ -618,9 +618,9 @@ an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
## END OF TERMS AND CONDITIONS
|
||||
----
|
||||
## How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||