]> granicus.if.org Git - handbrake/commitdiff
WinGui: Another set of assorted fixes and UI tweaks.
authorsr55 <sr55.hb@outlook.com>
Tue, 26 Jun 2012 20:46:19 +0000 (20:46 +0000)
committersr55 <sr55.hb@outlook.com>
Tue, 26 Jun 2012 20:46:19 +0000 (20:46 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4781 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/HandBrakeWPF/App.xaml
win/CS/HandBrakeWPF/ViewModels/Interfaces/IShellViewModel.cs
win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
win/CS/HandBrakeWPF/ViewModels/ShellViewModel.cs
win/CS/HandBrakeWPF/Views/QueueView.xaml
win/CS/HandBrakeWPF/Views/ShellView.xaml.cs

index 5ac1f993e0ae8087e40655cd2bc87ff6e71cf151..24ea02909a2ac7ff073a3b45d89b522107608baa 100644 (file)
@@ -1,6 +1,7 @@
 <Application x:Class="HandBrakeWPF.App"\r
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"\r
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:HandBrakeWPF.Startup">\r
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:HandBrakeWPF.Startup"\r
+             ShutdownMode="OnMainWindowClose">\r
     <Application.Resources>\r
         <ResourceDictionary>\r
             <ResourceDictionary.MergedDictionaries>\r
index 4964e8b40b1db0699801d4d176e677a696fc2a44..6c537ef664e72e6778ab2bad3ad6809eb7d2dd9f 100644 (file)
@@ -23,5 +23,13 @@ namespace HandBrakeWPF.ViewModels.Interfaces
         /// The window.\r
         /// </param>\r
         void DisplayWindow(ShellWindow window);\r
+\r
+        /// <summary>\r
+        /// Checks with the use if this window can be closed.\r
+        /// </summary>\r
+        /// <returns>\r
+        /// Returns true if the window can be closed.\r
+        /// </returns>\r
+        bool CanClose();\r
     }\r
 }\r
index fe1e333eb7792a4923cf41937789de5e3f6761dd..54c0d8e1e3e94960dd37f18f67d0c090b25b6e5c 100644 (file)
@@ -192,7 +192,6 @@ namespace HandBrakeWPF.ViewModels
             this.scanService.ScanStatusChanged += this.ScanStatusChanged;\r
             this.queueProcessor.JobProcessingStarted += this.QueueProcessorJobProcessingStarted;\r
             this.queueProcessor.QueueCompleted += this.QueueCompleted;\r
-            this.queueProcessor.QueuePaused += this.QueuePaused;\r
             this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeStatusChanged;\r
 \r
             this.Presets = this.presetService.Presets;\r
@@ -834,7 +833,6 @@ namespace HandBrakeWPF.ViewModels
             this.scanService.ScanStatusChanged -= this.ScanStatusChanged;\r
 \r
             this.queueProcessor.QueueCompleted -= this.QueueCompleted;\r
-            this.queueProcessor.QueuePaused -= this.QueuePaused;\r
             this.queueProcessor.JobProcessingStarted -= this.QueueProcessorJobProcessingStarted;\r
             this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeStatusChanged;\r
         }\r
@@ -935,7 +933,15 @@ namespace HandBrakeWPF.ViewModels
             }\r
 \r
             QueueTask task = new QueueTask { Task = new EncodeTask(this.CurrentTask) };\r
