mirror of
https://github.com/tribufu/ServerManagers
synced 2026-06-01 09:42:39 +00:00
asm & csm: add file size to WorldSaveRestoreWindow
This commit is contained in:
parent
957c18faf4
commit
0c18b60501
8 changed files with 90 additions and 5 deletions
|
|
@ -319,6 +319,7 @@
|
||||||
<sys:String x:Key="WorldSaveRestore_Refresh_FailedTitle">Refresh Backup Files Error</sys:String>
|
<sys:String x:Key="WorldSaveRestore_Refresh_FailedTitle">Refresh Backup Files Error</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="WorldSaveRestore_NameColumnLabel">Name</sys:String>
|
<sys:String x:Key="WorldSaveRestore_NameColumnLabel">Name</sys:String>
|
||||||
|
<sys:String x:Key="WorldSaveRestore_FileSizeColumnLabel">Size</sys:String>
|
||||||
<sys:String x:Key="WorldSaveRestore_CreatedDateColumnLabel">Created</sys:String>
|
<sys:String x:Key="WorldSaveRestore_CreatedDateColumnLabel">Created</sys:String>
|
||||||
<sys:String x:Key="WorldSaveRestore_UpdatedDateColumnLabel">Last Updated</sys:String>
|
<sys:String x:Key="WorldSaveRestore_UpdatedDateColumnLabel">Last Updated</sys:String>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:com="clr-namespace:ServerManagerTool.Common;assembly=ServerManager.Common"
|
xmlns:com="clr-namespace:ServerManagerTool.Common;assembly=ServerManager.Common"
|
||||||
|
xmlns:cc="clr-namespace:ServerManagerTool.Common.Converters;assembly=ServerManager.Common"
|
||||||
MinWidth="700" MinHeight="480" Width="800" Height="480" ResizeMode="CanResize" WindowStyle="ToolWindow" WindowStartupLocation="CenterOwner" ShowInTaskbar="False"
|
MinWidth="700" MinHeight="480" Width="800" Height="480" ResizeMode="CanResize" WindowStyle="ToolWindow" WindowStartupLocation="CenterOwner" ShowInTaskbar="False"
|
||||||
Loaded="Window_Loaded"
|
Loaded="Window_Loaded"
|
||||||
Icon="../Art/favicon.ico" Title="{DynamicResource WorldSaveRestore_Title}">
|
Icon="../Art/favicon.ico" Title="{DynamicResource WorldSaveRestore_Title}">
|
||||||
|
|
@ -55,6 +56,18 @@
|
||||||
|
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Width="1*" Binding="{Binding FileName, Mode=OneWay}" Header="{DynamicResource WorldSaveRestore_NameColumnLabel}"/>
|
<DataGridTextColumn Width="1*" Binding="{Binding FileName, Mode=OneWay}" Header="{DynamicResource WorldSaveRestore_NameColumnLabel}"/>
|
||||||
|
<DataGridTextColumn Width="130" Binding="{Binding FileSize, Mode=OneWay, Converter={cc:FileSizeConverter}}" Header="{DynamicResource WorldSaveRestore_FileSizeColumnLabel}">
|
||||||
|
<DataGridTextColumn.HeaderStyle>
|
||||||
|
<Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
|
||||||
|
<Setter Property="HorizontalContentAlignment" Value="Right"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.HeaderStyle>
|
||||||
|
<DataGridTextColumn.CellStyle>
|
||||||
|
<Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Right"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.CellStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
<DataGridTextColumn Width="130" Binding="{Binding CreatedDate, Mode=OneWay}" Header="{DynamicResource WorldSaveRestore_CreatedDateColumnLabel}">
|
<DataGridTextColumn Width="130" Binding="{Binding CreatedDate, Mode=OneWay}" Header="{DynamicResource WorldSaveRestore_CreatedDateColumnLabel}">
|
||||||
<DataGridTextColumn.HeaderStyle>
|
<DataGridTextColumn.HeaderStyle>
|
||||||
<Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
|
<Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ namespace ServerManagerTool
|
||||||
public static readonly DependencyProperty CreatedDateProperty = DependencyProperty.Register(nameof(CreatedDate), typeof(DateTime), typeof(WorldSaveFile), new PropertyMetadata(DateTime.MinValue));
|
public static readonly DependencyProperty CreatedDateProperty = DependencyProperty.Register(nameof(CreatedDate), typeof(DateTime), typeof(WorldSaveFile), new PropertyMetadata(DateTime.MinValue));
|
||||||
public static readonly DependencyProperty FileProperty = DependencyProperty.Register(nameof(File), typeof(string), typeof(WorldSaveFile), new PropertyMetadata(string.Empty));
|
public static readonly DependencyProperty FileProperty = DependencyProperty.Register(nameof(File), typeof(string), typeof(WorldSaveFile), new PropertyMetadata(string.Empty));
|
||||||
public static readonly DependencyProperty FileNameProperty = DependencyProperty.Register(nameof(FileName), typeof(string), typeof(WorldSaveFile), new PropertyMetadata(string.Empty));
|
public static readonly DependencyProperty FileNameProperty = DependencyProperty.Register(nameof(FileName), typeof(string), typeof(WorldSaveFile), new PropertyMetadata(string.Empty));
|
||||||
|
public static readonly DependencyProperty FileSizeProperty = DependencyProperty.Register(nameof(FileSize), typeof(long), typeof(WorldSaveFile), new PropertyMetadata());
|
||||||
public static readonly DependencyProperty UpdatedDateProperty = DependencyProperty.Register(nameof(UpdatedDate), typeof(DateTime), typeof(WorldSaveFile), new PropertyMetadata(DateTime.MinValue));
|
public static readonly DependencyProperty UpdatedDateProperty = DependencyProperty.Register(nameof(UpdatedDate), typeof(DateTime), typeof(WorldSaveFile), new PropertyMetadata(DateTime.MinValue));
|
||||||
public static readonly DependencyProperty IsActiveFileProperty = DependencyProperty.Register(nameof(IsActiveFile), typeof(bool), typeof(WorldSaveFile), new PropertyMetadata(false));
|
public static readonly DependencyProperty IsActiveFileProperty = DependencyProperty.Register(nameof(IsActiveFile), typeof(bool), typeof(WorldSaveFile), new PropertyMetadata(false));
|
||||||
public static readonly DependencyProperty IsArchiveFileProperty = DependencyProperty.Register(nameof(IsArchiveFile), typeof(bool), typeof(WorldSaveFile), new PropertyMetadata(false));
|
public static readonly DependencyProperty IsArchiveFileProperty = DependencyProperty.Register(nameof(IsArchiveFile), typeof(bool), typeof(WorldSaveFile), new PropertyMetadata(false));
|
||||||
|
|
@ -60,6 +61,12 @@ namespace ServerManagerTool
|
||||||
set { SetValue(FileNameProperty, value); }
|
set { SetValue(FileNameProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long FileSize
|
||||||
|
{
|
||||||
|
get { return (long)GetValue(FileSizeProperty); }
|
||||||
|
set { SetValue(FileSizeProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
public DateTime UpdatedDate
|
public DateTime UpdatedDate
|
||||||
{
|
{
|
||||||
get { return (DateTime)GetValue(UpdatedDateProperty); }
|
get { return (DateTime)GetValue(UpdatedDateProperty); }
|
||||||
|
|
@ -273,7 +280,7 @@ namespace ServerManagerTool
|
||||||
var saveFiles = saveFolderInfo.GetFiles(searchPattern);
|
var saveFiles = saveFolderInfo.GetFiles(searchPattern);
|
||||||
foreach (var file in saveFiles)
|
foreach (var file in saveFiles)
|
||||||
{
|
{
|
||||||
WorldSaveFiles.Add(new WorldSaveFile { File = file.FullName , FileName = file.Name, CreatedDate = file.CreationTime, UpdatedDate = file.LastWriteTime, IsArchiveFile = false, IsActiveFile = file.Name.Equals(mapFileName, StringComparison.OrdinalIgnoreCase) });
|
WorldSaveFiles.Add(new WorldSaveFile { File = file.FullName , FileName = file.Name, FileSize = file.Length, CreatedDate = file.CreationTime, UpdatedDate = file.LastWriteTime, IsArchiveFile = false, IsActiveFile = file.Name.Equals(mapFileName, StringComparison.OrdinalIgnoreCase) });
|
||||||
}
|
}
|
||||||
|
|
||||||
var backupFolder = ServerApp.GetServerBackupFolder(_profile);
|
var backupFolder = ServerApp.GetServerBackupFolder(_profile);
|
||||||
|
|
@ -285,7 +292,7 @@ namespace ServerManagerTool
|
||||||
var backupFiles = backupFolderInfo.GetFiles(searchPattern);
|
var backupFiles = backupFolderInfo.GetFiles(searchPattern);
|
||||||
foreach (var file in backupFiles)
|
foreach (var file in backupFiles)
|
||||||
{
|
{
|
||||||
WorldSaveFiles.Add(new WorldSaveFile { File = file.FullName, FileName = file.Name, CreatedDate = file.CreationTime, UpdatedDate = file.LastWriteTime, IsArchiveFile = true, IsActiveFile = false });
|
WorldSaveFiles.Add(new WorldSaveFile { File = file.FullName, FileName = file.Name, FileSize = file.Length, CreatedDate = file.CreationTime, UpdatedDate = file.LastWriteTime, IsArchiveFile = true, IsActiveFile = false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -294,6 +294,7 @@
|
||||||
<sys:String x:Key="WorldSaveRestore_Refresh_FailedTitle">Refresh Backup Files Error</sys:String>
|
<sys:String x:Key="WorldSaveRestore_Refresh_FailedTitle">Refresh Backup Files Error</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="WorldSaveRestore_NameColumnLabel">Name</sys:String>
|
<sys:String x:Key="WorldSaveRestore_NameColumnLabel">Name</sys:String>
|
||||||
|
<sys:String x:Key="WorldSaveRestore_FileSizeColumnLabel">Size</sys:String>
|
||||||
<sys:String x:Key="WorldSaveRestore_CreatedDateColumnLabel">Created</sys:String>
|
<sys:String x:Key="WorldSaveRestore_CreatedDateColumnLabel">Created</sys:String>
|
||||||
<sys:String x:Key="WorldSaveRestore_UpdatedDateColumnLabel">Last Updated</sys:String>
|
<sys:String x:Key="WorldSaveRestore_UpdatedDateColumnLabel">Last Updated</sys:String>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,10 @@
|
||||||
</Style>
|
</Style>
|
||||||
</DockPanel.Style>
|
</DockPanel.Style>
|
||||||
|
|
||||||
|
<Grid DockPanel.Dock="Top" Background="Red" Visibility="{Binding CommonConfig.SteamAPIKey, Converter={StaticResource InvertStringNullOrEmptyToVisibilityConverter}}">
|
||||||
|
<TextBlock Text="{DynamicResource MainWindow_SteamWebApiKeyMissingLabel}" Margin="0,5,0,5" HorizontalAlignment="Center" Foreground="White"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<Grid DockPanel.Dock="Left">
|
<Grid DockPanel.Dock="Left">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:com="clr-namespace:ServerManagerTool.Common;assembly=ServerManager.Common"
|
xmlns:com="clr-namespace:ServerManagerTool.Common;assembly=ServerManager.Common"
|
||||||
|
xmlns:cc="clr-namespace:ServerManagerTool.Common.Converters;assembly=ServerManager.Common"
|
||||||
MinWidth="700" MinHeight="480" Width="800" Height="480" ResizeMode="CanResize" WindowStyle="ToolWindow" WindowStartupLocation="CenterOwner" ShowInTaskbar="False"
|
MinWidth="700" MinHeight="480" Width="800" Height="480" ResizeMode="CanResize" WindowStyle="ToolWindow" WindowStartupLocation="CenterOwner" ShowInTaskbar="False"
|
||||||
Loaded="Window_Loaded"
|
Loaded="Window_Loaded"
|
||||||
Icon="../Art/favicon.ico" Title="{DynamicResource WorldSaveRestore_Title}">
|
Icon="../Art/favicon.ico" Title="{DynamicResource WorldSaveRestore_Title}">
|
||||||
|
|
@ -56,6 +57,18 @@
|
||||||
|
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Width="1*" Binding="{Binding FileName, Mode=OneWay}" Header="{DynamicResource WorldSaveRestore_NameColumnLabel}"/>
|
<DataGridTextColumn Width="1*" Binding="{Binding FileName, Mode=OneWay}" Header="{DynamicResource WorldSaveRestore_NameColumnLabel}"/>
|
||||||
|
<DataGridTextColumn Width="130" Binding="{Binding FileSize, Mode=OneWay, Converter={cc:FileSizeConverter}}" Header="{DynamicResource WorldSaveRestore_FileSizeColumnLabel}">
|
||||||
|
<DataGridTextColumn.HeaderStyle>
|
||||||
|
<Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
|
||||||
|
<Setter Property="HorizontalContentAlignment" Value="Right"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.HeaderStyle>
|
||||||
|
<DataGridTextColumn.CellStyle>
|
||||||
|
<Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Right"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.CellStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
<DataGridTextColumn Width="130" Binding="{Binding CreatedDate, Mode=OneWay}" Header="{DynamicResource WorldSaveRestore_CreatedDateColumnLabel}">
|
<DataGridTextColumn Width="130" Binding="{Binding CreatedDate, Mode=OneWay}" Header="{DynamicResource WorldSaveRestore_CreatedDateColumnLabel}">
|
||||||
<DataGridTextColumn.HeaderStyle>
|
<DataGridTextColumn.HeaderStyle>
|
||||||
<Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
|
<Style TargetType="DataGridColumnHeader" BasedOn="{StaticResource {x:Type DataGridColumnHeader}}">
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ namespace ServerManagerTool
|
||||||
public static readonly DependencyProperty CreatedDateProperty = DependencyProperty.Register(nameof(CreatedDate), typeof(DateTime), typeof(WorldSaveFile), new PropertyMetadata(DateTime.MinValue));
|
public static readonly DependencyProperty CreatedDateProperty = DependencyProperty.Register(nameof(CreatedDate), typeof(DateTime), typeof(WorldSaveFile), new PropertyMetadata(DateTime.MinValue));
|
||||||
public static readonly DependencyProperty FileProperty = DependencyProperty.Register(nameof(File), typeof(string), typeof(WorldSaveFile), new PropertyMetadata(string.Empty));
|
public static readonly DependencyProperty FileProperty = DependencyProperty.Register(nameof(File), typeof(string), typeof(WorldSaveFile), new PropertyMetadata(string.Empty));
|
||||||
public static readonly DependencyProperty FileNameProperty = DependencyProperty.Register(nameof(FileName), typeof(string), typeof(WorldSaveFile), new PropertyMetadata(string.Empty));
|
public static readonly DependencyProperty FileNameProperty = DependencyProperty.Register(nameof(FileName), typeof(string), typeof(WorldSaveFile), new PropertyMetadata(string.Empty));
|
||||||
|
public static readonly DependencyProperty FileSizeProperty = DependencyProperty.Register(nameof(FileSize), typeof(long), typeof(WorldSaveFile), new PropertyMetadata());
|
||||||
public static readonly DependencyProperty UpdatedDateProperty = DependencyProperty.Register(nameof(UpdatedDate), typeof(DateTime), typeof(WorldSaveFile), new PropertyMetadata(DateTime.MinValue));
|
public static readonly DependencyProperty UpdatedDateProperty = DependencyProperty.Register(nameof(UpdatedDate), typeof(DateTime), typeof(WorldSaveFile), new PropertyMetadata(DateTime.MinValue));
|
||||||
public static readonly DependencyProperty IsActiveFileProperty = DependencyProperty.Register(nameof(IsActiveFile), typeof(bool), typeof(WorldSaveFile), new PropertyMetadata(false));
|
public static readonly DependencyProperty IsActiveFileProperty = DependencyProperty.Register(nameof(IsActiveFile), typeof(bool), typeof(WorldSaveFile), new PropertyMetadata(false));
|
||||||
public static readonly DependencyProperty IsArchiveFileProperty = DependencyProperty.Register(nameof(IsArchiveFile), typeof(bool), typeof(WorldSaveFile), new PropertyMetadata(false));
|
public static readonly DependencyProperty IsArchiveFileProperty = DependencyProperty.Register(nameof(IsArchiveFile), typeof(bool), typeof(WorldSaveFile), new PropertyMetadata(false));
|
||||||
|
|
@ -60,6 +61,12 @@ namespace ServerManagerTool
|
||||||
set { SetValue(FileNameProperty, value); }
|
set { SetValue(FileNameProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long FileSize
|
||||||
|
{
|
||||||
|
get { return (long)GetValue(FileSizeProperty); }
|
||||||
|
set { SetValue(FileSizeProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
public DateTime UpdatedDate
|
public DateTime UpdatedDate
|
||||||
{
|
{
|
||||||
get { return (DateTime)GetValue(UpdatedDateProperty); }
|
get { return (DateTime)GetValue(UpdatedDateProperty); }
|
||||||
|
|
@ -261,14 +268,14 @@ namespace ServerManagerTool
|
||||||
var saveFiles = saveFolderInfo.GetFiles(searchPattern);
|
var saveFiles = saveFolderInfo.GetFiles(searchPattern);
|
||||||
foreach (var file in saveFiles)
|
foreach (var file in saveFiles)
|
||||||
{
|
{
|
||||||
WorldSaveFiles.Add(new WorldSaveFile { File = file.FullName, FileName = file.Name, CreatedDate = file.CreationTime, UpdatedDate = file.LastWriteTime, IsArchiveFile = false, IsActiveFile = file.Name.Equals(mapFileName, StringComparison.OrdinalIgnoreCase) });
|
WorldSaveFiles.Add(new WorldSaveFile { File = file.FullName, FileName = file.Name, FileSize = file.Length, CreatedDate = file.CreationTime, UpdatedDate = file.LastWriteTime, IsArchiveFile = false, IsActiveFile = file.Name.Equals(mapFileName, StringComparison.OrdinalIgnoreCase) });
|
||||||
}
|
}
|
||||||
|
|
||||||
searchPattern = $"{mapName}_backup_*{mapExtension}";
|
searchPattern = $"{mapName}_backup_*{mapExtension}";
|
||||||
saveFiles = saveFolderInfo.GetFiles(searchPattern);
|
saveFiles = saveFolderInfo.GetFiles(searchPattern);
|
||||||
foreach (var file in saveFiles)
|
foreach (var file in saveFiles)
|
||||||
{
|
{
|
||||||
WorldSaveFiles.Add(new WorldSaveFile { File = file.FullName, FileName = file.Name, CreatedDate = file.CreationTime, UpdatedDate = file.LastWriteTime, IsArchiveFile = false, IsActiveFile = file.Name.Equals(mapFileName, StringComparison.OrdinalIgnoreCase) });
|
WorldSaveFiles.Add(new WorldSaveFile { File = file.FullName, FileName = file.Name, FileSize = file.Length, CreatedDate = file.CreationTime, UpdatedDate = file.LastWriteTime, IsArchiveFile = false, IsActiveFile = file.Name.Equals(mapFileName, StringComparison.OrdinalIgnoreCase) });
|
||||||
}
|
}
|
||||||
|
|
||||||
var backupFolder = ServerApp.GetServerBackupFolder(_profile);
|
var backupFolder = ServerApp.GetServerBackupFolder(_profile);
|
||||||
|
|
@ -280,7 +287,7 @@ namespace ServerManagerTool
|
||||||
var backupFiles = backupFolderInfo.GetFiles(searchPattern);
|
var backupFiles = backupFolderInfo.GetFiles(searchPattern);
|
||||||
foreach (var file in backupFiles)
|
foreach (var file in backupFiles)
|
||||||
{
|
{
|
||||||
WorldSaveFiles.Add(new WorldSaveFile { File = file.FullName, FileName = file.Name, CreatedDate = file.CreationTime, UpdatedDate = file.LastWriteTime, IsArchiveFile = true, IsActiveFile = false });
|
WorldSaveFiles.Add(new WorldSaveFile { File = file.FullName, FileName = file.Name, FileSize = file.Length, CreatedDate = file.CreationTime, UpdatedDate = file.LastWriteTime, IsArchiveFile = true, IsActiveFile = false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
39
src/ServerManager.Common/Converters/FileSizeConverter.cs
Normal file
39
src/ServerManager.Common/Converters/FileSizeConverter.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Markup;
|
||||||
|
|
||||||
|
namespace ServerManagerTool.Common.Converters
|
||||||
|
{
|
||||||
|
public class FileSizeConverter : MarkupExtension, IValueConverter
|
||||||
|
{
|
||||||
|
private const decimal DIVISOR = 1024M;
|
||||||
|
|
||||||
|
// Load all suffixes in an array
|
||||||
|
private static readonly string[] suffixes = { "Bytes", "KB", "MB", "GB", "TB", "PB" };
|
||||||
|
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
var counter = 0;
|
||||||
|
var number = System.Convert.ToDecimal(value);
|
||||||
|
|
||||||
|
while (number / DIVISOR >= 1)
|
||||||
|
{
|
||||||
|
number /= DIVISOR;
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Format("{0:n2} {1}", number, suffixes[counter]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("FileSizeConverter can only be used OneWay.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue