void textDecorationCheckStateChanged(object sender, RoutedEventArgs e) { var textDecorations = new TextDecorationCollection(); if (underlineCheckBox.IsChecked.Value) { textDecorations.Add(TextDecorations.Underline[0]); } if (baselineCheckBox.IsChecked.Value) { textDecorations.Add(TextDecorations.Baseline[0]); } if (strikethroughCheckBox.IsChecked.Value) { textDecorations.Add(TextDecorations.Strikethrough[0]); } if (overlineCheckBox.IsChecked.Value) { textDecorations.Add(TextDecorations.OverLine[0]); } textDecorations.Freeze(); SelectedTextDecorations = textDecorations; }
private void OnTextDecorationCheckBoxChanged(object sender, RoutedEventArgs eventArgs) { // Only handle if changed was caused by user. if (_isInternalUpdate) return; var textDecorations = new TextDecorationCollection(); if (_underlineCheckBox.IsChecked.GetValueOrDefault()) textDecorations.Add(TextDecorations.Underline); if (_baselineCheckBox.IsChecked.GetValueOrDefault()) textDecorations.Add(TextDecorations.Baseline); if (_strikethroughCheckBox.IsChecked.GetValueOrDefault()) textDecorations.Add(TextDecorations.Strikethrough); if (_overlineCheckBox.IsChecked.GetValueOrDefault()) textDecorations.Add(TextDecorations.OverLine); textDecorations.Freeze(); SelectedTextDecorations = textDecorations; }
/// <summary> /// Initializes a new instance of the <see cref="TextFormattingRunProperties"/> class. /// </summary> public TextFormattingRunProperties(Typeface typeface, Double size, Color foreground) { _typeface = typeface; _size = _hintingSize = size; _foreground = foreground; _foregroundBrush = new SolidColorBrush(foreground); _backgroundBrush = Brushes.Transparent; _textDecorations = new TextDecorationCollection(); _textEffects = new TextEffectCollection(); _cultureInfo = CultureInfo.CurrentCulture; if (_foregroundBrush.CanFreeze) { _foregroundBrush.Freeze(); } if (_backgroundBrush.CanFreeze) { _backgroundBrush.Freeze(); } if (_textEffects.CanFreeze) { _textEffects.Freeze(); } if (_textDecorations.CanFreeze) { _textDecorations.Freeze(); } }
private void UpdateSelectedDecorations() { TextDecorationCollection newDecorations = new TextDecorationCollection(); if (IsUnderline) { newDecorations.Add(System.Windows.TextDecorations.Underline[0]); } if (IsStrikethrough) { newDecorations.Add(System.Windows.TextDecorations.Strikethrough[0]); } if (IsBaseline) { newDecorations.Add(System.Windows.TextDecorations.Baseline[0]); } if (IsOverLine) { newDecorations.Add(System.Windows.TextDecorations.OverLine[0]); } newDecorations.Freeze(); SelectedDecorations = newDecorations; }