Skip to content

Commit e2c6b10

Browse files
committed
Added representation of estimated size confidence to UI, based on user submission results.
1 parent 6c3a2a0 commit e2c6b10

File tree

4 files changed

+70
-3
lines changed

4 files changed

+70
-3
lines changed

CompactGUI/Components/Converters/IValueConverters.vb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,43 @@ Public Class CompressionLevelAbbreviatedConverter : Implements IValueConverter
9696
Throw New NotImplementedException()
9797
End Function
9898
End Class
99+
100+
Public Class ConfidenceIntToStringConverter : Implements IValueConverter
101+
102+
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
103+
Select Case value
104+
Case 0
105+
Return "▬"
106+
Case 1
107+
Return "▬▬"
108+
Case 2
109+
Return "▬▬▬"
110+
Case Else
111+
Return "▭▭▭"
112+
End Select
113+
End Function
114+
115+
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
116+
Throw New NotImplementedException()
117+
End Function
118+
End Class
119+
120+
Public Class ConfidenceIntToColorConverter : Implements IValueConverter
121+
122+
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
123+
Select Case value
124+
Case 0
125+
Return New SolidColorBrush(ColorConverter.ConvertFromString("#FF996B6B"))
126+
Case 1
127+
Return New SolidColorBrush(ColorConverter.ConvertFromString("#F1CE92"))
128+
Case 2
129+
Return New SolidColorBrush(ColorConverter.ConvertFromString("#92F1AB"))
130+
Case Else
131+
Return New SolidColorBrush(ColorConverter.ConvertFromString("#BAC2CA"))
132+
End Select
133+
End Function
134+
135+
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
136+
Throw New NotImplementedException()
137+
End Function
138+
End Class

CompactGUI/Models/SharedObjects.vb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Public Class ActiveFolder : Inherits ObservableObject
1414
Public Property UncompressedBytes As Long
1515
Public Property CompressedBytes As Long
1616
Public Property SelectedCompressionMode = 0
17+
Public Property CompressionConfidence = -1
1718

1819
Public Property IsFreshlyCompressed As Boolean = False
1920

CompactGUI/ViewModels/MainViewModel.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ Public Class MainViewModel : Inherits ObservableObject
198198

199199
'TODO: Modify the 100 cutoff based on level of aggressiveness selected by user in settings
200200
ActiveFolder.WikiPoorlyCompressedFiles = res.poorlyCompressedList.Where(Function(k) k.Value > 100 AndAlso k.Key <> "").Select(Function(k) k.Key).ToList
201-
201+
ActiveFolder.CompressionConfidence = res.confidence
202202
Return CLng(ActiveFolder.UncompressedBytes * res.estimatedRatio)
203203

204204
End Function

CompactGUI/Views/MainWindow.xaml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
<local:StrippedFolderPathConverter x:Key="StrippedFolderPathConverter"/>
2121
<local:RelativeDateConverter x:Key="RelativeDateConverter"/>
2222
<local:CompressionLevelAbbreviatedConverter x:Key="CompressionLevelAbbreviatedConverter"/>
23+
<local:ConfidenceIntToColorConverter x:Key="ConfidenceIntToColorConverter"/>
24+
<local:ConfidenceIntToStringConverter x:Key="ConfidenceIntToStringConverter"/>
2325
</ResourceDictionary>
2426

2527
</Window.Resources>
@@ -201,6 +203,9 @@
201203
<StringAnimationUsingKeyFrames Storyboard.TargetName="RightLabel" Storyboard.TargetProperty="(TextBlock.Text)" >
202204
<DiscreteStringKeyFrame Value="estimated size" KeyTime="0:0:0" />
203205
</StringAnimationUsingKeyFrames>
206+
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Confidence" Storyboard.TargetProperty="(UIElement.Visibility)">
207+
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/>
208+
</ObjectAnimationUsingKeyFrames>
204209
</Storyboard>
205210
</VisualState>
206211
<VisualState x:Name="AnalysingFolderSelected">
@@ -371,6 +376,9 @@
371376
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="grid3" Storyboard.TargetProperty="(UIElement.Visibility)">
372377
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Collapsed}"/>
373378
</ObjectAnimationUsingKeyFrames>
379+
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Confidence" Storyboard.TargetProperty="(UIElement.Visibility)">
380+
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Collapsed}"/>
381+
</ObjectAnimationUsingKeyFrames>
374382

