diff options
author | sr55 <[email protected]> | 2014-03-06 19:20:58 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2014-03-06 19:20:58 +0000 |
commit | 41dd0af9c6b059b05de8c8a98047437ffaac75e3 (patch) | |
tree | 02251ccb3c2a3e7a9daf29f91c490461b08c77e1 /win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | |
parent | c5c1c8b01454e3d13556ef9473cd6de29f9d581a (diff) |
WinGui: Improvements and fixes to the Output Format Dropdown / Destination
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6100 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs')
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 98 |
1 files changed, 66 insertions, 32 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index a2ae6708b..4dcf9bc67 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -636,8 +636,30 @@ namespace HandBrakeWPF.ViewModels }
set
{
- this.CurrentTask.Destination = value;
- this.NotifyOfPropertyChange(() => this.Destination);
+ if (!object.Equals(this.CurrentTask.Destination, value))
+ {
+ this.CurrentTask.Destination = value;
+ this.NotifyOfPropertyChange(() => this.Destination);
+
+ if (!string.IsNullOrEmpty(this.CurrentTask.Destination))
+ {
+ switch (Path.GetExtension(this.CurrentTask.Destination))
+ {
+ case ".mkv":
+ this.SelectedOutputFormat = OutputFormat.Mkv;
+ break;
+ case ".mp4":
+ this.SelectedOutputFormat = OutputFormat.Mp4;
+ break;
+ case ".m4v":
+ this.SelectedOutputFormat = OutputFormat.Mp4;
+ break;
+ case ".x265":
+ this.SelectedOutputFormat = OutputFormat.X265;
+ break;
+ }
+ }
+ }
}
}
@@ -855,15 +877,18 @@ namespace HandBrakeWPF.ViewModels set
{
- this.selectedOutputFormat = value;
- this.CurrentTask.OutputFormat = value;
- this.NotifyOfPropertyChange(() => SelectedOutputFormat);
- this.NotifyOfPropertyChange(() => this.CurrentTask.OutputFormat);
- this.NotifyOfPropertyChange(() => IsMkv);
- this.SetExtension(string.Format(".{0}", this.selectedOutputFormat.ToString().ToLower()));
+ if (!object.Equals(this.selectedOutputFormat, value))
+ {
+ this.selectedOutputFormat = value;
+ this.CurrentTask.OutputFormat = value;
+ this.NotifyOfPropertyChange(() => SelectedOutputFormat);
+ this.NotifyOfPropertyChange(() => this.CurrentTask.OutputFormat);
+ this.NotifyOfPropertyChange(() => IsMkv);
+ this.SetExtension(string.Format(".{0}", this.selectedOutputFormat.ToString().ToLower()));
- this.VideoViewModel.RefreshTask();
- this.AudioViewModel.RefreshTask();
+ this.VideoViewModel.RefreshTask();
+ this.AudioViewModel.RefreshTask();
+ }
}
}
@@ -1144,7 +1169,7 @@ namespace HandBrakeWPF.ViewModels }
QueueTask task = new QueueTask(new EncodeTask(this.CurrentTask), HBConfigurationFactory.Create());
-
+
if (!this.queueProcessor.CheckForDestinationPathDuplicates(task.Task.Destination))
{
this.queueProcessor.Add(task);
@@ -1411,9 +1436,15 @@ namespace HandBrakeWPF.ViewModels AddExtension = true,
DefaultExt = ".mp4",
OverwritePrompt = true,
- FilterIndex = this.CurrentTask.OutputFormat == OutputFormat.Mkv ? 1 : 0,
};
+ string extension = Path.GetExtension(this.CurrentTask.Destination);
+
+ saveFileDialog.FilterIndex = !string.IsNullOrEmpty(this.CurrentTask.Destination)
+ && !string.IsNullOrEmpty(extension)
+ ? (extension == ".mp4" || extension == ".m4v" ? 1 : 2)
+ : (this.CurrentTask.OutputFormat == OutputFormat.Mkv ? 2 : 0);
+
if (this.CurrentTask != null && !string.IsNullOrEmpty(this.CurrentTask.Destination))
{
saveFileDialog.InitialDirectory = Directory.Exists(Path.GetDirectoryName(this.CurrentTask.Destination))
@@ -1423,29 +1454,32 @@ namespace HandBrakeWPF.ViewModels saveFileDialog.FileName = Path.GetFileName(this.CurrentTask.Destination);
}
- saveFileDialog.ShowDialog();
- this.Destination = saveFileDialog.FileName;
-
- // Set the Extension Dropdown. This will also set Mp4/m4v correctly.
- if (!string.IsNullOrEmpty(saveFileDialog.FileName))
+ bool? result = saveFileDialog.ShowDialog();
+ if (result.HasValue && result.Value)
{
- switch (Path.GetExtension(saveFileDialog.FileName))
+ this.Destination = saveFileDialog.FileName;
+
+ // Set the Extension Dropdown. This will also set Mp4/m4v correctly.
+ if (!string.IsNullOrEmpty(saveFileDialog.FileName))
{
- case ".mkv":
- this.SelectedOutputFormat = OutputFormat.Mkv;
- break;
- case ".mp4":
- this.SelectedOutputFormat = OutputFormat.Mp4;
- break;
- case ".m4v":
- this.SelectedOutputFormat = OutputFormat.M4V;
- break;
- case ".x265":
- this.SelectedOutputFormat = OutputFormat.X265;
- break;
- }
+ switch (Path.GetExtension(saveFileDialog.FileName))
+ {
+ case ".mkv":
+ this.SelectedOutputFormat = OutputFormat.Mkv;
+ break;
+ case ".mp4":
+ this.SelectedOutputFormat = OutputFormat.Mp4;
+ break;
+ case ".m4v":
+ this.SelectedOutputFormat = OutputFormat.M4V;
+ break;
+ case ".x265":
+ this.SelectedOutputFormat = OutputFormat.X265;
+ break;
+ }
- this.NotifyOfPropertyChange(() => this.CurrentTask);
+ this.NotifyOfPropertyChange(() => this.CurrentTask);
+ }
}
}
|