summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels
diff options
context:
space:
mode:
authorsr55 <[email protected]>2013-03-07 22:11:11 +0000
committersr55 <[email protected]>2013-03-07 22:11:11 +0000
commit0058e66974b545911342f72078469653384b509d (patch)
tree91ee17656180a2065deb72c33abeb31a88a14ecc /win/CS/HandBrakeWPF/ViewModels
parentabb517d43f2d80b030fed462107bbfa67385673f (diff)
WinGui: Some Threading, Performance and Log window fixes.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5308 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/Interfaces/ILogViewModel.cs4
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs66
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs34
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs40
4 files changed, 121 insertions, 23 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ILogViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ILogViewModel.cs
index 6aa1020d4..6c7a7a2c8 100644
--- a/win/CS/HandBrakeWPF/ViewModels/Interfaces/ILogViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/Interfaces/ILogViewModel.cs
@@ -14,5 +14,9 @@ namespace HandBrakeWPF.ViewModels.Interfaces
/// </summary>
public interface ILogViewModel
{
+ /// <summary>
+ /// Gets or sets the selected tab.
+ /// </summary>
+ int SelectedTab { get; set; }
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs
index 5bf95d22f..ad76a56b2 100644
--- a/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs
@@ -10,7 +10,6 @@
namespace HandBrakeWPF.ViewModels
{
using System;
- using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
@@ -36,6 +35,16 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
private readonly IScanServiceWrapper scanService;
+ /// <summary>
+ /// The selected tab.
+ /// </summary>
+ private int selectedTab;
+
+ /// <summary>
+ /// The encode log index.
+ /// </summary>
+ private int encodeLogIndex;
+
#endregion
/// <summary>
@@ -52,12 +61,24 @@ namespace HandBrakeWPF.ViewModels
this.encodeService = encodeService;
this.scanService = scanService;
this.Title = "Log Viewer";
+ this.encodeLogIndex = 0;
}
/// <summary>
/// Gets or sets the selected tab.
/// </summary>
- public int SelectedTab { get; set; }
+ public int SelectedTab
+ {
+ get
+ {
+ return this.selectedTab;
+ }
+ set
+ {
+ this.selectedTab = value;
+ this.NotifyOfPropertyChange(() => this.SelectedTab);
+ }
+ }
/// <summary>
/// Gets Log.
@@ -97,7 +118,7 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public void CopyLog()
{
- Clipboard.SetDataObject(this.SelectedTab == 0 ? this.ScanLog : this.EncodeLog, true);
+ Clipboard.SetDataObject(this.SelectedTab == 1 ? this.ScanLog : this.EncodeLog, true);
}
/// <summary>
@@ -109,6 +130,8 @@ namespace HandBrakeWPF.ViewModels
this.encodeService.EncodeCompleted += EncodeServiceEncodeCompleted;
this.encodeService.EncodeStatusChanged += this.EncodeServiceEncodeStatusChanged;
this.scanService.ScanStatusChanged += this.ScanServiceScanStatusChanged;
+ this.scanService.ScanStared += this.scanService_ScanStared;
+ this.encodeService.EncodeStarted += this.encodeService_EncodeStarted;
base.OnActivate();
this.NotifyOfPropertyChange(() => this.ScanLog);
@@ -140,7 +163,12 @@ namespace HandBrakeWPF.ViewModels
/// </param>
private void EncodeServiceEncodeStatusChanged(object sender, EncodeProgressEventArgs e)
{
- this.NotifyOfPropertyChange(() => this.EncodeLog);
+ if (encodeLogIndex != this.encodeService.LogIndex || this.encodeService.LogIndex == -1)
+ {
+ this.NotifyOfPropertyChange(() => this.EncodeLog);
+ }
+
+ encodeLogIndex = this.encodeService.LogIndex;
}
/// <summary>
@@ -155,6 +183,8 @@ namespace HandBrakeWPF.ViewModels
this.encodeService.EncodeCompleted -= EncodeServiceEncodeCompleted;
this.encodeService.EncodeStatusChanged -= this.EncodeServiceEncodeStatusChanged;
this.scanService.ScanStatusChanged -= this.ScanServiceScanStatusChanged;
+ this.scanService.ScanStared -= this.scanService_ScanStared;
+ this.encodeService.EncodeStarted -= this.encodeService_EncodeStarted;
base.OnDeactivate(close);
}
@@ -186,5 +216,33 @@ namespace HandBrakeWPF.ViewModels
{
this.NotifyOfPropertyChange(() => this.EncodeLog);
}
+
+ /// <summary>
+ /// The encode service encode started.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void encodeService_EncodeStarted(object sender, EventArgs e)
+ {
+ this.SelectedTab = 0;
+ }
+
+ /// <summary>
+ /// The scan service scan stared.
+ /// </summary>
+ /// <param name="sender">
+ /// The sender.
+ /// </param>
+ /// <param name="e">
+ /// The e.
+ /// </param>
+ private void scanService_ScanStared(object sender, EventArgs e)
+ {
+ this.SelectedTab = 1;
+ }
}
} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
index c837627c4..8f643a74b 100644
--- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs
@@ -95,6 +95,11 @@ namespace HandBrakeWPF.ViewModels
private readonly IEncodeServiceWrapper encodeService;
/// <summary>
+ /// Windows 7 API Pack wrapper
+ /// </summary>
+ private readonly Win7 windowsSeven = new Win7();
+
+ /// <summary>
/// HandBrakes Main Window Title
/// </summary>
private string windowName;
@@ -163,6 +168,11 @@ namespace HandBrakeWPF.ViewModels
/// The Source Menu Backing Field
/// </summary>
private IEnumerable<SourceMenuItem> sourceMenu;
+
+ /// <summary>
+ /// The last percentage complete value.
+ /// </summary>
+ private int lastEncodePercentage;
#endregion
/// <summary>
@@ -956,11 +966,15 @@ namespace HandBrakeWPF.ViewModels
if (window != null)
{
+ ILogViewModel logvm = (ILogViewModel)window.DataContext;
+ logvm.SelectedTab = this.IsEncoding ? 0 : 1;
window.Activate();
}
else
{
- this.WindowManager.ShowWindow(IoC.Get<ILogViewModel>());
+ ILogViewModel logvm = IoC.Get<ILogViewModel>();
+ logvm.SelectedTab = this.IsEncoding ? 0 : 1;
+ this.WindowManager.ShowWindow(logvm);
}
}
@@ -1782,6 +1796,12 @@ namespace HandBrakeWPF.ViewModels
/// </param>
private void EncodeStatusChanged(object sender, HandBrake.ApplicationServices.EventArgs.EncodeProgressEventArgs e)
{
+ int percent;
+ int.TryParse(
+ Math.Round(e.PercentComplete).ToString(CultureInfo.InvariantCulture),
+ out percent);
+
+
Execute.OnUIThread(
() =>
{
@@ -1796,6 +1816,13 @@ namespace HandBrakeWPF.ViewModels
e.EstimatedTimeLeft,
e.ElapsedTime,
this.queueProcessor.Count);
+
+ if (lastEncodePercentage != percent && this.windowsSeven.IsWindowsSeven)
+ {
+ this.windowsSeven.SetTaskBarProgress(percent);
+ }
+
+ lastEncodePercentage = percent;
}
});
}
@@ -1837,6 +1864,11 @@ namespace HandBrakeWPF.ViewModels
{
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 4f344db08..79532b9ee 100644
--- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
@@ -101,7 +101,7 @@ namespace HandBrakeWPF.ViewModels
this.errorService = errorService;
this.Title = "Queue";
this.JobsPending = "No encodes pending";
- this.JobStatus = "There are no jobs currently encoding";
+ this.JobStatus = "There are no jobs currently encoding";
}
#endregion
@@ -263,9 +263,9 @@ namespace HandBrakeWPF.ViewModels
{
MessageBoxResult result =
this.errorService.ShowMessageBox(
- "This encode is currently in progress. If you delete it, the encode will be stoped. Are you sure you wish to proceed?",
- "Warning",
- MessageBoxButton.YesNo,
+ "This encode is currently in progress. If you delete it, the encode will be stoped. Are you sure you wish to proceed?",
+ "Warning",
+ MessageBoxButton.YesNo,
MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
@@ -330,7 +330,7 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public void Import()
{
- VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "HandBrake Queue Files (*.hbq)|*.hbq", CheckFileExists = true };
+ VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "HandBrake Queue Files (*.hbq)|*.hbq", CheckFileExists = true };
dialog.ShowDialog();
this.queueProcessor.RestoreQueue(dialog.FileName);
@@ -374,7 +374,7 @@ namespace HandBrakeWPF.ViewModels
{
this.Load();
- this.WhenDoneAction = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.WhenCompleteAction);
+ this.WhenDoneAction = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.WhenCompleteAction);
this.queueProcessor.JobProcessingStarted += this.queueProcessor_JobProcessingStarted;
this.queueProcessor.QueueCompleted += this.queueProcessor_QueueCompleted;
@@ -414,19 +414,23 @@ namespace HandBrakeWPF.ViewModels
private void EncodeService_EncodeStatusChanged(
object sender, EncodeProgressEventArgs e)
{
- if (this.IsEncoding)
+ Caliburn.Micro.Execute.OnUIThread(() =>
{
- 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);
- }
+ 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);
+ }
+
+ });
}
/// <summary>