enhance: use custom JsonConverter instead of converting string to FontFamily in each control

This commit is contained in:
leo 2024-03-21 23:19:09 +08:00
parent 0fadab2ca2
commit 56f5f3b4a7
10 changed files with 49 additions and 49 deletions

View file

@ -70,29 +70,5 @@ namespace SourceGit.Converters
public static FuncValueConverter<string, string> ToShortSHA =
new FuncValueConverter<string, string>(v => v.Length > 10 ? v.Substring(0, 10) : v);
public class ToFontFamilyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var name = value as string;
if (string.IsNullOrEmpty(name))
{
return FontManager.Current.DefaultFontFamily;
}
else
{
return new FontFamily(name);
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
var fontFamily = value as FontFamily;
return fontFamily == null ? string.Empty : fontFamily.ToString();
}
}
public static ToFontFamilyConverter ToFontFamily = new ToFontFamilyConverter();
}
}