]> granicus.if.org Git - handbrake/commitdiff
WinGui: Queue Stats cosmetics
authorsr55 <sr55.hb@outlook.com>
Fri, 4 Oct 2019 21:41:18 +0000 (22:41 +0100)
committersr55 <sr55.hb@outlook.com>
Fri, 4 Oct 2019 21:41:39 +0000 (22:41 +0100)
win/CS/HandBrakeWPF/Services/Queue/Model/QueueStats.cs
win/CS/HandBrakeWPF/Views/QueueView.xaml

index 781105d8f6bcb72b1268968f7338363e49e4fc8c..8069259f81b709aa331b58eb377fe7bc08990c2a 100644 (file)
@@ -10,6 +10,7 @@
 namespace HandBrakeWPF.Services.Queue.Model
 {
     using System;
+    using System.Runtime.CompilerServices;
 
     using Caliburn.Micro;
 
@@ -26,6 +27,8 @@ namespace HandBrakeWPF.Services.Queue.Model
         private DateTime pausedStartPoint;
         private TimeSpan pausedTimespan;
 
+        private bool isPaused;
+
         public QueueStats()
         {
             this.pausedTimespan = new TimeSpan();
@@ -40,7 +43,11 @@ namespace HandBrakeWPF.Services.Queue.Model
 
             set
             {
-                if (value.Equals(this.startTime)) return;
+                if (value.Equals(this.startTime))
+                {
+                    return;
+                }
+
                 this.startTime = value;
                 this.NotifyOfPropertyChange(() => this.StartTime);
                 this.NotifyOfPropertyChange(() => this.Duration);
@@ -70,7 +77,11 @@ namespace HandBrakeWPF.Services.Queue.Model
 
             set
             {
-                if (value.Equals(this.endTime)) return;
+                if (value.Equals(this.endTime))
+                {
+                    return;
+                }
+
                 this.endTime = value;
                 this.NotifyOfPropertyChange(() => this.EndTime);
                 this.NotifyOfPropertyChange(() => this.Duration);
@@ -84,7 +95,7 @@ namespace HandBrakeWPF.Services.Queue.Model
             {
                 if (this.endTime == DateTime.MinValue)
                 {
-                    return Resources.QueueView_NotAvailable;
+                    return string.Empty;
                 }
 
                 return this.endTime.ToString();
@@ -99,6 +110,24 @@ namespace HandBrakeWPF.Services.Queue.Model
             }
         }
 
+        public string PausedDisplay
+        {
+            get
+            {
+                if (this.isPaused)
+                {
+                    return Resources.QueueView_CurrentlyPaused;
+                }
+
+                if (this.PausedDuration == TimeSpan.Zero)
+                {
+                    return string.Empty;
+                }
+
+                return PausedDuration.ToString("hh\\:mm\\:ss");
+            }
+        }
+
         public TimeSpan Duration
         {
             get
@@ -112,9 +141,19 @@ namespace HandBrakeWPF.Services.Queue.Model
             }
         }
 
-        /// <summary>
-        /// Final filesize in Bytes
-        /// </summary>
+        public string DurationDisplay
+        {
+            get
+            {
+                if (this.Duration == TimeSpan.Zero)
+                {
+                    return string.Empty;
+                }
+
+                return this.Duration.ToString("hh\\:mm\\:ss");
+            }
+        }
+
         public long? FinalFileSize
         {
             get
@@ -124,7 +163,11 @@ namespace HandBrakeWPF.Services.Queue.Model
 
             set
             {
-                if (value == this.finalFileSize) return;
+                if (value == this.finalFileSize)
+                {
+                    return;
+                }
+
                 this.finalFileSize = value;
                 this.NotifyOfPropertyChange(() => this.FinalFileSize);
                 this.NotifyOfPropertyChange(() => this.FinalFileSizeInMegaBytes);
@@ -144,10 +187,24 @@ namespace HandBrakeWPF.Services.Queue.Model
             }
         }
 
+        public string FileSizeDisplay
+        {
+            get
+            {
+                if (FinalFileSizeInMegaBytes == 0)
+                {
+                    return string.Empty;
+                }
+
+                return string.Format("{0:##.###} MB", FinalFileSizeInMegaBytes);
+            }
+        }
+
         public string CompletedActivityLogPath { get; set; }
 
         public void SetPaused(bool isPaused)
         {
+            this.isPaused = isPaused;
             if (isPaused)
             {
                 this.pausedStartPoint = DateTime.Now;
@@ -157,6 +214,8 @@ namespace HandBrakeWPF.Services.Queue.Model
                 TimeSpan pausedDuration = DateTime.Now - this.pausedStartPoint;
                 this.pausedTimespan = this.PausedDuration.Add(pausedDuration);
             }
+
+            this.NotifyOfPropertyChange(() => this.PausedDisplay);
         }
 
         public void Reset()
@@ -170,7 +229,7 @@ namespace HandBrakeWPF.Services.Queue.Model
 
             this.NotifyOfPropertyChange(() => this.FinalFileSizeInMegaBytes);
             this.NotifyOfPropertyChange(() => this.PausedDuration);
-            this.NotifyOfPropertyChange(() => this.Duration);
+            this.NotifyOfPropertyChange(() => this.DurationDisplay);
         }
     }
 }
