/// <summary> /// Helper function that converts the values stored in the settings into the font values /// and then sets the tasklist font values. /// </summary> public void SetFont() { var family = new FontFamily(User.Default.TaskListFontFamily); double size = User.Default.TaskListFontSize; var styleConverter = new FontStyleConverter(); FontStyle style = (FontStyle)styleConverter.ConvertFromString(User.Default.TaskListFontStyle); var stretchConverter = new FontStretchConverter(); FontStretch stretch = (FontStretch)stretchConverter.ConvertFromString(User.Default.TaskListFontStretch); var weightConverter = new FontWeightConverter(); FontWeight weight = (FontWeight)weightConverter.ConvertFromString(User.Default.TaskListFontWeight); Color color = (Color)ColorConverter.ConvertFromString(User.Default.TaskListFontBrushColor); lbTasks.FontFamily = family; lbTasks.FontSize = size; lbTasks.FontStyle = style; lbTasks.FontStretch = stretch; lbTasks.FontWeight = weight; lbTasks.Foreground = new SolidColorBrush(color); }
internal static Typeface CreateTypeFace(string fontFamily, string fontStyle, string fontWeight, string fontStretch, string fallbackFontFamily) { if ((fontFamily == null) || (fontStyle == null) || (fontWeight == null) || (fontStretch == null)) { return(null); } FontFamily family = new FontFamily(fontFamily); FontStyle style = (FontStyle)styleConverter.ConvertFromString(fontStyle); FontWeight weight = (FontWeight)weightConverter.ConvertFromString(fontWeight); FontStretch stretch = (FontStretch)stretchConverter.ConvertFromString(fontStretch); if (fallbackFontFamily == null) { return(new Typeface(family, style, weight, stretch)); } else { return(new Typeface(family, style, weight, stretch, new FontFamily(fallbackFontFamily))); } }