From e91ee8d30f0f620fd78bcbb0ca2f2f911a47442f Mon Sep 17 00:00:00 2001 From: sr55 Date: Wed, 3 Jul 2019 21:19:16 +0100 Subject: WinGui: Nice display of statistics when information isn't available. #2179 --- .../HandBrakeWPF/Properties/Resources.Designer.cs | 9 ++++ win/CS/HandBrakeWPF/Properties/Resources.resx | 3 ++ .../Services/Queue/Model/QueueStats.cs | 49 +++++++++++++++++++++- win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs | 1 + 4 files changed, 61 insertions(+), 1 deletion(-) (limited to 'win/CS') diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index 799647272..b29ec5229 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -4137,6 +4137,15 @@ namespace HandBrakeWPF.Properties { } } + /// + /// Looks up a localized string similar to Not Available. + /// + public static string QueueView_NotAvailable { + get { + return ResourceManager.GetString("QueueView_NotAvailable", resourceCulture); + } + } + /// /// Looks up a localized string similar to Open Destination Directory. /// diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 4bd8e3e1f..172b478bf 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -2017,4 +2017,7 @@ Where supported, any user presets will have been imported. Use the Dark Theme. (Requires Restart) (THIS IS AN EARLY PREVIEW. IT IS NOT YET COMPLETE!) + + Not Available + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueStats.cs b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueStats.cs index 3378bd6aa..781105d8f 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueStats.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueStats.cs @@ -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); + } } } diff --git a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs index e86d8f488..362f10ec6 100644 --- a/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/QueueViewModel.cs @@ -467,6 +467,7 @@ namespace HandBrakeWPF.ViewModels } task.Status = QueueItemStatus.Waiting; + task.Statistics.Reset(); this.queueProcessor.BackupQueue(null); this.JobsPending = string.Format(Resources.QueueViewModel_JobsPending, this.queueProcessor.Count); this.NotifyOfPropertyChange(() => this.CanRetryJob); -- cgit v1.2.3