mirror of
https://github.com/Tichau/FileConverter.git
synced 2026-11-20 01:22:16 +01:00
Merged development into master
This commit is contained in:
commit
ca9bdaf474
43 files changed
+1400
-175
No files matched your search
+4
-1
@@ -194,4 +194,7 @@ FakesAssemblies/
|
||||
*.opt
|
||||
|
||||
# Ignore the installer signing commands file
|
||||
Installer/Installer.sign
|
||||
Installer/Installer.sign
|
||||
|
||||
# Ignore the installer languages file because it is automatically generated
|
||||
Installer/Languages.wxs
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
// <copyright file="ConversionJob_Excel.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.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace FileConverter.ConversionJobs
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert video quality index to lib theora video quality level.
|
||||
/// Convert video quality index to lib <c>theora</c> video quality level.
|
||||
/// </summary>
|
||||
/// <param name="quality">The quality index.</param>
|
||||
/// <returns>Returns the video quality index.</returns>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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<float>(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<float>(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<int>(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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// <copyright file="ConversionJob_Office.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
// <copyright file="ConversionJob_PowerPoint.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.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
// <copyright file="ConversionJob_Word.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.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -66,7 +66,6 @@
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</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.2.900\lib\net40-client\Magick.NET-Q16-AnyCPU.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@@ -74,23 +73,28 @@
|
||||
<Reference Include="Markdown.Xaml">
|
||||
<HintPath>..\..\Middleware\Markdown.Xaml.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Office.Interop.Excel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Office.Interop.PowerPoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Office.Interop.Word, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL">
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</Reference>
|
||||
<Reference Include="office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
|
||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||
</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" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
@@ -120,12 +124,16 @@
|
||||
</Compile>
|
||||
<Compile Include="Commands\CancelConversionJobCommand.cs" />
|
||||
<Compile Include="ConversionJobs\ConversionFlags.cs" />
|
||||
<Compile Include="ConversionJobs\ConversionJob_Office.cs" />
|
||||
<Compile Include="ConversionJobs\ConversionJob_PowerPoint.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_Gif.cs" />
|
||||
<Compile Include="ConversionJobs\ConversionJob_Ico.cs" />
|
||||
<Compile Include="ConversionJobs\ConversionJob_Excel.cs" />
|
||||
<Compile Include="ConversionJobs\ConversionJob_Word.cs" />
|
||||
<Compile Include="ConversionJobs\ConversionJob_ImageMagick.cs" />
|
||||
<Compile Include="ConversionJobs\VideoEncodingSpeed.cs" />
|
||||
<Compile Include="ConversionPreset\ConversionSettingsOverride.cs" />
|
||||
@@ -141,11 +149,13 @@
|
||||
<DependentUpon>Resources.fr.resx</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<ExcludeFromStyleCop>True</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.en.Designer.cs">
|
||||
<DependentUpon>Resources.en.resx</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<ExcludeFromStyleCop>True</ExcludeFromStyleCop>
|
||||
</Compile>
|
||||
<Compile Include="Registry.cs" />
|
||||
<Compile Include="Settings.Migration.cs" />
|
||||
@@ -257,6 +267,7 @@
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
|
||||
@@ -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<CultureInfo> 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;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Check whether Microsoft office is available or not.
|
||||
/// </summary>
|
||||
/// <returns>Returns true if Office is installed on the computer.</returns>
|
||||
/// 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";
|
||||
|
||||
@@ -21,5 +21,6 @@ namespace FileConverter
|
||||
Png,
|
||||
Wav,
|
||||
Webm,
|
||||
Webp,
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
+87
-6
@@ -268,20 +268,29 @@ namespace FileConverter.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Read input image.
|
||||
/// Looks up a localized string similar to Prepare conversion.
|
||||
/// </summary>
|
||||
public static string ConversionStateReadIntputImage {
|
||||
public static string ConversionStatePrepareConversion {
|
||||
get {
|
||||
return ResourceManager.GetString("ConversionStateReadIntputImage", resourceCulture);
|
||||
return ResourceManager.GetString("ConversionStatePrepareConversion", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Read document.
|
||||
/// </summary>
|
||||
public static string ConversionStateReadPdf {
|
||||
public static string ConversionStateReadDocument {
|
||||
get {
|
||||
return ResourceManager.GetString("ConversionStateReadPdf", resourceCulture);
|
||||
return ResourceManager.GetString("ConversionStateReadDocument", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Read input image.
|
||||
/// </summary>
|
||||
public static string ConversionStateReadIntputImage {
|
||||
get {
|
||||
return ResourceManager.GetString("ConversionStateReadIntputImage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,7 +421,16 @@ namespace FileConverter.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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)..
|
||||
/// </summary>
|
||||
public static string ErrorCantFindOutputFiles {
|
||||
get {
|
||||
return ResourceManager.GetString("ErrorCantFindOutputFiles", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Audio CD track extraction failed..
|
||||
/// </summary>
|
||||
public static string ErrorCDAExtractionFailed {
|
||||
get {
|
||||
@@ -429,6 +447,15 @@ namespace FileConverter.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The conversion job failed but there is an output file that does exists..
|
||||
/// </summary>
|
||||
public static string ErrorConversionFailedWithOutput {
|
||||
get {
|
||||
return ResourceManager.GetString("ErrorConversionFailedWithOutput", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Fail to launch ffmpeg..
|
||||
/// </summary>
|
||||
@@ -510,6 +537,51 @@ namespace FileConverter.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Microsoft Excel must be installed in order to convert Excel documents..
|
||||
/// </summary>
|
||||
public static string ErrorMicrosoftExcelIsNotAvailable {
|
||||
get {
|
||||
return ResourceManager.GetString("ErrorMicrosoftExcelIsNotAvailable", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Microsoft Office must be installed in order to convert Office documents..
|
||||
/// </summary>
|
||||
public static string ErrorMicrosoftOfficeIsNotAvailable {
|
||||
get {
|
||||
return ResourceManager.GetString("ErrorMicrosoftOfficeIsNotAvailable", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Microsoft PowerPoint must be installed in order to convert PowerPoint documents..
|
||||
/// </summary>
|
||||
public static string ErrorMicrosoftPowerPointIsNotAvailable {
|
||||
get {
|
||||
return ResourceManager.GetString("ErrorMicrosoftPowerPointIsNotAvailable", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Microsoft Word must be installed in order to convert Word documents..
|
||||
/// </summary>
|
||||
public static string ErrorMicrosoftWordIsNotAvailable {
|
||||
get {
|
||||
return ResourceManager.GetString("ErrorMicrosoftWordIsNotAvailable", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Fail to open document with Microsoft Office (check if your licence/installation is valid)..
|
||||
/// </summary>
|
||||
public static string ErrorUnableToUseMicrosoftOffice {
|
||||
get {
|
||||
return ResourceManager.GetString("ErrorUnableToUseMicrosoftOffice", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Unsupported output format '{0}'..
|
||||
/// </summary>
|
||||
@@ -1003,6 +1075,15 @@ namespace FileConverter.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Misc.
|
||||
/// </summary>
|
||||
public static string StringMiscName {
|
||||
get {
|
||||
return ResourceManager.GetString("StringMiscName", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Video.
|
||||
/// </summary>
|
||||
|
||||
@@ -400,7 +400,7 @@ use maj for uppercase version</value>
|
||||
<data name="ConversionStateReadIntputImage" xml:space="preserve">
|
||||
<value>Read input image</value>
|
||||
</data>
|
||||
<data name="ConversionStateReadPdf" xml:space="preserve">
|
||||
<data name="ConversionStateReadDocument" xml:space="preserve">
|
||||
<value>Read document</value>
|
||||
</data>
|
||||
<data name="StringAnimatedImageName" xml:space="preserve">
|
||||
@@ -514,4 +514,31 @@ use maj for uppercase version</value>
|
||||
<data name="ApplicationWillTerminateInOneSecond" xml:space="preserve">
|
||||
<value>The application will automatically terminate in 1 second.</value>
|
||||
</data>
|
||||
<data name="StringMiscName" xml:space="preserve">
|
||||
<value>Misc</value>
|
||||
</data>
|
||||
<data name="ErrorCantFindOutputFiles" xml:space="preserve">
|
||||
<value>Can't find the output file(s).</value>
|
||||
</data>
|
||||
<data name="ErrorConversionFailedWithOutput" xml:space="preserve">
|
||||
<value>The conversion job failed but there is an output file that does exists.</value>
|
||||
</data>
|
||||
<data name="ConversionStatePrepareConversion" xml:space="preserve">
|
||||
<value>Prepare conversion</value>
|
||||
</data>
|
||||
<data name="ErrorMicrosoftOfficeIsNotAvailable" xml:space="preserve">
|
||||
<value>Microsoft Office must be installed in order to convert Office documents.</value>
|
||||
</data>
|
||||
<data name="ErrorUnableToUseMicrosoftOffice" xml:space="preserve">
|
||||
<value>Fail to open document with Microsoft Office (check if your licence/installation are valid).</value>
|
||||
</data>
|
||||
<data name="ErrorMicrosoftExcelIsNotAvailable" xml:space="preserve">
|
||||
<value>Microsoft Excel must be installed in order to convert Excel documents.</value>
|
||||
</data>
|
||||
<data name="ErrorMicrosoftPowerPointIsNotAvailable" xml:space="preserve">
|
||||
<value>Microsoft PowerPoint must be installed in order to convert PowerPoint documents.</value>
|
||||
</data>
|
||||
<data name="ErrorMicrosoftWordIsNotAvailable" xml:space="preserve">
|
||||
<value>Microsoft Word must be installed in order to convert Word documents.</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -414,7 +414,7 @@ utilisez maj pour une version en majuscules</value>
|
||||
<data name="ConversionStateReadIntputImage" xml:space="preserve">
|
||||
<value>Lecture de l'image d'origine</value>
|
||||
</data>
|
||||
<data name="ConversionStateReadPdf" xml:space="preserve">
|
||||
<data name="ConversionStateReadDocument" xml:space="preserve">
|
||||
<value>Lecture du document</value>
|
||||
</data>
|
||||
<data name="StringAnimatedImageName" xml:space="preserve">
|
||||
@@ -494,7 +494,7 @@ utilisez maj pour une version en majuscules</value>
|
||||
<comment>Invalid output path generated by output file path template.</comment>
|
||||
</data>
|
||||
<data name="ErrorUnsupportedOutputFormat" xml:space="preserve">
|
||||
<value>Format de fichier de destion non supporté '{0}'.</value>
|
||||
<value>Format de fichier de destination non supporté '{0}'.</value>
|
||||
</data>
|
||||
<data name="ChannelCountTitle" xml:space="preserve">
|
||||
<value>Nombre de canaux :</value>
|
||||
@@ -532,4 +532,31 @@ utilisez maj pour une version en majuscules</value>
|
||||
<data name="ApplicationWillTerminateInOneSecond" xml:space="preserve">
|
||||
<value>L'application se fermera automatiquement dans 1 seconde.</value>
|
||||
</data>
|
||||
<data name="StringMiscName" xml:space="preserve">
|
||||
<value>Autre</value>
|
||||
</data>
|
||||
<data name="ErrorCantFindOutputFiles" xml:space="preserve">
|
||||
<value>Les fichiers n'ont pas pu être converti.</value>
|
||||
</data>
|
||||
<data name="ErrorConversionFailedWithOutput" xml:space="preserve">
|
||||
<value>Des fichiers sont présents malgré l'echec de la conversion.</value>
|
||||
</data>
|
||||
<data name="ConversionStatePrepareConversion" xml:space="preserve">
|
||||
<value>Préparation</value>
|
||||
</data>
|
||||
<data name="ErrorMicrosoftOfficeIsNotAvailable" xml:space="preserve">
|
||||
<value>Microsoft Office doit être installé pour pouvoir convertir les documents Office.</value>
|
||||
</data>
|
||||
<data name="ErrorUnableToUseMicrosoftOffice" xml:space="preserve">
|
||||
<value>Impossible d'ouvrir le document avec Microsoft Office (vérifiez que la licence/l'installation sont valides).</value>
|
||||
</data>
|
||||
<data name="ErrorMicrosoftExcelIsNotAvailable" xml:space="preserve">
|
||||
<value>Microsoft Excel doit être installé pour pouvoir convertir les documents Excel.</value>
|
||||
</data>
|
||||
<data name="ErrorMicrosoftPowerPointIsNotAvailable" xml:space="preserve">
|
||||
<value>Microsoft PowerPoint doit être installé pour pouvoir convertir les documents PowerPoint.</value>
|
||||
</data>
|
||||
<data name="ErrorMicrosoftWordIsNotAvailable" xml:space="preserve">
|
||||
<value>Microsoft Word doit être installé pour pouvoir convertir les documents Word.</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -403,7 +403,7 @@ use maj for uppercase version</value>
|
||||
<data name="ConversionStateReadIntputImage" xml:space="preserve">
|
||||
<value>Read input image</value>
|
||||
</data>
|
||||
<data name="ConversionStateReadPdf" xml:space="preserve">
|
||||
<data name="ConversionStateReadDocument" xml:space="preserve">
|
||||
<value>Read document</value>
|
||||
</data>
|
||||
<data name="StringAnimatedImageName" xml:space="preserve">
|
||||
@@ -446,7 +446,7 @@ use maj for uppercase version</value>
|
||||
<value>Fail to find ffmpeg executable. You should try to reinstall the application.</value>
|
||||
</data>
|
||||
<data name="ErrorCDAExtractionFailed" xml:space="preserve">
|
||||
<value>Audio CD track extraction failed</value>
|
||||
<value>Audio CD track extraction failed.</value>
|
||||
</data>
|
||||
<data name="ErrorCDDriveNotReady" xml:space="preserve">
|
||||
<value>CD drive is not ready.</value>
|
||||
@@ -514,4 +514,31 @@ use maj for uppercase version</value>
|
||||
<data name="ApplicationWillTerminateInOneSecond" xml:space="preserve">
|
||||
<value>The application will automatically terminate in 1 second.</value>
|
||||
</data>
|
||||
<data name="StringMiscName" xml:space="preserve">
|
||||
<value>Misc</value>
|
||||
</data>
|
||||
<data name="ErrorCantFindOutputFiles" xml:space="preserve">
|
||||
<value>Can't find the output file(s).</value>
|
||||
</data>
|
||||
<data name="ErrorConversionFailedWithOutput" xml:space="preserve">
|
||||
<value>The conversion job failed but there is an output file that does exists.</value>
|
||||
</data>
|
||||
<data name="ConversionStatePrepareConversion" xml:space="preserve">
|
||||
<value>Prepare conversion</value>
|
||||
</data>
|
||||
<data name="ErrorMicrosoftOfficeIsNotAvailable" xml:space="preserve">
|
||||
<value>Microsoft Office must be installed in order to convert Office documents.</value>
|
||||
</data>
|
||||
<data name="ErrorUnableToUseMicrosoftOffice" xml:space="preserve">
|
||||
<value>Fail to open document with Microsoft Office (check if your licence/installation is valid).</value>
|
||||
</data>
|
||||
<data name="ErrorMicrosoftExcelIsNotAvailable" xml:space="preserve">
|
||||
<value>Microsoft Excel must be installed in order to convert Excel documents.</value>
|
||||
</data>
|
||||
<data name="ErrorMicrosoftPowerPointIsNotAvailable" xml:space="preserve">
|
||||
<value>Microsoft PowerPoint must be installed in order to convert PowerPoint documents.</value>
|
||||
</data>
|
||||
<data name="ErrorMicrosoftWordIsNotAvailable" xml:space="preserve">
|
||||
<value>Microsoft Word must be installed in order to convert Word documents.</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1,12 +1,9 @@
|
||||
// <copyright file="Settings.Settings.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<?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="3">
|
||||
<Settings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SerializationVersion="3">
|
||||
<ApplicationLanguageName>fr</ApplicationLanguageName>
|
||||
<ExitApplicationWhenConversionsFinished>true</ExitApplicationWhenConversionsFinished>
|
||||
<DurationBetweenEndOfConversionsAndApplicationExit>3</DurationBetweenEndOfConversionsAndApplicationExit>
|
||||
<MaximumNumberOfSimultaneousConversions>2</MaximumNumberOfSimultaneousConversions>
|
||||
<ConversionPreset Name="To Mkv" OutputType="Mkv" IsDefaultSettings="true">
|
||||
<InputTypes>3gp</InputTypes>
|
||||
<InputTypes>avi</InputTypes>
|
||||
@@ -208,6 +210,7 @@
|
||||
<InputTypes>webm</InputTypes>
|
||||
<InputTypes>wmv</InputTypes>
|
||||
<InputTypes>gif</InputTypes>
|
||||
<InputTypes>webp</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="VideoScale" Value="1" />
|
||||
<Settings Key="VideoRotation" Value="0" />
|
||||
@@ -239,6 +242,7 @@
|
||||
<InputTypes>webm</InputTypes>
|
||||
<InputTypes>wmv</InputTypes>
|
||||
<InputTypes>gif</InputTypes>
|
||||
<InputTypes>webp</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="VideoScale" Value="0,75" />
|
||||
<Settings Key="VideoRotation" Value="0" />
|
||||
@@ -266,8 +270,10 @@
|
||||
<InputTypes>ogv</InputTypes>
|
||||
<InputTypes>webm</InputTypes>
|
||||
<InputTypes>wmv</InputTypes>
|
||||
<InputTypes>oga</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioBitrate" Value="160" />
|
||||
<Settings Key="AudioChannelCount" Value="0" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Flac" OutputType="Flac" IsDefaultSettings="true">
|
||||
@@ -276,6 +282,7 @@
|
||||
<InputTypes>wma</InputTypes>
|
||||
<InputTypes>aiff</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioChannelCount" Value="0" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Wav" OutputType="Wav" IsDefaultSettings="true">
|
||||
@@ -302,6 +309,7 @@
|
||||
<InputTypes>mpeg</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioEncodingMode" Value="Wav16" />
|
||||
<Settings Key="AudioChannelCount" Value="0" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Mp3" OutputType="Mp3" IsDefaultSettings="true">
|
||||
@@ -329,6 +337,7 @@
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioEncodingMode" Value="Mp3VBR" />
|
||||
<Settings Key="AudioBitrate" Value="190" />
|
||||
<Settings Key="AudioChannelCount" Value="0" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Aac" OutputType="Aac" IsDefaultSettings="true">
|
||||
@@ -355,6 +364,7 @@
|
||||
<InputTypes>oga</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioBitrate" Value="128" />
|
||||
<Settings Key="AudioChannelCount" Value="0" />
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="Extract DVD to Mp4" OutputType="Mp4" IsDefaultSettings="true">
|
||||
@@ -382,12 +392,14 @@
|
||||
<ConversionPreset Name="Extract DVD to Flac" OutputType="Flac" IsDefaultSettings="true">
|
||||
<InputTypes>vob</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioChannelCount" Value="0" />
|
||||
<OutputFileNameTemplate>(p:m)DVD Extraction\(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="Extract DVD to Ogg" OutputType="Ogg" IsDefaultSettings="true">
|
||||
<InputTypes>vob</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioBitrate" Value="192" />
|
||||
<Settings Key="AudioChannelCount" Value="0" />
|
||||
<OutputFileNameTemplate>(p:m)DVD Extraction\(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="Extract DVD to Mp3" OutputType="Mp3" IsDefaultSettings="true">
|
||||
@@ -395,17 +407,20 @@
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioEncodingMode" Value="Mp3VBR" />
|
||||
<Settings Key="AudioBitrate" Value="225" />
|
||||
<Settings Key="AudioChannelCount" Value="0" />
|
||||
<OutputFileNameTemplate>(p:m)DVD Extraction\(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="Extract CDA to Flac" OutputType="Flac" IsDefaultSettings="true">
|
||||
<InputTypes>cda</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioChannelCount" Value="0" />
|
||||
<OutputFileNameTemplate>(p:m)CDA Extraction\(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="Extract CDA to Ogg" OutputType="Ogg" IsDefaultSettings="true">
|
||||
<InputTypes>cda</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioBitrate" Value="192" />
|
||||
<Settings Key="AudioChannelCount" Value="0" />
|
||||
<OutputFileNameTemplate>(p:m)CDA Extraction\(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="Extract CDA to Mp3" OutputType="Mp3" IsDefaultSettings="true">
|
||||
@@ -413,6 +428,7 @@
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="AudioEncodingMode" Value="Mp3VBR" />
|
||||
<Settings Key="AudioBitrate" Value="225" />
|
||||
<Settings Key="AudioChannelCount" Value="0" />
|
||||
<OutputFileNameTemplate>(p:m)CDA Extraction\(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Png" OutputType="Png" IsDefaultSettings="true">
|
||||
@@ -427,6 +443,7 @@
|
||||
<InputTypes>tga</InputTypes>
|
||||
<InputTypes>tiff</InputTypes>
|
||||
<InputTypes>xcf</InputTypes>
|
||||
<InputTypes>webp</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="ImageScale" Value="1" />
|
||||
<Settings Key="ImageRotation" Value="0" />
|
||||
@@ -436,7 +453,16 @@
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Png (paged)" OutputType="Png" IsDefaultSettings="true">
|
||||
<InputTypes>xcf</InputTypes>
|
||||
<InputTypes>doc</InputTypes>
|
||||
<InputTypes>docx</InputTypes>
|
||||
<InputTypes>odp</InputTypes>
|
||||
<InputTypes>ods</InputTypes>
|
||||
<InputTypes>odt</InputTypes>
|
||||
<InputTypes>pdf</InputTypes>
|
||||
<InputTypes>ppt</InputTypes>
|
||||
<InputTypes>pptx</InputTypes>
|
||||
<InputTypes>xls</InputTypes>
|
||||
<InputTypes>xlsx</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="ImageScale" Value="1" />
|
||||
<Settings Key="ImageRotation" Value="0" />
|
||||
@@ -444,6 +470,27 @@
|
||||
<Settings Key="ImageMaximumSize" Value="0" />
|
||||
<OutputFileNameTemplate>(p)(f) (n:i) of (n:c)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
<ConversionPreset Name="To Webp" OutputType="Webp" IsDefaultSettings="true">
|
||||
<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>
|
||||
<InputTypes>webp</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="ImageQuality" Value="40" />
|
||||
<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" IsDefaultSettings="true">
|
||||
<InputTypes>bmp</InputTypes>
|
||||
<InputTypes>exr</InputTypes>
|
||||
@@ -456,6 +503,7 @@
|
||||
<InputTypes>tga</InputTypes>
|
||||
<InputTypes>tiff</InputTypes>
|
||||
<InputTypes>xcf</InputTypes>
|
||||
<InputTypes>webp</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="ImageScale" Value="0,25" />
|
||||
<Settings Key="ImageRotation" Value="0" />
|
||||
@@ -474,6 +522,7 @@
|
||||
<InputTypes>svg</InputTypes>
|
||||
<InputTypes>tga</InputTypes>
|
||||
<InputTypes>tiff</InputTypes>
|
||||
<InputTypes>webp</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="ImageScale" Value="1" />
|
||||
<Settings Key="ImageRotation" Value="90" />
|
||||
@@ -492,6 +541,7 @@
|
||||
<InputTypes>svg</InputTypes>
|
||||
<InputTypes>tga</InputTypes>
|
||||
<InputTypes>tiff</InputTypes>
|
||||
<InputTypes>webp</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="ImageScale" Value="1" />
|
||||
<Settings Key="ImageRotation" Value="270" />
|
||||
@@ -511,6 +561,7 @@
|
||||
<InputTypes>tga</InputTypes>
|
||||
<InputTypes>tiff</InputTypes>
|
||||
<InputTypes>xcf</InputTypes>
|
||||
<InputTypes>webp</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<Settings Key="ImageQuality" Value="40" />
|
||||
<Settings Key="ImageScale" Value="1" />
|
||||
@@ -531,6 +582,7 @@
|
||||
<InputTypes>tga</InputTypes>
|
||||
<InputTypes>tiff</InputTypes>
|
||||
<InputTypes>xcf</InputTypes>
|
||||
<InputTypes>webp</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
@@ -545,6 +597,16 @@
|
||||
<InputTypes>tga</InputTypes>
|
||||
<InputTypes>tiff</InputTypes>
|
||||
<InputTypes>xcf</InputTypes>
|
||||
<InputTypes>webp</InputTypes>
|
||||
<InputTypes>doc</InputTypes>
|
||||
<InputTypes>docx</InputTypes>
|
||||
<InputTypes>odp</InputTypes>
|
||||
<InputTypes>ods</InputTypes>
|
||||
<InputTypes>odt</InputTypes>
|
||||
<InputTypes>ppt</InputTypes>
|
||||
<InputTypes>pptx</InputTypes>
|
||||
<InputTypes>xls</InputTypes>
|
||||
<InputTypes>xlsx</InputTypes>
|
||||
<InputPostConversionAction>None</InputPostConversionAction>
|
||||
<OutputFileNameTemplate>(p)(f)</OutputFileNameTemplate>
|
||||
</ConversionPreset>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
// <copyright file="UpgradeVersionDescription.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
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")]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// <copyright file="BoolInverterConverter.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
// <copyright file="CultureInfoToStringConverter.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
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)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// <copyright file="BoolInverterConverter.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
// <copyright file="ObjectToLocalizedString.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.ValueConverters.Generic
|
||||
{
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
// <copyright file="BitrateToString.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
// <copyright file="OutputTypeEnumToViewModel.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;
|
||||
using System.Linq;
|
||||
using System.Windows.Data;
|
||||
|
||||
using FileConverter.Windows;
|
||||
|
||||
public class OutputTypeEnumToViewModel : IValueConverter
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// <copyright file="OutputFileType.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
// <copyright file="OutputTypeViewModel.cs" company="AAllard">License: http://www.gnu.org/licenses/gpl.html GPL version 3.</copyright>
|
||||
|
||||
namespace FileConverter.Windows
|
||||
{
|
||||
|
||||
@@ -710,7 +710,8 @@
|
||||
OgvSettingsDataTemplate="{StaticResource OgvSettingsDataTemplate}"
|
||||
PngSettingsDataTemplate="{StaticResource PngSettingsDataTemplate}"
|
||||
WavSettingsDataTemplate="{StaticResource WavSettingsDataTemplate}"
|
||||
WebmSettingsDataTemplate="{StaticResource WebmSettingsDataTemplate}" />
|
||||
WebmSettingsDataTemplate="{StaticResource WebmSettingsDataTemplate}"
|
||||
WebpSettingsDataTemplate="{StaticResource JpgSettingsDataTemplate}" />
|
||||
</Window.Resources>
|
||||
<Window.Title>
|
||||
<Binding Converter="{StaticResource ApplicationVersionToApplicationName}" Mode="OneWay" Path="(local:Application.ApplicationVersion)"/>
|
||||
@@ -826,7 +827,7 @@
|
||||
</CheckBox>
|
||||
</HierarchicalDataTemplate>
|
||||
<DataTemplate DataType="{x:Type local:InputExtension}">
|
||||
<CheckBox Content="{Binding Name}" Height="20" VerticalAlignment="Top" Margin="2" Checked="OnInputTypeChecked" Unchecked="OnInputTypeUnchecked">
|
||||
<CheckBox Content="{Binding Name}" Foreground="{Binding ForegroundBrush}" ToolTip="{Binding ToolTip}" 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"/>
|
||||
|
||||
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
@@ -57,6 +57,26 @@ namespace FileConverter
|
||||
|
||||
public event EventHandler<EventArgs> 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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||
<Fragment>
|
||||
<DirectoryRef Id="INSTALLFOLDER">
|
||||
<Directory Id="dir59665241F3CDDE1A2AC55595EAB82331" Name="Languages" />
|
||||
</DirectoryRef>
|
||||
</Fragment>
|
||||
<Fragment>
|
||||
<ComponentGroup Id="Languages">
|
||||
<Component Id="cmp416BC2ED150FADE2B6C889B2E30BEFF1" Directory="dir69039193B93E3CF7D8D647984CD644EA" Guid="{0CA9BF52-0792-493A-8758-B4A5B8958F71}">
|
||||
<File Id="fil5460820E8FE9AB69A71E15E4E9BEB1E2" KeyPath="yes" Source="$(var.FileConverter.TargetDir)\en\FileConverter.resources.dll" />
|
||||
</Component>
|
||||
<Component Id="cmpF149529191A3B87AAB82B9301A2CAB8B" Directory="dir6DD71661C1CC5A2A0CCF37D75E6494F1" Guid="{8488EC70-06C5-4FD0-A8DA-F68481FEA431}">
|
||||
<File Id="fil47BB5F07444A2330EB2978EA5E7A488E" KeyPath="yes" Source="$(var.FileConverter.TargetDir)\fr\FileConverter.resources.dll" />
|
||||
</Component>
|
||||
</ComponentGroup>
|
||||
</Fragment>
|
||||
<Fragment>
|
||||
<DirectoryRef Id="dir59665241F3CDDE1A2AC55595EAB82331">
|
||||
<Directory Id="dir69039193B93E3CF7D8D647984CD644EA" Name="en" />
|
||||
</DirectoryRef>
|
||||
</Fragment>
|
||||
<Fragment>
|
||||
<DirectoryRef Id="dir59665241F3CDDE1A2AC55595EAB82331">
|
||||
<Directory Id="dir6DD71661C1CC5A2A0CCF37D75E6494F1" Name="fr" />
|
||||
</DirectoryRef>
|
||||
</Fragment>
|
||||
</Wix>
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<!-- 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="1.1.0" Manufacturer="Adrien Allard" UpgradeCode="e3ca717b-a897-418a-bbef-5c7e35c76e4b">
|
||||
<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="1.2.0" Manufacturer="Adrien Allard" UpgradeCode="e3ca717b-a897-418a-bbef-5c7e35c76e4b">
|
||||
<?if $(var.Platform) = x64 ?>
|
||||
<Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Platform="x64" />
|
||||
<?else ?>
|
||||
@@ -142,7 +142,7 @@
|
||||
<Component Id="RegistryEntries" Guid="{C3EF3D67-0206-4DBD-B2EA-78FF2E290093}">
|
||||
<RegistryKey Root="HKCU" Key="Software\FileConverter" ForceDeleteOnUninstall="yes">
|
||||
<RegistryValue Name="Path" Type="string" Value="[INSTALLFOLDER]FileConverter.exe"/>
|
||||
<RegistryValue Name="CompatibleInputExtensions" Type="string" Value="3gp;aac;aiff;ape;avi;bik;bmp;cda;exr;flac;flv;gif;ico;jpg;jpeg;m4a;m4v;mkv;mov;mp3;mp4;mpeg;oga;ogg;ogv;pdf;png;psd;svg;tga;tiff;vob;wav;webm;wma;wmv"/>
|
||||
<RegistryValue Name="CompatibleInputExtensions" Type="string" Value="3gp;aac;aiff;ape;avi;bik;bmp;cda;doc;docx;exr;flac;flv;gif;ico;jpg;jpeg;m4a;m4v;mkv;mov;mp3;mp4;mpeg;odp;ods;odt;oga;ogg;ogv;pdf;png;ppt;pptx;psd;svg;tga;tiff;vob;wav;webm;webp;wma;wmv;xls;xlsx"/>
|
||||
</RegistryKey>
|
||||
</Component>
|
||||
</ComponentGroup>
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user