Skip to content
Permalink
Browse files

[F] Fix sorting by Size

[*] make sorting by Size obey the actual number based sorting
[*] also fix size suffixes (converter provided by @da3dsoul )

Co-Authored-By: da3dsoul <da3dsoul@gmail.com>
  • Loading branch information...
Baine and da3dsoul committed Jan 24, 2019
1 parent a3ac0d3 commit 33bd38776c3c506dd3a71eceb39fb215c06de0cd
@@ -8,15 +8,13 @@
xmlns:downloads1="clr-namespace:Shoko.Desktop.UserControls.Downloads"
xmlns:dataTemplateSelectors="clr-namespace:Shoko.Desktop.DataTemplateSelectors"
xmlns:System="clr-namespace:System;assembly=mscorlib"
xmlns:wpfhelpers="clr-namespace:Shoko.Desktop.WPFHelpers"
WindowStartupLocation="CenterScreen" UseLayoutRounding="True"
Title="Shoko Desktop" Height="700" Width="1350" x:Name="mainWindow" Icon="/ShokoDesktop;component/Images/db.ico" >



<Window.Resources>
<ResourceDictionary>


<wpfhelpers:LongToFileSizeConverter x:Key="LongToFileSizeConverter"/>
<dataTemplateSelectors:MainListTemplateSelector x:Key="MainListTemplateSelector"/>
<dataTemplateSelectors:BreadCrumbTemplateSelector x:Key="BreadCrumbTemplateSelector"/>
<dataTemplateSelectors:GroupsSeriesDataTemplateSelector x:Key="myDataTemplateSelector"/>
@@ -5,11 +5,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:usercontrols="clr-namespace:Shoko.Desktop.UserControls"
xmlns:local="clr-namespace:Shoko.Desktop.ViewModel"
xmlns:wpfhelpers="clr-namespace:Shoko.Desktop.WPFHelpers"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">

<UserControl.Resources>

<ResourceDictionary>


@@ -22,6 +22,7 @@


<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<wpfhelpers:LongToFileSizeConverter x:Key="LongToFileSizeConverter" />

<!-- SimpleVideoLocalTemplate -->
<DataTemplate x:Key="SimpleVideoLocalTemplate">
@@ -360,7 +361,13 @@
<DataGrid.Columns>
<DataGridTextColumn Header="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Utilities_Folder}" Binding="{Binding Path=FileDirectory}" IsReadOnly="True" Width="100" />
<DataGridTextColumn Header="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Utilities_FileName}" Binding="{Binding Path=FileName}" IsReadOnly="True" Width="300" />
<DataGridTextColumn Header="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Utilities_Size}" Binding="{Binding Path=FormattedFileSize}" IsReadOnly="True" />
<DataGridTextColumn Header="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Utilities_Size}" Binding="{Binding Path=FileSize, Converter={StaticResource LongToFileSizeConverter}}" IsReadOnly="True">
<DataGridTextColumn.ElementStyle>
<Style>
<Setter Property="TextBlock.TextAlignment" Value="Right" />
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Header="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Hash}" Binding="{Binding Path=Hash}" IsReadOnly="True" />
<DataGridTextColumn Header="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Unrecognized_CRC}" Binding="{Binding Path=CRC32}" IsReadOnly="True" />
<DataGridTextColumn Header="{Resx ResxName=Shoko.Commons.Properties.Resources, Key=Unrecognized_Date}" Binding="{Binding Path=DateTimeUpdated}" IsReadOnly="True" />
@@ -471,8 +478,7 @@
<Image Source="/Images/16_videofile.png" Width="16" Height="16" Margin="5,0,0,0" VerticalAlignment="Center" ></Image>
<ComboBox Name="cboMultiType" Margin="10,0,0,0" Height="24" VerticalAlignment="Center"/>
<StackPanel Orientation="Horizontal" Visibility="{Binding Path=MultipleTypeSingle, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type usercontrols:UnrecognisedVideos}}, Converter={StaticResource BooleanToVisibilityConverter}}">
<ComboBox Name="cboEpisodes" Margin="10,0,0,0" Height="24" VerticalAlignment="Center" ItemTemplate="{DynamicResource SimpleAnimeEpisodeTemplate}"
/>
<ComboBox Name="cboEpisodes" Margin="10,0,0,0" Height="24" VerticalAlignment="Center" ItemTemplate="{DynamicResource SimpleAnimeEpisodeTemplate}" />
</StackPanel>
<StackPanel Orientation="Horizontal"
Visibility="{Binding Path=MultipleTypeRange, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type usercontrols:UnrecognisedVideos}}, Converter={StaticResource BooleanToVisibilityConverter}}">
@@ -27,11 +27,11 @@ private static string FormatFileSize(long byteCount)
{
string[] suf = { "B", "KB", "MB", "GB", "TB", "PB", "EB" };
if (byteCount == 0)
return "0" + suf[0];
return "0" + " " + suf[0];
long bytes = Math.Abs(byteCount);
int place = System.Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
double num = Math.Round(bytes / Math.Pow(1024, place), 2);
return num + suf[place];
return num + " " + suf[place];
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

0 comments on commit 33bd387

Please sign in to comment.
You can’t perform that action at this time.