Files
harmonia/Harmonia.UI/Converters/RepeatStateToIconConverter.cs

28 lines
779 B
C#

using Avalonia;
using Avalonia.Controls;
using Avalonia.Data.Converters;
using Harmonia.Core.Player;
using System;
using System.Globalization;
namespace Harmonia.UI.Converters;
public class RepeatStateToIconConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is not RepeatState repeatMode)
return null;
string resourceName = repeatMode == RepeatState.RepeatOne
? "RepeatOneIcon"
: "RepeatIcon";
return Application.Current?.FindResource(resourceName);
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}