]> granicus.if.org Git - handbrake/commitdiff
WinGui: Nice display of statistics when information isn't available. #2179
authorsr55 <sr55.hb@outlook.com>
Wed, 3 Jul 2019 20:19:16 +0000 (21:19 +0100)
committersr55 <sr55.hb@outlook.com>
Wed, 3 Jul 2019 20:23:56 +0000 (21:23 +0100)
win/CS/HandBrakeWPF/Properties/Resources.Designer.cs
win/CS/HandBrakeWPF/Properties/Resources.resx
win/CS/HandBrakeWPF/Services/Queue/Model/QueueStats.cs
win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs

index 799647272f6c74ffaf2a1c4c674898b313a54da5..b29ec52293e4c9fbfa0ee37ba6e4d5805d06c660 100644 (file)
@@ -4137,6 +4137,15 @@ namespace HandBrakeWPF.Properties {
             }
         }
         
+        /// <summary>
+        ///   Looks up a localized string similar to Not Available.
+        /// </summary>
+        public static string QueueView_NotAvailable {
+            get {
+                return ResourceManager.GetString("QueueView_NotAvailable", resourceCulture);
+            }
+        }
+        
         /// <summary>
         ///   Looks up a localized string similar to Open Destination Directory.
         /// </summary>
index 4bd8e3e1f945985d45a61657e6a75753ecf510f8..172b478bfa8753a51203a4c1f8ee245812b5c938 100644 (file)
@@ -2017,4 +2017,7 @@ Where supported, any user presets will have been imported.</value>
   <data name="Options_DarkTheme" xml:space="preserve">\r
     <value>Use the Dark Theme. (Requires Restart)  (THIS IS AN EARLY PREVIEW. IT IS NOT YET COMPLETE!)</value>\r
   </data>\r
+  <data name="QueueView_NotAvailable" xml:space="preserve">\r
+    <value>Not Available</value>\r
+  </data>\r
 </root>
\ No newline at end of file
index 3378bd6aae26db29872e5092248bfb4e1e339999..781105d8f6bcb72b1268968f7338363e49e4fc8c 100644 (file)
@@ -13,6 +13,8 @@ namespace HandBrakeWPF.Services.Queue.Model
 
     using Caliburn.Micro;
 
+    using HandBrakeWPF.Properties;
+
     using Newtonsoft.Json;
 
     [JsonObject(MemberSerialization.OptOut)]
@@ -35,12 +37,27 @@ namespace HandBrakeWPF.Services.Queue.Model
             {
                 return this.startTime;
             }
+
             set
             {
                 if (value.Equals(this.startTime)) return;
                 this.startTime = value;
                 this.NotifyOfPropertyChange(() => this.StartTime);
                 this.NotifyOfPropertyChange(() => this.Duration);
+                this.NotifyOfPropertyChange(() => this.StartTimeDisplay);
+            }
+        }
+
+        public string StartTimeDisplay
+        {
+            get
+            {
+                if (this.startTime == DateTime.MinValue)
+                {
+                    return Resources.QueueView_NotAvailable;
+                }
+
+                return this.startTime.ToString();
             }
         }
 
@@ -50,12 +67,27 @@ namespace HandBrakeWPF.Services.Queue.Model
             {
                 return this.endTime;
             }
+
             set
             {
                 if (value.Equals(this.endTime)) return;
                 this.endTime = value;
                 this.NotifyOfPropertyChange(() => this.EndTime);
                 this.NotifyOfPropertyChange(() => this.Duration);
+                this.NotifyOfPropertyChange(() => this.EndTimeDisplay);
+            }
+        }
+
+        public string EndTimeDisplay
+        {
+            get
+            {
+                if (this.endTime == DateTime.MinValue)
+                {
+                    return Resources.QueueView_NotAvailable;
+                }
+
+                return this.endTime.ToString();
             }
         }
 
@@ -73,7 +105,7 @@ namespace HandBrakeWPF.Services.Queue.Model
             {
                 if (this.endTime == DateTime.MinValue)
                 {
-                    return TimeSpan.MinValue;
+                    return TimeSpan.Zero;
                 }
 
                 return this.EndTime - this.StartTime - this.PausedDuration;
@@ -89,6 +121,7 @@ namespace HandBrakeWPF.Services.Queue.Model
             {
                 return this.finalFileSize;
             }
+
             set
             {
                 if (value == this.finalFileSize) return;
@@ -125,5 +158,19 @@ namespace HandBrakeWPF.Services.Queue.Model
                 this.pausedTimespan = this.PausedDuration.Add(pausedDuration);
             }
         }
+
+        public void Reset()
+        {
+            this.StartTime = DateTime.MinValue;
+            this.EndTime = DateTime.MinValue;
+            this.FinalFileSize = 0;
+            this.pausedTimespan = TimeSpan.Zero;
+            this.pausedStartPoint = DateTime.MinValue;
+            this.CompletedActivityLogPath = null;
+
+            this.NotifyOfPropertyChange(() => this.FinalFileSizeInMegaBytes);
+            this.NotifyOfPropertyChange(() => this.PausedDuration);
+            this.NotifyOfPropertyChange(() => this.Duration);
+        }
     }
 }
index e86d8f4880455efae7cf0aa0f5ec7b477536cab8..362f10ec6c1972e8ec12fa6c4db319e6c1c92301 100644 (file)
@@ -467,6 +467,7 @@ namespace HandBrakeWPF.ViewModels
             }\r
 \r
             task.Status = QueueItemStatus.Waiting;\r
+            task.Statistics.Reset();\r
             this.queueProcessor.BackupQueue(null);\r
             this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count);\r
             this.NotifyOfPropertyChange(() => this.CanRetryJob);\r