index 21d226deb5924ef8e444a30e6f766ad4a678671b..1c566fb312a62580953ee0ad8599707225ebcd34 100644 (file)
                                 </Grid.RowDefinitions>\r
 \r
                                 <Grid.ColumnDefinitions>\r
-                                    <ColumnDefinition Width="Auto" MinWidth="100" />\r
+                                    <ColumnDefinition Width="Auto" MinWidth="125" />\r
                                     <ColumnDefinition Width="*" />\r
                                 </Grid.ColumnDefinitions>\r
 \r
                                 <TextBlock Text="{Binding SelectedTask.Statistics.EndTimeDisplay}" TextWrapping="Wrap" Grid.Row="1" Grid.Column="1" />\r
 \r
                                 <TextBlock FontWeight="Bold" Text="{x:Static Properties:Resources.QueueView_PausedDuration}" VerticalAlignment="Top" Grid.Row="2" Grid.Column="0" />\r
-                                <TextBlock Text="{Binding SelectedTask.Statistics.PausedDuration,StringFormat=hh\\:mm\\:ss}" TextWrapping="Wrap" Grid.Row="2" Grid.Column="1" />\r
+                                <TextBlock Text="{Binding SelectedTask.Statistics.PausedDisplay}" TextWrapping="Wrap" Grid.Row="2" Grid.Column="1" />\r
 \r
                                 <TextBlock FontWeight="Bold" Text="{x:Static Properties:Resources.QueueView_Duration}" VerticalAlignment="Top" Grid.Row="3" Grid.Column="0" />\r
-                                <TextBlock Text="{Binding SelectedTask.Statistics.Duration,StringFormat=hh\\:mm\\:ss}" TextWrapping="Wrap" Grid.Row="3" Grid.Column="1" />\r
+                                <TextBlock Text="{Binding SelectedTask.Statistics.DurationDisplay}" TextWrapping="Wrap" Grid.Row="3" Grid.Column="1" />\r
 \r
                                 <TextBlock FontWeight="Bold" Text="{x:Static Properties:Resources.QueueView_FileSize}" VerticalAlignment="Top" Grid.Row="4" Grid.Column="0" />\r
-                                <StackPanel Orientation="Horizontal" Grid.Row="4" Grid.Column="1" >\r
-                                    <TextBlock Text="{Binding SelectedTask.Statistics.FinalFileSizeInMegaBytes}" TextWrapping="Wrap" />\r
-                                    <TextBlock Text=" MB" />\r
-                                </StackPanel>\r
-\r
+                                    <TextBlock Text="{Binding SelectedTask.Statistics.FileSizeDisplay}" TextWrapping="Wrap" Grid.Row="4" Grid.Column="1"  />\r
                             </Grid>\r
-\r
                         </StackPanel>\r
                     </ScrollViewer>\r
                 </TabItem>\r