using System.Globalization; using System.Windows.Data; namespace ytLive.Helpers; public class DroppedPercentConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { var dropped = values.Length > 0 && values[0] is int d ? d : 0; var fps = values.Length > 1 && values[1] is double f ? f : 0; var duration = values.Length > 2 && values[2] is TimeSpan t ? t : TimeSpan.Zero; var total = fps * duration.TotalSeconds; var percent = total > 0 ? dropped / total * 100 : 0; return $"{dropped} ({percent.ToString("0.0", CultureInfo.InvariantCulture)}%)"; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotSupportedException(); }