XSDVisualizer/XSDVisualiser.Desktop/Converters/CardinalityToLabelConverter.cs
Frederik Jacobsen 813e1ce6e9 Initial better gui implemented.
UX and information still missing alot
2025-10-18 18:09:17 +02:00

25 lines
753 B
C#

using System;
using System.Globalization;
using Avalonia.Data.Converters;
using XSDVisualiser.Models;
namespace XSDVisualiser.Desktop.Converters
{
public class CardinalityToLabelConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is Occurs occ)
{
var min = occ.Min;
var max = occ.MaxIsUnbounded ? "*" : occ.Max.ToString(culture);
return $"[{min}..{max}]";
}
return null;
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
}