/// </summary>\r
public void Load()\r
{\r
- // If the preset file doesn't exist. Create it.\r
- if (!File.Exists(this.presetFile))\r
- {\r
- this.UpdateBuiltInPresets();\r
- return;\r
- }\r
-\r
// Load the presets from file\r
this.LoadPresets();\r
}\r
/// </summary>\r
public void UpdateBuiltInPresets()\r
{\r
- // Clear the current built in Presets and now parse the tempory Presets file.\r
+ // Clear the current built in Presets and now parse the temporary Presets file.\r
this.ClearBuiltIn();\r
\r
IList<PresetCategory> presetCategories = HandBrakePresetService.GetBuiltInPresets();\r
// If we don't have a presets file. Create one for first load.\r
if (!File.Exists(this.presetFile))\r
{\r
- // If this is a nightly, and we don't have a presets file, try port the main version if it exists.\r
- string releasePresetFile = Path.Combine(DirectoryUtilities.GetUserStoragePath(false), "presets.json");\r
- if (VersionHelper.IsNightly() && File.Exists(releasePresetFile))\r
- {\r
- File.Copy(releasePresetFile, DirectoryUtilities.GetUserStoragePath(true));\r
- }\r
- else\r
- {\r
- this.UpdateBuiltInPresets();\r
- return; // Update built-in presets stores the presets locally, so just return.\r
- }\r
+ this.UpdateBuiltInPresets();\r
+ return;\r
}\r
\r
// Otherwise, we already have a file, so lets try load it.\r
// Version Check\r
// If we have old presets, or the container wasn't parseable, or we have a version mismatch, backup the user preset file \r
// incase something goes wrong and reset built-in presets, then re-save.\r
+ bool ignoreBuildIn = false;\r
if (container.VersionMajor != Constants.PresetVersionMajor || container.VersionMinor != Constants.PresetVersionMinor || container.VersionMicro != Constants.PresetVersionMicro)\r
{\r
string fileName = this.ArchivePresetFile(this.presetFile);\r
+ Environment.NewLine + Environment.NewLine + Resources.PresetService_ArchiveFile + fileName,\r
Resources.PresetService_UnableToLoad,\r
MessageBoxButton.OK,\r
- MessageBoxImage.Exclamation);\r
+ MessageBoxImage.Information);\r
this.UpdateBuiltInPresets(); // Update built-in presets stores the presets locally, so just return.\r
- return;\r
+ ignoreBuildIn = true;\r
}\r
\r
// Force Upgrade of presets\r
+ Environment.NewLine + Environment.NewLine + Resources.PresetService_ArchiveFile + fileName,\r
Resources.PresetService_UnableToLoad,\r
MessageBoxButton.OK,\r
- MessageBoxImage.Exclamation);\r
+ MessageBoxImage.Information);\r
this.UpdateBuiltInPresets(); // Update built-in presets stores the presets locally, so just return.\r
return;\r
}\r
\r
- // The presets file loaded was OK, so process it.\r
- foreach (var item in container.PresetList)\r
- {\r
- object deserialisedItem = JsonConvert.DeserializeObject<PresetCategory>(item.ToString());\r
+ this.ProcessPresetList(container, ignoreBuildIn);\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ Debug.WriteLine(ex);\r
+ this.RecoverFromCorruptedPresetFile(this.presetFile);\r
+ this.UpdateBuiltInPresets();\r
+ }\r
+ }\r
\r
- // Handle Categorised Presets.\r
- PresetCategory category = deserialisedItem as PresetCategory;\r
- if (category != null && category.Folder)\r
- {\r
- foreach (HBPreset hbpreset in category.ChildrenArray)\r
- {\r
- Preset preset = JsonPresetFactory.ImportPreset(hbpreset);\r
- \r
- // Migration\r
- if (category.PresetName == "User Presets")\r
- {\r
- preset.Category = UserPresetCatgoryName;\r
- }\r
- else\r
- {\r
- preset.Category = category.PresetName;\r
- }\r
- preset.IsBuildIn = hbpreset.Type == 0;\r
+ private void ProcessPresetList(PresetTransportContainer container, bool ignoreOldBuiltIn)\r
+ {\r
+ // The presets file loaded was OK, so process it.\r
+ foreach (var item in container.PresetList)\r
+ {\r
+ object deserialisedItem = JsonConvert.DeserializeObject<PresetCategory>(item.ToString());\r
\r
- // IF we are using Source Max, Set the Max Width / Height values.\r
- if (preset.PictureSettingsMode == PresetPictureSettingsMode.SourceMaximum)\r
- {\r
- preset.Task.MaxWidth = preset.Task.Height;\r
- preset.Task.MaxHeight = preset.Task.Width;\r
- }\r
+ // Handle Categorised Presets.\r
+ PresetCategory category = deserialisedItem as PresetCategory;\r
+ if (category != null && category.Folder)\r
+ {\r
+ foreach (HBPreset hbpreset in category.ChildrenArray)\r
+ {\r
+ Preset preset = JsonPresetFactory.ImportPreset(hbpreset);\r
\r
- this.Add(preset, true);\r
+ if (preset.IsBuildIn && ignoreOldBuiltIn)\r
+ {\r
+ continue;\r
}\r
- }\r
\r
- // Uncategorised Presets\r
- deserialisedItem = JsonConvert.DeserializeObject<HBPreset>(item.ToString());\r
- HBPreset hbPreset = deserialisedItem as HBPreset;\r
- if (hbPreset != null && !hbPreset.Folder)\r
- {\r
- Preset preset = JsonPresetFactory.ImportPreset(hbPreset);\r
- preset.Category = UserPresetCatgoryName;\r
- preset.IsBuildIn = hbPreset.Type == 1;\r
+ // Migration\r
+ preset.Category = category.PresetName == "User Presets" ? UserPresetCatgoryName : category.PresetName;\r
+ preset.IsBuildIn = hbpreset.Type == 0;\r
\r
// IF we are using Source Max, Set the Max Width / Height values.\r
if (preset.PictureSettingsMode == PresetPictureSettingsMode.SourceMaximum)\r
this.Add(preset, true);\r
}\r
}\r
+\r
+ // Uncategorised Presets\r
+ deserialisedItem = JsonConvert.DeserializeObject<HBPreset>(item.ToString());\r
+ HBPreset hbPreset = deserialisedItem as HBPreset;\r
+ if (hbPreset != null && !hbPreset.Folder)\r
+ {\r
+ Preset preset = JsonPresetFactory.ImportPreset(hbPreset);\r
+ preset.Category = UserPresetCatgoryName;\r
+ preset.IsBuildIn = hbPreset.Type == 1;\r
+\r
+ // IF we are using Source Max, Set the Max Width / Height values.\r
+ if (preset.PictureSettingsMode == PresetPictureSettingsMode.SourceMaximum)\r
+ {\r
+ preset.Task.MaxWidth = preset.Task.Height;\r
+ preset.Task.MaxHeight = preset.Task.Width;\r
+ }\r
+\r
+ this.Add(preset, true);\r
+ }\r
}\r
- catch (Exception ex)\r
- {\r
- Debug.WriteLine(ex);\r
- this.RecoverFromCorruptedPresetFile(this.presetFile);\r
- this.UpdateBuiltInPresets();\r
- }\r
+\r
}\r
\r
/// <summary>\r