Skip to content

Commit 99c70a3

Browse files
author
RandomEngy
committed
Adds tooltip explaining Queue Total ETA. Changed tooltip on individual job progress bar to show individual job ETA.
1 parent e344c65 commit 99c70a3

6 files changed

Lines changed: 119 additions & 7 deletions

File tree

VidCoder/Controls/NumberBox.xaml

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
<Style x:Key="Arrow" TargetType="Polygon">
77
<Setter Property="Fill" Value="#333" />
88
</Style>
9-
<Style x:Key="UpDownButton" TargetType="Button">
9+
<!-- UpButton and DownButton are identical except for the border radius in the control template.
10+
We can't pass that through so we need to duplicate the template. After a change is made from one button
11+
template it should be copied to the other. -->
12+
<Style x:Key="UpButton" TargetType="Button">
1013
<Setter Property="Margin" Value="0"/>
1114
<Setter Property="Background" >
1215
<Setter.Value>
@@ -23,7 +26,65 @@
2326
Name="border"
2427
BorderThickness="1"
2528
BorderBrush="#888"
26-
CornerRadius="0,2,2,0"
29+
CornerRadius="0,2,0,0"
30+
Background="{TemplateBinding Background}">
31+
<ContentPresenter
32+
Name="content"
33+
HorizontalAlignment="Center" VerticalAlignment="Center" />
34+
</Border>
35+
<ControlTemplate.Triggers>
36+
<Trigger Property="IsMouseOver" Value="True">
37+
<Setter TargetName="border" Property="BorderBrush" Value="#FF4788c8" />
38+
<Setter Property="Foreground" Value="#FF4788c8" />
39+
</Trigger>
40+
<Trigger Property="IsPressed" Value="True">
41+
<Setter Property="Background" >
42+
<Setter.Value>
43+
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1" >
44+
<GradientStop Color="#CCC" Offset="0.4"/>
45+
<GradientStop Color="#999" Offset="1"/>
46+
</LinearGradientBrush>
47+
</Setter.Value>
48+
</Setter>
49+
<Setter TargetName="content" Property="RenderTransform" >
50+
<Setter.Value>
51+
<TranslateTransform Y="1.0" />
52+
</Setter.Value>
53+
</Setter>
54+
</Trigger>
55+
<Trigger Property="IsDefaulted" Value="True">
56+
<Setter TargetName="border" Property="BorderBrush" Value="#FF282828" />
57+
</Trigger>
58+
<Trigger Property="IsFocused" Value="True">
59+
<Setter TargetName="border" Property="BorderBrush" Value="#FF282828" />
60+
</Trigger>
61+
<Trigger Property="IsEnabled" Value="False">
62+
<Setter TargetName="border" Property="Opacity" Value="0.7" />
63+
<Setter Property="Foreground" Value="Gray" />
64+
</Trigger>
65+
</ControlTemplate.Triggers>
66+
</ControlTemplate>
67+
</Setter.Value>
68+
</Setter>
69+
</Style>
70+
<Style x:Key="DownButton" TargetType="Button">
71+
<Setter Property="Margin" Value="0"/>
72+
<Setter Property="Background" >
73+
<Setter.Value>
74+
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1" >
75+
<GradientStop Color="#EEE" Offset="0.4"/>
76+
<GradientStop Color="#BBB" Offset="1"/>
77+
</LinearGradientBrush>
78+
</Setter.Value>
79+
</Setter>
80+
<Setter Property="Template">
81+
<Setter.Value>
82+
<ControlTemplate TargetType="Button">
83+
<Border
84+
Name="border"
85+
BorderThickness="1"
86+
BorderBrush="#888"
87+
CornerRadius="0,0,2,0"
2788
Background="{TemplateBinding Background}">
2889
<ContentPresenter
2990
Name="content"
@@ -61,7 +122,6 @@
61122
</Trigger>
62123
</ControlTemplate.Triggers>
63124
</ControlTemplate>
64-
65125
</Setter.Value>
66126
</Setter>
67127
</Style>
@@ -89,7 +149,7 @@
89149
<RowDefinition Height="*" />
90150
</Grid.RowDefinitions>
91151
<Button
92-
Style="{StaticResource UpDownButton}"
152+
Style="{StaticResource UpButton}"
93153
Grid.Row="0"
94154
FontSize="4"
95155
PreviewMouseLeftButtonDown="UpButtonMouseLeftButtonDown"
@@ -99,7 +159,7 @@
99159
Points="4,0 0,4 8,4" />
100160
</Button>
101161
<Button
102-
Style="{StaticResource UpDownButton}"
162+
Style="{StaticResource DownButton}"
103163
Grid.Row="1"
104164
FontSize="4"
105165
PreviewMouseLeftButtonDown="DownButtonMouseLeftButtonDown"

VidCoder/Properties/Resources.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

VidCoder/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,7 @@ Higher values take more bits away from edges and complex areas to improve areas
300300
<data name="Audio_GainToolTip" xml:space="preserve">
301301
<value>Amplify or attenuate audio before encoding. Valid values are -20 to +20 dB.</value>
302302
</data>
303+
<data name="QueueEtaToolTip" xml:space="preserve">
304+
<value>Estimated time remaining for all jobs in the queue to complete.</value>
305+
</data>
303306
</root>

VidCoder/View/MainWindow.xaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
xmlns:localmodel="clr-namespace:VidCoder.Model"
66
xmlns:controls="clr-namespace:VidCoder.Controls"
77
xmlns:model="clr-namespace:HandBrake.Interop;assembly=HandBrakeInterop"
8+
xmlns:resx="clr-namespace:VidCoder.Properties"
89
xmlns:VidCoderDragDrop="clr-namespace:VidCoder.DragDropUtils"
910
Title="VidCoder"
1011
Width="671"
@@ -140,7 +141,8 @@
140141
Visibility="{Binding ShowRemoveButton, Converter={StaticResource VisibilityConverter}}">Remove from queue</Button>
141142
<ProgressBar VerticalAlignment="Center" Height="12"
142143
Value="{Binding PercentComplete}"
143-
Visibility="{Binding ShowProgressBar, Converter={StaticResource VisibilityConverter}}" ToolTip="Encoding..." />
144+
Visibility="{Binding ShowProgressBar, Converter={StaticResource VisibilityConverter}}"
145+
ToolTip="{Binding ProgressToolTip}" ToolTipService.ShowDuration="120000" />
144146
</Grid>
145147
</DataTemplate>
146148
<DataTemplate x:Key="CompletedDestinationTemplate">
@@ -577,9 +579,11 @@
577579
Visibility="{Binding Encoding, Converter={StaticResource VisibilityConverter}}"/>
578580
<TextBlock
579581
Text="ETA:" Width="25" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="135,111,0,0"
582+
ToolTip="{x:Static resx:Resources.QueueEtaToolTip}"
580583
Visibility="{Binding EncodeSpeedDetailsAvailable, Converter={StaticResource VisibilityConverter}}" />
581584
<TextBlock
582585
Text="{Binding EstimatedTimeRemaining}" Width="50" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="163,111,0,0"
586+
ToolTip="{x:Static resx:Resources.QueueEtaToolTip}"
583587
Visibility="{Binding EncodeSpeedDetailsAvailable, Converter={StaticResource VisibilityConverter}}"/>
584588

585589

VidCoder/ViewModel/DataModels/EncodeJobViewModel.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class EncodeJobViewModel : ViewModelBase, IDragItem
2222
private int percentComplete;
2323
private bool isOnlyItem;
2424
private Stopwatch encodeTimeStopwatch;
25+
private TimeSpan eta;
2526

2627
private ICommand removeQueueJobCommand;
2728

@@ -150,6 +151,34 @@ public bool ShowProgressBar
150151
}
151152
}
152153

154+
public TimeSpan Eta
155+
{
156+
get
157+
{
158+
return this.eta;
159+
}
160+
161+
set
162+
{
163+
this.eta = value;
164+
this.NotifyPropertyChanged("Eta");
165+
this.NotifyPropertyChanged("ProgressToolTip");
166+
}
167+
}
168+
169+
public string ProgressToolTip
170+
{
171+
get
172+
{
173+
if (this.Eta == TimeSpan.Zero)
174+
{
175+
return null;
176+
}
177+
178+
return "Job ETA: " + Utilities.FormatTimeSpan(this.Eta);
179+
}
180+
}
181+
153182
public int PercentComplete
154183
{
155184
get

VidCoder/ViewModel/MainViewModel.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2436,6 +2436,7 @@ private void OnEncodeProgress(object sender, EncodeProgressEventArgs e)
24362436
double totalCompletedWork = this.completedQueueWork + currentJobCompletedWork;
24372437

24382438
this.OverallEncodeProgressFraction = totalCompletedWork / this.totalQueueCost;
2439+
double overallWorkCompletionRate = totalCompletedWork / this.elapsedQueueEncodeTime.Elapsed.TotalSeconds;
24392440

24402441
// Only update encode time every 5th update.
24412442
if (Interlocked.Increment(ref this.pollCount) % 5 == 1)
@@ -2451,10 +2452,16 @@ private void OnEncodeProgress(object sender, EncodeProgressEventArgs e)
24512452
TimeSpan eta = TimeSpan.FromSeconds((long)(((1.0 - this.OverallEncodeProgressFraction) * this.elapsedQueueEncodeTime.Elapsed.TotalSeconds) / this.OverallEncodeProgressFraction));
24522453
this.EstimatedTimeRemaining = Utilities.FormatTimeSpan(eta);
24532454
}
2455+
2456+
double currentJobRemainingWork = this.EncodeQueue[0].Cost - currentJobCompletedWork;
2457+
2458+
TimeSpan currentJobEta =
2459+
TimeSpan.FromSeconds(currentJobRemainingWork / overallWorkCompletionRate);
2460+
this.EncodeQueue[0].Eta = currentJobEta;
24542461
}
24552462
}
24562463

2457-
this.EncodeQueue[0].PercentComplete = (int)(currentJobCompletedWork / this.EncodeQueue[0].Cost * 100.0);
2464+
this.EncodeQueue[0].PercentComplete = (int)((currentJobCompletedWork / this.EncodeQueue[0].Cost) * 100.0);
24582465

24592466
if (e.EstimatedTimeLeft >= TimeSpan.Zero)
24602467
{

0 commit comments

Comments
 (0)