Files
WCS/Plugins/Wcs/Plugin.Cowain.Wcs/Converters/LayoutRowDefinitionsConverter.cs
2026-03-02 09:13:29 +08:00

34 lines
898 B
C#

using Avalonia.Controls;
using Avalonia.Data.Converters;
using Plugin.Cowain.Wcs.ViewModels;
using System.Collections;
using System.Globalization;
namespace Plugin.Cowain.Wcs.Converters;
public class LayoutRowDefinitionsConverter : IValueConverter
{
public LayoutRowDefinitionsConverter()
{
}
public object? Convert(object? value, Type targetType, object? prefix, CultureInfo culture)
{
if (value is not IEnumerable elements)
return 1;
int maxRow = elements.OfType<LayoutViewModel>()
.Select(e => e.LayOutY)
.DefaultIfEmpty(0)
.Max();
return maxRow + 1;
}
public object? ConvertBack(object? value, Type targetType, object? prefix, CultureInfo culture)
{
throw new NotSupportedException("ConvertBack is not supported.");
}
}