From 0a535389348c04fb8f2ccae1fcf37215d2072f80 Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 24 May 2013 19:13:09 +0000 Subject: WinGui: Some usability improvements and bug fixes around the queue window. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5510 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Services/QueueProcessor.cs | 37 +++++++---- win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 12 +++- win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs | 74 ++++++++++------------ win/CS/HandBrakeWPF/Views/QueueView.xaml | 8 +-- 4 files changed, 75 insertions(+), 56 deletions(-) (limited to 'win') diff --git a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs index 92f69142c..a8cb55f58 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/QueueProcessor.cs @@ -51,6 +51,11 @@ namespace HandBrake.ApplicationServices.Services /// private string queueFile; + /// + /// The is paused. + /// + private bool isPaused; + #endregion #region Constructors and Destructors @@ -236,15 +241,15 @@ namespace HandBrake.ApplicationServices.Services { Execute.OnUIThread( () => + { + List deleteList = + this.queue.Where(task => task.Status == QueueItemStatus.Completed).ToList(); + foreach (QueueTask item in deleteList) { - List deleteList = - this.queue.Where(task => task.Status == QueueItemStatus.Completed).ToList(); - foreach (QueueTask item in deleteList) - { - this.queue.Remove(item); - } - this.InvokeQueueChanged(EventArgs.Empty); - }); + this.queue.Remove(item); + } + this.InvokeQueueChanged(EventArgs.Empty); + }); } /// @@ -379,8 +384,8 @@ namespace HandBrake.ApplicationServices.Services catch (Exception exc) { throw new GeneralApplicationException( - "Unable to restore queue file.", - "The file may be corrupted or from an older incompatible version of HandBrake", + "Unable to restore queue file.", + "The file may be corrupted or from an older incompatible version of HandBrake", exc); } @@ -419,6 +424,7 @@ namespace HandBrake.ApplicationServices.Services { this.InvokeQueuePaused(EventArgs.Empty); this.IsProcessing = false; + this.isPaused = true; } /// @@ -432,9 +438,16 @@ namespace HandBrake.ApplicationServices.Services throw new Exception("Already Processing the Queue"); } - this.IsProcessing = true; + this.EncodeService.EncodeCompleted -= this.EncodeServiceEncodeCompleted; this.EncodeService.EncodeCompleted += this.EncodeServiceEncodeCompleted; - this.ProcessNextJob(); + + if (!this.EncodeService.IsEncoding) + { + this.ProcessNextJob(); + } + + this.IsProcessing = true; + this.isPaused = false; } #endregion diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 4063c1e68..f3945fb7a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -1843,7 +1843,7 @@ namespace HandBrakeWPF.ViewModels Execute.OnUIThread( () => { - if (this.IsEncoding) + if (this.queueProcessor.EncodeService.IsEncoding) { this.ProgramStatusLabel = string.Format( @@ -1862,6 +1862,16 @@ namespace HandBrakeWPF.ViewModels lastEncodePercentage = percent; } + else + { + this.ProgramStatusLabel = "Queue Finished"; + this.IsEncoding = false; + + if (this.windowsSeven.IsWindowsSeven) + { + this.windowsSeven.SetTaskBarProgressToNoProgress(); + } + } }); } diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs index faa856d6b..3465fe273 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -237,6 +237,13 @@ namespace HandBrakeWPF.ViewModels public void PauseEncode() { this.queueProcessor.Pause(); + + this.JobStatus = "Queue Paused"; + this.JobsPending = string.Format("{0} jobs pending", this.queueProcessor.Count); + this.IsEncoding = false; + + MessageBox.Show("The Queue has been pasued. The currently running job will run to completion and no further jobs will start.", "Queue", + MessageBoxButton.OK, MessageBoxImage.Information); } /// @@ -293,6 +300,10 @@ namespace HandBrakeWPF.ViewModels return; } + this.JobStatus = "Queue Started"; + this.JobsPending = string.Format("{0} jobs pending", this.queueProcessor.Count); + this.IsEncoding = true; + this.queueProcessor.Start(); } @@ -364,13 +375,13 @@ namespace HandBrakeWPF.ViewModels this.WhenDoneAction = this.userSettingService.GetUserSetting(UserSettingConstants.WhenCompleteAction); - this.queueProcessor.JobProcessingStarted += this.queueProcessor_JobProcessingStarted; this.queueProcessor.QueueCompleted += this.queueProcessor_QueueCompleted; - this.queueProcessor.QueuePaused += this.queueProcessor_QueuePaused; this.queueProcessor.QueueChanged += this.QueueManager_QueueChanged; this.queueProcessor.EncodeService.EncodeStatusChanged += this.EncodeService_EncodeStatusChanged; + this.queueProcessor.EncodeService.EncodeCompleted += EncodeService_EncodeCompleted; this.JobsPending = string.Format("{0} jobs pending", this.queueProcessor.Count); + this.JobStatus = "Queue Ready"; base.OnActivate(); } @@ -383,11 +394,10 @@ namespace HandBrakeWPF.ViewModels /// protected override void OnDeactivate(bool close) { - this.queueProcessor.JobProcessingStarted -= this.queueProcessor_JobProcessingStarted; this.queueProcessor.QueueCompleted -= this.queueProcessor_QueueCompleted; - this.queueProcessor.QueuePaused -= this.queueProcessor_QueuePaused; this.queueProcessor.QueueChanged -= this.QueueManager_QueueChanged; this.queueProcessor.EncodeService.EncodeStatusChanged -= this.EncodeService_EncodeStatusChanged; + this.queueProcessor.EncodeService.EncodeCompleted -= EncodeService_EncodeCompleted; base.OnDeactivate(close); } @@ -406,19 +416,16 @@ namespace HandBrakeWPF.ViewModels { Caliburn.Micro.Execute.OnUIThread(() => { - if (this.IsEncoding) - { - this.JobStatus = - string.Format( - "Encoding: Pass {0} of {1}, {2:00.00}%, FPS: {3:000.0}, Avg FPS: {4:000.0}, Time Remaining: {5}, Elapsed: {6:hh\\:mm\\:ss}", - e.Task, - e.TaskCount, - e.PercentComplete, - e.CurrentFrameRate, - e.AverageFrameRate, - e.EstimatedTimeLeft, - e.ElapsedTime); - } + this.JobStatus = + string.Format( + "Encoding: Pass {0} of {1}, {2:00.00}%, FPS: {3:000.0}, Avg FPS: {4:000.0}, Time Remaining: {5}, Elapsed: {6:hh\\:mm\\:ss}", + e.Task, + e.TaskCount, + e.PercentComplete, + e.CurrentFrameRate, + e.AverageFrameRate, + e.EstimatedTimeLeft, + e.ElapsedTime); }); } @@ -434,23 +441,11 @@ namespace HandBrakeWPF.ViewModels private void QueueManager_QueueChanged(object sender, EventArgs e) { this.JobsPending = string.Format("{0} jobs pending", this.queueProcessor.Count); - } - /// - /// Handle teh Job Processing Started Event - /// - /// - /// The sender. - /// - /// - /// The QueueProgressEventArgs. - /// - private void queueProcessor_JobProcessingStarted( - object sender, QueueProgressEventArgs e) - { - this.JobStatus = "Queue Started"; - this.JobsPending = string.Format("{0} jobs pending", this.queueProcessor.Count); - this.IsEncoding = true; + if (!queueProcessor.IsProcessing) + { + this.JobStatus = "Queue Not Running"; + } } /// @@ -470,19 +465,20 @@ namespace HandBrakeWPF.ViewModels } /// - /// Handle the Queue Paused Event + /// The encode service_ encode completed. /// /// /// The sender. /// /// - /// The EventArgs. + /// The e. /// - private void queueProcessor_QueuePaused(object sender, EventArgs e) + private void EncodeService_EncodeCompleted(object sender, EncodeCompletedEventArgs e) { - this.JobStatus = "Queue Paused"; - this.JobsPending = string.Format("{0} jobs pending", this.queueProcessor.Count); - this.IsEncoding = false; + if (!this.queueProcessor.IsProcessing) + { + this.JobStatus = "Last Queued Job Finished"; + } } #endregion diff --git a/win/CS/HandBrakeWPF/Views/QueueView.xaml b/win/CS/HandBrakeWPF/Views/QueueView.xaml index e0758689d..d3df53451 100644 --- a/win/CS/HandBrakeWPF/Views/QueueView.xaml +++ b/win/CS/HandBrakeWPF/Views/QueueView.xaml @@ -10,10 +10,10 @@ xmlns:YourNamespace="clr-namespace:HandBrakeWPF.AttachedProperties" xmlns:Audio="clr-namespace:HandBrakeWPF.Converters.Audio" xmlns:Subtitles="clr-namespace:HandBrakeWPF.Converters.Subtitles" Title="{Binding Title}" - Width="600" - Height="400" - MinWidth="600" - MinHeight="400" + Width="700" + Height="500" + MinWidth="200" + MinHeight="200" Background="#FFF0F0F0" WindowStartupLocation="CenterScreen" TextOptions.TextFormattingMode="Display" -- cgit v1.2.3