]> granicus.if.org Git - handbrake/commitdiff
WinGui: Couple of UI fixes.
authorsr55 <sr55.hb@outlook.com>
Sun, 21 Oct 2012 13:44:25 +0000 (13:44 +0000)
committersr55 <sr55.hb@outlook.com>
Sun, 21 Oct 2012 13:44:25 +0000 (13:44 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5024 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs

index 1aa60eb97c1904ab5eb217c34476edffec183222..934a0b18d80de9dae89e41309eecd1da2b80ff5b 100644 (file)
@@ -35,6 +35,8 @@ namespace HandBrakeWPF.ViewModels
     using HandBrakeWPF.ViewModels.Interfaces;\r
     using HandBrakeWPF.Views;\r
 \r
+    using Microsoft.Win32;\r
+\r
     using Ookii.Dialogs.Wpf;\r
 \r
     using Image = System.Windows.Controls.Image;\r
@@ -218,6 +220,7 @@ namespace HandBrakeWPF.ViewModels
             this.scanService.ScanStatusChanged += this.ScanStatusChanged;\r
             this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;\r
             this.queueProcessor.QueueCompleted += this.QueueCompleted;\r
+            this.queueProcessor.QueueChanged += this.QueueChanged;\r
             this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;\r
 \r
             this.Presets = this.presetService.Presets;\r
@@ -606,10 +609,10 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         public bool ShowDebugMenu\r
         {\r
-           get\r
-           {\r
-               return this.userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableDebugFeatures);\r
-           }\r
+            get\r
+            {\r
+                return this.userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableDebugFeatures);\r
+            }\r
         }\r
 \r
         /// <summary>\r
@@ -849,6 +852,7 @@ namespace HandBrakeWPF.ViewModels
             this.scanService.ScanStatusChanged -= this.ScanStatusChanged;\r
 \r
             this.queueProcessor.QueueCompleted -= this.QueueCompleted;\r
+            this.queueProcessor.QueueChanged -= this.QueueChanged;\r
             this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted;\r
             this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged;\r
         }\r
@@ -1171,7 +1175,7 @@ namespace HandBrakeWPF.ViewModels
         public void ShowCliQuery()\r
         {\r
             this.errorService.ShowMessageBox(\r
-                QueryGeneratorUtility.GenerateQuery(this.CurrentTask, \r
+                QueryGeneratorUtility.GenerateQuery(this.CurrentTask,\r
                 userSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount),\r
                 userSettingService.GetUserSetting<int>(ASUserSettingConstants.Verbosity),\r
                 userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav)),\r
@@ -1186,13 +1190,13 @@ namespace HandBrakeWPF.ViewModels
         public void DebugScanLog()\r
         {\r
             VistaOpenFileDialog dialog = new VistaOpenFileDialog();\r
-             \r
+\r
             dialog.ShowDialog();\r
 \r
             if (File.Exists(dialog.FileName))\r
             {\r
                 this.scanService.DebugScanLog(dialog.FileName);\r
-            }    \r
+            }\r
         }\r
 \r
         #endregion\r
@@ -1224,30 +1228,33 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         public void BrowseDestination()\r
         {\r
-            VistaSaveFileDialog dialog = new VistaSaveFileDialog\r
+            SaveFileDialog saveFileDialog = new SaveFileDialog\r
                 {\r
                     Filter = "mp4|*.mp4;*.m4v|mkv|*.mkv",\r
+                    CheckPathExists = true,\r
                     AddExtension = true,\r
-                    OverwritePrompt = true,\r
                     DefaultExt = ".mp4",\r
+                    OverwritePrompt = true,\r
+                    FilterIndex = this.CurrentTask.OutputFormat == OutputFormat.Mkv ? 1 : 0,\r
                 };\r
 \r
             if (this.CurrentTask != null && !string.IsNullOrEmpty(this.CurrentTask.Destination))\r
             {\r
                 if (Directory.Exists(Path.GetDirectoryName(this.CurrentTask.Destination)))\r
                 {\r
-                    dialog.InitialDirectory = Path.GetDirectoryName(this.CurrentTask.Destination) + "\\";\r
-                    dialog.FileName = Path.GetFileName(this.CurrentTask.Destination);\r
+                    saveFileDialog.InitialDirectory = Path.GetDirectoryName(this.CurrentTask.Destination) + "\\";\r
                 }\r
+\r
+                saveFileDialog.FileName = Path.GetFileName(this.CurrentTask.Destination);\r
             }\r
 \r
-            dialog.ShowDialog();\r
-            this.Destination = dialog.FileName;\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(dialog.FileName))\r
+            if (!string.IsNullOrEmpty(saveFileDialog.FileName))\r
             {\r
-                switch (Path.GetExtension(dialog.FileName))\r
+                switch (Path.GetExtension(saveFileDialog.FileName))\r
                 {\r
                     case ".mkv":\r
                         this.SelectedOutputFormat = OutputFormat.Mkv;\r
@@ -1301,7 +1308,7 @@ namespace HandBrakeWPF.ViewModels
 \r
                 this.errorService.ShowMessageBox(\r
                         "The Preset has now been updated with your current settings.", "Preset Updated", MessageBoxButton.OK, MessageBoxImage.Information);\r
-            } \r
+            }\r
         }\r
 \r
         /// <summary>\r
