summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Services/PresetService.cs')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/PresetService.cs76
1 files changed, 39 insertions, 37 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs
index c3bfa7fb7..75d9805cc 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/PresetService.cs
@@ -11,6 +11,7 @@ namespace HandBrake.ApplicationServices.Services
using System.Diagnostics;
using System.IO;
using System.Linq;
+ using System.Text;
using System.Text.RegularExpressions;
using System.Windows;
using System.Xml.Serialization;
@@ -222,55 +223,56 @@ namespace HandBrake.ApplicationServices.Services
if (File.Exists(presetsPath))
{
- StreamReader presetInput = new StreamReader(presetsPath);
-
- string category = String.Empty;
-
- while (!presetInput.EndOfStream)
+ using (StreamReader presetInput = new StreamReader(presetsPath))
{
- string line = presetInput.ReadLine();
+ StringBuilder contents = new StringBuilder();
- // Found the beginning of a preset block
- if (line != null && line.Contains("<") && !line.Contains("<<"))
- {
- category = line.Replace("<", string.Empty).Trim();
- }
+ string category = String.Empty;
- // Found a preset
- if (line != null && line.Contains("+"))
+ while (!presetInput.EndOfStream)
{
- Regex r = new Regex("(: )"); // Split on hyphens.
- string[] presetName = r.Split(line);
+ string line = presetInput.ReadLine();
+ contents.AppendLine(line);
- bool pic = false;
- if (presetName[2].Contains("crop"))
+ // Found the beginning of a preset block )
+ if (line != null && line.Contains("<") && !line.Contains("<<"))
{
- pic = true;
+ category = line.Replace("<", string.Empty).Trim();
}
- Preset newPreset = new Preset
+ // Found a preset
+ if (line != null && line.Contains("+"))
+ {
+ Regex r = new Regex("(: )"); // Split on hyphens.
+ string[] presetName = r.Split(line);
+
+ bool pic = false;
+ if (presetName[2].Contains("crop"))
{
- Category = category,
- Name = presetName[0].Replace("+", string.Empty).Trim(),
- Query = presetName[2],
- Version = Properties.Settings.Default.HandBrakeVersion,
- CropSettings = pic,
- Description = string.Empty, // Maybe one day we will populate this.
- IsBuildIn = true
- };
-
- this.presets.Add(newPreset);
+ pic = true;
+ }
+
+ Preset newPreset = new Preset
+ {
+ Category = category,
+ Name = presetName[0].Replace("+", string.Empty).Trim(),
+ Query = presetName[2],
+ Version = Properties.Settings.Default.HandBrakeVersion,
+ CropSettings = pic,
+ Description = string.Empty, // Maybe one day we will populate this.
+ IsBuildIn = true
+ };
+
+ this.presets.Add(newPreset);
+ }
}
- }
- // Verify we have presets.
- if (this.presets.Count == 0)
- {
- throw new GeneralApplicationException("Failed to load built-in presets.", "Restarting HandBrake may resolve this issue", null);
+ // Verify we have presets.
+ if (this.presets.Count == 0)
+ {
+ throw new GeneralApplicationException("Failed to load built-in presets.", "Restarting HandBrake may resolve this issue", new Exception(contents.ToString()));
+ }
}
-
- presetInput.Close();
- presetInput.Dispose();
}
else
{