-            this.queueProcessor.QueueManager.Add(task);\r
+            if (!this.queueProcessor.QueueManager.CheckForDestinationPathDuplicates(task.Task.Destination))\r
+            {\r
+                this.queueProcessor.QueueManager.Add(task);\r
+            } \r
+            else\r
+            {\r
+                this.errorService.ShowMessageBox("There are jobs on the queue with the same destination path. Please choose a different path for this job.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);\r
+            }\r
+            \r
 \r
             if (!this.IsEncoding)\r
             {\r
@@ -1044,6 +1050,12 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         public void StartEncode()\r
         {\r
+            if (this.queueProcessor.IsProcessing)\r
+            {\r
+                this.errorService.ShowMessageBox("HandBrake is already encoding.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);\r
+                return;\r
+            }\r
+\r
             // Check if we already have jobs, and if we do, just start the queue.\r
             if (this.queueProcessor.QueueManager.Count != 0)\r
             {\r
@@ -1064,11 +1076,6 @@ namespace HandBrakeWPF.ViewModels
                 return;\r
             }\r
 \r
-            if (this.queueProcessor.IsProcessing)\r
-            {\r
-                this.errorService.ShowMessageBox("HandBrake is already encoding.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);\r
-                return;\r
-            }\r
 \r
             if (File.Exists(this.Destination))\r
             {\r
@@ -1103,6 +1110,7 @@ namespace HandBrakeWPF.ViewModels
         /// </summary>\r
         public void StopEncode()\r
         {\r
+            this.queueProcessor.Pause();\r
             this.encodeService.Stop();\r
         }\r
 \r
@@ -1534,23 +1542,6 @@ namespace HandBrakeWPF.ViewModels
                    this.ProgramStatusLabel = "Preparing to encode ...";\r
                    this.IsEncoding = true;\r
                });\r
-\r
-            // TODO Handle Updating the UI\r
-        }\r
-\r
-        /// <summary>\r
-        /// The Queue has been paused handler\r
-        /// </summary>\r
-        /// <param name="sender">\r
-        /// The Sender\r
-        /// </param>\r
-        /// <param name="e">\r
-        /// The EventArgs\r
-        /// </param>\r
-        private void QueuePaused(object sender, EventArgs e)\r
-        {\r
-            this.IsEncoding = false;\r
-            // TODO Handle Updating the UI\r
         }\r
 \r
         /// <summary>\r
@@ -1572,8 +1563,6 @@ namespace HandBrakeWPF.ViewModels
                     this.ProgramStatusLabel = "Queue Finished";\r
                     this.IsEncoding = false;\r
                 });\r
-\r
-            // TODO Handle Updating the UI\r
         }\r
 \r
         /// <summary>\r
index 349dc1200b1315e902a3ac9e1a3e2dbeb3b9485c..ef3f1a53aa8725b55017206a5e08a8a1c818db83 100644 (file)
 namespace HandBrakeWPF.ViewModels\r
 {\r
     using System.ComponentModel.Composition;\r
+    using System.Windows;\r
+\r
+    using Caliburn.Micro;\r
+\r
+    using HandBrake.ApplicationServices.Services.Interfaces;\r
 \r
     using HandBrakeWPF.Model;\r
+    using HandBrakeWPF.Services.Interfaces;\r
     using HandBrakeWPF.ViewModels.Interfaces;\r
 \r
     /// <summary>\r
@@ -20,6 +26,11 @@ namespace HandBrakeWPF.ViewModels
     [Export(typeof(IShellViewModel))]\r
     public class ShellViewModel : ViewModelBase, IShellViewModel\r
     {\r
+        /// <summary>\r
+        /// Backing field for the error service.\r
+        /// </summary>\r
+        private readonly IErrorService errorService;\r
+\r
         #region Constants and Fields\r
 \r
         /// <summary>\r
@@ -37,8 +48,12 @@ namespace HandBrakeWPF.ViewModels
         /// <summary>\r
         /// Initializes a new instance of the <see cref="ShellViewModel"/> class.\r
         /// </summary>\r
-        public ShellViewModel()\r
+        /// <param name="errorService">\r
+        /// The error Service.\r
+        /// </param>\r
+        public ShellViewModel(IErrorService errorService)\r
         {\r
+            this.errorService = errorService;\r
             this.showMainWindow = true;\r
             this.showOptions = false;\r
         }\r
@@ -60,7 +75,7 @@ namespace HandBrakeWPF.ViewModels
             {\r
                 this.ShowOptions = true;\r
                 this.ShowMainWindow = false;\r
-            } \r
+            }\r
             else\r
             {\r
                 this.ShowMainWindow = true;\r
@@ -124,5 +139,35 @@ namespace HandBrakeWPF.ViewModels
         }\r
 \r
         #endregion\r
+\r
+        /// <summary>\r
+        /// Checks with the use if this window can be closed.\r
+        /// </summary>\r
+        /// <returns>\r
+        /// Returns true if the window can be closed.\r
+        /// </returns>\r
+        public bool CanClose()\r
+        {\r
+            IQueueProcessor processor = IoC.Get<IQueueProcessor>();\r
+            if (processor.EncodeService.IsEncoding)\r
+            {\r
+                MessageBoxResult result =\r
+                    errorService.ShowMessageBox(\r
+                        "An Encode is currently running. Exiting HandBrake will stop this encode.\nAre you sure you wish to continue?",\r
+                        "Warning",\r
+                        MessageBoxButton.YesNo,\r
+                        MessageBoxImage.Warning);\r
+\r
+                if (result == MessageBoxResult.Yes)\r
+                {\r
+                    processor.Pause();\r
+                    processor.EncodeService.Stop();\r
+                    return true;\r
+                }\r
+                return false;\r
+            }\r
+\r
+            return true;\r
+        }\r
     }\r
 }
