using System; using System.Globalization; using Avalonia.Data; using Avalonia.Data.Converters; namespace Ocarina2.Converter; public class PositionConverter:IValueConverter { public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { if (value is not TimeSpan t) return new BindingNotification(new InvalidCastException(), BindingErrorType.Error); return $"{(t.Minutes<10?"0"+t.Minutes:t.Minutes)}:{(t.Seconds<10?"0"+t.Seconds:t.Seconds)}"; } public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) { throw new NotImplementedException(); } }