Skip to content

Commit 0cd7d80

Browse files
author
RandomEngy
committed
Changed framerate display to always include one decimal point, rather than dropping it when it's 0.
1 parent ffeb051 commit 0cd7d80

4 files changed

Lines changed: 27 additions & 2 deletions

File tree

VidCoder/App.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<converters:EnumBoolInverseConverter x:Key="EnumBoolInverseConverter" />
99
<converters:InverseBoolConverter x:Key="InverseBoolConverter" />
1010
<converters:PercentDisplayConverter x:Key="PercentDisplayConverter" />
11+
<converters:DoubleDisplayConverter x:Key="DoubleDisplayConverter" />
1112
<Style x:Key="RowButton" TargetType="{x:Type Button}">
1213
<Setter Property="Height" Value="23" />
1314
<Setter Property="VerticalAlignment" Value="Center" />
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 DoubleDisplayConverter : 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\DoubleDisplayConverter.cs" />
194195
<Compile Include="Converters\PercentDisplayConverter.cs" />
195196
<Compile Include="EnumStringConverter.cs" />
196197
<Compile Include="IListItemConverter.cs" />

VidCoder/View/MainWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,14 +463,14 @@
463463
TextAlignment="Right"
464464
Visibility="{Binding EncodeSpeedDetailsAvailable, Converter={StaticResource VisibilityConverter}}"/>
465465
<TextBlock
466-
Text="{Binding CurrentFps}" Width="30" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="286,94,0,0"
466+
Text="{Binding CurrentFps, Mode=OneWay, Converter={StaticResource DoubleDisplayConverter}}" Width="30" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="286,94,0,0"
467467
Visibility="{Binding EncodeSpeedDetailsAvailable, Converter={StaticResource VisibilityConverter}}"/>
468468
<TextBlock
469469
Text="Average FPS:" Width="70" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="213,111,0,0"
470470
TextAlignment="Right"
471471
Visibility="{Binding EncodeSpeedDetailsAvailable, Converter={StaticResource VisibilityConverter}}"/>
472472
<TextBlock
473-
Text="{Binding AverageFps}" Width="30" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="286,111,0,0"
473+
Text="{Binding AverageFps, Mode=OneWay, Converter={StaticResource DoubleDisplayConverter}}" Width="30" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="286,111,0,0"
474474
Visibility="{Binding EncodeSpeedDetailsAvailable, Converter={StaticResource VisibilityConverter}}"/>
475475
<Grid
476476
Margin="317,100,179,0" VerticalAlignment="Top" Height="20.44"

0 commit comments

Comments
 (0)