]> granicus.if.org Git - handbrake/commitdiff
WinGui: Improved handling of preview filename generation and fixed the seconds /...
authorsr55 <sr55.hb@outlook.com>
Thu, 27 Dec 2012 21:26:24 +0000 (21:26 +0000)
committersr55 <sr55.hb@outlook.com>
Thu, 27 Dec 2012 21:26:24 +0000 (21:26 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5108 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.ApplicationServices/Utilities/QueryGeneratorUtility.cs
win/CS/HandBrakeWPF/ViewModels/PreviewViewModel.cs
win/CS/HandBrakeWPF/Views/MainView.xaml

index 83e551b429234aebe6d42bd254c48e326418c561..a6dc977581ce42a62ef66ba4141d3d3203d07be2 100644 (file)
@@ -210,14 +210,7 @@ namespace HandBrake.ApplicationServices.Utilities
         /// </returns>\r
         private static string DestinationQuery(EncodeTask task)\r
         {\r
-            string query = string.Empty;\r
-\r
-            if (task.PointToPointMode == PointToPointMode.Preview)\r
-                query += string.Format(" -o \"{0}\" ", task.Destination.Replace(".m", "_sample.m"));\r
-            else\r
-                query += string.Format(" -o \"{0}\" ", task.Destination);\r
-\r
-            return query;\r
+            return string.Format(" -o \"{0}\" ", task.Destination);\r
         }\r
 \r
         /// <summary>\r
index ff723c7f0db042f9adfec2f82adb7a5e6b91a05d..d917c20c8d1e362e9700ad499c0384a073a138c3 100644 (file)
@@ -17,8 +17,6 @@ namespace HandBrakeWPF.ViewModels
     using System.Threading;\r
     using System.Windows;\r
 \r
-    using Caliburn.Micro;\r
-\r
     using HandBrake.ApplicationServices;\r
     using HandBrake.ApplicationServices.Model;\r
     using HandBrake.ApplicationServices.Model.Encoding;\r
@@ -76,9 +74,6 @@ namespace HandBrakeWPF.ViewModels
         /// <summary>\r
         /// Initializes a new instance of the <see cref="PreviewViewModel"/> class.\r
         /// </summary>\r
-        /// <param name="windowManager">\r
-        /// The window manager.\r
-        /// </param>\r
         /// <param name="encodeService">\r
         /// The encode Service.\r
         /// </param>\r
@@ -88,7 +83,7 @@ namespace HandBrakeWPF.ViewModels
         /// <param name="userSettingService">\r
         /// The user Setting Service.\r
         /// </param>\r
-        public PreviewViewModel(IWindowManager windowManager, IEncodeServiceWrapper encodeService, IErrorService errorService, IUserSettingService userSettingService) \r
+        public PreviewViewModel(IEncodeServiceWrapper encodeService, IErrorService errorService, IUserSettingService userSettingService) \r
         {\r
             this.encodeService = encodeService;\r
             this.errorService = errorService;\r
@@ -274,8 +269,24 @@ namespace HandBrakeWPF.ViewModels
                     PointToPointMode = PointToPointMode.Preview\r
                 };\r
 \r
-            this.CurrentlyPlaying = encodeTask.Destination.Replace(".m", "_sample.m");\r
-\r
+            // Filename handling.\r
+            if (string.IsNullOrEmpty(encodeTask.Destination))\r
+            {\r
+                string filename = Path.ChangeExtension(Path.GetTempFileName(), encodeTask.OutputFormat == OutputFormat.Mkv ? "m4v" : "mkv");\r
+                encodeTask.Destination = filename;\r
+                this.CurrentlyPlaying = filename;\r
+            }\r
+            else\r
+            {\r
+                string directory =  Path.GetDirectoryName(encodeTask.Destination) ?? string.Empty;\r
+                string filename = Path.GetFileNameWithoutExtension(encodeTask.Destination);\r
+                string extension = Path.GetExtension(encodeTask.Destination);\r
+                string previewFilename = string.Format("{0}_preview{1}", filename, extension);\r
+                string previewFullPath = Path.Combine(directory, previewFilename);\r
+                encodeTask.Destination = previewFullPath;\r
+                this.CurrentlyPlaying = previewFullPath;\r
+            }\r
+            \r
             // Setup the encode task as a preview encode\r
             encodeTask.IsPreviewEncode = true;\r
             encodeTask.PreviewEncodeStartAt = this.StartAt.ToString(CultureInfo.InvariantCulture);\r
index ebca0805c6f44604fb8cd362b763b61a1bfc50a5..5bed28974081f2723ce4022fae1922dbc207de2f 100644 (file)
                         <TextBox Name="StartPointText"\r
                                  MinWidth="60"\r
                                  Margin="8,0,0,0"\r
-                                 Text="{Binding SelectedStartPoint}"\r
+                                 Text="{Binding SelectedStartPoint, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"\r
                                  Visibility="{Binding ShowTextEntryForPointToPointMode,\r
                                                       Converter={StaticResource boolToVisConverter},\r
                                                       ConverterParameter=false}"\r
                         <TextBox Name="EndPointText"\r
                                  MinWidth="60"\r
                                  Margin="8,0,0,0"\r
-                                 Text="{Binding SelectedEndPoint}"\r
+                                 Text="{Binding SelectedEndPoint, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"\r
                                  Visibility="{Binding ShowTextEntryForPointToPointMode,\r
                                                       Converter={StaticResource boolToVisConverter},\r
                                                       ConverterParameter=false}"\r