37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Data.Converters;
|
|
using Avalonia;
|
|
using Harmonia.UI.Models;
|
|
using System;
|
|
using System.Globalization;
|
|
using Harmonia.Core.Playlists;
|
|
|
|
namespace Harmonia.UI.Converters;
|
|
|
|
public class VolumeStateToIconConverter : IValueConverter
|
|
{
|
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
if (value is not VolumeState volumeState)
|
|
return AvaloniaProperty.UnsetValue;
|
|
|
|
return Application.Current?.FindResource($"Volume{volumeState}Icon") ?? AvaloniaProperty.UnsetValue;
|
|
}
|
|
|
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
|
}
|
|
|
|
public class PlaylistSongEqualityConverter : IValueConverter
|
|
{
|
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
if (value is PlaylistSong playingSong && parameter is PlaylistSong currentSong)
|
|
{
|
|
return playingSong == currentSong;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) => throw new NotImplementedException();
|
|
} |