]> granicus.if.org Git - handbrake/commitdiff
WinGui: Improvements and fixes to the Output Format Dropdown / Destination
authorsr55 <sr55.hb@outlook.com>
Thu, 6 Mar 2014 19:20:58 +0000 (19:20 +0000)
committersr55 <sr55.hb@outlook.com>
Thu, 6 Mar 2014 19:20:58 +0000 (19:20 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6100 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrake.ApplicationServices/Model/Encoding/OutputFormat.cs
win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs

index d9070de2fa227396962c342dd8c61e3fee3f162b..98116773f7053aa2936eb629c274a4a9b5fe1431 100644 (file)
@@ -17,7 +17,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding
     public enum OutputFormat\r
     {\r
         [Description("MP4")]\r
-        Mp4,\r
+        Mp4 = 0,\r
 \r
         [Description("M4V")]\r
         M4V,\r
index a2ae6708b0cffeca48eb5f7f6c838a4bba927596..4dcf9bc67f6f73d2fac42297216a2637adbef795 100644 (file)
@@ -636,8 +636,30 @@ namespace HandBrakeWPF.ViewModels
             }\r
             set\r
             {\r
-                this.CurrentTask.Destination = value;\r
-                this.NotifyOfPropertyChange(() => this.Destination);\r
+                if (!object.Equals(this.CurrentTask.Destination, value))\r
+                {\r
+                    this.CurrentTask.Destination = value;\r
+                    this.NotifyOfPropertyChange(() => this.Destination);\r
+\r
+                    if (!string.IsNullOrEmpty(this.CurrentTask.Destination))\r
+                    {\r
+                        switch (Path.GetExtension(this.CurrentTask.Destination))\r
+                        {\r
+                            case ".mkv":\r
+                                this.SelectedOutputFormat = OutputFormat.Mkv;\r
+                                break;\r
+                            case ".mp4":\r
+                                this.SelectedOutputFormat = OutputFormat.Mp4;\r
+                                break;\r
+                            case ".m4v":\r
+                                this.SelectedOutputFormat = OutputFormat.Mp4;\r
+                                break;\r
+                            case ".x265":\r
+                                this.SelectedOutputFormat = OutputFormat.X265;\r
+                                break;\r
+                        }\r
+                    }\r
+                }\r
             }\r
         }\r
 \r
@@ -855,15 +877,18 @@ namespace HandBrakeWPF.ViewModels
 \r
             set\r
             {\r
-                this.selectedOutputFormat = value;\r
-                this.CurrentTask.OutputFormat = value;\r
-                this.NotifyOfPropertyChange(() => SelectedOutputFormat);\r
-                this.NotifyOfPropertyChange(() => this.CurrentTask.OutputFormat);\r
-                this.NotifyOfPropertyChange(() => IsMkv);\r
-                this.SetExtension(string.Format(".{0}", this.selectedOutputFormat.ToString().ToLower()));\r
+                if (!object.Equals(this.selectedOutputFormat, value))\r
+                {\r
+                    this.selectedOutputFormat = value;\r
+                    this.CurrentTask.OutputFormat = value;\r
+                    this.NotifyOfPropertyChange(() => SelectedOutputFormat);\r
+                    this.NotifyOfPropertyChange(() => this.CurrentTask.OutputFormat);\r
+                    this.NotifyOfPropertyChange(() => IsMkv);\r
+                    this.SetExtension(string.Format(".{0}", this.selectedOutputFormat.ToString().ToLower()));\r
 \r
-                this.VideoViewModel.RefreshTask();\r
-                this.AudioViewModel.RefreshTask();\r
+                    this.VideoViewModel.RefreshTask();\r
+                    this.AudioViewModel.RefreshTask();\r
+                }\r
             }\r
         }\r
 \r
@@ -1144,7 +1169,7 @@ namespace HandBrakeWPF.ViewModels
             }\r
 \r
             QueueTask task = new QueueTask(new EncodeTask(this.CurrentTask), HBConfigurationFactory.Create());\r
-            \r
+\r
             if (!this.queueProcessor.CheckForDestinationPathDuplicates(task.Task.Destination))\r
             {\r
                 this.queueProcessor.Add(task);\r
@@ -1411,9 +1436,15 @@ namespace HandBrakeWPF.ViewModels
                     AddExtension = true,\r
                     DefaultExt = ".mp4",\r
                     OverwritePrompt = true,\r
-                    FilterIndex = this.CurrentTask.OutputFormat == OutputFormat.Mkv ? 1 : 0,\r
                 };\r
 \r
+            string extension = Path.GetExtension(this.CurrentTask.Destination);\r
+\r
+            saveFileDialog.FilterIndex = !string.IsNullOrEmpty(this.CurrentTask.Destination)\r
+                                         && !string.IsNullOrEmpty(extension)\r
+                                             ? (extension == ".mp4" || extension == ".m4v" ? 1 : 2)\r
+                                             : (this.CurrentTask.OutputFormat == OutputFormat.Mkv ? 2 : 0);\r
+\r
             if (this.CurrentTask != null && !string.IsNullOrEmpty(this.CurrentTask.Destination))\r
             {\r
                 saveFileDialog.InitialDirectory = Directory.Exists(Path.GetDirectoryName(this.CurrentTask.Destination))\r
@@ -1423,29 +1454,32 @@ namespace HandBrakeWPF.ViewModels
                 saveFileDialog.FileName = Path.GetFileName(this.CurrentTask.Destination);\r
             }\r
 \r
-            saveFileDialog.ShowDialog();\r
-            this.Destination = saveFileDialog.FileName;\r
-\r
-            // Set the Extension Dropdown. This will also set Mp4/m4v correctly.\r
-            if (!string.IsNullOrEmpty(saveFileDialog.FileName))\r
+            bool? result = saveFileDialog.ShowDialog();\r
+            if (result.HasValue && result.Value)\r
             {\r
-                switch (Path.GetExtension(saveFileDialog.FileName))\r
+                this.Destination = saveFileDialog.FileName;\r
+\r
+                // Set the Extension Dropdown. This will also set Mp4/m4v correctly.\r
+                if (!string.IsNullOrEmpty(saveFileDialog.FileName))\r
                 {\r
-                    case ".mkv":\r
-                        this.SelectedOutputFormat = OutputFormat.Mkv;\r
-                        break;\r
-                    case ".mp4":\r
-                        this.SelectedOutputFormat = OutputFormat.Mp4;\r
-                        break;\r
-                    case ".m4v":\r
-                        this.SelectedOutputFormat = OutputFormat.M4V;\r
-                        break;\r
-                    case ".x265":\r
-                        this.SelectedOutputFormat = OutputFormat.X265;\r
-                        break;\r
-                }\r
+                    switch (Path.GetExtension(saveFileDialog.FileName))\r
+                    {\r
+                        case ".mkv":\r
+                            this.SelectedOutputFormat = OutputFormat.Mkv;\r
+                            break;\r
+                        case ".mp4":\r
+                            this.SelectedOutputFormat = OutputFormat.Mp4;\r
+                            break;\r
+                        case ".m4v":\r
+                            this.SelectedOutputFormat = OutputFormat.M4V;\r
+                            break;\r
+                        case ".x265":\r
+                            this.SelectedOutputFormat = OutputFormat.X265;\r
+                            break;\r
+                    }\r
 \r
-                this.NotifyOfPropertyChange(() => this.CurrentTask);\r
+                    this.NotifyOfPropertyChange(() => this.CurrentTask);\r
+                }\r
             }\r
         }\r
 \r