From b87cca000d252e72f4d130068e9a2ea70f28b07f Mon Sep 17 00:00:00 2001 From: sr55 Date: Thu, 27 Dec 2012 21:26:24 +0000 Subject: WinGui: Improved handling of preview filename generation and fixed the seconds / frames options to update in realtime with the duration calculation. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5108 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Utilities/QueryGeneratorUtility.cs | 9 +------- win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs | 27 +++++++++++++++------- win/CS/HandBrakeWPF/Views/MainView.xaml | 4 ++-- 3 files changed, 22 insertions(+), 18 deletions(-) (limited to 'win') diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs index 83e551b42..a6dc97758 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs @@ -210,14 +210,7 @@ namespace HandBrake.ApplicationServices.Utilities /// private static string DestinationQuery(EncodeTask task) { - string query = string.Empty; - - if (task.PointToPointMode == PointToPointMode.Preview) - query += string.Format(" -o \"{0}\" ", task.Destination.Replace(".m", "_sample.m")); - else - query += string.Format(" -o \"{0}\" ", task.Destination); - - return query; + return string.Format(" -o \"{0}\" ", task.Destination); } /// diff --git a/win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs index ff723c7f0..d917c20c8 100644 --- a/win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs @@ -17,8 +17,6 @@ namespace HandBrakeWPF.ViewModels using System.Threading; using System.Windows; - using Caliburn.Micro; - using HandBrake.ApplicationServices; using HandBrake.ApplicationServices.Model; using HandBrake.ApplicationServices.Model.Encoding; @@ -76,9 +74,6 @@ namespace HandBrakeWPF.ViewModels /// /// Initializes a new instance of the class. /// - /// - /// The window manager. - /// /// /// The encode Service. /// @@ -88,7 +83,7 @@ namespace HandBrakeWPF.ViewModels /// /// The user Setting Service. /// - public PreviewViewModel(IWindowManager windowManager, IEncodeServiceWrapper encodeService, IErrorService errorService, IUserSettingService userSettingService) + public PreviewViewModel(IEncodeServiceWrapper encodeService, IErrorService errorService, IUserSettingService userSettingService) { this.encodeService = encodeService; this.errorService = errorService; @@ -274,8 +269,24 @@ namespace HandBrakeWPF.ViewModels PointToPointMode = PointToPointMode.Preview }; - this.CurrentlyPlaying = encodeTask.Destination.Replace(".m", "_sample.m"); - + // Filename handling. + if (string.IsNullOrEmpty(encodeTask.Destination)) + { + string filename = Path.ChangeExtension(Path.GetTempFileName(), encodeTask.OutputFormat == OutputFormat.Mkv ? "m4v" : "mkv"); + encodeTask.Destination = filename; + this.CurrentlyPlaying = filename; + } + else + { + string directory = Path.GetDirectoryName(encodeTask.Destination) ?? string.Empty; + string filename = Path.GetFileNameWithoutExtension(encodeTask.Destination); + string extension = Path.GetExtension(encodeTask.Destination); + string previewFilename = string.Format("{0}_preview{1}", filename, extension); + string previewFullPath = Path.Combine(directory, previewFilename); + encodeTask.Destination = previewFullPath; + this.CurrentlyPlaying = previewFullPath; + } + // Setup the encode task as a preview encode encodeTask.IsPreviewEncode = true; encodeTask.PreviewEncodeStartAt = this.StartAt.ToString(CultureInfo.InvariantCulture); diff --git a/win/CS/HandBrakeWPF/Views/MainView.xaml b/win/CS/HandBrakeWPF/Views/MainView.xaml index ebca0805c..5bed28974 100644 --- a/win/CS/HandBrakeWPF/Views/MainView.xaml +++ b/win/CS/HandBrakeWPF/Views/MainView.xaml @@ -373,7 +373,7 @@