-/* PlistPresetHandler.cs $\r
+/* PlistUtility.cs $\r
This file is part of the HandBrake source code.\r
Homepage: <http://handbrake.fr/>.\r
It may be used under the terms of the GNU General Public License. */\r
track.MixDown = Converters.GetAudioMixDown(value.Trim());\r
break;\r
case "AudioSamplerate":\r
- track.SampleRate = double.Parse(value);\r
+ track.SampleRate = value == "Auto" ? 0 : double.Parse(value);\r
break;\r
case "AudioTrack":\r
//track.SourceTrack = value;\r
\r
switch (key)\r
{\r
- // Output Settings\r
+ // Output Settings\r
case "FileFormat":\r
parsed.OutputFormat = Converters.GetFileFormat(value);\r
break;\r
parsed.IPod5GSupport = value == "1";\r
break;\r
\r
- // Picture Settings\r
+ // Picture Settings\r
case "PictureAutoCrop":\r
// Not used\r
break;\r
case "PicturePAR":\r
switch (value)\r
{\r
- \r
case "0":\r
parsed.Anamorphic = Anamorphic.None;\r
break;\r
default:\r
parsed.Anamorphic = Anamorphic.Strict;\r
break;\r
- case "2":\r
+ case "2":\r
parsed.Anamorphic = Anamorphic.Loose;\r
break;\r
- case "3":\r
+ case "3":\r
parsed.Anamorphic = Anamorphic.Custom;\r
break;\r
-\r
}\r
break;\r
\r
- // Filters\r
+ // Filters\r
case "PictureDeblock":\r
parsed.Deblock = int.Parse(value);\r
break;\r
case "PictureDecomb":\r
parsed.Decomb = Decomb.Off;\r
// Don't place custom here as it's handled in the filter panel\r
- if (value == "2") parsed.Decomb = Decomb.Default;\r
+ if (value == "2")\r
+ {\r
+ parsed.Decomb = Decomb.Default;\r
+ }\r
break;\r
case "PictureDecombCustom":\r
if (value != string.Empty)\r
+ {\r
parsed.CustomDecomb = value;\r
+ }\r
break;\r
case "PictureDecombDeinterlace":\r
// Not Used\r
case "0":\r
parsed.Deinterlace = Deinterlace.Off;\r
break;\r
- // Don't place custom here as it's handled in the filter panel\r
+ // Don't place custom here as it's handled in the filter panel\r
case "2":\r
parsed.Deinterlace = Deinterlace.Fast;\r
break;\r
break;\r
case "PictureDeinterlaceCustom":\r
if (value != string.Empty)\r
+ {\r
parsed.CustomDeinterlace = value;\r
+ }\r
break;\r
case "PictureDenoise":\r
switch (value)\r
case "0":\r
parsed.Denoise = Denoise.Off;\r
break;\r
- // Don't place custom here as it's handled in the filter panel\r
+ // Don't place custom here as it's handled in the filter panel\r
case "2":\r
parsed.Denoise = Denoise.Weak;\r
break;\r
break;\r
case "PictureDenoiseCustom":\r
if (value != string.Empty)\r
+ {\r
parsed.CustomDenoise = value;\r
+ }\r
break;\r
case "PictureDetelecine":\r
parsed.Detelecine = Detelecine.Off;\r
- if (value == "1") parsed.Detelecine = Detelecine.Default;\r
+ if (value == "1")\r
+ {\r
+ parsed.Detelecine = Detelecine.Default;\r
+ }\r
break;\r
case "PictureDetelecineCustom":\r
if (value != string.Empty)\r
+ {\r
parsed.CustomDetelecine = value;\r
+ }\r
break;\r
\r
- // Video Tab\r
+ // Video Tab\r
case "VideoAvgBitrate":\r
- parsed.VideoBitrate = int.Parse(value);\r
+ if (!string.IsNullOrEmpty(value))\r
+ {\r
+ parsed.VideoBitrate = int.Parse(value);\r
+ }\r
break;\r
case "VideoEncoder":\r
parsed.VideoEncoder = Converters.GetVideoEncoder(value);\r
break;\r
case "VideoFramerate":\r
- parsed.Framerate = int.Parse(value);\r
+\r
+ if (value == "Same as source")\r
+ {\r
+ parsed.Framerate = null;\r
+ }\r
+ else if (!string.IsNullOrEmpty(value))\r
+ {\r
+ parsed.Framerate = int.Parse(value);\r
+ }\r
break;\r
case "VideoGrayScale":\r
parsed.Grayscale = value == "1";\r
parsed.TwoPass = value == "1";\r
break;\r
\r
- // Chapter Markers Tab\r
+ // Chapter Markers Tab\r
case "ChapterMarkers":\r
parsed.IncludeChapterMarkers = value == "1";\r
break;\r
\r
- // Advanced x264 tab\r
+ // Advanced x264 tab\r
case "x264Option":\r
parsed.AdvancedEncoderOptions = value;\r
break;\r
\r
- // Preset Information\r
+ // Preset Information\r
case "PresetBuildNumber":\r
parsed.PresetBuildNumber = int.Parse(value);\r
break;\r
\r
// Now enable the save menu if the selected preset is a user preset\r
if (treeView_presets.SelectedNode != null)\r
- pmnu_saveChanges.Enabled = presetHandler.CanUpdatePreset(treeView_presets.SelectedNode.Text);\r
+ pmnu_saveChanges.Enabled = presetHandler.CanUpdatePreset(treeView_presets.SelectedNode.Text);\r
\r
treeView_presets.Select();\r
}\r
treeView_presets.Select();\r
}\r
\r
-\r
private void MnuSetDefaultPreset_Click(object sender, EventArgs e)\r
{\r
if (treeView_presets.SelectedNode != null)\r
}\r
\r
private void MnuImportPreset_Click(object sender, EventArgs e)\r
- {\r
+ { \r
this.ImportPreset();\r
}\r
\r
/// </summary>\r
private void ImportPreset()\r
{\r
+ if (this.selectedTitle == null)\r
+ {\r
+ MessageBox.Show(\r
+ "Please scan a source before trying to import a preset.",\r
+ "Error",\r
+ MessageBoxButtons.OK,\r
+ MessageBoxIcon.Error);\r
+ return;\r
+ }\r
+\r
if (openPreset.ShowDialog() == DialogResult.OK)\r
{\r
EncodeTask parsed = PlistPresetHandler.Import(openPreset.FileName);\r
- if (presetHandler.CheckIfPresetExists(parsed.PresetName + " (Imported)"))\r
+ if (presetHandler.CheckIfPresetExists(parsed.PresetName))\r
{\r
+ if (!presetHandler.CanUpdatePreset(parsed.PresetName))\r
+ {\r
+ MessageBox.Show(\r
+ "You can not import a preset with the same name as a built-in preset.",\r
+ "Error",\r
+ MessageBoxButtons.OK,\r
+ MessageBoxIcon.Error);\r
+ return;\r
+ }\r
+\r
DialogResult result =\r
MessageBox.Show("This preset appears to already exist. Would you like to overwrite it?",\r
"Overwrite preset?",\r
MessageBoxButtons.YesNo, MessageBoxIcon.Warning);\r
if (result == DialogResult.Yes)\r
{\r
+\r
PresetLoader.LoadPreset(this, parsed, parsed.PresetName);\r
\r
Preset preset = new Preset\r
{\r
- Name = parsed.PresetName + " (Imported)",\r
+ Name = parsed.PresetName,\r
Query = QueryGenerator.GenerateFullQuery(this),\r
CropSettings = parsed.UsesPictureSettings\r
};\r
\r
Preset preset = new Preset\r
{\r
- Name = parsed.PresetName + " (Imported)",\r
+ Name = parsed.PresetName,\r
Query = QueryGenerator.GenerateFullQuery(this),\r
- CropSettings = parsed.UsesPictureSettings\r
+ CropSettings = parsed.UsesPictureSettings,\r
};\r
\r
if (presetHandler.Add(preset))\r
{\r
- TreeNode preset_treeview = new TreeNode(parsed.PresetName + " (Imported)")\r
+ TreeNode preset_treeview = new TreeNode(parsed.PresetName)\r
{\r
- ForeColor = Color.Black\r
+ ForeColor = Color.Black,\r
+ Tag = preset,\r
};\r
treeView_presets.Nodes.Add(preset_treeview);\r
}\r
/// </summary>\r
private void ExportPreset()\r
{\r
+ if (this.selectedTitle == null)\r
+ {\r
+ MessageBox.Show(\r
+ "Please scan a source before trying to export a preset.",\r
+ "Error",\r
+ MessageBoxButtons.OK,\r
+ MessageBoxIcon.Error);\r
+ return;\r
+ }\r
+\r
SaveFileDialog savefiledialog = new SaveFileDialog { Filter = "plist|*.plist" };\r
\r
if (treeView_presets.SelectedNode != null)\r