using System; using System.Globalization; using System.Windows.Data; namespace UtopiaCanteenSystem.Converters; /// Converts MealSession int (0=Breakfast, 1=Lunch, 2=Tea, 3=Dinner) to display name. public class MealSessionToNameConverter : IValueConverter { private static readonly string[] Names = { "Breakfast", "Lunch", "Tea", "Dinner" }; public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is int i && i >= 0 && i < Names.Length) return Names[i]; return value?.ToString() ?? ""; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }