void WriteColorAttributes(XshdColor color) { if (color.Foreground != null) { writer.WriteAttributeString("foreground", color.Foreground.ToString()); } if (color.Background != null) { writer.WriteAttributeString("background", color.Background.ToString()); } if (color.FontWeight != null) { writer.WriteAttributeString("fontWeight", FontWeightConverter.ConvertToString(color.FontWeight.Value).ToLowerInvariant()); } if (color.FontStyle != null) { writer.WriteAttributeString("fontStyle", FontStyleConverter.ConvertToString(color.FontStyle.Value).ToLowerInvariant()); } }
private void InitText() { var fwc = new FontWeightConverter(); var fsc = new FontStyleConverter(); FontSelector.ItemsSource = Fonts.SystemFontFamilies; var fontIndex = -1; // Font name... if (string.IsNullOrEmpty(Properties.Settings.Default.Plot_Font_Name)) { var g = new Graph(null, null); _fontName = g.FontFamily.Source; Properties.Settings.Default.Plot_Font_Name = _fontName; } else { _fontName = Properties.Settings.Default.Plot_Font_Name; } // Font size... if (string.IsNullOrEmpty(Properties.Settings.Default.Plot_Font_Size)) { PlotFontSize = 12; } else { try { PlotFontSize = double.Parse(Properties.Settings.Default.Plot_Font_Size); } catch { } } // Font weight... if (string.IsNullOrEmpty(Properties.Settings.Default.Plot_Font_Weight)) { PlotFontWeight = (FontWeight)fwc.ConvertFromString("Normal"); } else { PlotFontWeight = (FontWeight)fwc.ConvertFromString(Properties.Settings.Default.Plot_Font_Weight); } // Font style... if (string.IsNullOrEmpty(Properties.Settings.Default.Plot_Font_Style)) { PlotFontStyle = (FontStyle)fsc.ConvertFromString("Normal"); } else { PlotFontStyle = (FontStyle)fsc.ConvertFromString(Properties.Settings.Default.Plot_Font_Style); } foreach (System.Windows.Media.FontFamily ff in FontSelector.Items) { fontIndex++; if (System.String.Compare(ff.Source, _fontName, System.StringComparison.Ordinal) == 0) { _fontFamily = ff; break; } } // Font FG color if (Properties.Settings.Default.Plot_FG_Color != null) { _fgBrush = new SolidColorBrush( System.Windows.Media.Color.FromRgb( Properties.Settings.Default.Plot_FG_Color.R, Properties.Settings.Default.Plot_FG_Color.G, Properties.Settings.Default.Plot_FG_Color.B)); } // Init the controls FontSelector.SelectedIndex = fontIndex; ComboBoxStyle.SelectedValue = fsc.ConvertToString(PlotFontStyle); ComboBoxWeight.SelectedValue = fwc.ConvertToString(PlotFontWeight); SliderFontSize.DataContext = this; }
/// <summary> /// Serializes the font style. /// </summary> /// <param name="fontStyle">The font style.</param> /// <returns>The serialized font style.</returns> public static string SerializeFontStyle(FontStyle fontStyle) { var converter = new FontStyleConverter(); return(converter.ConvertToString(fontStyle)); }