统计大小
This commit is contained in:
parent
157ebda24d
commit
d4226132c5
1
App.xaml
1
App.xaml
@ -33,6 +33,7 @@
|
||||
<BooleanToVisibilityConverter />
|
||||
</c:ValueConverterAggregate>
|
||||
<c:MultiValueEqualityConverter x:Key="MultiValueEqualityConverter" />
|
||||
<c:SizeConverter x:Key="SizeConverter" />
|
||||
<Style x:Key="CommonStyle" TargetType="Control">
|
||||
<Setter
|
||||
Property="Foreground"
|
||||
|
@ -19,6 +19,8 @@ namespace HashCalculator.GUI
|
||||
public string InstanceIdString { get; }
|
||||
public string TypeIdString { get; }
|
||||
|
||||
public int Size { get; }
|
||||
|
||||
public string LocalizedNames
|
||||
{
|
||||
get
|
||||
@ -121,6 +123,7 @@ namespace HashCalculator.GUI
|
||||
}
|
||||
InstanceIdString = $"{InstanceId:x8} ({InstanceId,10})";
|
||||
TypeIdString = $"{TypeId:x8} ({TypeId,10})";
|
||||
Size = asset.InstanceDataSize;
|
||||
}
|
||||
|
||||
private AssetEntry(string kind, string type)
|
||||
|
@ -175,6 +175,7 @@ namespace HashCalculator.GUI
|
||||
}).ConfigureAwait(true);
|
||||
AddEntries(entries);
|
||||
ViewModel.StatusText = $"Manifest文件读取完毕,加载了{_loadedAssets.Count}个素材";
|
||||
ViewModel.SizeAvailable = true;
|
||||
}
|
||||
|
||||
public async Task CancelLoadingXml()
|
||||
@ -210,6 +211,7 @@ namespace HashCalculator.GUI
|
||||
};
|
||||
ViewModel.IsXml = true;
|
||||
ViewModel.IsXsd = type == InputEntryType.XsdFile;
|
||||
ViewModel.SizeAvailable = false;
|
||||
var task = LoadXmlInternal(await modXml, tokenSource.Token);
|
||||
_lastXmlTask = (tokenSource, task).ToTuple();
|
||||
|
||||
|
33
Converters/SizeConverter.cs
Normal file
33
Converters/SizeConverter.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace HashCalculator.GUI.Converters
|
||||
{
|
||||
internal class SizeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var size = (int)value;
|
||||
var suffixes = new[]
|
||||
{
|
||||
(1024, 1.0, ""),
|
||||
(1024 * 1024, 1024.0, "K"),
|
||||
(1024 * 1024 * 1024, 1024 * 1024.0, "M"),
|
||||
};
|
||||
foreach (var (limit, divisor, suffix) in suffixes)
|
||||
{
|
||||
if (size < limit)
|
||||
{
|
||||
return $"{size / divisor:0.00}{suffix}B";
|
||||
}
|
||||
}
|
||||
return $"{size / (1024.0 * 1024.0 * 1024.0):0.00}GB";
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -291,6 +291,14 @@
|
||||
Path=DataContext.ConsiderTypeId,
|
||||
Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
/>
|
||||
<DataGridTextColumn
|
||||
Header="大小"
|
||||
Binding="{Binding Size, Converter={StaticResource SizeConverter}}"
|
||||
FontFamily="Courier New"
|
||||
Visibility="{Binding Source={x:Reference Name=ReferenceProvider},
|
||||
Path=DataContext.SizeAvailable,
|
||||
Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||
/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</DockPanel>
|
||||
|
@ -89,6 +89,13 @@ namespace HashCalculator.GUI
|
||||
set => SetField(ref _considerTypeId, value, () => GameObjectOnly &= !value);
|
||||
}
|
||||
|
||||
private bool _sizeAvailable;
|
||||
public bool SizeAvailable
|
||||
{
|
||||
get => _sizeAvailable;
|
||||
set => SetField(ref _sizeAvailable, value);
|
||||
}
|
||||
|
||||
public Command FilterDisplayEntries { get; }
|
||||
|
||||
private int _totalCount;
|
||||
|
Loading…
x
Reference in New Issue
Block a user