summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2018-05-18 20:47:53 +0100
committersr55 <[email protected]>2018-05-18 20:47:53 +0100
commitde65fd561304c553c13fe06f35796a31dd362602 (patch)
tree5f7f990e4c64624cb46868ab8e8457ad5771733f /win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
parentad88c56567ea543de294f25fa59b504ddb3013a2 (diff)
WinGui: Some more backend work for the upcoming Queue redesign.
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs63
1 files changed, 60 insertions, 3 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
index 52a09def3..6f8e8c176 100644
--- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
@@ -29,9 +29,8 @@ namespace HandBrakeWPF.ViewModels
using Microsoft.Win32;
- using EncodeCompletedEventArgs = HandBrakeWPF.Services.Encode.EventArgs.EncodeCompletedEventArgs;
- using EncodeProgressEventArgs = HandBrakeWPF.Services.Encode.EventArgs.EncodeProgressEventArgs;
- using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
+ using EncodeCompletedEventArgs = Services.Encode.EventArgs.EncodeCompletedEventArgs;
+ using EncodeProgressEventArgs = Services.Encode.EventArgs.EncodeProgressEventArgs;
/// <summary>
/// The Preview View Model
@@ -47,6 +46,7 @@ namespace HandBrakeWPF.ViewModels
private string jobStatus;
private string jobsPending;
private string whenDoneAction;
+ private QueueTask selectedTask;
private bool isQueueRunning;
@@ -94,6 +94,7 @@ namespace HandBrakeWPF.ViewModels
{
return this.isQueueRunning;
}
+
set
{
if (value == this.isQueueRunning) return;
@@ -145,6 +146,7 @@ namespace HandBrakeWPF.ViewModels
{
return this.whenDoneAction;
}
+
set
{
this.whenDoneAction = value;
@@ -168,6 +170,26 @@ namespace HandBrakeWPF.ViewModels
/// </summary>
public BindingList<QueueTask> SelectedItems { get; set; }
+ public QueueTask SelectedTask
+ {
+ get
+ {
+ return this.selectedTask;
+ }
+
+ set
+ {
+ if (Equals(value, this.selectedTask)) return;
+ this.selectedTask = value;
+ this.NotifyOfPropertyChange(() => this.SelectedTask);
+ this.HandleLogData();
+ }
+ }
+
+ public bool ShowLogTab { get; private set; }
+
+ public string ActivityLog { get; private set; }
+
#endregion
#region Public Methods
@@ -547,6 +569,41 @@ namespace HandBrakeWPF.ViewModels
}
}
+ private void HandleLogData()
+ {
+ if (this.SelectedTask == null || this.SelectedTask.Status == QueueItemStatus.InProgress)
+ {
+ this.ShowLogTab = false;
+ }
+ else
+ {
+ try
+ {
+ // TODO full log path
+ if (!string.IsNullOrEmpty(this.SelectedTask.Statistics.CompletedActivityLogPath)
+ && File.Exists(this.SelectedTask.Statistics.CompletedActivityLogPath))
+ {
+ using (StreamReader logReader = new StreamReader(this.SelectedTask.Statistics.CompletedActivityLogPath))
+ {
+ string logContent = logReader.ReadToEnd();
+ this.ActivityLog = logContent;
+ }
+
+ this.ShowLogTab = true;
+ }
+ }
+ catch (Exception exc)
+ {
+ Debug.WriteLine(exc);
+ this.ShowLogTab = true;
+ this.ActivityLog = exc.ToString();
+ }
+ }
+
+ this.NotifyOfPropertyChange(() => this.ShowLogTab);
+ this.NotifyOfPropertyChange(() => this.ActivityLog);
+ }
+
/// <summary>
/// Handle the Encode Status Changed Event.
/// </summary>