61 lines
1.7 KiB
C#
61 lines
1.7 KiB
C#
using System;
|
|
using Microsoft.UI.Xaml;
|
|
using Microsoft.UI.Xaml.Data;
|
|
using Microsoft.UI.Xaml.Markup;
|
|
using Microsoft.UI.Xaml.Media;
|
|
using Harmonia.WinUI.Models;
|
|
|
|
namespace Harmonia.WinUI.Converters;
|
|
|
|
public sealed partial class VolumeStateToIconConverter : IValueConverter
|
|
{
|
|
public object? Convert(object value, Type targetType, object parameter, string language)
|
|
{
|
|
if (value is not VolumeState volumeState)
|
|
return null;
|
|
|
|
if (Application.Current.Resources[$"Volume{volumeState}Icon2"] is not string pathData)
|
|
return null;
|
|
|
|
return XamlBindingHelper.ConvertValue(typeof(Geometry), pathData.Trim());
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
|
|
public sealed partial class VolumeStateToFillConverter : IValueConverter
|
|
{
|
|
public object? Convert(object value, Type targetType, object parameter, string language)
|
|
{
|
|
return value is VolumeState.Muted ? parameter : null;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
} |