]> granicus.if.org Git - handbrake/commitdiff
WinGui: Some more backend work for the upcoming Queue redesign.
authorsr55 <sr55.hb@outlook.com>
Fri, 18 May 2018 19:47:53 +0000 (20:47 +0100)
committersr55 <sr55.hb@outlook.com>
Fri, 18 May 2018 19:47:53 +0000 (20:47 +0100)
win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs
win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs
win/CS/HandBrakeWPF/Views/QueueView.xaml

index ffc33113f5f2556d6529fac249b6e304c465c143..922a4ceb4de1941db2e2eae4f640569a0cfbfffd 100644 (file)
@@ -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)
             {
index 52a09def300f54d09b2652dd3da7b0c4d34c4073..6f8e8c176e6dc0dbbf6453c5ebb2c77e9f05d819 100644 (file)
@@ -29,9 +29,8 @@ namespace HandBrakeWPF.ViewModels
 \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
@@ -47,6 +46,7 @@ namespace HandBrakeWPF.ViewModels
         private string jobStatus;\r
         private string jobsPending;\r
         private string whenDoneAction;\r
+        private QueueTask selectedTask;\r
 \r
         private bool isQueueRunning;\r
 \r
@@ -94,6 +94,7 @@ namespace HandBrakeWPF.ViewModels
             {\r
                 return this.isQueueRunning;\r
             }\r
+\r
             set\r
             {\r
                 if (value == this.isQueueRunning) return;\r
@@ -145,6 +146,7 @@ namespace HandBrakeWPF.ViewModels
             {\r
                 return this.whenDoneAction;\r
             }\r
+\r
             set\r
             {\r
                 this.whenDoneAction = value;\r
@@ -168,6 +170,26 @@ namespace HandBrakeWPF.ViewModels
         /// </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
@@ -547,6 +569,41 @@ namespace HandBrakeWPF.ViewModels
             }\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
index e13c646bdded29d54e8adbc5b3ac78b91a7da6d1..6fb07daf2af8bc5c95fe2685a0ad138aaab8b64f 100644 (file)
                  dd:DragDrop.IsDropTarget="True"\r
                  ItemsSource="{Binding QueueTasks, Mode=OneWay}"\r
                  helpers:ListBoxHelper.SelectedItems="{Binding SelectedItems}" \r
+                 SelectedItem="{Binding SelectedTask}"\r
                  SelectionMode="Extended">\r
 \r
             <i:Interaction.Triggers>\r