@@ -1384,8 +1391,7 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         public void PresetExport()\r
         {\r
-            VistaSaveFileDialog savefiledialog = new VistaSaveFileDialog\r
-                { Filter = "plist|*.plist", CheckPathExists = true, AddExtension = true };\r
+            VistaSaveFileDialog savefiledialog = new VistaSaveFileDialog { Filter = "plist|*.plist", CheckPathExists = true, AddExtension = true };\r
             if (this.selectedPreset != null)\r
             {\r
                 savefiledialog.ShowDialog();\r
@@ -1631,11 +1637,11 @@ namespace HandBrakeWPF.ViewModels
                 {\r
                     if (e.Successful)\r
                     {\r
-                        this.NotifyOfPropertyChange("ScannedSource");\r
-                        this.NotifyOfPropertyChange("ScannedSource.Titles");\r
+                        this.NotifyOfPropertyChange(() => this.ScannedSource);\r
+                        this.NotifyOfPropertyChange(() => this.ScannedSource.Titles);\r
                         this.SelectedTitle = this.ScannedSource.Titles.FirstOrDefault(t => t.MainTitle)\r
                                              ?? this.ScannedSource.Titles.FirstOrDefault();\r
-                        this.SetupTabs();      \r
+                        this.SetupTabs();\r
                     }\r
 \r
                     this.ShowStatusWindow = false;\r
@@ -1644,23 +1650,23 @@ namespace HandBrakeWPF.ViewModels
                         if (this.SelectedTitle != null && !string.IsNullOrEmpty(this.SelectedTitle.SourceName))\r
                         {\r
                             this.SourceLabel = this.SelectedTitle.SourceName;\r
-                        } \r
+                        }\r
                         else\r
                         {\r
                             this.SourceLabel = this.SourceName;\r
                         }\r
 \r
                         this.StatusLabel = "Scan Completed";\r
-                    } \r
+                    }\r
                     else if (!e.Successful && e.Exception == null)\r
                     {\r
                         this.SourceLabel = "Scan Cancelled.";\r
                         this.StatusLabel = "Scan Cancelled.";\r
-                    } \r
+                    }\r
                     else\r
                     {\r
                         this.SourceLabel = "Scan Failed... See Activity Log for details.";\r
-                        this.StatusLabel = "Scan Failed... See Activity Log for details."; \r
+                        this.StatusLabel = "Scan Failed... See Activity Log for details.";\r
                     }\r
                 });\r
         }\r
@@ -1753,6 +1759,24 @@ namespace HandBrakeWPF.ViewModels
                 });\r
         }\r
 \r
+        /// <summary>\r
+        /// The queue changed.\r
+        /// </summary>\r
+        /// <param name="sender">\r
+        /// The sender.\r
+        /// </param>\r
+        /// <param name="e">\r
+        /// The EventArgs.\r
+        /// </param>\r
+        private void QueueChanged(object sender, EventArgs e)\r
+        {\r
+            Execute.OnUIThread(\r
+              () =>\r
+              {\r
+                  this.ProgramStatusLabel = string.Format("{0} Encodes Pending", this.queueProcessor.Count);\r
+              });\r
+        }\r
+\r
         /// <summary>\r
         /// The process drive.\r
         /// </summary>\r
@@ -1831,7 +1855,7 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         private void DriveTrayChanged()\r
         {\r
-            Caliburn.Micro.Execute.OnUIThread(() => this.SourceMenu = this.GenerateSourceMenu());       \r
+            Caliburn.Micro.Execute.OnUIThread(() => this.SourceMenu = this.GenerateSourceMenu());\r
         }\r
 \r
         #endregion\r