Files
2026-08-27 11:22:54 -06:00

54 lines
1.1 KiB
C#

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<InventoryDot> enumerable = values[0] as IEnumerable<InventoryDot>;
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<InventoryDot>();
}
if (!flag2)
{
return enumerable.Take(4).ToList();
}
return enumerable;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}