private static void EditingCommandsEx_SelectFontFamily_Executed(Object sender, ExecutedRoutedEventArgs e) { var editor = sender as RichTextBox; if (e.Handled = (editor != null && e.Parameter is FontFamily)) { RichTextBoxToolBarHelper.ApplyNewValueToFormattingProperty <FontFamily>( editor.Selection, Paragraph.FontFamilyProperty, (FontFamily)e.Parameter, (item1, item2) => FontFamily.Equals(item1, item2)); } }
private static void EditingCommandsEx_ToggleStrikethrough_Executed(Object sender, ExecutedRoutedEventArgs e) { var editor = sender as RichTextBox; if (e.Handled = editor != null) { RichTextBoxToolBarHelper.ToggleSelectionFormattingProperty <TextDecorationCollection>(editor.Selection, Inline.TextDecorationsProperty, TextDecorations.Strikethrough, null, (item1, item2) => TextDecorationCollection.Equals(item1, item2)); } }
private static void EditingCommands_ToggleSuperscript_Executed(object sender, ExecutedRoutedEventArgs e) { var editor = sender as RichTextBox; if (e.Handled = editor != null) { RichTextBoxToolBarHelper.ToggleSelectionFormattingProperty <BaselineAlignment>(editor.Selection, Inline.BaselineAlignmentProperty, BaselineAlignment.Superscript, BaselineAlignment.Baseline, (item1, item2) => item1 == item2); } }
private static void EditingCommandsEx_SelectBackgroundColor_Executed(Object sender, ExecutedRoutedEventArgs e) { var editor = sender as RichTextBox; Color?color = RichTextBoxToolBarHelper.GetSelectionColor(e.Parameter, Colors.White); if (e.Handled = (editor != null && color != null)) { RichTextBoxToolBarHelper.ApplyNewValueToFormattingProperty <SolidColorBrush>( editor.Selection, TextElement.BackgroundProperty, new SolidColorBrush((Color)color), (item1, item2) => SolidColorBrush.Equals(item1, item2)); } }
private static void EditingCommandsEx_SelectFontSize_Executed(Object sender, ExecutedRoutedEventArgs e) { var editor = sender as RichTextBox; Double?size = RichTextBoxToolBarHelper.GetSelectionFontSize(e.Parameter); if (e.Handled = (editor != null && size != null)) { RichTextBoxToolBarHelper.ApplyNewValueToFormattingProperty <Double>( editor.Selection, Paragraph.FontSizeProperty, (Double)size, (item1, item2) => Double.Equals(item1, item2)); } }
private Boolean SetFontSize(Object fontSize) { RichTextBox editor = this.CurrentEditor; Double? newSize = RichTextBoxToolBarHelper.GetSelectionFontSize(fontSize); if (editor != null && newSize != null) { EditingCommandsEx.SelectFontSize.Execute( (Double)newSize, editor); editor.Focus(); this.IsOverflowOpen = false; return(true); } return(false); }
public void UpdateToolItems() { var selection = this.GetCurrentEditorSelection(); try { // Disable circular updates by the recall tool bar items commands this.IsEnabledToolBarItems = true; RichTextBoxToolBarHelper.UpdateSelectionFontFamily( this._cbFontFamily, selection); RichTextBoxToolBarHelper.UpdateSelectionFontSize( this._cbFontSize, selection); RichTextBoxToolBarHelper.UpdateSelectionItemCheckedState( this._tgbtnBold, selection, TextElement.FontWeightProperty, FontWeights.Bold); RichTextBoxToolBarHelper.UpdateSelectionItemCheckedState( this._tgbtnItalic, selection, TextElement.FontStyleProperty, FontStyles.Italic); RichTextBoxToolBarHelper.UpdateSelectionItemCheckedState( this._tgbtnUnderline, selection, Inline.TextDecorationsProperty, TextDecorations.Underline); RichTextBoxToolBarHelper.UpdateSelectionItemCheckedState( this._tgbtnStrikeout, selection, Inline.TextDecorationsProperty, TextDecorations.Strikethrough); RichTextBoxToolBarHelper.UpdateSelectionItemCheckedState( this._tgbtnAlignLeft, selection, Paragraph.TextAlignmentProperty, TextAlignment.Left); RichTextBoxToolBarHelper.UpdateSelectionItemCheckedState( this._tgbtnAlignCenter, selection, Paragraph.TextAlignmentProperty, TextAlignment.Center); RichTextBoxToolBarHelper.UpdateSelectionItemCheckedState( this._tgbtnAlignRight, selection, Paragraph.TextAlignmentProperty, TextAlignment.Right); RichTextBoxToolBarHelper.UpdateSelectionItemCheckedState( this._tgbtnAlignJustify, selection, Paragraph.TextAlignmentProperty, TextAlignment.Justify); RichTextBoxToolBarHelper.UpdateSelectionColor( this._cbBackgroundColors, selection, TextElement.BackgroundProperty, Colors.White); RichTextBoxToolBarHelper.UpdateSelectionColor( this._cbForegroundColors, selection, TextElement.ForegroundProperty, Colors.Black); RichTextBoxToolBarHelper.UpdateSelectionListType( this._tgbtnBullets, selection, TextMarkerStyle.Disc); RichTextBoxToolBarHelper.UpdateSelectionListType( this._tgbtnNumbering, selection, TextMarkerStyle.Decimal); RichTextBoxToolBarHelper.UpdateSelectionItemCheckedState( this._tgbtnSubscript, selection, Inline.BaselineAlignmentProperty, BaselineAlignment.Subscript); RichTextBoxToolBarHelper.UpdateSelectionItemCheckedState( this._tgbtnSuperscript, selection, Inline.BaselineAlignmentProperty, BaselineAlignment.Superscript); } finally { this.IsEnabledToolBarItems = true; } }