mirror of
https://github.com/jayfunc/BetterLyrics.git
synced 2026-01-12 10:54:55 +08:00
- Add album text in lyrics render - Improve song info update and draw algo - Upgrade to .NET 10
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using Microsoft.UI.Xaml.Data;
|
|
using System;
|
|
|
|
namespace BetterLyrics.WinUI3.Converter
|
|
{
|
|
public partial class SecondsToFormattedTimeConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, string language)
|
|
{
|
|
TimeSpan timeSpan = TimeSpan.Zero;
|
|
if (value is double seconds)
|
|
{
|
|
timeSpan = TimeSpan.FromSeconds(seconds);
|
|
}
|
|
else if (value is int secondsInt)
|
|
{
|
|
timeSpan = TimeSpan.FromSeconds(secondsInt);
|
|
}
|
|
if (timeSpan.Days > 0)
|
|
{
|
|
return timeSpan.ToString(@"dd\.hh\:mm\:ss");
|
|
}
|
|
else if (timeSpan.Hours > 0)
|
|
{
|
|
return timeSpan.ToString(@"hh\:mm\:ss");
|
|
}
|
|
else
|
|
{
|
|
return timeSpan.ToString(@"mm\:ss");
|
|
}
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|