mirror of
https://github.com/Tichau/FileConverter.git
synced 2026-11-22 10:31:58 +01:00
Add notion of name and folders on conversion jobs.
This commit is contained in:
1 parent
845ea763f0
commit
4ff7b5148e
5 files changed
+65
-20
No files matched your search
@@ -391,7 +391,7 @@ namespace FileConverter
|
||||
IConversionService conversionService = SimpleIoc.Default.GetInstance<IConversionService>();
|
||||
|
||||
// Create conversion jobs.
|
||||
Debug.Log("Create jobs for conversion preset: '{0}'", conversionPreset.Name);
|
||||
Debug.Log("Create jobs for conversion preset: '{0}'", conversionPreset.FullName);
|
||||
try
|
||||
{
|
||||
for (int index = 0; index < filePaths.Count; index++)
|
||||
|
||||
@@ -319,7 +319,7 @@ namespace FileConverter.ConversionJobs
|
||||
this.State = ConversionState.Ready;
|
||||
}
|
||||
|
||||
Debug.Log("Job initialized: Preset: '{0}' Input: {1} Output: {2}", this.ConversionPreset.Name, this.InputFilePath, this.OutputFilePath);
|
||||
Debug.Log("Job initialized: Preset: '{0}' Input: {1} Output: {2}", this.ConversionPreset.FullName, this.InputFilePath, this.OutputFilePath);
|
||||
|
||||
if (this.State != ConversionState.Failed)
|
||||
{
|
||||
|
||||
@@ -19,7 +19,8 @@ namespace FileConverter
|
||||
[XmlType]
|
||||
public class ConversionPreset : ObservableObject, IDataErrorInfo, IXmlSerializable
|
||||
{
|
||||
private string name;
|
||||
private string shortName;
|
||||
|
||||
private OutputType outputType;
|
||||
private List<string> inputTypes;
|
||||
private InputPostConversionAction inputPostConversionAction;
|
||||
@@ -28,12 +29,12 @@ namespace FileConverter
|
||||
|
||||
public ConversionPreset()
|
||||
{
|
||||
this.Name = Properties.Resources.DefaultPresetName;
|
||||
this.FullName = Properties.Resources.DefaultPresetName;
|
||||
}
|
||||
|
||||
public ConversionPreset(string name, OutputType outputType, params string[] inputTypes)
|
||||
public ConversionPreset(string fullName, OutputType outputType, params string[] inputTypes)
|
||||
{
|
||||
this.Name = name;
|
||||
this.FullName = fullName;
|
||||
this.OutputType = outputType;
|
||||
List<string> inputTypeList = new List<string>();
|
||||
inputTypeList.AddRange(inputTypes);
|
||||
@@ -42,9 +43,9 @@ namespace FileConverter
|
||||
this.outputFileNameTemplate = "(p)(f)";
|
||||
}
|
||||
|
||||
public ConversionPreset(string name, ConversionPreset source, params string[] additionalInputTypes)
|
||||
public ConversionPreset(string fullName, ConversionPreset source, params string[] additionalInputTypes)
|
||||
{
|
||||
this.Name = name;
|
||||
this.FullName = fullName;
|
||||
this.OutputType = source.outputType;
|
||||
List<string> inputTypeList = new List<string>();
|
||||
if (source.inputTypes != null)
|
||||
@@ -67,22 +68,61 @@ namespace FileConverter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[XmlAttribute]
|
||||
public string Name
|
||||
[XmlAttribute("Name")]
|
||||
public string FullName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.name;
|
||||
string fullName = string.Empty;
|
||||
if (this.ParentFoldersNames != null)
|
||||
{
|
||||
foreach (string folder in this.ParentFoldersNames)
|
||||
{
|
||||
fullName += $"{folder}/";
|
||||
}
|
||||
}
|
||||
|
||||
fullName += this.shortName;
|
||||
|
||||
return fullName;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.name = value;
|
||||
string[] folders = value.Split('/');
|
||||
if (folders.Length == 0)
|
||||
{
|
||||
Diagnostics.Debug.Log("Invalid full name.");
|
||||
this.ShortName = value;
|
||||
return;
|
||||
}
|
||||
|
||||
this.ShortName = folders[folders.Length - 1];
|
||||
Array.Resize(ref folders, folders.Length - 1);
|
||||
|
||||
this.ParentFoldersNames = folders;
|
||||
}
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public string ShortName
|
||||
{
|
||||
get => this.shortName;
|
||||
|
||||
set
|
||||
{
|
||||
this.shortName = value;
|
||||
this.RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
[XmlIgnore]
|
||||
public string[] ParentFoldersNames
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
[XmlAttribute]
|
||||
public OutputType OutputType
|
||||
{
|
||||
@@ -551,20 +591,25 @@ namespace FileConverter
|
||||
// Return error message if there is an error, else return empty or null string.
|
||||
switch (propertyName)
|
||||
{
|
||||
case "Name":
|
||||
case "ShortName":
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.Name))
|
||||
if (string.IsNullOrEmpty(this.ShortName))
|
||||
{
|
||||
return "The preset name can't be empty.";
|
||||
}
|
||||
|
||||
if (this.Name.Contains(";"))
|
||||
if (this.ShortName.Contains(";"))
|
||||
{
|
||||
return "The preset name can't contains the character ';'.";
|
||||
}
|
||||
|
||||
if (this.ShortName.Contains("/"))
|
||||
{
|
||||
return "The preset name can't contains the character '/'.";
|
||||
}
|
||||
|
||||
ISettingsService settingsService = SimpleIoc.Default.GetInstance<ISettingsService>();
|
||||
int? count = settingsService.Settings?.ConversionPresets?.Count(match => match?.name == this.Name);
|
||||
int? count = settingsService.Settings?.ConversionPresets?.Count(match => match?.shortName == this.ShortName);
|
||||
if (count > 1)
|
||||
{
|
||||
return "The preset name is already used.";
|
||||
|
||||
@@ -451,7 +451,7 @@ namespace FileConverter.Services
|
||||
registryEntries.Add(inputType, new List<string>());
|
||||
}
|
||||
|
||||
registryEntries[inputType].Add(conversionPreset.Name);
|
||||
registryEntries[inputType].Add(conversionPreset.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace FileConverter
|
||||
|
||||
public ConversionPreset GetPresetFromName(string presetName)
|
||||
{
|
||||
return this.conversionPresets.FirstOrDefault(match => match.Name == presetName);
|
||||
return this.conversionPresets.FirstOrDefault(match => match.FullName == presetName);
|
||||
}
|
||||
|
||||
public void Clean()
|
||||
@@ -73,7 +73,7 @@ namespace FileConverter
|
||||
for (int index = 0; index < settings.conversionPresets.Count; index++)
|
||||
{
|
||||
ConversionPreset conversionPreset = settings.conversionPresets[index];
|
||||
if (this.conversionPresets.Any(match => match.Name == conversionPreset.Name))
|
||||
if (this.conversionPresets.Any(match => match.FullName == conversionPreset.FullName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user