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;
public void InvokeEncodeStatusChanged(EncodeProgressEventArgs e)
{
EncodeProgessStatus handler = this.EncodeStatusChanged;
- if (handler != null)
- {
- handler(this, e);
- }
+ handler?.Invoke(this, e);
}
/// <summary>
public void InvokeEncodeCompleted(EncodeCompletedEventArgs e)
{
EncodeCompletedStatus handler = this.EncodeCompleted;
- if (handler != null)
- {
- handler(this, e);
- }
+ handler?.Invoke(this, e);
}
/// <summary>
public void InvokeEncodeStarted(System.EventArgs e)
{
EventHandler handler = this.EncodeStarted;
- if (handler != null)
- {
- handler(this, e);
- }
+ handler?.Invoke(this, e);
}
#endregion
this.WriteFile(logContent, Path.Combine(configuration.SaveLogCopyDirectory, encodeLogFile));
}
- return encodeLogFile;
+ return Path.Combine(logDir, encodeLogFile);
}
catch (Exception exc)
{
\r
using Microsoft.Win32;\r
\r
- using EncodeCompletedEventArgs = HandBrakeWPF.Services.Encode.EventArgs.EncodeCompletedEventArgs;\r
- using EncodeProgressEventArgs = HandBrakeWPF.Services.Encode.EventArgs.EncodeProgressEventArgs;\r
- using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;\r
+ using EncodeCompletedEventArgs = Services.Encode.EventArgs.EncodeCompletedEventArgs;\r
+ using EncodeProgressEventArgs = Services.Encode.EventArgs.EncodeProgressEventArgs;\r
\r
/// <summary>\r
/// The Preview View Model\r
private string jobStatus;\r
private string jobsPending;\r
private string whenDoneAction;\r
+ private QueueTask selectedTask;\r
\r
private bool isQueueRunning;\r
\r
{\r
return this.isQueueRunning;\r
}\r
+\r
set\r
{\r
if (value == this.isQueueRunning) return;\r
{\r
return this.whenDoneAction;\r
}\r
+\r
set\r
{\r
this.whenDoneAction = value;\r
/// </summary>\r
public BindingList<QueueTask> SelectedItems { get; set; }\r
\r
+ public QueueTask SelectedTask\r
+ {\r
+ get\r
+ {\r
+ return this.selectedTask;\r
+ }\r
+\r
+ set\r
+ {\r
+ if (Equals(value, this.selectedTask)) return;\r
+ this.selectedTask = value;\r
+ this.NotifyOfPropertyChange(() => this.SelectedTask);\r
+ this.HandleLogData();\r
+ }\r
+ }\r
+\r
+ public bool ShowLogTab { get; private set; }\r
+\r
+ public string ActivityLog { get; private set; }\r
+\r
#endregion\r
\r
#region Public Methods\r
}\r
}\r
\r
+ private void HandleLogData()\r
+ {\r
+ if (this.SelectedTask == null || this.SelectedTask.Status == QueueItemStatus.InProgress)\r
+ {\r
+ this.ShowLogTab = false;\r
+ }\r
+ else\r
+ {\r
+ try\r
+ {\r
+ // TODO full log path\r
+ if (!string.IsNullOrEmpty(this.SelectedTask.Statistics.CompletedActivityLogPath)\r
+ && File.Exists(this.SelectedTask.Statistics.CompletedActivityLogPath))\r
+ {\r
+ using (StreamReader logReader = new StreamReader(this.SelectedTask.Statistics.CompletedActivityLogPath))\r
+ {\r
+ string logContent = logReader.ReadToEnd();\r
+ this.ActivityLog = logContent;\r
+ }\r
+\r
+ this.ShowLogTab = true;\r
+ }\r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ Debug.WriteLine(exc);\r
+ this.ShowLogTab = true;\r
+ this.ActivityLog = exc.ToString();\r
+ }\r
+ }\r
+\r
+ this.NotifyOfPropertyChange(() => this.ShowLogTab);\r
+ this.NotifyOfPropertyChange(() => this.ActivityLog);\r
+ }\r
+\r
/// <summary>\r
/// Handle the Encode Status Changed Event.\r
/// </summary>\r