375383
</Storyboard>
376384
</VisualState>
@@ -444,6 +452,9 @@
444452
<StringAnimationUsingKeyFrames Storyboard.TargetName="RightLabel" Storyboard.TargetProperty="(TextBlock.Text)" >
445453
<DiscreteStringKeyFrame Value="after" KeyTime="0:0:0" />
446454
</StringAnimationUsingKeyFrames>
455+
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Confidence" Storyboard.TargetProperty="(UIElement.Visibility)">
456+
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Collapsed}"/>
457+
</ObjectAnimationUsingKeyFrames>
447458

448459
</Storyboard>
449460
</VisualState>
@@ -687,14 +698,18 @@
687698
</Style.Triggers>
688699
</Style>
689700
</Border.Style>
690-
<Grid >
701+
<Grid>
691702
<Grid.ColumnDefinitions>
692703
<ColumnDefinition Width="60"/>
693704
<ColumnDefinition Width="*"/>
694705
<ColumnDefinition Width="40"/>
695706
<ColumnDefinition Width="*"/>
696707
<ColumnDefinition Width="60"/>
697708
</Grid.ColumnDefinitions>
709+
<Grid.RowDefinitions>
710+
<RowDefinition Height="*"/>
711+
<RowDefinition Height="30"/>
712+
</Grid.RowDefinitions>
698713

699714
<StackPanel Orientation="Vertical" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center">
700715
<TextBlock Text="{Binding ActiveFolder.UncompressedBytes, Converter={StaticResource BytesToReadableConverter}}" d:Text="21.7 GB" FontFamily="Segoe UI Semibold" FontSize="31" Foreground="White" HorizontalAlignment="Center"/>
@@ -704,8 +719,19 @@
704719
<StackPanel Orientation="Vertical" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center">
705720
<TextBlock Text="{Binding ActiveFolder.CompressedBytes, Converter={StaticResource BytesToReadableConverter}}" d:Text="29.7 GB" FontFamily="Segoe UI Semibold" FontSize="31" Foreground="White" HorizontalAlignment="Center"/>
706721
<TextBlock x:Name="RightLabel" Text="estimated size" FontFamily="Segoe UI Semibold" FontSize="17" Foreground="#BAC2CA" HorizontalAlignment="Center"/>
722+
707723
</StackPanel>
708-
724+
<Grid Margin="0,3,0,0" x:Name="Confidence" Grid.Column="3" Grid.Row="1" Grid.ColumnSpan="1" HorizontalAlignment="Center" Width="110">
725+
<TextBlock HorizontalAlignment="Left" Text="confidence" FontFamily="Segoe UI " FontSize="13" Foreground="#50BAC2CA" />
726+
<TextBlock HorizontalAlignment="Right" Text="{Binding ActiveFolder.CompressionConfidence, Converter={StaticResource ConfidenceIntToStringConverter}}" FontFamily="Segoe UI SemiBold" FontSize="13" Foreground="{Binding ActiveFolder.CompressionConfidence, Converter={StaticResource ConfidenceIntToColorConverter}}" />
727+
<Grid.ToolTip>
728+
<ToolTip>
729+
<!-- Your tooltip content goes here -->
730+
<TextBlock Text="Confidence of the estimated size, determined by number of submitted user results" />
731+
</ToolTip>
732+
</Grid.ToolTip>
733+
</Grid>
734+
709735
</Grid>
710736
</Border>
711737

0 commit comments

Comments
 (0)