diff --git a/src/KKManager.Core/Data/Cards/Card.cs b/src/KKManager.Core/Data/Cards/Card.cs index bacefb8..b788510 100644 --- a/src/KKManager.Core/Data/Cards/Card.cs +++ b/src/KKManager.Core/Data/Cards/Card.cs @@ -27,9 +27,12 @@ public abstract class Card : IFileInfoBase [DisplayName("Extended Data Size")] public FileSize ExtendedSize { get; } - [ReadOnly(true)] public string[] MissingZipmods { get; set; } - [ReadOnly(true)] public string[] MissingPlugins { get; set; } - [ReadOnly(true)] public string[] MissingPluginsMaybe { get; set; } + [ReadOnly(true), TypeConverter(typeof(ReadOnlyStringCollectionConverterWithPreview))] + public string[] MissingZipmods { get; set; } + [ReadOnly(true), TypeConverter(typeof(ReadOnlyStringCollectionConverterWithPreview))] + public string[] MissingPlugins { get; set; } + [ReadOnly(true), TypeConverter(typeof(ReadOnlyStringCollectionConverterWithPreview))] + public string[] MissingPluginsMaybe { get; set; } public virtual Image GetCardImage() { diff --git a/src/KKManager.Core/Util/TypeConverters/DictionaryTypeConverter.cs b/src/KKManager.Core/Util/TypeConverters/DictionaryTypeConverter.cs index 81894e2..8dd6a3a 100644 --- a/src/KKManager.Core/Util/TypeConverters/DictionaryTypeConverter.cs +++ b/src/KKManager.Core/Util/TypeConverters/DictionaryTypeConverter.cs @@ -1,11 +1,24 @@ using System; +using System.Collections; using System.Collections.Generic; using System.ComponentModel; +using System.Globalization; namespace KKManager.Util { public class DictionaryTypeConverter : CollectionConverter { + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (destinationType == null) + throw new ArgumentNullException(nameof(destinationType)); + + if (value is ICollection arr) + return $"{arr.Count} item{(arr.Count == 1 ? "" : "s")}"; + + return base.ConvertTo(context, culture, value, destinationType); + } + public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { var d = value as Dictionary; diff --git a/src/KKManager.Core/Util/TypeConverters/ListTypeConverter.cs b/src/KKManager.Core/Util/TypeConverters/ListTypeConverter.cs index c17fce9..9b1af52 100644 --- a/src/KKManager.Core/Util/TypeConverters/ListTypeConverter.cs +++ b/src/KKManager.Core/Util/TypeConverters/ListTypeConverter.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Collections.Generic; using System.ComponentModel; using System.Globalization; using System.Linq; @@ -9,6 +10,17 @@ namespace KKManager.Util { public class ListTypeConverter : CollectionConverter { + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (destinationType == null) + throw new ArgumentNullException(nameof(destinationType)); + + if (value is ICollection arr) + return $"{arr.Count} item{(arr.Count == 1 ? "" : "s")}"; + + return base.ConvertTo(context, culture, value, destinationType); + } + public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; diff --git a/src/KKManager.Core/Util/TypeConverters/ReadOnlyStringCollectionConverterWithPreview.cs b/src/KKManager.Core/Util/TypeConverters/ReadOnlyStringCollectionConverterWithPreview.cs index b634386..2463af2 100644 --- a/src/KKManager.Core/Util/TypeConverters/ReadOnlyStringCollectionConverterWithPreview.cs +++ b/src/KKManager.Core/Util/TypeConverters/ReadOnlyStringCollectionConverterWithPreview.cs @@ -18,7 +18,7 @@ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cul if (arr != null || arr2 != null) { var count = arr?.Count ?? arr2.Count; - var result = $"{count} items"; + var result = $"{count} item{(count == 1 ? "" : "s")}"; if (count > 0) { result += $" - {string.Join(", ", ((IEnumerable)arr ?? arr2).Take(3))}";