/// <summary> /// /// </summary> /// <param name="newRender"></param> /// <param name="pixelsPerDip"></param> /// <param name="textDecorations"></param> /// <param name="foregroundBrush"></param> /// <param name="style"></param> /// <param name="weight"></param> /// <param name="backgroundBrush"></param> public GenericTextRunProperties(FontRendering?newRender, double pixelsPerDip, TextDecorationCollection?textDecorations = null, Brush?foregroundBrush = null, FontStyle?style = null, FontWeight?weight = null, Brush backgroundBrush = null) { Typeface?typeface = newRender?.Typeface; if (style.HasValue || weight.HasValue) { typeface = new Typeface(new FontFamily(newRender?.Typeface.FontFamily.FamilyNames[XmlLanguage.GetLanguage("en-US")]), style ?? newRender?.Typeface.Style ?? default, weight ?? newRender?.Typeface.Weight ?? default, newRender?.Typeface.Stretch ?? default); } _typeface = typeface; _emSize = newRender?.FontSize ?? 12.0; _emHintingSize = _emSize; _textDecorations = textDecorations ?? newRender?.TextDecorations ?? new TextDecorationCollection(); _foregroundBrush = foregroundBrush ?? Brushes.Black; _backgroundBrush = backgroundBrush; // if (backgroundBrush != null && backgroundBrush.Opacity > 0.5) // { // _backgroundBrush = new SolidColorBrush(backgroundBrush.Color) {Opacity = 0.40}; // } _baselineAlignment = BaselineAlignment.Baseline; _culture = CultureInfo.CurrentUICulture; PixelsPerDip = pixelsPerDip; }
public FontNode(IList <TextNode> children, string family = null, Scalar?height = null, FontWeight?weight = null, FontStyle?style = null) : base(children) { Family = family; Height = height; Weight = weight; Style = style; }
public void AddMessage(string text, Brush msgBrush = null, FontWeight?weight = null, double size = 12) { if (String.IsNullOrWhiteSpace(text)) { return; } if (msgBrush == null) { msgBrush = Brushes.White; } if (weight == null) { weight = FontWeights.Normal; } this.Dispatcher.Invoke(() => { Run r = new Run { Text = text + "\n", Foreground = msgBrush, FontWeight = weight.GetValueOrDefault(), FontSize = size }; MessageContainer.Inlines.Add(r); ContainerScroller.ScrollToEnd(); }); }
public FontAndColorSetting( FontFamily fontFamily, double fontSize, Brush foreground = null, Brush background = null, FontWeight?fontWeight = null, FontStyle?fontStyle = null, FontStretch?fontStretch = null) { if (fontFamily == null) { throw new ArgumentNullException("fontFamily"); } if (fontSize < 0.0) { throw new ArgumentOutOfRangeException("fontSize"); } this.fontFamily = fontFamily; this.fontSize = fontSize; this.foreground = foreground ?? Brushes.Black; this.background = background ?? Brushes.White; this.fontWeight = fontWeight ?? FontWeights.Normal; this.fontStyle = fontStyle ?? FontStyles.Normal; this.fontStretch = fontStretch ?? FontStretches.Normal; this.hasFontFamily = true; this.hasFontSize = true; this.hasForeground = true; this.hasBackground = true; this.hasFontWeight = true; this.hasFontStyle = true; this.hasFontStretch = true; }
public EtAlParameters( string tag, Parameters original, TermName term, FontStyle?fontStyle = null, FontVariant?fontVariant = null, FontWeight?fontWeight = null, TextDecoration?textDecoration = null, VerticalAlign?verticalAlign = null, bool?stripPeriods = null, string namesDelimiter = null, And?and = null, string nameDelimiter = null, DelimiterBehavior?delimiterPrecedesEtAl = null, DelimiterBehavior?delimiterPrecedesLast = null, int?etAlMin = null, int?etAlUseFirst = null, int?etAlSubsequentMin = null, int?etAlSubsequentUseFirst = null, bool?etAlUseLast = null, NameFormat?nameFormat = null, bool?initialize = null, string initializeWith = null, NameSortOptions?nameAsSortOrder = null, string sortSeparator = null ) : base(original, fontStyle, fontVariant, fontWeight, textDecoration, verticalAlign, stripPeriods, namesDelimiter, and, nameDelimiter, delimiterPrecedesEtAl, delimiterPrecedesLast, etAlMin, etAlUseFirst, etAlSubsequentMin, etAlSubsequentUseFirst, etAlUseLast, nameFormat, initialize, initializeWith, nameAsSortOrder, sortSeparator) { // init this.Tag = tag; this.Term = term; }
/// <summary> /// Commit the current values. /// </summary> public void Commit() { _originalForeground = Foreground; _originalBackground = Background; _originalWeight = Weight; _originalStyle = Style; }
private void SetFontWeightAndStyle(FontWeight?fontWeight, FontStyle?fontStyle) { if (fontStyle.HasValue && fontWeight.HasValue) { if (fontStyle.Value == FontStyles.Italic) { if (fontWeight.Value == FontWeights.Bold) { this.fontStyleListBox.SelectedValue = DialogFontStyle.BoldItalic; } else { this.fontStyleListBox.SelectedValue = DialogFontStyle.Italic; } } else { if (fontWeight.Value == FontWeights.Bold) { this.fontStyleListBox.SelectedValue = DialogFontStyle.Bold; } else { this.fontStyleListBox.SelectedValue = DialogFontStyle.Regular; } } } else { this.fontStyleListBox.SelectedItem = null; } }
public void setProporties(FontFamily fontFamily, double?fontSize, Color?color, FontStyle?fontStyle, FontWeight?fontWight) { if (color.HasValue) { this.color = color.Value; } this.fontFamily = fontFamily; if (fontSize.HasValue) { this.fontSize = fontSize.Value; } if (fontStyle.HasValue) { this.fontStyle = fontStyle.Value; } if (fontWight.HasValue) { fontWeight = fontWight.Value; } Reload(); }
/// <summary> /// Overwrites the properties in this HighlightingColor with those from the given color; /// but maintains the current values where the properties of the given color return <c>null</c>. /// </summary> public void MergeWith(HighlightingColor color) { FreezableHelper.ThrowIfFrozen(this); if (color.fontWeight != null) { this.fontWeight = color.fontWeight; } if (color.fontStyle != null) { this.fontStyle = color.fontStyle; } if (color.foreground != null) { this.foreground = color.foreground; } if (color.background != null) { this.background = color.background; } if (color.underline != null) { this.underline = color.underline; } if (color.fontFamily != null) { this.fontFamily = color.fontFamily; } if (color.fontSize != null) { this.fontSize = color.fontSize; } }
/// <summary> /// Constructor /// </summary> /// <param name="foreground">Foreground color or null</param> /// <param name="background">Background color or null</param> /// <param name="fontWeight">Font weight or null</param> /// <param name="fontStyle">Font style or null</param> public ThemeTextColor(Brush foreground, Brush background = null, FontWeight?fontWeight = null, FontStyle?fontStyle = null) { Foreground = foreground; Background = background; FontWeight = fontWeight; FontStyle = fontStyle; }
/// <summary> /// Initializes a new instance of the <see cref="FontProperties" /> class. /// </summary> /// <param name="fontFace">fontFace.</param> /// <param name="fontSize">Font size property..</param> /// <param name="fontWeight">fontWeight.</param> /// <param name="fontColor">Hexadecimal color value..</param> public FontProperties(FontFace?fontFace = null, string fontSize = default(string), FontWeight?fontWeight = null, string fontColor = default(string)) { this.FontFace = fontFace; this.FontSize = fontSize; this.FontWeight = fontWeight; this.FontColor = fontColor; }
private string ResolveCommonCss(string elementName, double?fontsize, FontWeight?fontweight, Color?foregroundColor, string margin) { string css = ""; var resFontSize = ResolveFontSize(fontsize); var resFontWeight = ResolveFontWeight(fontweight); var resForeground = ResolveForeground(foregroundColor); var resMargin = ResolveMargin(margin); if (resFontSize != "") { css += resFontSize + "\n"; } if (resFontWeight != "") { css += resFontWeight + "\n"; } if (resForeground != "") { css += resForeground + "\n"; } if (resMargin != "") { css += resMargin + "\n"; } if (css != "") { css = $"{elementName}{{\n" + $"{css}" + $"}}\n"; } return(css); }
public FontAndColorSetting( FontAndColorSetting baseSetting, FontFamily fontFamily = null, double?fontSize = null, Brush foreground = null, Brush background = null, FontWeight?fontWeight = null, FontStyle?fontStyle = null, FontStretch?fontStretch = null) { if (baseSetting == null) { throw new ArgumentNullException("baseSetting"); } this.baseSetting = baseSetting; if (fontFamily != null) { this.hasFontFamily = true; this.fontFamily = fontFamily; } if (fontSize != null) { this.hasFontSize = true; this.fontSize = fontSize.Value; } if (foreground != null) { this.hasForeground = true; this.foreground = foreground; } if (background != null) { this.hasBackground = true; this.background = background; } if (fontWeight != null) { this.hasFontWeight = true; this.fontWeight = fontWeight.Value; } if (fontStyle != null) { this.hasFontStyle = true; this.fontStyle = fontStyle.Value; } if (fontStretch != null) { this.hasFontStretch = true; this.fontStretch = fontStretch.Value; } }
public static HighlightingColor ToHighlightingColor(this Color color, FontWeight?fontWeight = null) { return(new HighlightingColor { Foreground = new SimpleHighlightingBrush(color), FontWeight = fontWeight }); }
private string ResolveFontWeight(FontWeight?fontweight) { if (fontweight.HasValue) { return($"font-weight: {fontweight.Value.ToString()};"); } return(""); }
public void UpdateInspectorStyles() { __Foreground = null; __FontSize = null; __IsBold = false; __FontWeight = null; __IsItalic = false; __FontStyle = null; __IsStrikethrough = false; __TextDecorations = new TextDecorationCollection(); __FontFamily = null; foreach (LevelStyleProperty style in __StyleList) { switch (style.PropertyType) { case StylePropertyType.FontColor: __Foreground = style.Value as SolidColorBrush; break; case StylePropertyType.FontSize: __FontSize = (double?)style.Value; break; case StylePropertyType.IsBold: __IsBold = (bool)style.Value; __FontWeight = __IsBold ? FontWeights.Bold : FontWeights.Normal; break; case StylePropertyType.IsItalic: __IsItalic = (bool)style.Value; __FontStyle = __IsItalic ? FontStyles.Italic : FontStyles.Normal; break; case StylePropertyType.IsStrike: __IsStrikethrough = (bool)style.Value; if (__IsStrikethrough) { __TextDecorations.Add(TextDecorations.Strikethrough); } break; case StylePropertyType.IsUnderlined: __IsUnderlined = (bool)style.Value; if (__IsUnderlined) { __TextDecorations.Add(TextDecorations.Underline); } break; case StylePropertyType.Typeface: __FontFamily = style.Value as FontFamily; break; } } DoInspectorChanged(); DoStyleChanged(); }
public FontDefinition(Brush?fontBrush, FontFamily?fontFamily, double?fontSize, FontStretch?fontStretch, FontStyle?fontStyle, FontWeight?fontWeight) { FontBrush = fontBrush; FontFamily = fontFamily; FontSize = fontSize; FontStretch = fontStretch; FontStyle = fontStyle; FontWeight = fontWeight; }
/// <summary> /// Sets the value of the <see cref="T:ReactNative.Views.TextInput.PlaceholderAdorner" />.FontWeight attached property to a specified element. /// </summary> /// <param name="adornedElement"> /// The element to which the attached property is written. /// </param> /// <param name="fontWeight"> /// The placeholder text Font weight value. /// </param> /// <exception cref="T:ArgumentNullException"> /// Raised when adornedElement is null. /// </exception> /// <exception cref="T:InvalidOperationException"> /// Raised when adornedElement is not a <see cref="T:System.Windows.Controls.TextBox"/>, /// <see cref="T:System.Windows.Controls.RichTextBox"/> or <see cref="T:System.Windows.Controls.PasswordBox"/>. /// </exception> public static void SetFontWeight(Control adornedElement, FontWeight?fontWeight) { if (adornedElement == null) { throw new ArgumentNullException(nameof(adornedElement)); } adornedElement.SetValue(FontWeightProperty, fontWeight); }
public Parameters( Parameters original, FontStyle?fontStyle = null, FontVariant?fontVariant = null, FontWeight?fontWeight = null, TextDecoration?textDecoration = null, VerticalAlign?verticalAlign = null, bool?stripPeriods = null, string namesDelimiter = null, And?and = null, string nameDelimiter = null, DelimiterBehavior?delimiterPrecedesEtAl = null, DelimiterBehavior?delimiterPrecedesLast = null, int?etAlMin = null, int?etAlUseFirst = null, int?etAlSubsequentMin = null, int?etAlSubsequentUseFirst = null, bool?etAlUseLast = null, NameFormat?nameFormat = null, bool?initialize = null, string initializeWith = null, NameSortOptions?nameAsSortOrder = null, string sortSeparator = null ) { // formatting this.FontStyle = fontStyle ?? original.FontStyle; this.FontVariant = fontVariant ?? original.FontVariant; this.FontWeight = fontWeight ?? original.FontWeight; this.TextDecoration = textDecoration ?? original.TextDecoration; this.VerticalAlign = verticalAlign ?? original.VerticalAlign; // strip periods this.StripPeriods = stripPeriods ?? original.StripPeriods; // names this.NamesDelimiter = namesDelimiter ?? original.NamesDelimiter; // name this.And = and ?? original.And; this.NameDelimiter = nameDelimiter ?? original.NameDelimiter; this.DelimiterPrecedesEtAl = delimiterPrecedesEtAl ?? original.DelimiterPrecedesEtAl; this.DelimiterPrecedesLast = delimiterPrecedesLast ?? original.DelimiterPrecedesLast; this.EtAlMin = etAlMin ?? original.EtAlMin; this.EtAlUseFirst = etAlUseFirst ?? original.EtAlUseFirst; this.EtAlSubsequentMin = etAlSubsequentMin ?? original.EtAlSubsequentMin; this.EtAlSubsequentUseFirst = etAlSubsequentUseFirst ?? original.EtAlSubsequentUseFirst; this.EtAlUseLast = etAlUseLast ?? original.EtAlUseLast; this.NameFormat = nameFormat ?? original.NameFormat; this.Initialize = initialize ?? original.Initialize; this.InitializeWith = initializeWith ?? (original == null ? null : original.InitializeWith); this.NameAsSortOrder = nameAsSortOrder ?? original.NameAsSortOrder; this.SortSeparator = sortSeparator ?? original.SortSeparator; }
/// <summary> /// Creates the new cell in the specified worksheet. /// </summary> /// <param name="sheet">The worksheet in which to create the cell.</param> /// <param name="row">Row number.</param> /// <param name="col">Column number.</param> /// <param name="fontWeight">The font weight.</param> /// <param name="border">The border.</param> /// <param name="backgroundColor">Color of the background.</param> /// <param name="horizontalAlignment">Cell's content horizontal alignment.</param> /// <param name="italic">if set to <c>true</c> font will be italic.</param> /// <param name="underlineType">Type of the underline style.</param> /// <param name="struckOut">if set to <c>true</c> font will be struck out.</param> /// <param name="color">The color of font.</param> /// <param name="fontName">Name of the font.</param> /// <param name="fontSize">Size of the font.</param> /// <returns>Created cell.</returns> private static Cell CreateNewCell(Worksheet sheet, int row, int col, FontWeight?fontWeight, ushort border, Color backgroundColor, HorizontalAlignments horizontalAlignment, bool italic, UnderlineTypes?underlineType, bool struckOut, FontColor color, string fontName, ushort?fontSize) { if (sheet == null) { throw new ArgumentNullException("sheet", "sheet cannot be null"); } Cell cell = sheet.Cells.Add(row, col, String.Empty); if (border > 0) { cell.RightLineStyle = border; cell.LeftLineStyle = border; cell.TopLineStyle = border; cell.BottomLineStyle = border; cell.UseBorder = true; } if (backgroundColor != null) { cell.PatternColor = backgroundColor; cell.Pattern = 1; } if (fontWeight != null) { cell.Font.Weight = fontWeight.Value; } cell.Font.Italic = italic; if (underlineType != null) { cell.Font.Underline = underlineType.Value; } cell.Font.StruckOut = struckOut; if (fontName != null) { cell.Font.FontName = fontName; } if (fontSize != null) { cell.Font.Height = (ushort)(fontSize.Value * 20); } cell.HorizontalAlignment = horizontalAlignment; cell.Font.ColorIndex = (ushort)color; return(cell); }
//----------------------------------------------------------------------------- #region ** formatting void _btnBold_Click(object sender, RoutedEventArgs e) { FontWeight?fw = null; var cs = GetFirstSelectedStyle(); if (cs == null || cs.FontWeight == null) { fw = FontWeights.Bold; } _flex.SetCellFormat(_flex.Selection.Cells, CellFormat.FontWeight, fw); }
private void DoBoldTextChanges() { TextRange currentTextRange = new TextRange(MainTextBox.Selection.Start, MainTextBox.Selection.End); FontWeight?currentStyledTextRange = currentTextRange.GetPropertyValue(Inline.FontWeightProperty) as FontWeight?; if (currentStyledTextRange is not null) { currentStyledTextRange = FontWeights.Bold; currentTextRange.ApplyPropertyValue(Inline.FontWeightProperty, currentStyledTextRange); } }
public void SetFontWeight(string fontWeightValue) { var fontWeight = FontStyleHelpers.ParseFontWeight(fontWeightValue); if (_fontWeight.HasValue != fontWeight.HasValue || (_fontWeight.HasValue && fontWeight.HasValue && _fontWeight.Value.Weight != fontWeight.Value.Weight)) { _fontWeight = fontWeight; MarkUpdated(); } }
//----------------------------------------------------------------------------- #region ** formatting (TODO) void _btnBold_Click(object sender, RoutedEventArgs e) { FontWeight?fw = null; var cs = GetFirstSelectedStyle(); if (cs == null || cs.FontWeight == null) { fw = FontWeights.Bold; } SetSelectionStyle("FontWeight", fw); }
public void SetFontWeight(FontWeight?value) { if (value != null) { Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { Label_Main.FontWeight = (FontWeight)value; })); UpdateSize(); } }
public void SetFontWeight(string fontWeightValue) { var fontWeight = FontStyleHelpers.ParseFontWeight(fontWeightValue); if (_fontWeight.HasValue != fontWeight.HasValue || (_fontWeight.HasValue && fontWeight.HasValue && _fontWeight.Value != fontWeight.Value)) { _fontWeight = fontWeight; MarkUpdated(); } }
public Font() { this.fontSize = null; this.fontSizeUnit = null; this.gdiCharSet = null; this.fontStretch = null; this.fontWeight = null; this.fontStyle = null; this.underline = null; this.strikeout = null; this.fontFamily = null; }
public Font(string familyName, double fontSize, UnitType fontSizeUnit) { this.underline = null; this.strikeout = null; this.fontFamilyName = familyName; this.fontSize = new double?(fontSize); this.fontSizeUnit = new UnitType?(fontSizeUnit); this.fontStyle = null; this.fontWeight = null; this.fontStretch = null; this.gdiCharSet = null; }
public ComboBoxItemFontFamilyFontWeightFontStyle(FontFamily systemFontFamily, FontWeight?systemFontWeight, FontStyle?systemFontStyle) { Label l = new Label { Height = 16, VerticalAlignment = VerticalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, Padding = new Thickness(0), Foreground = Brushes.Black, Content = "Text" }; if (systemFontFamily != null) { SystemFontFamily = systemFontFamily; l.FontFamily = SystemFontFamily; } if (systemFontWeight != null) { SystemFontWeight = systemFontWeight; l.FontWeight = (FontWeight)SystemFontWeight; } if (systemFontStyle != null) { SystemFontStyle = systemFontStyle; l.FontStyle = (FontStyle)systemFontStyle; } if (systemFontFamily != null) { l.Content = SystemFontFamily.ToString(); } if (systemFontWeight != null) { l.Content = SystemFontWeight.ToString(); } if (systemFontStyle != null) { l.Content = SystemFontStyle.ToString(); } StackPanel sp = new StackPanel { Height = 16, Orientation = Orientation.Horizontal }; sp.Children.Add(l); Content = sp; }
/// <summary> /// Default constructor which is only to be used by the xml serialzier. /// </summary> public EditorSymbolSettings() { Name = null; Foreground = null; Background = null; Weight = null; Style = null; _originalForeground = null; _originalBackground = null; _originalWeight = null; _originalStyle = null; }
private void DrawText(double x, double y, string text, Color color, FontWeight?weight = null) { var textBlock = new TextBlock { Text = text, Foreground = new SolidColorBrush(color), FontWeight = weight ?? FontWeights.Normal }; Canvas.SetLeft(textBlock, x + 5); Canvas.SetTop(textBlock, y); Canvas.Children.Add(textBlock); }
private void TargetBoxItemsRefresh(ListBox box, object itmsSource = null) { if (back_font != null || itmsSource != null) { box.Items.Refresh(); back_font = null; } }
private void targetBoxItem_PreviewDragLeave(object sender, DragEventArgs e) { try { var item = sender as ListBoxItem; if (item == null) return; if (dStartBox(e) == TargetBox) { if (back_font != null) item.FontWeight = (FontWeight)back_font; back_font = null; } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }
private void targetBoxItem_PreviewDragOver(object sender, DragEventArgs e) { try { var item = sender as ListBoxItem; if (item == null) return; if (dStartBox(e) == SourceBox) { TargetBox.UnselectAll(); item.IsSelected = true; } else if (dStartBox(e) == TargetBox) { if (back_font == null) back_font = item.FontWeight; item.FontWeight = FontWeights.Bold; } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }
public ComboBoxItemFontFamilyFontWeightFontStyle(FontFamily systemFontFamily, FontWeight? systemFontWeight, FontStyle? systemFontStyle) { Label l = new Label { Height = 16, VerticalAlignment = VerticalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, Padding = new Thickness(0), Foreground = Brushes.Black, Content = "Text" }; if (systemFontFamily != null) { SystemFontFamily = systemFontFamily; l.FontFamily = SystemFontFamily; } if (systemFontWeight != null) { SystemFontWeight = systemFontWeight; l.FontWeight = (FontWeight)SystemFontWeight; } if (systemFontStyle != null) { SystemFontStyle = systemFontStyle; l.FontStyle = (FontStyle)systemFontStyle; } if (systemFontFamily != null) l.Content = SystemFontFamily.ToString(); if (systemFontWeight != null) l.Content = SystemFontWeight.ToString(); if (systemFontStyle != null) l.Content = SystemFontStyle.ToString(); StackPanel sp = new StackPanel { Height = 16, Orientation = Orientation.Horizontal }; sp.Children.Add(l); Content = sp; }
public void UpdateInspectorStyles() { __Foreground = null; __FontSize = null; __IsBold = false; __FontWeight = null; __IsItalic = false; __FontStyle = null; __IsStrikethrough = false; __TextDecorations = new TextDecorationCollection(); __FontFamily = null; foreach (LevelStyleProperty style in __StyleList) { switch (style.PropertyType) { case StylePropertyType.FontColor: __Foreground = style.Value as SolidColorBrush; break; case StylePropertyType.FontSize: __FontSize = (double?)style.Value; break; case StylePropertyType.IsBold: __IsBold = (bool)style.Value; __FontWeight = __IsBold ? FontWeights.Bold : FontWeights.Normal; break; case StylePropertyType.IsItalic: __IsItalic = (bool)style.Value; __FontStyle = __IsItalic ? FontStyles.Italic : FontStyles.Normal; break; case StylePropertyType.IsStrike: __IsStrikethrough = (bool)style.Value; if (__IsStrikethrough) __TextDecorations.Add(TextDecorations.Strikethrough); break; case StylePropertyType.IsUnderlined: __IsUnderlined = (bool)style.Value; if (__IsUnderlined) __TextDecorations.Add(TextDecorations.Underline); break; case StylePropertyType.Typeface: __FontFamily = style.Value as FontFamily; break; } } DoInspectorChanged(); DoStyleChanged(); }