Added WinUI project.
This commit is contained in:
26
Harmonia.WinUI/Converters/ArtistsToStringConverter.cs
Normal file
26
Harmonia.WinUI/Converters/ArtistsToStringConverter.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Harmonia.WinUI.Converters;
|
||||
|
||||
public partial class ArtistsToStringConverter : IValueConverter
|
||||
{
|
||||
public ArtistsToStringConverter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is not string[] artists)
|
||||
return string.Empty;
|
||||
|
||||
return string.Join(" / ", artists);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
27
Harmonia.WinUI/Converters/NullVisibilityConverter.cs
Normal file
27
Harmonia.WinUI/Converters/NullVisibilityConverter.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Harmonia.WinUI.Converters;
|
||||
|
||||
public sealed partial class NullVisibilityConverter : IValueConverter
|
||||
{
|
||||
public NullVisibilityConverter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is not IList list)
|
||||
return Visibility.Collapsed;
|
||||
|
||||
return list.Count == 0 ? Visibility.Collapsed : Visibility.Visible;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
26
Harmonia.WinUI/Converters/RepeatStateConverter.cs
Normal file
26
Harmonia.WinUI/Converters/RepeatStateConverter.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Harmonia.Core.Player;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using System;
|
||||
|
||||
namespace Harmonia.WinUI.Converters;
|
||||
|
||||
public sealed partial class RepeatStateConverter : IValueConverter
|
||||
{
|
||||
public RepeatStateConverter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is not RepeatState repeatState)
|
||||
return null;
|
||||
|
||||
return repeatState.ToString();
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
30
Harmonia.WinUI/Converters/SecondsToStringConverter.cs
Normal file
30
Harmonia.WinUI/Converters/SecondsToStringConverter.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using System;
|
||||
|
||||
namespace Harmonia.WinUI.Converters;
|
||||
|
||||
public sealed partial class SecondsToStringConverter : IValueConverter
|
||||
{
|
||||
public SecondsToStringConverter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is not double doubleValue)
|
||||
return null;
|
||||
|
||||
TimeSpan timeSpan = TimeSpan.FromSeconds(doubleValue);
|
||||
|
||||
if (timeSpan.Hours >= 1)
|
||||
return timeSpan.ToString(@"%h\:mm\:ss");
|
||||
|
||||
return timeSpan.ToString(@"%m\:ss");
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
return TimeSpan.Parse((string)value);
|
||||
}
|
||||
}
|
||||
26
Harmonia.WinUI/Converters/SongTitleConverter.cs
Normal file
26
Harmonia.WinUI/Converters/SongTitleConverter.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Harmonia.Core.Models;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using System;
|
||||
|
||||
namespace Harmonia.WinUI.Converters;
|
||||
|
||||
public sealed partial class SongTitleConverter : IValueConverter
|
||||
{
|
||||
public SongTitleConverter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
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, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
26
Harmonia.WinUI/Converters/VolumeStateToIconConverter.cs
Normal file
26
Harmonia.WinUI/Converters/VolumeStateToIconConverter.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Harmonia.WinUI.Models;
|
||||
|
||||
namespace Harmonia.WinUI.Converters;
|
||||
|
||||
public sealed partial class VolumeStateConverter : IValueConverter
|
||||
{
|
||||
public VolumeStateConverter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is not VolumeState volumeState)
|
||||
return null;
|
||||
|
||||
return volumeState.ToString();
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user