}\r
}\r
\r
+ /// <summary>\r
+ /// Gets the log index.\r
+ /// </summary>\r
+ public int LogIndex\r
+ {\r
+ get\r
+ {\r
+ return -1;\r
+ }\r
+ }\r
+\r
/// <summary>\r
/// Gets a value indicating whether IsEncoding.\r
/// </summary>\r
using System.Text;\r
using System.Text.RegularExpressions;\r
\r
- using Caliburn.Micro;\r
-\r
using HandBrake.ApplicationServices.EventArgs;\r
using HandBrake.ApplicationServices.Exceptions;\r
using HandBrake.ApplicationServices.Model;\r
/// </summary>\r
private readonly IUserSettingService userSettingService;\r
\r
- /// <summary>\r
- /// Windows 7 API Pack wrapper\r
- /// </summary>\r
- private readonly Win7 windowsSeven = new Win7();\r
-\r
/// <summary>\r
/// The Log File Header\r
/// </summary>\r
GeneralUtilities.CreateCliLogHeader(\r
userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeVersion),\r
userSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild));\r
+\r
+ this.LogIndex = 0;\r
}\r
\r
#region Events\r
}\r
\r
/// <summary>\r
- /// Gets LogBuffer.\r
+ /// Gets the log index.\r
/// </summary>\r
- public StringBuilder LogBuffer\r
- {\r
- get\r
- {\r
- return this.logBuffer;\r
- }\r
- }\r
+ public int LogIndex { get; private set; }\r
\r
/// <summary>\r
- /// Gets WindowsSeven.\r
+ /// Gets LogBuffer.\r
/// </summary>\r
- public Win7 WindowsSeven\r
+ public StringBuilder LogBuffer\r
{\r
get\r
{\r
- return this.windowsSeven;\r
+ return this.logBuffer;\r
}\r
}\r
\r
/// </param>\r
public void InvokeEncodeStatusChanged(EncodeProgressEventArgs e)\r
{\r
- Execute.OnUIThread(\r
- () =>\r
- {\r
- EncodeProgessStatus handler = this.EncodeStatusChanged;\r
- if (handler != null)\r
- {\r
- handler(this, e);\r
- }\r
- });\r
+ EncodeProgessStatus handler = this.EncodeStatusChanged;\r
+ if (handler != null)\r
+ {\r
+ handler(this, e);\r
+ }\r
}\r
\r
/// <summary>\r
/// </param>\r
public void InvokeEncodeCompleted(EncodeCompletedEventArgs e)\r
{\r
- Execute.OnUIThread(\r
- () =>\r
- {\r
- EncodeCompletedStatus handler = this.EncodeCompleted;\r
- if (handler != null)\r
- {\r
- handler(this, e);\r
- }\r
- });\r
+ EncodeCompletedStatus handler = this.EncodeCompleted;\r
+ if (handler != null)\r
+ {\r
+ handler(this, e);\r
+ }\r
+\r
+ this.LogIndex = 0; // Reset\r
}\r
\r
/// <summary>\r
/// </param>\r
public void InvokeEncodeStarted(EventArgs e)\r
{\r
- Execute.OnUIThread(() =>\r
- {\r
- EventHandler handler = this.EncodeStarted;\r
- if (handler != null)\r
- {\r
- handler(this, e);\r
- }\r
- });\r
+ EventHandler handler = this.EncodeStarted;\r
+ if (handler != null)\r
+ {\r
+ handler(this, e);\r
+ }\r
}\r
\r
#endregion\r
}\r
}\r
\r
-\r
/// <summary>\r
/// Pase the CLI status output (from standard output)\r
/// </summary>\r
{\r
try\r
{\r
+ this.LogIndex = this.LogIndex + 1;\r
+\r
lock (this.LogBuffer)\r
{\r
this.LogBuffer.AppendLine(message);\r
{\r
using System;\r
using System.Diagnostics;\r
- using System.Globalization;\r
using System.IO;\r
using System.Windows.Forms;\r
\r
public Encode(IUserSettingService userSettingService)\r
: base(userSettingService)\r
{\r
- this.userSettingService = userSettingService; \r
+ this.userSettingService = userSettingService;\r
}\r
\r
#region Properties\r
userSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount),\r
userSettingService.GetUserSetting<int>(ASUserSettingConstants.Verbosity),\r
userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav))\r
- : QueryGeneratorUtility.GenerateQuery(new EncodeTask(this.currentTask.Task), \r
+ : QueryGeneratorUtility.GenerateQuery(new EncodeTask(this.currentTask.Task),\r
userSettingService.GetUserSetting<int>(ASUserSettingConstants.PreviewScanCount),\r
userSettingService.GetUserSetting<int>(ASUserSettingConstants.Verbosity),\r
userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav));\r
}\r
\r
Execute.OnUIThread(() =>\r
+ {\r
+ if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep))\r
{\r
- if (this.WindowsSeven.IsWindowsSeven)\r
- {\r
- this.WindowsSeven.SetTaskBarProgressToNoProgress();\r
- }\r
-\r
- if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep))\r
- {\r
- Win32.AllowSleep();\r
- }\r
+ Win32.AllowSleep();\r
+ }\r
+ });\r
\r
- this.currentTask.Status = QueueItemStatus.Completed;\r
- this.IsEncoding = false;\r
- this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(true, null, string.Empty));\r
- });\r
+ this.currentTask.Status = QueueItemStatus.Completed;\r
+ this.IsEncoding = false;\r
+ this.InvokeEncodeCompleted(new EncodeCompletedEventArgs(true, null, string.Empty));\r
}\r
\r
/// <summary>\r
{\r
if (!String.IsNullOrEmpty(e.Data))\r
{\r
- if (initShutdown && this.LogBuffer.Length < 25000000) \r
+ if (initShutdown && this.LogBuffer.Length < 25000000)\r
{\r
initShutdown = false; // Reset this flag.\r
}\r
\r
if (this.LogBuffer.Length > 25000000 && !initShutdown) // Approx 23.8MB and make sure it's only printed once\r
{\r
- this.ProcessLogMessage("ERROR: Initiating automatic shutdown of encode process. The size of the log file inidcates that there is an error! ");\r
+ this.ProcessLogMessage("ERROR: Initiating automatic shutdown of encode process. The size of the log file indicates that there is an error! ");\r
initShutdown = true;\r
this.Stop();\r
}\r
EncodeProgressEventArgs eventArgs = this.ReadEncodeStatus(e.Data, this.startTime);\r
if (eventArgs != null)\r
{\r
- Execute.OnUIThread(\r
- () =>\r
- {\r
- if (!this.IsEncoding)\r
- {\r
- // We can get events out of order since the CLI progress is monitored on a background thread.\r
- // So make sure we don't send a status update after an encode complete event.\r
- return;\r
- }\r
-\r
- this.InvokeEncodeStatusChanged(eventArgs);\r
-\r
- if (this.WindowsSeven.IsWindowsSeven)\r
- {\r
- int percent;\r
- int.TryParse(\r
- Math.Round(eventArgs.PercentComplete).ToString(CultureInfo.InvariantCulture),\r
- out percent);\r
-\r
- this.WindowsSeven.SetTaskBarProgress(percent);\r
- }\r
- });\r
+ if (!this.IsEncoding)\r
+ {\r
+ // We can get events out of order since the CLI progress is monitored on a background thread.\r
+ // So make sure we don't send a status update after an encode complete event.\r
+ return;\r
+ }\r
+\r
+ this.InvokeEncodeStatusChanged(eventArgs);\r
}\r
}\r
}\r
/// </summary>\r
string ActivityLog { get; }\r
\r
+ /// <summary>\r
+ /// Gets the log index. The current log row counter.\r
+ /// </summary>\r
+ int LogIndex { get; }\r
+\r
/// <summary>\r
/// Start with a LibHb EncodeJob Object\r
/// </summary>\r
};\r
\r
this.InvokeEncodeStatusChanged(args);\r
-\r
- if (this.WindowsSeven.IsWindowsSeven)\r
- {\r
- int percent;\r
- int.TryParse(Math.Round(e.FractionComplete).ToString(CultureInfo.InvariantCulture), out percent);\r
-\r
- this.WindowsSeven.SetTaskBarProgress(percent);\r
- }\r
}\r
\r
/// <summary>\r
? new EncodeCompletedEventArgs(false, null, string.Empty)\r
: new EncodeCompletedEventArgs(true, null, string.Empty));\r
\r
- if (this.WindowsSeven.IsWindowsSeven)\r
- {\r
- this.WindowsSeven.SetTaskBarProgressToNoProgress();\r
- }\r
-\r
if (this.userSettingService.GetUserSetting<bool>(ASUserSettingConstants.PreventSleep))\r
{\r
Win32.AllowSleep();\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Gets the log index.\r
+ /// </summary>\r
+ public int LogIndex\r
+ {\r
+ get\r
+ {\r
+ return this.encodeService.LogIndex;\r
+ }\r
+ }\r
+\r
/// <summary>\r
/// Gets a value indicating whether IsEncoding.\r
/// </summary>\r
/// </summary>\r
public interface ILogViewModel\r
{\r
+ /// <summary>\r
+ /// Gets or sets the selected tab.\r
+ /// </summary>\r
+ int SelectedTab { get; set; }\r
}\r
}
\ No newline at end of file
namespace HandBrakeWPF.ViewModels\r
{\r
using System;\r
- using System.Collections.Generic;\r
using System.Diagnostics;\r
using System.Windows;\r
\r
/// </summary>\r
private readonly IScanServiceWrapper scanService;\r
\r
+ /// <summary>\r
+ /// The selected tab.\r
+ /// </summary>\r
+ private int selectedTab;\r
+\r
+ /// <summary>\r
+ /// The encode log index.\r
+ /// </summary>\r
+ private int encodeLogIndex;\r
+\r
#endregion\r
\r
/// <summary>\r
this.encodeService = encodeService;\r
this.scanService = scanService;\r
this.Title = "Log Viewer";\r
+ this.encodeLogIndex = 0;\r
}\r
\r
/// <summary>\r
/// Gets or sets the selected tab.\r
/// </summary>\r
- public int SelectedTab { get; set; }\r
+ public int SelectedTab\r
+ {\r
+ get\r
+ {\r
+ return this.selectedTab;\r
+ }\r
+ set\r
+ {\r
+ this.selectedTab = value;\r
+ this.NotifyOfPropertyChange(() => this.SelectedTab);\r
+ }\r
+ }\r
\r
/// <summary>\r
/// Gets Log.\r
/// </summary>\r
public void CopyLog()\r
{\r
- Clipboard.SetDataObject(this.SelectedTab == 0 ? this.ScanLog : this.EncodeLog, true);\r
+ Clipboard.SetDataObject(this.SelectedTab == 1 ? this.ScanLog : this.EncodeLog, true);\r
}\r
\r
/// <summary>\r
this.encodeService.EncodeCompleted += EncodeServiceEncodeCompleted;\r
this.encodeService.EncodeStatusChanged += this.EncodeServiceEncodeStatusChanged;\r
this.scanService.ScanStatusChanged += this.ScanServiceScanStatusChanged;\r
+ this.scanService.ScanStared += this.scanService_ScanStared;\r
+ this.encodeService.EncodeStarted += this.encodeService_EncodeStarted;\r
base.OnActivate();\r
\r
this.NotifyOfPropertyChange(() => this.ScanLog);\r
/// </param>\r
private void EncodeServiceEncodeStatusChanged(object sender, EncodeProgressEventArgs e)\r
{\r
- this.NotifyOfPropertyChange(() => this.EncodeLog);\r
+ if (encodeLogIndex != this.encodeService.LogIndex || this.encodeService.LogIndex == -1)\r
+ {\r
+ this.NotifyOfPropertyChange(() => this.EncodeLog);\r
+ }\r
+\r
+ encodeLogIndex = this.encodeService.LogIndex;\r
}\r
\r
/// <summary>\r
this.encodeService.EncodeCompleted -= EncodeServiceEncodeCompleted;\r
this.encodeService.EncodeStatusChanged -= this.EncodeServiceEncodeStatusChanged;\r
this.scanService.ScanStatusChanged -= this.ScanServiceScanStatusChanged;\r
+ this.scanService.ScanStared -= this.scanService_ScanStared;\r
+ this.encodeService.EncodeStarted -= this.encodeService_EncodeStarted;\r
\r
base.OnDeactivate(close);\r
}\r
{\r
this.NotifyOfPropertyChange(() => this.EncodeLog);\r
}\r
+\r
+ /// <summary>\r
+ /// The encode service encode started.\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
+ private void encodeService_EncodeStarted(object sender, EventArgs e)\r
+ {\r
+ this.SelectedTab = 0;\r
+ }\r
+\r
+ /// <summary>\r
+ /// The scan service scan stared.\r
+ /// </summary>\r
+ /// <param name="sender">\r
+ /// The sender.\r
+ /// </param>\r
+ /// <param name="e">\r
+ /// The e.\r
+ /// </param>\r
+ private void scanService_ScanStared(object sender, EventArgs e)\r
+ {\r
+ this.SelectedTab = 1;\r
+ }\r
}\r
}
\ No newline at end of file
/// </summary>\r
private readonly IEncodeServiceWrapper encodeService;\r
\r
+ /// <summary>\r
+ /// Windows 7 API Pack wrapper\r
+ /// </summary>\r
+ private readonly Win7 windowsSeven = new Win7();\r
+\r
/// <summary>\r
/// HandBrakes Main Window Title\r
/// </summary>\r
/// The Source Menu Backing Field\r
/// </summary>\r
private IEnumerable<SourceMenuItem> sourceMenu;\r
+\r
+ /// <summary>\r
+ /// The last percentage complete value.\r
+ /// </summary>\r
+ private int lastEncodePercentage;\r
#endregion\r
\r
/// <summary>\r
\r
if (window != null)\r
{\r
+ ILogViewModel logvm = (ILogViewModel)window.DataContext;\r
+ logvm.SelectedTab = this.IsEncoding ? 0 : 1;\r
window.Activate();\r
}\r
else\r
{\r
- this.WindowManager.ShowWindow(IoC.Get<ILogViewModel>());\r
+ ILogViewModel logvm = IoC.Get<ILogViewModel>();\r
+ logvm.SelectedTab = this.IsEncoding ? 0 : 1;\r
+ this.WindowManager.ShowWindow(logvm);\r
}\r
}\r
\r
/// </param>\r
private void EncodeStatusChanged(object sender, HandBrake.ApplicationServices.EventArgs.EncodeProgressEventArgs e)\r
{\r
+ int percent;\r
+ int.TryParse(\r
+ Math.Round(e.PercentComplete).ToString(CultureInfo.InvariantCulture),\r
+ out percent);\r
+\r
+\r
Execute.OnUIThread(\r
() =>\r
{\r
e.EstimatedTimeLeft,\r
e.ElapsedTime,\r
this.queueProcessor.Count);\r
+\r
+ if (lastEncodePercentage != percent && this.windowsSeven.IsWindowsSeven)\r
+ {\r
+ this.windowsSeven.SetTaskBarProgress(percent);\r
+ }\r
+\r
+ lastEncodePercentage = percent;\r
}\r
});\r
}\r
{\r
this.ProgramStatusLabel = "Queue Finished";\r
this.IsEncoding = false;\r
+\r
+ if (this.windowsSeven.IsWindowsSeven)\r
+ {\r
+ this.windowsSeven.SetTaskBarProgressToNoProgress();\r
+ }\r
});\r
}\r
\r
this.errorService = errorService;\r
this.Title = "Queue";\r
this.JobsPending = "No encodes pending";\r
- this.JobStatus = "There are no jobs currently encoding"; \r
+ this.JobStatus = "There are no jobs currently encoding";\r
}\r
\r
#endregion\r
{\r
MessageBoxResult result =\r
this.errorService.ShowMessageBox(\r
- "This encode is currently in progress. If you delete it, the encode will be stoped. Are you sure you wish to proceed?", \r
- "Warning", \r
- MessageBoxButton.YesNo, \r
+ "This encode is currently in progress. If you delete it, the encode will be stoped. Are you sure you wish to proceed?",\r
+ "Warning",\r
+ MessageBoxButton.YesNo,\r
MessageBoxImage.Question);\r
\r
if (result == MessageBoxResult.Yes)\r
/// </summary>\r
public void Import()\r
{\r
- VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "HandBrake Queue Files (*.hbq)|*.hbq", CheckFileExists = true };\r
+ VistaOpenFileDialog dialog = new VistaOpenFileDialog { Filter = "HandBrake Queue Files (*.hbq)|*.hbq", CheckFileExists = true };\r
dialog.ShowDialog();\r
\r
this.queueProcessor.RestoreQueue(dialog.FileName);\r
{\r
this.Load();\r
\r
- this.WhenDoneAction = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.WhenCompleteAction); \r
+ this.WhenDoneAction = this.userSettingService.GetUserSetting<string>(ASUserSettingConstants.WhenCompleteAction);\r
\r
this.queueProcessor.JobProcessingStarted += this.queueProcessor_JobProcessingStarted;\r
this.queueProcessor.QueueCompleted += this.queueProcessor_QueueCompleted;\r
private void EncodeService_EncodeStatusChanged(\r
object sender, EncodeProgressEventArgs e)\r
{\r
- if (this.IsEncoding)\r
+ Caliburn.Micro.Execute.OnUIThread(() =>\r
{\r
- this.JobStatus =\r
- string.Format(\r
- "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}",\r
- e.Task,\r
- e.TaskCount,\r
- e.PercentComplete,\r
- e.CurrentFrameRate,\r
- e.AverageFrameRate,\r
- e.EstimatedTimeLeft,\r
- e.ElapsedTime);\r
- }\r
+ if (this.IsEncoding)\r
+ {\r
+ this.JobStatus =\r
+ string.Format(\r
+ "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}",\r
+ e.Task,\r
+ e.TaskCount,\r
+ e.PercentComplete,\r
+ e.CurrentFrameRate,\r
+ e.AverageFrameRate,\r
+ e.EstimatedTimeLeft,\r
+ e.ElapsedTime);\r
+ }\r
+\r
+ });\r
}\r
\r
/// <summary>\r
</ToolBar>\r
\r
<TabControl Grid.Row="1" SelectedIndex="{Binding SelectedTab}">\r
- <TabItem Header="Scan Log">\r
+ <TabItem Header="Encode Log">\r
<TextBox Grid.Row="1"\r
AcceptsReturn="True"\r
IsReadOnly="True"\r
ScrollViewer.VerticalScrollBarVisibility="Visible"\r
- Text="{Binding ScanLog, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"\r
+ Text="{Binding EncodeLog, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"\r
TextWrapping="Wrap" />\r
</TabItem>\r
-\r
- <TabItem Header="Encode Log">\r
+ \r
+ <TabItem Header="Scan Log">\r
<TextBox Grid.Row="1"\r
AcceptsReturn="True"\r
IsReadOnly="True"\r
ScrollViewer.VerticalScrollBarVisibility="Visible"\r
- Text="{Binding EncodeLog, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"\r
+ Text="{Binding ScanLog, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"\r
TextWrapping="Wrap" />\r
</TabItem>\r
\r