- Update StorageView.xaml: DataGrid top, GridSplitter, chart panel bottom - Add PieChart and CartesianChart with MultiDataTrigger visibility - Add radio buttons for donut/bar chart toggle in left panel - Create BytesLabelConverter for chart tooltip formatting - Add stor.chart.* localization keys in EN and FR resx files Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
24 lines
931 B
C#
24 lines
931 B
C#
using System.Globalization;
|
|
using System.Windows.Data;
|
|
|
|
namespace SharepointToolbox.Views.Converters;
|
|
|
|
/// <summary>
|
|
/// Converts a long byte value to a human-readable label for chart axes and tooltips.
|
|
/// Similar to BytesConverter but implements IValueConverter for XAML binding.
|
|
/// </summary>
|
|
public class BytesLabelConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value is not long bytes) return value?.ToString() ?? "";
|
|
if (bytes < 1024) return $"{bytes} B";
|
|
if (bytes < 1024 * 1024) return $"{bytes / 1024.0:F1} KB";
|
|
if (bytes < 1024 * 1024 * 1024) return $"{bytes / (1024.0 * 1024):F1} MB";
|
|
return $"{bytes / (1024.0 * 1024 * 1024):F2} GB";
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
=> throw new NotSupportedException();
|
|
}
|