Skip to content

Commit ffeb051

Browse files
author
RandomEngy
committed
Added percent display on top of overall encode progress bar.
1 parent 91c1094 commit ffeb051

5 files changed

Lines changed: 37 additions & 6 deletions

File tree

VidCoder/App.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<converters:EnumBoolConverter x:Key="EnumBoolConverter" />
88
<converters:EnumBoolInverseConverter x:Key="EnumBoolInverseConverter" />
99
<converters:InverseBoolConverter x:Key="InverseBoolConverter" />
10+
<converters:PercentDisplayConverter x:Key="PercentDisplayConverter" />
1011
<Style x:Key="RowButton" TargetType="{x:Type Button}">
1112
<Setter Property="Height" Value="23" />
1213
<Setter Property="VerticalAlignment" Value="Center" />

VidCoder/Converters/EnumBoolConverter.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
1414
if (targetType.IsAssignableFrom(typeof(bool)) && targetType.IsAssignableFrom(typeof(string)))
1515
{
1616
throw new ArgumentException("EnumBoolConverter can only convert to boolean or string.");
17-
1817
}
1918

2019
if (targetType == typeof(string))
@@ -49,6 +48,5 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
4948

5049
return null;
5150
}
52-
5351
}
5452
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Globalization;
6+
using System.Windows.Data;
7+
8+
namespace VidCoder.Converters
9+
{
10+
public class PercentDisplayConverter : IValueConverter
11+
{
12+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
13+
{
14+
double percent = (double)value;
15+
return percent.ToString("F1") + "%";
16+
}
17+
18+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
19+
{
20+
throw new NotSupportedException("Converting back not supported.");
21+
}
22+
}
23+
}

VidCoder/VidCoder.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@
191191
<DependentUpon>App.xaml</DependentUpon>
192192
<SubType>Code</SubType>
193193
</Compile>
194+
<Compile Include="Converters\PercentDisplayConverter.cs" />
194195
<Compile Include="EnumStringConverter.cs" />
195196
<Compile Include="IListItemConverter.cs" />
196197
<Compile Include="Model\Logger.cs" />

VidCoder/View/MainWindow.xaml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,18 @@
472472
<TextBlock
473473
Text="{Binding AverageFps}" Width="30" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="286,111,0,0"
474474
Visibility="{Binding EncodeSpeedDetailsAvailable, Converter={StaticResource VisibilityConverter}}"/>
475-
<ProgressBar
476-
Margin="317,100,179,0" Visibility="{Binding Encoding, Converter={StaticResource VisibilityConverter}}"
477-
Value="{Binding OverallEncodeProgressPercent, Mode=OneWay}" Height="20.44" VerticalAlignment="Top"
478-
Foreground="{Binding ProgressBarColor}"/>
475+
<Grid
476+
Margin="317,100,179,0" VerticalAlignment="Top" Height="20.44"
477+
Visibility="{Binding Encoding, Converter={StaticResource VisibilityConverter}}">
478+
<ProgressBar
479+
Value="{Binding OverallEncodeProgressPercent, Mode=OneWay}" Height="20.44" VerticalAlignment="Top"
480+
Foreground="{Binding ProgressBarColor}"/>
481+
<TextBlock
482+
Text="{Binding OverallEncodeProgressPercent, Mode=OneWay, Converter={StaticResource PercentDisplayConverter}}"
483+
VerticalAlignment="Center" HorizontalAlignment="Center" />
484+
</Grid>
485+
486+
479487

480488
<Button Height="37" HorizontalAlignment="Right" Margin="0,90,94,0" VerticalAlignment="Top" Width="78"
481489
Command="{Binding StopEncodeCommand}"

0 commit comments

Comments
 (0)