Added playlist view and initial playlist view logic.
This commit is contained in:
28
Harmonia.UI/Converters/RepeatStateToIconConverter.cs
Normal file
28
Harmonia.UI/Converters/RepeatStateToIconConverter.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
37
Harmonia.UI/Converters/VolumeStateToIconConverter.cs
Normal file
37
Harmonia.UI/Converters/VolumeStateToIconConverter.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
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();
|
||||
}
|
||||
Reference in New Issue
Block a user