22 lines
750 B
C#
22 lines
750 B
C#
using System.Globalization;
|
|
using System.Windows.Data;
|
|
using System.Windows.Media;
|
|
using Livia.Properties;
|
|
using Livia.Views.Utility;
|
|
|
|
namespace Livia.Views.Converters;
|
|
|
|
[ValueConversion(typeof(string), typeof(FontFamily))]
|
|
public class StringToFontFamilyConverter : IValueConverter
|
|
{
|
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
ViewUtility.DefaultFontFamilyDictionary.TryGetValue(Settings.Default.Language, out FontFamily? defaultFontFamily);
|
|
return defaultFontFamily ?? Fonts.SystemFontFamilies.First();
|
|
}
|
|
|
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
} |