27 lines
669 B
C#
27 lines
669 B
C#
using Avalonia.Data.Converters;
|
|
using Harmonia.Core.Models;
|
|
using System;
|
|
using System.Globalization;
|
|
|
|
namespace Harmonia.UI.Converters;
|
|
|
|
public sealed class SongTitleConverter : IValueConverter
|
|
{
|
|
public SongTitleConverter()
|
|
{
|
|
|
|
}
|
|
|
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
if (value is not Song song)
|
|
return null;
|
|
|
|
return string.IsNullOrWhiteSpace(song.Title) ? song.ShortFileName : song.Title;
|
|
}
|
|
|
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
} |