using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Windows.Data; using Crysome.Server.Model; namespace Crysome.Server.Converters; public class InventoryDotsCollapseConverter : IMultiValueConverter { private const int CollapsedCount = 4; public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { if (values == null || values.Length < 2) { if (values == null) { return null; } return values[0]; } IEnumerable enumerable = values[0] as IEnumerable; object obj = values[1]; bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } bool flag2 = (byte)((uint)num & (flag ? 1u : 0u)) != 0; if (enumerable == null) { return new List(); } if (!flag2) { return enumerable.Take(4).ToList(); } return enumerable; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotSupportedException(); } }