mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 05:05:00 +00:00
enhance: use custom JsonConverter instead of converting string to FontFamily in each control
This commit is contained in:
parent
0fadab2ca2
commit
56f5f3b4a7
10 changed files with 49 additions and 49 deletions
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue