summaryrefslogtreecommitdiffstats
path: root/win/C#/Presets
diff options
context:
space:
mode:
authorsr55 <[email protected]>2009-04-01 23:48:34 +0000
committersr55 <[email protected]>2009-04-01 23:48:34 +0000
commit414d6a56cc67f2fa56353ee3ce80adaa8cfeb45f (patch)
tree171172730223e0e525b68f4afb3ea6ff2e5ccc9c /win/C#/Presets
parent683faec1c917365b32332d86693e72479ba315bf (diff)
WinGui:
- Just some minor code tweaks to clean things up. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2291 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Presets')
-rw-r--r--win/C#/Presets/PresetsHandler.cs49
1 files changed, 25 insertions, 24 deletions
diff --git a/win/C#/Presets/PresetsHandler.cs b/win/C#/Presets/PresetsHandler.cs
index aa52d0685..e29c4d227 100644
--- a/win/C#/Presets/PresetsHandler.cs
+++ b/win/C#/Presets/PresetsHandler.cs
@@ -12,7 +12,7 @@ namespace Handbrake.Presets
{
List<Preset> presets = new List<Preset>(); // Category+Level+Preset Name: Query
List<Preset> user_presets = new List<Preset>(); // Preset Name: Query
- private static XmlSerializer ser = new XmlSerializer(typeof(List<Preset>));
+ private static readonly XmlSerializer ser = new XmlSerializer(typeof(List<Preset>));
/// <summary>
/// Add a new preset to the system
@@ -24,19 +24,13 @@ namespace Handbrake.Presets
{
if (checkIfPresetExists(presetName) == false)
{
- Preset newPreset = new Preset();
- newPreset.Name = presetName;
- newPreset.Query = query;
- newPreset.PictureSettings = pictureSettings;
+ Preset newPreset = new Preset {Name = presetName, Query = query, PictureSettings = pictureSettings};
user_presets.Add(newPreset);
updateUserPresetsFile();
return true;
}
- else
- {
- MessageBox.Show("Sorry, that preset name already exists. Please choose another!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return false;
- }
+ MessageBox.Show("Sorry, that preset name already exists. Please choose another!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ return false;
}
/// <summary>
@@ -155,13 +149,16 @@ namespace Handbrake.Presets
string strCmdLine = String.Format(@"cmd /c """"{0}"" --preset-list >""{1}"" 2>&1""", handbrakeCLIPath, presetsPath);
- ProcessStartInfo hbGetPresets = new ProcessStartInfo("CMD.exe", strCmdLine);
- hbGetPresets.WindowStyle = ProcessWindowStyle.Hidden;
+ ProcessStartInfo hbGetPresets = new ProcessStartInfo("CMD.exe", strCmdLine)
+ {WindowStyle = ProcessWindowStyle.Hidden};
Process hbproc = Process.Start(hbGetPresets);
- hbproc.WaitForExit();
- hbproc.Dispose();
- hbproc.Close();
+ if (hbproc != null)
+ {
+ hbproc.WaitForExit();
+ hbproc.Dispose();
+ hbproc.Close();
+ }
// Clear the current built in presets and now parse the tempory presets file.
presets.Clear();
@@ -200,11 +197,13 @@ namespace Handbrake.Presets
Regex r = new Regex("(: )"); // Split on hyphens.
string[] presetName = r.Split(line);
- Preset newPreset = new Preset();
- newPreset.Level = level;
- newPreset.Category = category;
- newPreset.Name = presetName[0].Replace("+", "").Trim();
- newPreset.Query = presetName[2];
+ Preset newPreset = new Preset
+ {
+ Level = level,
+ Category = category,
+ Name = presetName[0].Replace("+", "").Trim(),
+ Query = presetName[2]
+ };
presets.Add(newPreset);
}
}
@@ -236,8 +235,9 @@ namespace Handbrake.Presets
{
List<Preset> list = ser.Deserialize(strm) as List<Preset>;
- foreach (Preset preset in list)
- presets.Add(preset);
+ if (list != null)
+ foreach (Preset preset in list)
+ presets.Add(preset);
}
}
}
@@ -252,8 +252,9 @@ namespace Handbrake.Presets
{
List<Preset> list = ser.Deserialize(strm) as List<Preset>;
- foreach (Preset preset in list)
- user_presets.Add(preset);
+ if (list != null)
+ foreach (Preset preset in list)
+ user_presets.Add(preset);
}
}
}