\ No newline at end of file
index e505800fcc7be97493493d4e2c297496f044b111..7ef652b2965ed0a4e3199cda085ba822a1d7f6fb 100644 (file)
 \r
             <ListBox.ContextMenu>\r
                 <ContextMenu>\r
-                    <MenuItem cal:Message.Attach="[Event Click] = [Action Import]" Header="Import Queue" />\r
-                    <MenuItem cal:Message.Attach="[Event Click] = [Action Export]" Header="Export Queue" />\r
-                    <Separator />\r
                     <MenuItem cal:Message.Attach="[Event Click] = [Action Clear]" Header="Clear" />\r
                     <MenuItem cal:Message.Attach="[Event Click] = [Action ClearCompleted]" Header="Clear Completed" />\r
+                    <Separator />\r
+                    <MenuItem cal:Message.Attach="[Event Click] = [Action Import]" Header="Import Queue" />\r
+                    <MenuItem cal:Message.Attach="[Event Click] = [Action Export]" Header="Export Queue" />\r
                 </ContextMenu>\r
             </ListBox.ContextMenu>\r
 \r
                                 <TextBlock FontWeight="Bold" Text="Destination: " />\r
                                 <TextBlock Text="{Binding Task.Destination, Converter={StaticResource filePathToFilenameConverter}}" />\r
                             </StackPanel>\r
-\r
-                            <StackPanel Orientation="Horizontal">\r
-                                <TextBlock FontWeight="Bold" Text="Status: " />\r
-                                <TextBlock Text="{Binding Status, Converter={StaticResource enumComboConverter}}" />\r
-                            </StackPanel>\r
                         </StackPanel>\r
 \r
                         <!--  Delete  -->\r
index cc6b381de315faaf3e2348355572ac40d854f5fd..6b291702db64d2026d19ef4be02ba2a035a16b68 100644 (file)
@@ -11,6 +11,8 @@ namespace HandBrakeWPF.Views
 {\r
     using System.Windows;\r
 \r
+    using HandBrakeWPF.ViewModels.Interfaces;\r
+\r
     /// <summary>\r
     /// Interaction logic for ShellView.xaml\r
     /// </summary>\r
@@ -23,5 +25,22 @@ namespace HandBrakeWPF.Views
         {\r
             this.InitializeComponent();\r
         }\r
+\r
+        /// <summary>\r
+        /// Check with the user before closing.\r
+        /// </summary>\r
+        /// <param name="e">\r
+        /// The CancelEventArgs.\r
+        /// </param>\r
+        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)\r
+        {\r
+            bool canClose = ((IShellViewModel)this.DataContext).CanClose();\r
+            if (!canClose)\r
+            {\r
+                e.Cancel = true;\r
+            }\r
+\r
+            base.OnClosing(e);\r
+        }\r
     }\r
 }\r