using System; using System.Collections.Generic; using System.Globalization; using Avalonia.Data.Converters; namespace DispenserUI.ViewModels.Converter; public class StrikeDirectionConverter : IValueConverter { private static readonly List Directions = ["未选择", "行方向", "列方向"]; public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { return Directions[(int)value!]; } public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) { for (var i = 0; i < Directions.Count; i++) if (ReferenceEquals(Directions[i], value)) return i; return 0; } }