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

28 lines
927 B
C#

using System;
using System.Globalization;
using Avalonia;
using Avalonia.Data.Converters;
using XSDVisualiser.Models;
namespace XSDVisualiser.Desktop.Converters
{
public class OptionalToThicknessConverter : IValueConverter
{
private static readonly Thickness Required = new Thickness(2);
private static readonly Thickness Optional = new Thickness(2);
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is Occurs occ)
{
// We could vary thickness; for now same thickness regardless, reserved for future styling.
return occ.Min == 0 ? Optional : Required;
}
return Required;
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}
}