summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels
diff options
context:
space:
mode:
authorsr55 <[email protected]>2015-06-26 20:14:25 +0000
committersr55 <[email protected]>2015-06-26 20:14:25 +0000
commitfe53ec37cbb0da69f4ef0b924303378397d49fc6 (patch)
tree0b5ff181a06b39e4661232fb376b1cc138ff2cc4 /win/CS/HandBrakeWPF/ViewModels
parentf5bbd0ac20d3b8e548c1a31fd2d065c68dbe03cf (diff)
WinGui: Completely replace the plist preset import code with the functionality built into libhb. This now allows the new json preset format to be imported, as well as the legacy plist format.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7318 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs71
1 files changed, 4 insertions, 67 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index f995b4d2e..60b0c74a5 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -30,6 +30,7 @@ namespace HandBrakeWPF.ViewModels
using HandBrake.ApplicationServices.Services.Scan.Model;
using HandBrake.ApplicationServices.Utilities;
using HandBrake.ApplicationServices.Interop;
+ using HandBrake.ApplicationServices.Interop.Json.Presets;
using HandBrakeWPF.Commands;
using HandBrakeWPF.EventArgs;
@@ -1813,74 +1814,10 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public void PresetImport()
{
- OpenFileDialog dialog = new OpenFileDialog() { Filter = "Plist (*.plist)|*.plist", CheckFileExists = true };
+ OpenFileDialog dialog = new OpenFileDialog { Filter = "Preset Files|*.json;*.plist", CheckFileExists = true };
dialog.ShowDialog();
- string filename = dialog.FileName;
-
- if (!string.IsNullOrEmpty(filename))
- {
- PList plist = new PList(filename);
-
- object build;
- plist.TryGetValue("PresetBuildNumber", out build);
-
- string buildNumber = build as string;
- if (buildNumber == null)
- {
- MessageBox.Show(
- Resources.Preset_UnableToImport_Message,
- Resources.Preset_UnableToImport_Header,
- MessageBoxButton.YesNo, MessageBoxImage.Question);
- return;
- }
-
- if (buildNumber != HandBrakeUtils.Build.ToString(CultureInfo.InvariantCulture))
- {
- MessageBoxResult result = MessageBox.Show(
- Resources.Preset_OldVersion_Message,
- Resources.Preset_OldVersion_Header,
- MessageBoxButton.YesNo, MessageBoxImage.Question);
-
- if (result == MessageBoxResult.No)
- {
- return;
- }
- }
-
- Preset preset = null;
- try
- {
- preset = PlistPresetFactory.CreatePreset(plist);
- }
- catch (Exception exc)
- {
- this.errorService.ShowError(Resources.Main_PresetImportFailed, Resources.Main_PresetImportFailedSolution, exc);
- }
-
- if (preset != null)
- {
- if (this.presetService.CheckIfPresetExists(preset.Name))
- {
- if (!presetService.CanUpdatePreset(preset.Name))
- {
- MessageBox.Show(Resources.Main_PresetErrorBuiltInName, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
- return;
- }
-
- MessageBoxResult result = MessageBox.Show(Resources.Main_PresetOverwriteWarning, Resources.Overwrite, MessageBoxButton.YesNo, MessageBoxImage.Warning);
- if (result == MessageBoxResult.Yes)
- {
- presetService.Update(preset);
- }
- }
- else
- {
- presetService.Add(preset);
- }
- }
-
- this.NotifyOfPropertyChange(() => this.Presets);
- }
+ this.presetService.Import(dialog.FileName);
+ this.NotifyOfPropertyChange(() => this.Presets);
}
/// <summary>