24 lines
762 B
C#
24 lines
762 B
C#
using System;
|
|
using System.Globalization;
|
|
using System.Windows.Data;
|
|
|
|
namespace UtopiaCanteenSystem.Converters;
|
|
|
|
/// <summary>Converts MealSession int (0=Breakfast, 1=Lunch, 2=Tea, 3=Dinner) to display name.</summary>
|
|
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();
|
|
}
|
|
}
|