summaryrefslogtreecommitdiffstats
path: root/win
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
parentad88c56567ea543de294f25fa59b504ddb3013a2 (diff)
WinGui: Some more backend work for the upcoming Queue redesign.
Diffstat (limited to 'win')
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs19
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs63
-rw-r--r--win/CS/HandBrakeWPF/Views/QueueView.xaml1
3 files changed, 67 insertions, 16 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs b/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs
index ffc33113f..922a4ceb4 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs
@@ -14,8 +14,10 @@ namespace HandBrakeWPF.Services.Encode
using System.Globalization;
using System.IO;
+ using HandBrake.ApplicationServices.Interop.EventArgs;
using HandBrake.ApplicationServices.Model;
+ using HandBrakeWPF.Services.Encode.Interfaces;
using HandBrakeWPF.Utilities;
using EncodeCompletedEventArgs = HandBrakeWPF.Services.Encode.EventArgs.EncodeCompletedEventArgs;
@@ -78,10 +80,7 @@ namespace HandBrakeWPF.Services.Encode
public void InvokeEncodeStatusChanged(EncodeProgressEventArgs e)
{
EncodeProgessStatus handler = this.EncodeStatusChanged;
- if (handler != null)
- {
- handler(this, e);
- }
+ handler?.Invoke(this, e);
}
/// <summary>
@@ -93,10 +92,7 @@ namespace HandBrakeWPF.Services.Encode
public void InvokeEncodeCompleted(EncodeCompletedEventArgs e)
{
EncodeCompletedStatus handler = this.EncodeCompleted;
- if (handler != null)
- {
- handler(this, e);
- }
+ handler?.Invoke(this, e);
}
/// <summary>
@@ -108,10 +104,7 @@ namespace HandBrakeWPF.Services.Encode
public void InvokeEncodeStarted(System.EventArgs e)
{
EventHandler handler = this.EncodeStarted;
- if (handler != null)
- {
- handler(this, e);
- }
+ handler?.Invoke(this, e);
}
#endregion
@@ -163,7 +156,7 @@ namespace HandBrakeWPF.Services.Encode
this.WriteFile(logContent, Path.Combine(configuration.SaveLogCopyDirectory, encodeLogFile));
}
- return encodeLogFile;
+ return Path.Combine(logDir, encodeLogFile);
}
catch (Exception exc)
{
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>
diff --git a/win/CS/HandBrakeWPF/Views/QueueView.xaml b/win/CS/HandBrakeWPF/Views/QueueView.xaml
index e13c646bd..6fb07daf2 100644
--- a/win/CS/HandBrakeWPF/Views/QueueView.xaml
+++ b/win/CS/HandBrakeWPF/Views/QueueView.xaml
@@ -175,6 +175,7 @@
dd:DragDrop.IsDropTarget="True"
ItemsSource="{Binding QueueTasks, Mode=OneWay}"
helpers:ListBoxHelper.SelectedItems="{Binding SelectedItems}"
+ SelectedItem="{Binding SelectedTask}"
SelectionMode="Extended">
<i:Interaction.Triggers>