diff --git a/.gitignore b/.gitignore
index 3285e5b..d656489 100644
--- a/.gitignore
+++ b/.gitignore
@@ -194,4 +194,7 @@ FakesAssemblies/
*.opt
# Ignore the installer signing commands file
-Installer/Installer.sign
\ No newline at end of file
+Installer/Installer.sign
+
+# Ignore the installer languages file because it is automatically generated
+Installer/Languages.wxs
diff --git a/Application/FileConverter/Application.xaml.cs b/Application/FileConverter/Application.xaml.cs
index 04318e5..467c973 100644
--- a/Application/FileConverter/Application.xaml.cs
+++ b/Application/FileConverter/Application.xaml.cs
@@ -31,7 +31,7 @@ namespace FileConverter
private static readonly Version Version = new Version()
{
Major = 1,
- Minor = 1,
+ Minor = 2,
Patch = 0,
};
@@ -341,8 +341,7 @@ namespace FileConverter
{
string inputFilePath = filePaths[index];
ConversionJob conversionJob = ConversionJobFactory.Create(conversionPreset, inputFilePath);
- conversionJob.PrepareConversion(inputFilePath);
-
+
this.conversionJobs.Add(conversionJob);
}
}
@@ -358,8 +357,14 @@ namespace FileConverter
private void ConvertFiles()
{
- Thread[] jobThreads = new Thread[this.numberOfConversionThread];
+ // Prepare conversions.
+ for (int index = 0; index < this.ConvertionJobs.Count; index++)
+ {
+ this.ConvertionJobs[index].PrepareConversion();
+ }
+ // Convert!
+ Thread[] jobThreads = new Thread[this.numberOfConversionThread];
while (true)
{
// Compute conversion flags.
@@ -396,7 +401,7 @@ namespace FileConverter
Thread thread = jobThreads[threadIndex];
if (thread == null || !thread.IsAlive)
{
- jobThread = Helpers.InstantiateThread("ConversionThread", this.ExecuteConversionJob);
+ jobThread = Helpers.InstantiateThread(conversionJob.GetType().Name, this.ExecuteConversionJob);
jobThreads[threadIndex] = jobThread;
break;
}
@@ -405,6 +410,12 @@ namespace FileConverter
if (jobThread != null)
{
jobThread.Start(conversionJob);
+
+ while (conversionJob.State == ConversionJob.ConversionState.Ready)
+ {
+ Debug.Log("Wait the launch of the conversion thread before launching any other thread.");
+ Thread.Sleep(20);
+ }
}
break;
diff --git a/Application/FileConverter/ConversionJobs/ConversionJob.cs b/Application/FileConverter/ConversionJobs/ConversionJob.cs
index be28ce9..a2dbe7b 100644
--- a/Application/FileConverter/ConversionJobs/ConversionJob.cs
+++ b/Application/FileConverter/ConversionJobs/ConversionJob.cs
@@ -19,24 +19,32 @@ namespace FileConverter.ConversionJobs
private CancelConversionJobCommand cancelCommand;
private string initialInputPath = string.Empty;
- private string[] outputFilePaths;
private int currentOuputFilePathIndex;
public ConversionJob()
{
this.State = ConversionState.Unknown;
this.ConversionPreset = null;
+ this.initialInputPath = string.Empty;
this.InputFilePath = string.Empty;
}
- public ConversionJob(ConversionPreset conversionPreset) : this()
+ public ConversionJob(ConversionPreset conversionPreset, string inputFilePath) : this()
{
if (conversionPreset == null)
{
- throw new ArgumentNullException("conversionPreset");
+ throw new ArgumentNullException(nameof(conversionPreset));
}
+ if (string.IsNullOrEmpty(inputFilePath))
+ {
+ throw new ArgumentNullException(nameof(inputFilePath));
+ }
+
+ this.initialInputPath = inputFilePath;
+ this.InputFilePath = inputFilePath;
this.ConversionPreset = conversionPreset;
+ this.UserState = Properties.Resources.ConversionStatePrepareConversion;
}
public event PropertyChangedEventHandler PropertyChanged;
@@ -67,22 +75,22 @@ namespace FileConverter.ConversionJobs
{
get
{
- if (this.outputFilePaths == null)
+ if (this.OutputFilePaths == null || this.OutputFilePaths.Length == 0)
{
return string.Empty;
}
if (this.CurrentOuputFilePathIndex < 0)
{
- return this.outputFilePaths[0];
+ return this.OutputFilePaths[0];
}
- if (this.CurrentOuputFilePathIndex >= this.outputFilePaths.Length)
+ if (this.CurrentOuputFilePathIndex >= this.OutputFilePaths.Length)
{
- return this.outputFilePaths[this.outputFilePaths.Length - 1];
+ return this.OutputFilePaths[this.OutputFilePaths.Length - 1];
}
- return this.outputFilePaths[this.CurrentOuputFilePathIndex];
+ return this.OutputFilePaths[this.CurrentOuputFilePathIndex];
}
}
@@ -200,24 +208,27 @@ namespace FileConverter.ConversionJobs
}
}
+ protected string[] OutputFilePaths
+ {
+ get;
+ private set;
+ }
+
public virtual bool CanStartConversion(ConversionFlags conversionFlags)
{
return (conversionFlags & ConversionFlags.CdDriveExtraction) == 0;
}
- public void PrepareConversion(string inputFilePath, string outputFilePath = null)
+ public void PrepareConversion(params string[] outputFilePaths)
{
- if (string.IsNullOrEmpty(inputFilePath))
- {
- throw new ArgumentNullException(nameof(inputFilePath));
- }
-
if (this.ConversionPreset == null)
{
throw new Exception("The conversion preset must be valid.");
}
- string extension = System.IO.Path.GetExtension(inputFilePath);
+ this.InputFilePath = this.initialInputPath;
+
+ string extension = System.IO.Path.GetExtension(this.initialInputPath);
extension = extension.Substring(1, extension.Length - 1);
string extensionCategory = Helpers.GetExtensionCategory(extension);
if (!Helpers.IsOutputTypeCompatibleWithCategory(this.ConversionPreset.OutputType, extensionCategory))
@@ -226,15 +237,22 @@ namespace FileConverter.ConversionJobs
return;
}
- this.initialInputPath = inputFilePath;
- this.InputFilePath = inputFilePath;
-
- int outputFilesCount = this.GetOuputFilesCount();
- this.outputFilePaths = new string[outputFilesCount];
-
- for (int index = 0; index < outputFilesCount; index++)
+ this.OutputFilePaths = outputFilePaths;
+ if (this.OutputFilePaths.Length == 0)
{
- string path = outputFilePath ?? this.ConversionPreset.GenerateOutputFilePath(inputFilePath, index + 1, outputFilesCount);
+ int outputFilesCount = this.GetOuputFilesCount();
+ this.OutputFilePaths = new string[outputFilesCount];
+ }
+
+ for (int index = 0; index < this.OutputFilePaths.Length; index++)
+ {
+ if (!string.IsNullOrEmpty(this.OutputFilePaths[index]))
+ {
+ // Don't generate a path if it has already been set.
+ continue;
+ }
+
+ string path = this.ConversionPreset.GenerateOutputFilePath(this.initialInputPath, index + 1, this.OutputFilePaths.Length);
if (!PathHelpers.IsPathValid(path))
{
@@ -252,7 +270,7 @@ namespace FileConverter.ConversionJobs
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);
+ System.IO.File.Move(this.initialInputPath, this.InputFilePath);
}
}
@@ -266,7 +284,7 @@ namespace FileConverter.ConversionJobs
// Make the output path valid.
try
{
- path = PathHelpers.GenerateUniquePath(path, this.outputFilePaths);
+ path = PathHelpers.GenerateUniquePath(path, this.OutputFilePaths);
}
catch (Exception exception)
{
@@ -275,7 +293,7 @@ namespace FileConverter.ConversionJobs
return;
}
- this.outputFilePaths[index] = path;
+ this.OutputFilePaths[index] = path;
}
this.CurrentOuputFilePathIndex = 0;
@@ -295,7 +313,10 @@ namespace FileConverter.ConversionJobs
Debug.Log("Job initialized: Preset: '{0}' Input: {1} Output: {2}", this.ConversionPreset.Name, this.InputFilePath, this.OutputFilePath);
- this.UserState = Properties.Resources.ConversionStateInQueue;
+ if (this.State != ConversionState.Failed)
+ {
+ this.UserState = Properties.Resources.ConversionStateInQueue;
+ }
}
public void StartConvertion()
@@ -336,11 +357,11 @@ namespace FileConverter.ConversionJobs
if (this.State == ConversionJob.ConversionState.Done && !this.AllOuputFilesExists())
{
- Debug.LogError("Can't find the output file(s).");
+ Debug.LogError(Properties.Resources.ErrorCantFindOutputFiles);
}
else if (this.State == ConversionJob.ConversionState.Failed && this.AtLeastOneOuputFilesExists())
{
- Debug.Log("The conversion job failed but there is an output file that does exists.");
+ Debug.Log(Properties.Resources.ErrorConversionFailedWithOutput);
}
}
@@ -372,9 +393,9 @@ namespace FileConverter.ConversionJobs
{
Debug.Log("Conversion Failed.");
- for (int index = 0; index < this.outputFilePaths.Length; index++)
+ for (int index = 0; index < this.OutputFilePaths.Length; index++)
{
- string outputFilePath = this.outputFilePaths[index];
+ string outputFilePath = this.OutputFilePaths[index];
try
{
if (System.IO.File.Exists(outputFilePath))
@@ -453,9 +474,9 @@ namespace FileConverter.ConversionJobs
private bool AllOuputFilesExists()
{
- for (int index = 0; index < this.outputFilePaths.Length; index++)
+ for (int index = 0; index < this.OutputFilePaths.Length; index++)
{
- string outputFilePath = this.outputFilePaths[index];
+ string outputFilePath = this.OutputFilePaths[index];
if (!System.IO.File.Exists(outputFilePath))
{
return false;
@@ -467,9 +488,9 @@ namespace FileConverter.ConversionJobs
private bool AtLeastOneOuputFilesExists()
{
- for (int index = 0; index < this.outputFilePaths.Length; index++)
+ for (int index = 0; index < this.OutputFilePaths.Length; index++)
{
- string outputFilePath = this.outputFilePaths[index];
+ string outputFilePath = this.OutputFilePaths[index];
if (System.IO.File.Exists(outputFilePath))
{
return true;
diff --git a/Application/FileConverter/ConversionJobs/ConversionJobFactory.cs b/Application/FileConverter/ConversionJobs/ConversionJobFactory.cs
index 83c8834..9791a66 100644
--- a/Application/FileConverter/ConversionJobs/ConversionJobFactory.cs
+++ b/Application/FileConverter/ConversionJobs/ConversionJobFactory.cs
@@ -10,31 +10,46 @@ namespace FileConverter.ConversionJobs
inputFileExtension = inputFileExtension.ToLowerInvariant().Substring(1, inputFileExtension.Length - 1);
if (inputFileExtension == "cda")
{
- return new ConversionJob_ExtractCDA(conversionPreset);
+ return new ConversionJob_ExtractCDA(conversionPreset, inputFilePath);
+ }
+
+ if (inputFileExtension == "docx" || inputFileExtension == "odt" || inputFileExtension == "doc")
+ {
+ return new ConversionJob_Word(conversionPreset, inputFilePath);
+ }
+
+ if (inputFileExtension == "xlsx" || inputFileExtension == "ods" || inputFileExtension == "xls")
+ {
+ return new ConversionJob_Excel(conversionPreset, inputFilePath);
+ }
+
+ if (inputFileExtension == "pptx" || inputFileExtension == "odp" || inputFileExtension == "ppt")
+ {
+ return new ConversionJob_PowerPoint(conversionPreset, inputFilePath);
}
if (conversionPreset.OutputType == OutputType.Ico)
{
- return new ConversionJob_Ico(conversionPreset);
+ return new ConversionJob_Ico(conversionPreset, inputFilePath);
}
if (conversionPreset.OutputType == OutputType.Gif)
{
- return new ConversionJob_Gif(conversionPreset);
+ return new ConversionJob_Gif(conversionPreset, inputFilePath);
+ }
+
+ if (conversionPreset.OutputType == OutputType.Pdf)
+ {
+ return new ConversionJob_ImageMagick(conversionPreset, inputFilePath);
}
if (Helpers.GetExtensionCategory(inputFileExtension) == Helpers.InputCategoryNames.Image ||
Helpers.GetExtensionCategory(inputFileExtension) == Helpers.InputCategoryNames.Document)
{
- return new ConversionJob_ImageMagick(conversionPreset);
+ return new ConversionJob_ImageMagick(conversionPreset, inputFilePath);
}
-
- if (conversionPreset.OutputType == OutputType.Pdf)
- {
- return new ConversionJob_ImageMagick(conversionPreset);
- }
-
- return new ConversionJob_FFMPEG(conversionPreset);
+
+ return new ConversionJob_FFMPEG(conversionPreset, inputFilePath);
}
}
}
diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_Excel.cs b/Application/FileConverter/ConversionJobs/ConversionJob_Excel.cs
new file mode 100644
index 0000000..bd80a7b
--- /dev/null
+++ b/Application/FileConverter/ConversionJobs/ConversionJob_Excel.cs
@@ -0,0 +1,228 @@
+// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
+
+namespace FileConverter.ConversionJobs
+{
+ using System;
+ using System.IO;
+ using System.Threading.Tasks;
+
+ using FileConverter.Diagnostics;
+
+ using Excel = Microsoft.Office.Interop.Excel;
+
+ public class ConversionJob_Excel : ConversionJob_Office
+ {
+ private Excel.Workbook document;
+ private Excel.Application application;
+
+ private string intermediateFilePath = string.Empty;
+ private ConversionJob pdf2ImageConversionJob = null;
+
+ public ConversionJob_Excel() : base()
+ {
+ }
+
+ public ConversionJob_Excel(ConversionPreset conversionPreset, string inputFilePath) : base(conversionPreset, inputFilePath)
+ {
+ }
+
+ protected override ApplicationName Application
+ {
+ get
+ {
+ return ApplicationName.Excel;
+ }
+ }
+
+ protected override int GetOuputFilesCount()
+ {
+ if (this.ConversionPreset.OutputType == OutputType.Pdf)
+ {
+ return 1;
+ }
+
+ if (!this.TryLoadDocumentIfNecessary())
+ {
+ return 1;
+ }
+
+ int pagesCount = 0;
+ foreach (object sheet in this.document.Sheets)
+ {
+ Excel.Worksheet worksheet = sheet as Excel.Worksheet;
+ if (worksheet != null)
+ {
+ pagesCount = worksheet.PageSetup.Pages.Count;
+ }
+ }
+
+ return pagesCount;
+ }
+
+ protected override void Initialize()
+ {
+ base.Initialize();
+
+ if (this.State == ConversionState.Failed)
+ {
+ return;
+ }
+
+ if (this.ConversionPreset == null)
+ {
+ throw new System.Exception("The conversion preset must be valid.");
+ }
+
+ // Initialize converters.
+ if (this.ConversionPreset.OutputType == OutputType.Pdf)
+ {
+ this.intermediateFilePath = this.OutputFilePath;
+ }
+ else
+ {
+ // Generate intermediate file path.
+ string fileName = Path.GetFileNameWithoutExtension(this.InputFilePath);
+ string tempPath = Path.GetTempPath();
+ this.intermediateFilePath = PathHelpers.GenerateUniquePath(tempPath + fileName + ".pdf");
+
+ ConversionPreset intermediatePreset = new ConversionPreset("Pdf to image", this.ConversionPreset, "pdf");
+ this.pdf2ImageConversionJob = ConversionJobFactory.Create(intermediatePreset, this.intermediateFilePath);
+ this.pdf2ImageConversionJob.PrepareConversion(this.OutputFilePaths);
+ }
+ }
+
+ protected override void Convert()
+ {
+ if (this.ConversionPreset == null)
+ {
+ throw new System.Exception("The conversion preset must be valid.");
+ }
+
+ this.UserState = Properties.Resources.ConversionStateReadDocument;
+
+ if (!this.TryLoadDocumentIfNecessary())
+ {
+ this.ConversionFailed(Properties.Resources.ErrorUnableToUseMicrosoftOffice);
+ return;
+ }
+
+ // Make this document the active document.
+ this.document.Activate();
+
+ this.UserState = Properties.Resources.ConversionStateConversion;
+
+ Diagnostics.Debug.Log("Convert excel document to pdf.");
+ this.document.ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, this.intermediateFilePath);
+
+ Diagnostics.Debug.Log("Close excel document '{0}'.", this.InputFilePath);
+ this.document.Close(false);
+ this.document = null;
+
+ this.ReleaseOfficeApplicationInstanceIfNeeded();
+
+ if (this.pdf2ImageConversionJob != null)
+ {
+ if (!System.IO.File.Exists(this.intermediateFilePath))
+ {
+ this.ConversionFailed(Properties.Resources.ErrorCantFindOutputFiles);
+ return;
+ }
+
+ Task updateProgress = this.UpdateProgress();
+
+ Diagnostics.Debug.Log("Convert pdf to images.");
+
+ this.pdf2ImageConversionJob.StartConvertion();
+
+ if (this.pdf2ImageConversionJob.State != ConversionState.Done)
+ {
+ this.ConversionFailed(this.pdf2ImageConversionJob.ErrorMessage);
+ return;
+ }
+
+ if (!string.IsNullOrEmpty(this.intermediateFilePath))
+ {
+ Diagnostics.Debug.Log("Delete intermediate file {0}.", this.intermediateFilePath);
+
+ File.Delete(this.intermediateFilePath);
+ }
+
+ updateProgress.Wait();
+ }
+ }
+
+ protected override void InitializeOfficeApplicationInstanceIfNecessary()
+ {
+ if (this.application != null)
+ {
+ return;
+ }
+
+ // Initialize excel application.
+ Diagnostics.Debug.Log("Instantiate excel application via interop.");
+ this.application = new Excel.Application
+ {
+ Visible = false
+ };
+ }
+
+ protected override void ReleaseOfficeApplicationInstanceIfNeeded()
+ {
+ if (this.application == null)
+ {
+ return;
+ }
+
+ Diagnostics.Debug.Log("Quit excel application via interop.");
+ this.application.Quit();
+ this.application = null;
+ }
+
+ private async Task UpdateProgress()
+ {
+ while (this.pdf2ImageConversionJob.State != ConversionState.Done &&
+ this.pdf2ImageConversionJob.State != ConversionState.Failed)
+ {
+ if (this.pdf2ImageConversionJob != null && this.pdf2ImageConversionJob.State == ConversionState.InProgress)
+ {
+ this.Progress = this.pdf2ImageConversionJob.Progress;
+ }
+
+ if (this.pdf2ImageConversionJob != null && this.pdf2ImageConversionJob.State == ConversionState.InProgress)
+ {
+ this.Progress = this.pdf2ImageConversionJob.Progress;
+ this.UserState = this.pdf2ImageConversionJob.UserState;
+ }
+
+ await Task.Delay(40);
+ }
+ }
+
+ private bool TryLoadDocumentIfNecessary()
+ {
+ try
+ {
+ this.InitializeOfficeApplicationInstanceIfNecessary();
+ }
+ catch (Exception exception)
+ {
+ Debug.Log(exception.ToString());
+ Debug.Log("Failed to initialize office application.");
+ }
+
+ if (this.application == null)
+ {
+ return false;
+ }
+
+ if (this.document == null)
+ {
+ Diagnostics.Debug.Log("Load excel document '{0}'.", this.InputFilePath);
+
+ this.document = this.application.Workbooks.Open(this.InputFilePath, System.Reflection.Missing.Value, true);
+ }
+
+ return this.document != null;
+ }
+ }
+}
diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_ExtractCDA.cs b/Application/FileConverter/ConversionJobs/ConversionJob_ExtractCDA.cs
index 85e8726..187c0c1 100644
--- a/Application/FileConverter/ConversionJobs/ConversionJob_ExtractCDA.cs
+++ b/Application/FileConverter/ConversionJobs/ConversionJob_ExtractCDA.cs
@@ -22,10 +22,12 @@ namespace FileConverter.ConversionJobs
public ConversionJob_ExtractCDA() : base()
{
+ this.IsCancelable = true;
}
- public ConversionJob_ExtractCDA(ConversionPreset conversionPreset) : base(conversionPreset)
+ public ConversionJob_ExtractCDA(ConversionPreset conversionPreset, string inputFilePath) : base(conversionPreset, inputFilePath)
{
+ this.IsCancelable = true;
}
protected override InputPostConversionAction InputPostConversionAction
@@ -35,7 +37,14 @@ namespace FileConverter.ConversionJobs
return InputPostConversionAction.None;
}
}
-
+
+ public override void Cancel()
+ {
+ base.Cancel();
+
+ this.compressionConversionJob.Cancel();
+ }
+
protected override void Initialize()
{
base.Initialize();
@@ -103,7 +112,7 @@ namespace FileConverter.ConversionJobs
// Sub conversion job (for compression).
this.compressionConversionJob = ConversionJobFactory.Create(this.ConversionPreset, this.intermediateFilePath);
- this.compressionConversionJob.PrepareConversion(this.intermediateFilePath, this.OutputFilePath);
+ this.compressionConversionJob.PrepareConversion(this.OutputFilePath);
this.compressionThread = Helpers.InstantiateThread("CDACompressionThread", this.CompressAsync);
}
@@ -193,6 +202,12 @@ namespace FileConverter.ConversionJobs
private void CdReadProgress(object sender, ReadProgressEventArgs eventArgs)
{
+ if (this.CancelIsRequested)
+ {
+ eventArgs.CancelRead = true;
+ return;
+ }
+
this.Progress = (float)eventArgs.BytesRead / (float)eventArgs.Bytes2Read;
eventArgs.CancelRead |= this.State != ConversionState.InProgress;
diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.Converters.cs b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.Converters.cs
index a2e3210..4862d7e 100644
--- a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.Converters.cs
+++ b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.Converters.cs
@@ -197,7 +197,7 @@ namespace FileConverter.ConversionJobs
}
///
- /// Convert video quality index to lib theora video quality level.
+ /// Convert video quality index to lib theora video quality level.
///
/// The quality index.
/// Returns the video quality index.
diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs
index 6cb53ef..df6d991 100644
--- a/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs
+++ b/Application/FileConverter/ConversionJobs/ConversionJob_FFMPEG.cs
@@ -28,7 +28,7 @@ namespace FileConverter.ConversionJobs
this.IsCancelable = true;
}
- public ConversionJob_FFMPEG(ConversionPreset conversionPreset) : base(conversionPreset)
+ public ConversionJob_FFMPEG(ConversionPreset conversionPreset, string inputFilePath) : base(conversionPreset, inputFilePath)
{
this.IsCancelable = true;
}
diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_Gif.cs b/Application/FileConverter/ConversionJobs/ConversionJob_Gif.cs
index d14f6cd..8035b12 100644
--- a/Application/FileConverter/ConversionJobs/ConversionJob_Gif.cs
+++ b/Application/FileConverter/ConversionJobs/ConversionJob_Gif.cs
@@ -12,8 +12,17 @@ namespace FileConverter.ConversionJobs
private ConversionJob pngConversionJob = null;
private ConversionJob gifConversionJob = null;
- public ConversionJob_Gif(ConversionPreset conversionPreset) : base(conversionPreset)
+ public ConversionJob_Gif(ConversionPreset conversionPreset, string inputFilePath) : base(conversionPreset, inputFilePath)
{
+ this.IsCancelable = true;
+ }
+
+ public override void Cancel()
+ {
+ base.Cancel();
+
+ this.pngConversionJob.Cancel();
+ this.gifConversionJob.Cancel();
}
protected override void Initialize()
@@ -41,7 +50,7 @@ namespace FileConverter.ConversionJobs
// Convert input in png file to send it to ffmpeg for the gif conversion.
ConversionPreset intermediatePreset = new ConversionPreset("To compatible image", OutputType.Png, this.ConversionPreset.InputTypes.ToArray());
this.pngConversionJob = ConversionJobFactory.Create(intermediatePreset, this.InputFilePath);
- this.pngConversionJob.PrepareConversion(this.InputFilePath, this.intermediateFilePath);
+ this.pngConversionJob.PrepareConversion(this.intermediateFilePath);
inputFilePath = this.intermediateFilePath;
}
@@ -51,8 +60,8 @@ namespace FileConverter.ConversionJobs
}
// Convert png file into ico.
- this.gifConversionJob = new ConversionJob_FFMPEG(this.ConversionPreset);
- this.gifConversionJob.PrepareConversion(inputFilePath, this.OutputFilePath);
+ this.gifConversionJob = new ConversionJob_FFMPEG(this.ConversionPreset, inputFilePath);
+ this.gifConversionJob.PrepareConversion(this.OutputFilePath);
}
protected override void Convert()
diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_Ico.cs b/Application/FileConverter/ConversionJobs/ConversionJob_Ico.cs
index e8d0ff5..46f8b73 100644
--- a/Application/FileConverter/ConversionJobs/ConversionJob_Ico.cs
+++ b/Application/FileConverter/ConversionJobs/ConversionJob_Ico.cs
@@ -11,8 +11,17 @@ namespace FileConverter.ConversionJobs
private ConversionJob pngConversionJob;
private ConversionJob icoConversionJob;
- public ConversionJob_Ico(ConversionPreset conversionPreset) : base(conversionPreset)
+ public ConversionJob_Ico(ConversionPreset conversionPreset, string inputFilePath) : base(conversionPreset, inputFilePath)
{
+ this.IsCancelable = true;
+ }
+
+ public override void Cancel()
+ {
+ base.Cancel();
+
+ this.pngConversionJob.Cancel();
+ this.icoConversionJob.Cancel();
}
protected override void Initialize()
@@ -34,11 +43,11 @@ namespace FileConverter.ConversionJobs
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);
+ this.pngConversionJob.PrepareConversion(this.intermediateFilePath);
// Convert png file into ico.
- this.icoConversionJob = new ConversionJob_FFMPEG(this.ConversionPreset);
- this.icoConversionJob.PrepareConversion(this.intermediateFilePath, this.OutputFilePath);
+ this.icoConversionJob = new ConversionJob_FFMPEG(this.ConversionPreset, this.intermediateFilePath);
+ this.icoConversionJob.PrepareConversion(this.OutputFilePath);
}
protected override void Convert()
diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_ImageMagick.cs b/Application/FileConverter/ConversionJobs/ConversionJob_ImageMagick.cs
index 4ccda9f..f6cf840 100644
--- a/Application/FileConverter/ConversionJobs/ConversionJob_ImageMagick.cs
+++ b/Application/FileConverter/ConversionJobs/ConversionJob_ImageMagick.cs
@@ -14,10 +14,12 @@ namespace FileConverter.ConversionJobs
public ConversionJob_ImageMagick() : base()
{
+ this.IsCancelable = true;
}
- public ConversionJob_ImageMagick(ConversionPreset conversionPreset) : base(conversionPreset)
+ public ConversionJob_ImageMagick(ConversionPreset conversionPreset, string inputFilePath) : base(conversionPreset, inputFilePath)
{
+ this.IsCancelable = true;
}
protected override void Initialize()
@@ -85,7 +87,7 @@ namespace FileConverter.ConversionJobs
float scaleFactor = this.ConversionPreset.GetSettingsValue(ConversionPreset.ConversionSettingKeys.ImageScale);
if (Math.Abs(scaleFactor - 1f) >= 0.005f)
{
- Debug.Log("Apply scale factor: {0}%.", scaleFactor*100);
+ Debug.Log("Apply scale factor: {0}%.", scaleFactor * 100);
dpi *= scaleFactor;
}
@@ -93,7 +95,7 @@ namespace FileConverter.ConversionJobs
Debug.Log("Density: {0}dpi.", dpi);
settings.Density = new Density(dpi, dpi);
- this.UserState = Properties.Resources.ConversionStateReadPdf;
+ this.UserState = Properties.Resources.ConversionStateReadDocument;
using (MagickImageCollection images = new MagickImageCollection())
{
@@ -124,9 +126,9 @@ namespace FileConverter.ConversionJobs
float scaleFactor = this.ConversionPreset.GetSettingsValue(ConversionPreset.ConversionSettingKeys.ImageScale);
if (Math.Abs(scaleFactor - 1f) >= 0.005f)
{
- Debug.Log("Apply scale factor: {0}%.", scaleFactor*100);
+ Debug.Log("Apply scale factor: {0}%.", scaleFactor * 100);
- image.Scale(new Percentage(scaleFactor*100f));
+ image.Scale(new Percentage(scaleFactor * 100f));
}
}
@@ -148,7 +150,7 @@ namespace FileConverter.ConversionJobs
{
int referenceSize = System.Math.Min(image.Width, image.Height);
int size = 2;
- while (size*2 <= referenceSize)
+ while (size * 2 <= referenceSize)
{
size *= 2;
}
@@ -187,6 +189,10 @@ namespace FileConverter.ConversionJobs
case OutputType.Pdf:
break;
+ case OutputType.Webp:
+ image.Quality = this.ConversionPreset.GetSettingsValue(ConversionPreset.ConversionSettingKeys.ImageQuality);
+ break;
+
default:
this.ConversionFailed(string.Format(Properties.Resources.ErrorUnsupportedOutputFormat, this.ConversionPreset.OutputType));
image.Progress -= this.Image_Progress;
@@ -199,8 +205,14 @@ namespace FileConverter.ConversionJobs
private void Image_Progress(object sender, ProgressEventArgs eventArgs)
{
+ if (this.CancelIsRequested)
+ {
+ eventArgs.Cancel = true;
+ return;
+ }
+
float alreadyCompletedPages = this.CurrentOuputFilePathIndex / (float)this.pageCount;
- this.Progress = alreadyCompletedPages + (float)eventArgs.Progress.ToDouble() / (100f * this.pageCount);
+ this.Progress = alreadyCompletedPages + ((float)eventArgs.Progress.ToDouble() / (100f * this.pageCount));
}
}
}
diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_Office.cs b/Application/FileConverter/ConversionJobs/ConversionJob_Office.cs
new file mode 100644
index 0000000..1519302
--- /dev/null
+++ b/Application/FileConverter/ConversionJobs/ConversionJob_Office.cs
@@ -0,0 +1,67 @@
+// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
+
+namespace FileConverter.ConversionJobs
+{
+ public abstract class ConversionJob_Office : ConversionJob
+ {
+ protected ConversionJob_Office() : base()
+ {
+ }
+
+ protected ConversionJob_Office(ConversionPreset conversionPreset, string inputFilePath) : base(conversionPreset, inputFilePath)
+ {
+ }
+
+ public enum ApplicationName
+ {
+ None,
+
+ Word,
+ Excel,
+ PowerPoint
+ }
+
+ protected abstract ApplicationName Application
+ {
+ get;
+ }
+
+ protected override void Initialize()
+ {
+ base.Initialize();
+
+ if (!Helpers.IsMicrosoftOfficeApplicationAvailable(this.Application))
+ {
+ switch (this.Application)
+ {
+ case ApplicationName.Word:
+ this.ConversionFailed(Properties.Resources.ErrorMicrosoftWordIsNotAvailable);
+ return;
+
+ case ApplicationName.PowerPoint:
+ this.ConversionFailed(Properties.Resources.ErrorMicrosoftPowerPointIsNotAvailable);
+ return;
+
+ case ApplicationName.Excel:
+ this.ConversionFailed(Properties.Resources.ErrorMicrosoftExcelIsNotAvailable);
+ return;
+
+ default:
+ this.ConversionFailed(Properties.Resources.ErrorMicrosoftOfficeIsNotAvailable);
+ return;
+ }
+ }
+ }
+
+ protected override void OnConversionFailed()
+ {
+ base.OnConversionFailed();
+
+ this.ReleaseOfficeApplicationInstanceIfNeeded();
+ }
+
+ protected abstract void InitializeOfficeApplicationInstanceIfNecessary();
+
+ protected abstract void ReleaseOfficeApplicationInstanceIfNeeded();
+ }
+}
\ No newline at end of file
diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_PowerPoint.cs b/Application/FileConverter/ConversionJobs/ConversionJob_PowerPoint.cs
new file mode 100644
index 0000000..1c46344
--- /dev/null
+++ b/Application/FileConverter/ConversionJobs/ConversionJob_PowerPoint.cs
@@ -0,0 +1,214 @@
+// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
+
+namespace FileConverter.ConversionJobs
+{
+ using System;
+ using System.IO;
+ using System.Threading.Tasks;
+
+ using FileConverter.Diagnostics;
+ using Microsoft.Office.Core;
+
+ using PowerPoint = Microsoft.Office.Interop.PowerPoint;
+
+ public class ConversionJob_PowerPoint : ConversionJob_Office
+ {
+ private PowerPoint.Presentation document;
+ private PowerPoint.Application application;
+
+ private string intermediateFilePath = string.Empty;
+ private ConversionJob pdf2ImageConversionJob = null;
+
+ public ConversionJob_PowerPoint() : base()
+ {
+ }
+
+ public ConversionJob_PowerPoint(ConversionPreset conversionPreset, string inputFilePath) : base(conversionPreset, inputFilePath)
+ {
+ }
+
+ protected override ApplicationName Application
+ {
+ get
+ {
+ return ApplicationName.PowerPoint;
+ }
+ }
+
+ protected override int GetOuputFilesCount()
+ {
+ if (this.ConversionPreset.OutputType == OutputType.Pdf)
+ {
+ return 1;
+ }
+
+ if (!this.TryLoadDocumentIfNecessary())
+ {
+ return 1;
+ }
+
+ int pagesCount = this.document.Slides.Count;
+ return pagesCount;
+ }
+
+ protected override void Initialize()
+ {
+ base.Initialize();
+
+ if (this.State == ConversionState.Failed)
+ {
+ return;
+ }
+
+ if (this.ConversionPreset == null)
+ {
+ throw new System.Exception("The conversion preset must be valid.");
+ }
+
+ // Initialize converters.
+ if (this.ConversionPreset.OutputType == OutputType.Pdf)
+ {
+ this.intermediateFilePath = this.OutputFilePath;
+ }
+ else
+ {
+ // Generate intermediate file path.
+ string fileName = Path.GetFileNameWithoutExtension(this.InputFilePath);
+ string tempPath = Path.GetTempPath();
+ this.intermediateFilePath = PathHelpers.GenerateUniquePath(tempPath + fileName + ".pdf");
+
+ ConversionPreset intermediatePreset = new ConversionPreset("Pdf to image", this.ConversionPreset, "pdf");
+ this.pdf2ImageConversionJob = ConversionJobFactory.Create(intermediatePreset, this.intermediateFilePath);
+ this.pdf2ImageConversionJob.PrepareConversion(this.OutputFilePaths);
+ }
+ }
+
+ protected override void Convert()
+ {
+ if (this.ConversionPreset == null)
+ {
+ throw new System.Exception("The conversion preset must be valid.");
+ }
+
+ this.UserState = Properties.Resources.ConversionStateReadDocument;
+
+ if (!this.TryLoadDocumentIfNecessary())
+ {
+ this.ConversionFailed(Properties.Resources.ErrorUnableToUseMicrosoftOffice);
+ return;
+ }
+
+ this.UserState = Properties.Resources.ConversionStateConversion;
+
+ Diagnostics.Debug.Log("Convert PowerPoint document to pdf.");
+ this.document.ExportAsFixedFormat(this.intermediateFilePath, PowerPoint.PpFixedFormatType.ppFixedFormatTypePDF);
+
+ Diagnostics.Debug.Log("Close PowerPoint document '{0}'.", this.InputFilePath);
+ this.document.Close();
+ this.document = null;
+
+ this.ReleaseOfficeApplicationInstanceIfNeeded();
+
+ if (this.pdf2ImageConversionJob != null)
+ {
+ if (!System.IO.File.Exists(this.intermediateFilePath))
+ {
+ this.ConversionFailed(Properties.Resources.ErrorCantFindOutputFiles);
+ return;
+ }
+
+ Task updateProgress = this.UpdateProgress();
+
+ Diagnostics.Debug.Log("Convert pdf to images.");
+
+ this.pdf2ImageConversionJob.StartConvertion();
+
+ if (this.pdf2ImageConversionJob.State != ConversionState.Done)
+ {
+ this.ConversionFailed(this.pdf2ImageConversionJob.ErrorMessage);
+ return;
+ }
+
+ if (!string.IsNullOrEmpty(this.intermediateFilePath))
+ {
+ Diagnostics.Debug.Log("Delete intermediate file {0}.", this.intermediateFilePath);
+
+ File.Delete(this.intermediateFilePath);
+ }
+
+ updateProgress.Wait();
+ }
+ }
+
+ protected override void InitializeOfficeApplicationInstanceIfNecessary()
+ {
+ if (this.application != null)
+ {
+ return;
+ }
+
+ // Initialize PowerPoint application.
+ Diagnostics.Debug.Log("Instantiate PowerPoint application via interop.");
+ this.application = new PowerPoint.Application();
+ }
+
+ protected override void ReleaseOfficeApplicationInstanceIfNeeded()
+ {
+ if (this.application == null)
+ {
+ return;
+ }
+
+ Diagnostics.Debug.Log("Quit PowerPoint application via interop.");
+ this.application.Quit();
+ this.application = null;
+ }
+
+ private async Task UpdateProgress()
+ {
+ while (this.pdf2ImageConversionJob.State != ConversionState.Done &&
+ this.pdf2ImageConversionJob.State != ConversionState.Failed)
+ {
+ if (this.pdf2ImageConversionJob != null && this.pdf2ImageConversionJob.State == ConversionState.InProgress)
+ {
+ this.Progress = this.pdf2ImageConversionJob.Progress;
+ }
+
+ if (this.pdf2ImageConversionJob != null && this.pdf2ImageConversionJob.State == ConversionState.InProgress)
+ {
+ this.Progress = this.pdf2ImageConversionJob.Progress;
+ this.UserState = this.pdf2ImageConversionJob.UserState;
+ }
+
+ await Task.Delay(40);
+ }
+ }
+
+ private bool TryLoadDocumentIfNecessary()
+ {
+ try
+ {
+ this.InitializeOfficeApplicationInstanceIfNecessary();
+ }
+ catch (Exception exception)
+ {
+ Debug.Log(exception.ToString());
+ Debug.Log("Failed to initialize office application.");
+ }
+
+ if (this.application == null)
+ {
+ return false;
+ }
+
+ if (this.document == null)
+ {
+ Diagnostics.Debug.Log("Load PowerPoint document '{0}'.", this.InputFilePath);
+
+ this.document = this.application.Presentations.Open(this.InputFilePath, ReadOnly: MsoTriState.msoTrue, WithWindow: MsoTriState.msoFalse);
+ }
+
+ return this.document != null;
+ }
+ }
+}
diff --git a/Application/FileConverter/ConversionJobs/ConversionJob_Word.cs b/Application/FileConverter/ConversionJobs/ConversionJob_Word.cs
new file mode 100644
index 0000000..c102c00
--- /dev/null
+++ b/Application/FileConverter/ConversionJobs/ConversionJob_Word.cs
@@ -0,0 +1,220 @@
+// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
+
+namespace FileConverter.ConversionJobs
+{
+ using System;
+ using System.IO;
+ using System.Threading.Tasks;
+
+ using FileConverter.Diagnostics;
+
+ using Word = Microsoft.Office.Interop.Word;
+
+ public class ConversionJob_Word : ConversionJob_Office
+ {
+ private Word.Document document;
+ private Word.Application application;
+
+ private string intermediateFilePath = string.Empty;
+ private ConversionJob pdf2ImageConversionJob = null;
+
+ public ConversionJob_Word() : base()
+ {
+ }
+
+ public ConversionJob_Word(ConversionPreset conversionPreset, string inputFilePath) : base(conversionPreset, inputFilePath)
+ {
+ }
+
+ protected override ApplicationName Application
+ {
+ get
+ {
+ return ApplicationName.Word;
+ }
+ }
+
+ protected override int GetOuputFilesCount()
+ {
+ if (this.ConversionPreset.OutputType == OutputType.Pdf)
+ {
+ return 1;
+ }
+
+ if (!this.TryLoadDocumentIfNecessary())
+ {
+ return 1;
+ }
+
+ int pagesCount = this.document.ComputeStatistics(Word.WdStatistic.wdStatisticPages);
+
+ return pagesCount;
+ }
+
+ protected override void Initialize()
+ {
+ base.Initialize();
+
+ if (this.State == ConversionState.Failed)
+ {
+ return;
+ }
+
+ if (this.ConversionPreset == null)
+ {
+ throw new System.Exception("The conversion preset must be valid.");
+ }
+
+ // Initialize converters.
+ if (this.ConversionPreset.OutputType == OutputType.Pdf)
+ {
+ this.intermediateFilePath = this.OutputFilePath;
+ }
+ else
+ {
+ // Generate intermediate file path.
+ string fileName = Path.GetFileNameWithoutExtension(this.InputFilePath);
+ string tempPath = Path.GetTempPath();
+ this.intermediateFilePath = PathHelpers.GenerateUniquePath(tempPath + fileName + ".pdf");
+
+ ConversionPreset intermediatePreset = new ConversionPreset("Pdf to image", this.ConversionPreset, "pdf");
+ this.pdf2ImageConversionJob = ConversionJobFactory.Create(intermediatePreset, this.intermediateFilePath);
+ this.pdf2ImageConversionJob.PrepareConversion(this.OutputFilePaths);
+ }
+ }
+
+ protected override void Convert()
+ {
+ if (this.ConversionPreset == null)
+ {
+ throw new System.Exception("The conversion preset must be valid.");
+ }
+
+ this.UserState = Properties.Resources.ConversionStateReadDocument;
+
+ if (!this.TryLoadDocumentIfNecessary())
+ {
+ this.ConversionFailed(Properties.Resources.ErrorUnableToUseMicrosoftOffice);
+ return;
+ }
+
+ // Make this document the active document.
+ this.document.Activate();
+
+ this.UserState = Properties.Resources.ConversionStateConversion;
+
+ Diagnostics.Debug.Log("Convert word document to pdf.");
+ this.document.ExportAsFixedFormat(this.intermediateFilePath, Word.WdExportFormat.wdExportFormatPDF);
+
+ Diagnostics.Debug.Log("Close word document '{0}'.", this.InputFilePath);
+ this.document.Close(Word.WdSaveOptions.wdDoNotSaveChanges);
+ this.document = null;
+
+ this.ReleaseOfficeApplicationInstanceIfNeeded();
+
+ if (this.pdf2ImageConversionJob != null)
+ {
+ if (!System.IO.File.Exists(this.intermediateFilePath))
+ {
+ this.ConversionFailed(Properties.Resources.ErrorCantFindOutputFiles);
+ return;
+ }
+
+ Task updateProgress = this.UpdateProgress();
+
+ Diagnostics.Debug.Log("Convert pdf to images.");
+
+ this.pdf2ImageConversionJob.StartConvertion();
+
+ if (this.pdf2ImageConversionJob.State != ConversionState.Done)
+ {
+ this.ConversionFailed(this.pdf2ImageConversionJob.ErrorMessage);
+ return;
+ }
+
+ if (!string.IsNullOrEmpty(this.intermediateFilePath))
+ {
+ Diagnostics.Debug.Log("Delete intermediate file {0}.", this.intermediateFilePath);
+
+ File.Delete(this.intermediateFilePath);
+ }
+
+ updateProgress.Wait();
+ }
+ }
+
+ protected override void InitializeOfficeApplicationInstanceIfNecessary()
+ {
+ if (this.application != null)
+ {
+ return;
+ }
+
+ // Initialize word application.
+ Diagnostics.Debug.Log("Instantiate word application via interop.");
+ this.application = new Microsoft.Office.Interop.Word.Application
+ {
+ Visible = false
+ };
+ }
+
+ protected override void ReleaseOfficeApplicationInstanceIfNeeded()
+ {
+ if (this.application == null)
+ {
+ return;
+ }
+
+ Diagnostics.Debug.Log("Quit word application via interop.");
+ this.application.Quit();
+ this.application = null;
+ }
+
+ private async Task UpdateProgress()
+ {
+ while (this.pdf2ImageConversionJob.State != ConversionState.Done &&
+ this.pdf2ImageConversionJob.State != ConversionState.Failed)
+ {
+ if (this.pdf2ImageConversionJob != null && this.pdf2ImageConversionJob.State == ConversionState.InProgress)
+ {
+ this.Progress = this.pdf2ImageConversionJob.Progress;
+ }
+
+ if (this.pdf2ImageConversionJob != null && this.pdf2ImageConversionJob.State == ConversionState.InProgress)
+ {
+ this.Progress = this.pdf2ImageConversionJob.Progress;
+ this.UserState = this.pdf2ImageConversionJob.UserState;
+ }
+
+ await Task.Delay(40);
+ }
+ }
+
+ private bool TryLoadDocumentIfNecessary()
+ {
+ try
+ {
+ this.InitializeOfficeApplicationInstanceIfNecessary();
+ }
+ catch (Exception exception)
+ {
+ Debug.Log(exception.ToString());
+ Debug.Log("Failed to initialize office application.");
+ }
+
+ if (this.application == null)
+ {
+ return false;
+ }
+
+ if (this.document == null)
+ {
+ Diagnostics.Debug.Log("Load word document '{0}'.", this.InputFilePath);
+
+ this.document = this.application.Documents.Open(this.InputFilePath, System.Reflection.Missing.Value, true);
+ }
+
+ return this.document != null;
+ }
+ }
+}
diff --git a/Application/FileConverter/ConversionPreset/ConversionPreset.cs b/Application/FileConverter/ConversionPreset/ConversionPreset.cs
index 5228799..bd550bf 100644
--- a/Application/FileConverter/ConversionPreset/ConversionPreset.cs
+++ b/Application/FileConverter/ConversionPreset/ConversionPreset.cs
@@ -30,7 +30,7 @@ namespace FileConverter
this.Name = Properties.Resources.DefaultPresetName;
}
- public ConversionPreset(string name, OutputType outputType, string[] inputTypes)
+ public ConversionPreset(string name, OutputType outputType, params string[] inputTypes)
{
this.Name = name;
this.OutputType = outputType;
@@ -41,7 +41,7 @@ namespace FileConverter
this.outputFileNameTemplate = "(p)(f)";
}
- public ConversionPreset(string name, ConversionPreset source)
+ public ConversionPreset(string name, ConversionPreset source, params string[] additionalInputTypes)
{
this.Name = name;
this.OutputType = source.outputType;
@@ -51,6 +51,11 @@ namespace FileConverter
inputTypeList.AddRange(source.inputTypes);
}
+ if (additionalInputTypes != null)
+ {
+ inputTypeList.AddRange(additionalInputTypes);
+ }
+
this.InputTypes = inputTypeList;
this.outputFileNameTemplate = source.OutputFileNameTemplate;
@@ -503,6 +508,14 @@ namespace FileConverter
this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.ImageMaximumSize, "0");
break;
+ case OutputType.Webp:
+ this.InitializeSettingsValue(ConversionPreset.ConversionSettingKeys.ImageQuality, "40");
+ 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.Ico:
break;
diff --git a/Application/FileConverter/Diagnostics/Debug.cs b/Application/FileConverter/Diagnostics/Debug.cs
index 2eb8fdf..350999c 100644
--- a/Application/FileConverter/Diagnostics/Debug.cs
+++ b/Application/FileConverter/Diagnostics/Debug.cs
@@ -5,9 +5,9 @@ namespace FileConverter.Diagnostics
using System;
using System.Collections.Generic;
using System.ComponentModel;
- using System.Diagnostics;
using System.IO;
using System.Linq;
+ using System.Threading;
using System.Windows;
public static class Debug
@@ -54,12 +54,14 @@ namespace FileConverter.Diagnostics
{
DiagnosticsData diagnosticsData;
- int threadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
+ Thread currentThread = System.Threading.Thread.CurrentThread;
+ int threadId = 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");
+ string threadName = Debug.threadCount > 0 ? $"{currentThread.Name} ({Debug.threadCount})" : "Application";
+ diagnosticsData = new DiagnosticsData(threadName);
diagnosticsData.Initialize(Debug.diagnosticsFolderPath, threadId);
Debug.diagnosticsDataById.Add(threadId, diagnosticsData);
Debug.threadCount++;
diff --git a/Application/FileConverter/Diagnostics/DiagnosticsData.cs b/Application/FileConverter/Diagnostics/DiagnosticsData.cs
index ac2efc6..1507bcb 100644
--- a/Application/FileConverter/Diagnostics/DiagnosticsData.cs
+++ b/Application/FileConverter/Diagnostics/DiagnosticsData.cs
@@ -77,7 +77,7 @@ namespace FileConverter.Diagnostics
public void Log(string message, params object[] arguments)
{
- string log = string.Format(message, arguments);
+ string log = arguments.Length > 0 ? string.Format(message, arguments) : message;
this.logMessages.Add(log);
this.logFileWriter.WriteLine(log);
diff --git a/Application/FileConverter/FileConverter.csproj b/Application/FileConverter/FileConverter.csproj
index f4f9c49..dad77ed 100644
--- a/Application/FileConverter/FileConverter.csproj
+++ b/Application/FileConverter/FileConverter.csproj
@@ -66,7 +66,6 @@
true
-
..\..\packages\Magick.NET-Q16-AnyCPU.7.0.2.900\lib\net40-client\Magick.NET-Q16-AnyCPU.dll
True
@@ -74,23 +73,28 @@
..\..\Middleware\Markdown.Xaml.dll
+
+ True
+
+
+ True
+
+
+ True
+
+
+ True
+
-
False
..\..\Middleware\Ripper.dll
-
-
-
-
-
-
4.0
@@ -120,12 +124,16 @@
+
+
+
+
@@ -141,11 +149,13 @@
Resources.fr.resx
True
True
+ True
Resources.en.resx
True
True
+ True
@@ -257,6 +267,7 @@
PublicResXFileCodeGenerator
Resources.Designer.cs
+ Designer
diff --git a/Application/FileConverter/Helpers.cs b/Application/FileConverter/Helpers.cs
index e748b31..a4c022b 100644
--- a/Application/FileConverter/Helpers.cs
+++ b/Application/FileConverter/Helpers.cs
@@ -10,17 +10,20 @@ namespace FileConverter
using System.Reflection;
using System.Threading;
+ using FileConverter.ConversionJobs;
+ using Microsoft.Win32;
+
public static class Helpers
{
public static IEnumerable GetSupportedCultures()
{
- //Get all culture
+ // Get all cultures.
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
- //Find the location where application installed.
+ // Find the location where application installed.
string exeLocation = Path.GetDirectoryName(Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path));
- //Return all culture for which satellite folder found with culture code.
+ // Return all culture for which satellite folder found with culture code.
return cultures.Where(cultureInfo => Directory.Exists(Path.Combine(exeLocation, "Languages", cultureInfo.Name)));
}
@@ -67,12 +70,22 @@ namespace FileConverter
case "tiff":
case "svg":
case "xcf":
+ case "webp":
return InputCategoryNames.Image;
case "gif":
return InputCategoryNames.AnimatedImage;
case "pdf":
+ case "doc":
+ case "docx":
+ case "ppt":
+ case "pptx":
+ case "odp":
+ case "ods":
+ case "odt":
+ case "xls":
+ case "xlsx":
return InputCategoryNames.Document;
}
@@ -106,13 +119,14 @@ namespace FileConverter
case OutputType.Ico:
case OutputType.Jpg:
case OutputType.Png:
+ case OutputType.Webp:
return category == InputCategoryNames.Image || category == InputCategoryNames.Document;
case OutputType.Gif:
return category == InputCategoryNames.Image || category == InputCategoryNames.Video || category == InputCategoryNames.AnimatedImage;
case OutputType.Pdf:
- return category == InputCategoryNames.Image;
+ return category == InputCategoryNames.Image || category == InputCategoryNames.Document;
default:
return false;
@@ -152,7 +166,82 @@ namespace FileConverter
return thread;
}
-
+
+ ///
+ /// Check whether Microsoft office is available or not.
+ ///
+ /// Returns true if Office is installed on the computer.
+ /// source: http://stackoverflow.com/questions/3266675/how-to-detect-installed-version-of-ms-office/3267832#3267832
+ /// source: http://www.codeproject.com/Articles/26520/Getting-Office-s-Version
+ public static bool IsMicrosoftOfficeApplicationAvailable(ConversionJobs.ConversionJob_Office.ApplicationName application)
+ {
+ string registryKeyPattern = @"Software\Microsoft\Windows\CurrentVersion\App Paths\";
+ switch (application)
+ {
+ case ConversionJob_Office.ApplicationName.Word:
+ registryKeyPattern += "winword.exe";
+ break;
+
+ case ConversionJob_Office.ApplicationName.PowerPoint:
+ registryKeyPattern += "powerpnt.exe";
+ break;
+
+ case ConversionJob_Office.ApplicationName.Excel:
+ registryKeyPattern += "excel.exe";
+ break;
+
+ case ConversionJob_Office.ApplicationName.None:
+ return false;
+ }
+
+ // Looks inside CURRENT_USER.
+ RegistryKey winwordKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(registryKeyPattern, false);
+ if (winwordKey != null)
+ {
+ string winwordPath = winwordKey.GetValue(string.Empty).ToString();
+ if (!string.IsNullOrEmpty(winwordPath))
+ {
+ return true;
+ }
+ }
+
+ // If not found, looks inside LOCAL_MACHINE.
+ winwordKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(registryKeyPattern, false);
+ if (winwordKey != null)
+ {
+ string winwordPath = winwordKey.GetValue(string.Empty).ToString();
+ if (!string.IsNullOrEmpty(winwordPath))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public static ConversionJob_Office.ApplicationName GetOfficeApplicationCompatibleWithExtension(string extension)
+ {
+ switch (extension)
+ {
+ case "doc":
+ case "docx":
+ case "odt":
+ return ConversionJob_Office.ApplicationName.Word;
+
+ case "ppt":
+ case "pptx":
+ case "odp":
+ return ConversionJob_Office.ApplicationName.PowerPoint;
+
+ case "ods":
+ case "xls":
+ case "xlsx":
+ return ConversionJob_Office.ApplicationName.Excel;
+ }
+
+ return ConversionJob_Office.ApplicationName.None;
+ }
+
public static class InputCategoryNames
{
public const string Audio = "Audio";
diff --git a/Application/FileConverter/OutputType.cs b/Application/FileConverter/OutputType.cs
index 15d5c77..fda2caf 100644
--- a/Application/FileConverter/OutputType.cs
+++ b/Application/FileConverter/OutputType.cs
@@ -21,5 +21,6 @@ namespace FileConverter
Png,
Wav,
Webm,
+ Webp,
}
}
\ No newline at end of file
diff --git a/Application/FileConverter/PathHelpers.cs b/Application/FileConverter/PathHelpers.cs
index d4e67b3..bf8a484 100644
--- a/Application/FileConverter/PathHelpers.cs
+++ b/Application/FileConverter/PathHelpers.cs
@@ -3,8 +3,8 @@
namespace FileConverter
{
using System;
- using System.Text;
using System.Collections.Generic;
+ using System.Text;
using System.Text.RegularExpressions;
using FileConverter.Diagnostics;
diff --git a/Application/FileConverter/Properties/Resources.Designer.cs b/Application/FileConverter/Properties/Resources.Designer.cs
index cc90056..6d7be31 100644
--- a/Application/FileConverter/Properties/Resources.Designer.cs
+++ b/Application/FileConverter/Properties/Resources.Designer.cs
@@ -268,20 +268,29 @@ namespace FileConverter.Properties {
}
///
- /// Looks up a localized string similar to Read input image.
+ /// Looks up a localized string similar to Prepare conversion.
///
- public static string ConversionStateReadIntputImage {
+ public static string ConversionStatePrepareConversion {
get {
- return ResourceManager.GetString("ConversionStateReadIntputImage", resourceCulture);
+ return ResourceManager.GetString("ConversionStatePrepareConversion", resourceCulture);
}
}
///
/// Looks up a localized string similar to Read document.
///
- public static string ConversionStateReadPdf {
+ public static string ConversionStateReadDocument {
get {
- return ResourceManager.GetString("ConversionStateReadPdf", resourceCulture);
+ return ResourceManager.GetString("ConversionStateReadDocument", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Read input image.
+ ///
+ public static string ConversionStateReadIntputImage {
+ get {
+ return ResourceManager.GetString("ConversionStateReadIntputImage", resourceCulture);
}
}
@@ -412,7 +421,16 @@ namespace FileConverter.Properties {
}
///
- /// Looks up a localized string similar to Audio CD track extraction failed.
+ /// Looks up a localized string similar to Can't find the output file(s)..
+ ///
+ public static string ErrorCantFindOutputFiles {
+ get {
+ return ResourceManager.GetString("ErrorCantFindOutputFiles", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Audio CD track extraction failed..
///
public static string ErrorCDAExtractionFailed {
get {
@@ -429,6 +447,15 @@ namespace FileConverter.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to The conversion job failed but there is an output file that does exists..
+ ///
+ public static string ErrorConversionFailedWithOutput {
+ get {
+ return ResourceManager.GetString("ErrorConversionFailedWithOutput", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Fail to launch ffmpeg..
///
@@ -510,6 +537,51 @@ namespace FileConverter.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Microsoft Excel must be installed in order to convert Excel documents..
+ ///
+ public static string ErrorMicrosoftExcelIsNotAvailable {
+ get {
+ return ResourceManager.GetString("ErrorMicrosoftExcelIsNotAvailable", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Microsoft Office must be installed in order to convert Office documents..
+ ///
+ public static string ErrorMicrosoftOfficeIsNotAvailable {
+ get {
+ return ResourceManager.GetString("ErrorMicrosoftOfficeIsNotAvailable", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Microsoft PowerPoint must be installed in order to convert PowerPoint documents..
+ ///
+ public static string ErrorMicrosoftPowerPointIsNotAvailable {
+ get {
+ return ResourceManager.GetString("ErrorMicrosoftPowerPointIsNotAvailable", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Microsoft Word must be installed in order to convert Word documents..
+ ///
+ public static string ErrorMicrosoftWordIsNotAvailable {
+ get {
+ return ResourceManager.GetString("ErrorMicrosoftWordIsNotAvailable", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Fail to open document with Microsoft Office (check if your licence/installation is valid)..
+ ///
+ public static string ErrorUnableToUseMicrosoftOffice {
+ get {
+ return ResourceManager.GetString("ErrorUnableToUseMicrosoftOffice", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Unsupported output format '{0}'..
///
@@ -1003,6 +1075,15 @@ namespace FileConverter.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Misc.
+ ///
+ public static string StringMiscName {
+ get {
+ return ResourceManager.GetString("StringMiscName", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Video.
///
diff --git a/Application/FileConverter/Properties/Resources.en.resx b/Application/FileConverter/Properties/Resources.en.resx
index c178ff1..ca362ac 100644
--- a/Application/FileConverter/Properties/Resources.en.resx
+++ b/Application/FileConverter/Properties/Resources.en.resx
@@ -400,7 +400,7 @@ use maj for uppercase version
Read input image
-
+
Read document
@@ -514,4 +514,31 @@ use maj for uppercase version
The application will automatically terminate in 1 second.
+
+ Misc
+
+
+ Can't find the output file(s).
+
+
+ The conversion job failed but there is an output file that does exists.
+
+
+ Prepare conversion
+
+
+ Microsoft Office must be installed in order to convert Office documents.
+
+
+ Fail to open document with Microsoft Office (check if your licence/installation are valid).
+
+
+ Microsoft Excel must be installed in order to convert Excel documents.
+
+
+ Microsoft PowerPoint must be installed in order to convert PowerPoint documents.
+
+
+ Microsoft Word must be installed in order to convert Word documents.
+
\ No newline at end of file
diff --git a/Application/FileConverter/Properties/Resources.fr.resx b/Application/FileConverter/Properties/Resources.fr.resx
index 9ccf435..59dbeef 100644
--- a/Application/FileConverter/Properties/Resources.fr.resx
+++ b/Application/FileConverter/Properties/Resources.fr.resx
@@ -414,7 +414,7 @@ utilisez maj pour une version en majuscules
Lecture de l'image d'origine
-
+
Lecture du document
@@ -494,7 +494,7 @@ utilisez maj pour une version en majuscules
Invalid output path generated by output file path template.
- Format de fichier de destion non supporté '{0}'.
+ Format de fichier de destination non supporté '{0}'.
Nombre de canaux :
@@ -532,4 +532,31 @@ utilisez maj pour une version en majuscules
L'application se fermera automatiquement dans 1 seconde.
+
+ Autre
+
+
+ Les fichiers n'ont pas pu être converti.
+
+
+ Des fichiers sont présents malgré l'echec de la conversion.
+
+
+ Préparation
+
+
+ Microsoft Office doit être installé pour pouvoir convertir les documents Office.
+
+
+ Impossible d'ouvrir le document avec Microsoft Office (vérifiez que la licence/l'installation sont valides).
+
+
+ Microsoft Excel doit être installé pour pouvoir convertir les documents Excel.
+
+
+ Microsoft PowerPoint doit être installé pour pouvoir convertir les documents PowerPoint.
+
+
+ Microsoft Word doit être installé pour pouvoir convertir les documents Word.
+
\ No newline at end of file
diff --git a/Application/FileConverter/Properties/Resources.resx b/Application/FileConverter/Properties/Resources.resx
index be70475..8857064 100644
--- a/Application/FileConverter/Properties/Resources.resx
+++ b/Application/FileConverter/Properties/Resources.resx
@@ -403,7 +403,7 @@ use maj for uppercase version
Read input image
-
+
Read document
@@ -446,7 +446,7 @@ use maj for uppercase version
Fail to find ffmpeg executable. You should try to reinstall the application.
- Audio CD track extraction failed
+ Audio CD track extraction failed.
CD drive is not ready.
@@ -514,4 +514,31 @@ use maj for uppercase version
The application will automatically terminate in 1 second.
+
+ Misc
+
+
+ Can't find the output file(s).
+
+
+ The conversion job failed but there is an output file that does exists.
+
+
+ Prepare conversion
+
+
+ Microsoft Office must be installed in order to convert Office documents.
+
+
+ Fail to open document with Microsoft Office (check if your licence/installation is valid).
+
+
+ Microsoft Excel must be installed in order to convert Excel documents.
+
+
+ Microsoft PowerPoint must be installed in order to convert PowerPoint documents.
+
+
+ Microsoft Word must be installed in order to convert Word documents.
+
\ No newline at end of file
diff --git a/Application/FileConverter/Settings.Settings.cs b/Application/FileConverter/Settings.Settings.cs
index 5d3f582..022700d 100644
--- a/Application/FileConverter/Settings.Settings.cs
+++ b/Application/FileConverter/Settings.Settings.cs
@@ -1,12 +1,9 @@
// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
-using System.Globalization;
-using System.Windows;
-using System.Windows.Markup;
-
namespace FileConverter
{
using System.Collections.ObjectModel;
+ using System.Globalization;
using System.Linq;
using System.Xml.Serialization;
diff --git a/Application/FileConverter/Settings.default.xml b/Application/FileConverter/Settings.default.xml
index 4489b1c..b5da24f 100644
--- a/Application/FileConverter/Settings.default.xml
+++ b/Application/FileConverter/Settings.default.xml
@@ -1,7 +1,9 @@
-
+
+ fr
true
3
+ 2
3gp
avi
@@ -208,6 +210,7 @@
webm
wmv
gif
+ webp
None
@@ -239,6 +242,7 @@
webm
wmv
gif
+ webp
None
@@ -266,8 +270,10 @@
ogv
webm
wmv
+ oga
None
+
(p)(f)
@@ -276,6 +282,7 @@
wma
aiff
None
+
(p)(f)
@@ -302,6 +309,7 @@
mpeg
None
+
(p)(f)
@@ -329,6 +337,7 @@
None
+
(p)(f)
@@ -355,6 +364,7 @@
oga
None
+
(p)(f)
@@ -382,12 +392,14 @@
vob
None
+
(p:m)DVD Extraction\(f)
vob
None
+
(p:m)DVD Extraction\(f)
@@ -395,17 +407,20 @@
None
+
(p:m)DVD Extraction\(f)
cda
None
+
(p:m)CDA Extraction\(f)
cda
None
+
(p:m)CDA Extraction\(f)
@@ -413,6 +428,7 @@
None
+
(p:m)CDA Extraction\(f)
@@ -427,6 +443,7 @@
tga
tiff
xcf
+ webp
None
@@ -436,7 +453,16 @@
xcf
+ doc
+ docx
+ odp
+ ods
+ odt
pdf
+ ppt
+ pptx
+ xls
+ xlsx
None
@@ -444,6 +470,27 @@
(p)(f) (n:i) of (n:c)
+
+ bmp
+ exr
+ ico
+ jpg
+ jpeg
+ png
+ psd
+ svg
+ tga
+ tiff
+ xcf
+ webp
+ None
+
+
+
+
+
+ (p)(f)
+
bmp
exr
@@ -456,6 +503,7 @@
tga
tiff
xcf
+ webp
None
@@ -474,6 +522,7 @@
svg
tga
tiff
+ webp
None
@@ -492,6 +541,7 @@
svg
tga
tiff
+ webp
None
@@ -511,6 +561,7 @@
tga
tiff
xcf
+ webp
None
@@ -531,6 +582,7 @@
tga
tiff
xcf
+ webp
None
(p)(f)
@@ -545,6 +597,16 @@
tga
tiff
xcf
+ webp
+ doc
+ docx
+ odp
+ ods
+ odt
+ ppt
+ pptx
+ xls
+ xlsx
None
(p)(f)
diff --git a/Application/FileConverter/Upgrade/Helpers.cs b/Application/FileConverter/Upgrade/Helpers.cs
index dfcb2b4..8d10032 100644
--- a/Application/FileConverter/Upgrade/Helpers.cs
+++ b/Application/FileConverter/Upgrade/Helpers.cs
@@ -128,7 +128,7 @@ namespace FileConverter.Upgrade
Helpers.currentlyDownloadedVersionDescription = upgradeVersionDescription;
Helpers.webClient.DownloadProgressChanged += Helpers.WebClient_DownloadProgressChanged;
- Helpers.webClient.DownloadFileCompleted += Helpers.WebClient_DownloadFileCompleted; ;
+ Helpers.webClient.DownloadFileCompleted += Helpers.WebClient_DownloadFileCompleted;
Task downloadTask = Helpers.webClient.DownloadFileTaskAsync(uri, installerPath);
}
diff --git a/Application/FileConverter/Upgrade/UpgradeVersionDescription.cs b/Application/FileConverter/Upgrade/UpgradeVersionDescription.cs
index 081d403..844f0e9 100644
--- a/Application/FileConverter/Upgrade/UpgradeVersionDescription.cs
+++ b/Application/FileConverter/Upgrade/UpgradeVersionDescription.cs
@@ -1,17 +1,18 @@
// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
-using System.ComponentModel;
-using System.Runtime.CompilerServices;
-using FileConverter.Annotations;
-
namespace FileConverter
{
+ using System.ComponentModel;
+ using System.Runtime.CompilerServices;
using System.Xml.Serialization;
+ using FileConverter.Annotations;
+
public class UpgradeVersionDescription : INotifyPropertyChanged
{
private int installerDownloadProgress;
private bool installerDownloadInProgress;
+
public event PropertyChangedEventHandler PropertyChanged;
[XmlElement("Latest")]
diff --git a/Application/FileConverter/ValueConverters/Generic/CultureInfoToStringConverter.cs b/Application/FileConverter/ValueConverters/Generic/CultureInfoToStringConverter.cs
index 76798ba..640fa07 100644
--- a/Application/FileConverter/ValueConverters/Generic/CultureInfoToStringConverter.cs
+++ b/Application/FileConverter/ValueConverters/Generic/CultureInfoToStringConverter.cs
@@ -1,4 +1,4 @@
-// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
+// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
namespace FileConverter.ValueConverters.Generic
{
@@ -27,7 +27,7 @@ namespace FileConverter.ValueConverters.Generic
return nativeName.ToUpper(cultureInfo);
}
- return nativeName.Substring(0, 1).ToUpper(cultureInfo) + nativeName.Substring(1, nativeName.Length - 1); ;
+ return nativeName.Substring(0, 1).ToUpper(cultureInfo) + nativeName.Substring(1, nativeName.Length - 1);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
diff --git a/Application/FileConverter/ValueConverters/Generic/ObjectToLocalizedString.cs b/Application/FileConverter/ValueConverters/Generic/ObjectToLocalizedString.cs
index 434a55e..e7e6edd 100644
--- a/Application/FileConverter/ValueConverters/Generic/ObjectToLocalizedString.cs
+++ b/Application/FileConverter/ValueConverters/Generic/ObjectToLocalizedString.cs
@@ -1,4 +1,4 @@
-// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
+// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
namespace FileConverter.ValueConverters.Generic
{
diff --git a/Application/FileConverter/ValueConverters/OutputTypeEnumToViewModel.cs b/Application/FileConverter/ValueConverters/OutputTypeEnumToViewModel.cs
index 377665c..caa05ee 100644
--- a/Application/FileConverter/ValueConverters/OutputTypeEnumToViewModel.cs
+++ b/Application/FileConverter/ValueConverters/OutputTypeEnumToViewModel.cs
@@ -1,11 +1,12 @@
-// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
+// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
namespace FileConverter.ValueConverters
{
using System;
using System.Globalization;
- using System.Windows.Data;
using System.Linq;
+ using System.Windows.Data;
+
using FileConverter.Windows;
public class OutputTypeEnumToViewModel : IValueConverter
diff --git a/Application/FileConverter/Windows/ConversionSettingsTemplateSelector.cs b/Application/FileConverter/Windows/ConversionSettingsTemplateSelector.cs
index 16bf79e..202fb6d 100644
--- a/Application/FileConverter/Windows/ConversionSettingsTemplateSelector.cs
+++ b/Application/FileConverter/Windows/ConversionSettingsTemplateSelector.cs
@@ -91,6 +91,12 @@ namespace FileConverter.Windows
set;
}
+ public DataTemplate WebpSettingsDataTemplate
+ {
+ get;
+ set;
+ }
+
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
if (item == null)
@@ -140,6 +146,9 @@ namespace FileConverter.Windows
case OutputType.Webm:
return this.WebmSettingsDataTemplate;
+
+ case OutputType.Webp:
+ return this.WebpSettingsDataTemplate;
}
return this.DefaultDataTemplate;
diff --git a/Application/FileConverter/Windows/InputExtension.cs b/Application/FileConverter/Windows/InputExtension.cs
index ea8c7e7..fcebe97 100644
--- a/Application/FileConverter/Windows/InputExtension.cs
+++ b/Application/FileConverter/Windows/InputExtension.cs
@@ -4,16 +4,48 @@ namespace FileConverter
{
using System.ComponentModel;
using System.Runtime.CompilerServices;
+ using System.Windows.Media;
using FileConverter.Annotations;
+ using FileConverter.ConversionJobs;
public class InputExtension : INotifyPropertyChanged
{
+ private readonly Brush defaultBrush = new SolidColorBrush(Color.FromRgb(0, 0, 0));
+ private readonly Brush errorBrush = new SolidColorBrush(Color.FromRgb(255, 65, 0));
+
private string name;
+ private Brush foregroundBrush;
+ private string toolTip;
public InputExtension(string name)
{
this.Name = name;
+
+ ConversionJob_Office.ApplicationName officeApplication = Helpers.GetOfficeApplicationCompatibleWithExtension(name);
+
+ if (officeApplication == ConversionJob_Office.ApplicationName.None || Helpers.IsMicrosoftOfficeApplicationAvailable(officeApplication))
+ {
+ this.ForegroundBrush = this.defaultBrush;
+ }
+ else
+ {
+ this.ForegroundBrush = this.errorBrush;
+ switch (officeApplication)
+ {
+ case ConversionJob_Office.ApplicationName.Word:
+ this.ToolTip = Properties.Resources.ErrorMicrosoftWordIsNotAvailable;
+ break;
+
+ case ConversionJob_Office.ApplicationName.PowerPoint:
+ this.ToolTip = Properties.Resources.ErrorMicrosoftPowerPointIsNotAvailable;
+ break;
+
+ case ConversionJob_Office.ApplicationName.Excel:
+ this.ToolTip = Properties.Resources.ErrorMicrosoftExcelIsNotAvailable;
+ break;
+ }
+ }
}
public event PropertyChangedEventHandler PropertyChanged;
@@ -32,6 +64,34 @@ namespace FileConverter
}
}
+ public Brush ForegroundBrush
+ {
+ get
+ {
+ return this.foregroundBrush;
+ }
+
+ set
+ {
+ this.foregroundBrush = value;
+ this.OnPropertyChanged();
+ }
+ }
+
+ public string ToolTip
+ {
+ get
+ {
+ return this.toolTip;
+ }
+
+ set
+ {
+ this.toolTip = value;
+ this.OnPropertyChanged();
+ }
+ }
+
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
diff --git a/Application/FileConverter/Windows/MainWindow.xaml.cs b/Application/FileConverter/Windows/MainWindow.xaml.cs
index 70f2514..0e6fe95 100644
--- a/Application/FileConverter/Windows/MainWindow.xaml.cs
+++ b/Application/FileConverter/Windows/MainWindow.xaml.cs
@@ -147,7 +147,7 @@ namespace FileConverter
else if (this.upgradeWindow == null)
{
this.upgradeWindow = new UpgradeWindow();
- this.upgradeWindow.Closed += UpgradeWindow_Closed;
+ this.upgradeWindow.Closed += this.UpgradeWindow_Closed;
}
Application application = Application.Current as Application;
diff --git a/Application/FileConverter/Windows/OutputTypeViewModel.cs b/Application/FileConverter/Windows/OutputTypeViewModel.cs
index 0f46b96..ffe7d01 100644
--- a/Application/FileConverter/Windows/OutputTypeViewModel.cs
+++ b/Application/FileConverter/Windows/OutputTypeViewModel.cs
@@ -1,4 +1,4 @@
-// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
+// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
namespace FileConverter.Windows
{
diff --git a/Application/FileConverter/Windows/SettingsWindow.xaml b/Application/FileConverter/Windows/SettingsWindow.xaml
index 4cfec49..e54f66e 100644
--- a/Application/FileConverter/Windows/SettingsWindow.xaml
+++ b/Application/FileConverter/Windows/SettingsWindow.xaml
@@ -710,7 +710,8 @@
OgvSettingsDataTemplate="{StaticResource OgvSettingsDataTemplate}"
PngSettingsDataTemplate="{StaticResource PngSettingsDataTemplate}"
WavSettingsDataTemplate="{StaticResource WavSettingsDataTemplate}"
- WebmSettingsDataTemplate="{StaticResource WebmSettingsDataTemplate}" />
+ WebmSettingsDataTemplate="{StaticResource WebmSettingsDataTemplate}"
+ WebpSettingsDataTemplate="{StaticResource JpgSettingsDataTemplate}" />
@@ -826,7 +827,7 @@
-
+
diff --git a/Application/FileConverter/Windows/SettingsWindow.xaml.cs b/Application/FileConverter/Windows/SettingsWindow.xaml.cs
index 8d962da..3d563cd 100644
--- a/Application/FileConverter/Windows/SettingsWindow.xaml.cs
+++ b/Application/FileConverter/Windows/SettingsWindow.xaml.cs
@@ -13,10 +13,10 @@ namespace FileConverter
using System.Windows.Data;
using System.Windows.Input;
- using FileConverter.Windows;
using FileConverter.Annotations;
using FileConverter.Commands;
using FileConverter.ConversionJobs;
+ using FileConverter.Windows;
using Microsoft.Win32;
///
@@ -57,6 +57,26 @@ namespace FileConverter
public event EventHandler OnSettingsWindowHide;
+ public static OutputTypeViewModel[] OutputTypeViewModels => new[]
+ {
+ new OutputTypeViewModel(OutputType.Ogg),
+ new OutputTypeViewModel(OutputType.Mp3),
+ new OutputTypeViewModel(OutputType.Aac),
+ new OutputTypeViewModel(OutputType.Flac),
+ new OutputTypeViewModel(OutputType.Wav),
+ new OutputTypeViewModel(OutputType.Mkv),
+ new OutputTypeViewModel(OutputType.Mp4),
+ new OutputTypeViewModel(OutputType.Ogv),
+ new OutputTypeViewModel(OutputType.Webm),
+ new OutputTypeViewModel(OutputType.Avi),
+ new OutputTypeViewModel(OutputType.Png),
+ new OutputTypeViewModel(OutputType.Jpg),
+ new OutputTypeViewModel(OutputType.Webp),
+ new OutputTypeViewModel(OutputType.Ico),
+ new OutputTypeViewModel(OutputType.Gif),
+ new OutputTypeViewModel(OutputType.Pdf),
+ };
+
public ICommand OpenUrlCommand
{
get
@@ -148,26 +168,7 @@ namespace FileConverter
get;
set;
}
-
- public static OutputTypeViewModel[] OutputTypeViewModels => new[]
- {
- new OutputTypeViewModel(OutputType.Ogg),
- new OutputTypeViewModel(OutputType.Mp3),
- new OutputTypeViewModel(OutputType.Aac),
- new OutputTypeViewModel(OutputType.Flac),
- new OutputTypeViewModel(OutputType.Wav),
- new OutputTypeViewModel(OutputType.Mkv),
- new OutputTypeViewModel(OutputType.Mp4),
- new OutputTypeViewModel(OutputType.Ogv),
- new OutputTypeViewModel(OutputType.Webm),
- new OutputTypeViewModel(OutputType.Avi),
- new OutputTypeViewModel(OutputType.Png),
- new OutputTypeViewModel(OutputType.Jpg),
- new OutputTypeViewModel(OutputType.Ico),
- new OutputTypeViewModel(OutputType.Gif),
- new OutputTypeViewModel(OutputType.Pdf),
- };
-
+
public InputPostConversionAction[] InputPostConversionActions => new[]
{
InputPostConversionAction.None,
diff --git a/Application/FileConverter/Windows/UpgradeWindow.xaml.cs b/Application/FileConverter/Windows/UpgradeWindow.xaml.cs
index 6cd43ea..3bbad11 100644
--- a/Application/FileConverter/Windows/UpgradeWindow.xaml.cs
+++ b/Application/FileConverter/Windows/UpgradeWindow.xaml.cs
@@ -2,12 +2,11 @@
namespace FileConverter.Windows
{
- using System;
- using System.Windows.Input;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows;
+ using System.Windows.Input;
using FileConverter.Annotations;
using FileConverter.Commands;
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 34ae3ba..34e6f8e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,16 @@
# Change Log
+## Version 1.2
+- New: Possibility to convert Word documents (docx, odt and doc) to pdf and images (this feature is only available if you have Microsoft Word installed).
+- New: Possibility to convert Excel documents (xlsx, ods and xls) to pdf and images (this feature is only available if you have Microsoft Excel installed).
+- New: Possibility to convert PowerPoint documents (pptx, odp and ppt) to pdf and images (this feature is only available if you have Microsoft PowerPoint installed).
+- New: Possibility to convert images and documents to webp format.
+- New: Support new image input format: webp.
+- New: Add the possibility to cancel image, CDA extraction and gif conversions.
+- Fixed: Issue where multiple conversion jobs were created for the same file resulting in an error message.
+- Tech: Improve application performances on startup.
+- Tech: Improve diagnostics.
+
## Version 1.1
- New: Localization system. File Converter can now be translated in multiple languages. The default language is the same than your OS language (if available).
- New: Add the possibility to choose the application language in the application settings.
diff --git a/Installer/Languages.wxs b/Installer/Languages.wxs
deleted file mode 100644
index e154616..0000000
--- a/Installer/Languages.wxs
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Installer/Product.wxs b/Installer/Product.wxs
index 9ffc523..2eb586a 100644
--- a/Installer/Product.wxs
+++ b/Installer/Product.wxs
@@ -12,7 +12,7 @@
-
+
@@ -142,7 +142,7 @@
-
+
diff --git a/Resources/Colors.md b/Resources/Colors.md
new file mode 100644
index 0000000..fa131df
--- /dev/null
+++ b/Resources/Colors.md
@@ -0,0 +1,9 @@
+# File Converter Colors
+
+Color | Code | Description
+------------|-----------|-------------------------------
+Blue | #0171BB | File Converter main color
+Dark Blue | #004B82 | File Converter main dark color
+Red | #FF4100 | Error
+Red | #DF3900 | Title
+Grey | #786C71 | Light text
\ No newline at end of file