From 2d69035bd72754d001c4810978bf0f0e42b3e23e Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 12 Nov 2021 07:12:08 +0300 Subject: [PATCH] 20211111-1 --- anbs_cp/CountFormatter.cs | 60 ++++++++++++++++++++++++++++++++++++ anbs_cp/FileSizeFormatter.cs | 4 +++ anbs_cp/anbs_cp.csproj | 2 +- 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 anbs_cp/CountFormatter.cs diff --git a/anbs_cp/CountFormatter.cs b/anbs_cp/CountFormatter.cs new file mode 100644 index 0000000..f6b608b --- /dev/null +++ b/anbs_cp/CountFormatter.cs @@ -0,0 +1,60 @@ +namespace anbs_cp +{ + /// + /// Форматирует число элементов в понятную строку + /// + public class CountFormatter : IValueFormatter + { + #region Cвойства класса + /// + /// Имена чисел ( , тысяч, миллионов, миллиардов и триллионов) + /// + public string[] SizeNames { get; set; } = { "Байт", "Кб", "Мб", "Гб", "Тб" }; + /// + /// Знаков после запятой + /// + public byte DecimalPlaces { get; set; } = 2; + /// + /// Максимально байт (далее идут Кбайты) + /// + public long ByteMax { get; set; } = 1024; + /// + /// Максимально Кбайт (далее идут Мбайты) + /// + public long KByteMax { get; set; } = 1048576; + /// + /// Максимально Мбайт (далее идут Гбайты) + /// + public long MByteMax { get; set; } = 1073741824; + /// + /// Максимально Гбайт (далее идут Тбайты) + /// + public long GByteMax { get; set; } = 1099511627776; + #endregion + + #region Реализация интерфейса + /// + /// Реализация интерфейса + /// + public string[] ValueNames { get => SizeNames; set => SizeNames = value; } + /// + /// Реализация интерфейса + /// + public long[] MaxSizes + { + get => new long[] { ByteMax, KByteMax, MByteMax, GByteMax }; + set + { + ByteMax = value[0]; + KByteMax = value[1]; + MByteMax = value[2]; + GByteMax = value[3]; + } + } + /// + /// Реализация интерфейса + /// + public string Format(long value) => (this as IValueFormatter).Format(value); + #endregion + } +} \ No newline at end of file diff --git a/anbs_cp/FileSizeFormatter.cs b/anbs_cp/FileSizeFormatter.cs index a4cbd33..e8e5537 100644 --- a/anbs_cp/FileSizeFormatter.cs +++ b/anbs_cp/FileSizeFormatter.cs @@ -51,6 +51,10 @@ GByteMax = value[3]; } } + /// + /// Реализация интерфейса + /// + public string Format(long value) => (this as IValueFormatter).Format(value); #endregion } } \ No newline at end of file diff --git a/anbs_cp/anbs_cp.csproj b/anbs_cp/anbs_cp.csproj index f7f326e..bc9380c 100644 --- a/anbs_cp/anbs_cp.csproj +++ b/anbs_cp/anbs_cp.csproj @@ -1,7 +1,7 @@ - net6.0-windows + net6.0 1.20211111.0 Alexander Babaev ANB Software Components Pack