示例#1
0
        /// <summary>
        /// AlignCenter command event handler.
        /// </summary>
        private static void OnAlignCenter(object sender, ExecutedRoutedEventArgs e)
        {
            TextEditor This = TextEditor._GetTextEditor(sender);

            if (This == null)
            {
                return;
            }

            TextEditorCharacters._OnApplyProperty(This, Block.TextAlignmentProperty, TextAlignment.Center, /*applyToParagraphs*/ true);
        }
        // Token: 0x06003837 RID: 14391 RVA: 0x000FAB18 File Offset: 0x000F8D18
        private static void OnToggleBold(object target, ExecutedRoutedEventArgs args)
        {
            TextEditor textEditor = TextEditor._GetTextEditor(target);

            if (textEditor == null || !textEditor._IsEnabled || textEditor.IsReadOnly || !textEditor.AcceptsRichContent || !(textEditor.Selection is TextSelection))
            {
                return;
            }
            TextEditorTyping._FlushPendingInputItems(textEditor);
            object     currentValue = ((TextSelection)textEditor.Selection).GetCurrentValue(TextElement.FontWeightProperty);
            FontWeight fontWeight   = (currentValue != DependencyProperty.UnsetValue && (FontWeight)currentValue == FontWeights.Bold) ? FontWeights.Normal : FontWeights.Bold;

            TextEditorCharacters._OnApplyProperty(textEditor, TextElement.FontWeightProperty, fontWeight);
        }
        // Token: 0x0600383B RID: 14395 RVA: 0x000FAD64 File Offset: 0x000F8F64
        private static void OnToggleSuperscript(object sender, ExecutedRoutedEventArgs args)
        {
            TextEditor textEditor = TextEditor._GetTextEditor(sender);

            if (textEditor == null || !textEditor._IsEnabled || textEditor.IsReadOnly || !textEditor.AcceptsRichContent || !(textEditor.Selection is TextSelection))
            {
                return;
            }
            TextEditorTyping._FlushPendingInputItems(textEditor);
            FontVariants fontVariants = (FontVariants)((TextSelection)textEditor.Selection).GetCurrentValue(Typography.VariantsProperty);

            fontVariants = ((fontVariants == FontVariants.Superscript) ? FontVariants.Normal : FontVariants.Superscript);
            TextEditorCharacters._OnApplyProperty(textEditor, Typography.VariantsProperty, fontVariants);
        }
示例#4
0
        /// <summary>
        /// ToggleItalic command event handler.
        /// </summary>
        private static void OnToggleItalic(object target, ExecutedRoutedEventArgs args)
        {
            TextEditor This = TextEditor._GetTextEditor(target);

            if (This == null || !This._IsEnabled || This.IsReadOnly || !This.AcceptsRichContent || !(This.Selection is TextSelection))
            {
                return;
            }

            TextEditorTyping._FlushPendingInputItems(This);

            object    propertyValue = ((TextSelection)This.Selection).GetCurrentValue(TextElement.FontStyleProperty);
            FontStyle fontStyle     = (propertyValue != DependencyProperty.UnsetValue && (FontStyle)propertyValue == FontStyles.Italic) ? FontStyles.Normal : FontStyles.Italic;

            TextEditorCharacters._OnApplyProperty(This, TextElement.FontStyleProperty, fontStyle);

            // Update the caret to show it as italic or normal caret.
            This.Selection.RefreshCaret();
        }
示例#5
0
        /// <summary>
        /// IncreaseFontSize command event handler
        /// </summary>
        private static void OnIncreaseFontSize(object target, ExecutedRoutedEventArgs args)
        {
            TextEditor This = TextEditor._GetTextEditor(target);

            if (This == null || !This._IsEnabled || This.IsReadOnly || !This.AcceptsRichContent || !(This.Selection is TextSelection))
            {
                return;
            }

            TextEditorTyping._FlushPendingInputItems(This);

            if (This.Selection.IsEmpty)
            {
                // Springload an increased font size
                double fontSize = (double)((TextSelection)This.Selection).GetCurrentValue(TextElement.FontSizeProperty);
                if (fontSize == 0.0)
                {
                    return; // no characters available for font operation
                }

                if (fontSize < TextEditorCharacters.MaxFontPoint)
                {
                    fontSize += TextEditorCharacters.OneFontPoint;
                    if (fontSize > TextEditorCharacters.MaxFontPoint)
                    {
                        fontSize = TextEditorCharacters.MaxFontPoint;
                    }

                    // The limiting constant is taken from Word UI - it suggests to choose font size from a range between 1 and 1638.
                    TextEditorCharacters._OnApplyProperty(This, TextElement.FontSizeProperty, fontSize);
                }
            }
            else
            {
                // Apply font size in incremental mode to a nonempty selection
                TextEditorCharacters._OnApplyProperty(This, TextElement.FontSizeProperty, OneFontPoint, /*applyToParagraphs:*/ false, PropertyValueAction.IncreaseByAbsoluteValue);
            }
        }
        // Token: 0x06003839 RID: 14393 RVA: 0x000FAC48 File Offset: 0x000F8E48
        private static void OnToggleUnderline(object target, ExecutedRoutedEventArgs args)
        {
            TextEditor textEditor = TextEditor._GetTextEditor(target);

            if (textEditor == null || !textEditor._IsEnabled || textEditor.IsReadOnly || !textEditor.AcceptsRichContent || !(textEditor.Selection is TextSelection))
            {
                return;
            }
            TextEditorTyping._FlushPendingInputItems(textEditor);
            object currentValue = ((TextSelection)textEditor.Selection).GetCurrentValue(Inline.TextDecorationsProperty);
            TextDecorationCollection textDecorationCollection = (currentValue != DependencyProperty.UnsetValue) ? ((TextDecorationCollection)currentValue) : null;
            TextDecorationCollection underline;

            if (!TextSchema.HasTextDecorations(textDecorationCollection))
            {
                underline = TextDecorations.Underline;
            }
            else if (!textDecorationCollection.TryRemove(TextDecorations.Underline, out underline))
            {
                underline.Add(TextDecorations.Underline);
            }
            TextEditorCharacters._OnApplyProperty(textEditor, Inline.TextDecorationsProperty, underline);
        }
示例#7
0
        /// <summary>
        /// ApplyInlineFlowDirectionLTR command event handler.
        /// </summary>
        private static void OnApplyInlineFlowDirectionLTR(object target, ExecutedRoutedEventArgs args)
        {
            TextEditor This = TextEditor._GetTextEditor(target);

            TextEditorCharacters._OnApplyProperty(This, Inline.FlowDirectionProperty, FlowDirection.LeftToRight);
        }
示例#8
0
        // Token: 0x06003893 RID: 14483 RVA: 0x000FDEFC File Offset: 0x000FC0FC
        private static void OnApplyParagraphFlowDirectionLTR(object sender, ExecutedRoutedEventArgs e)
        {
            TextEditor @this = TextEditor._GetTextEditor(sender);

            TextEditorCharacters._OnApplyProperty(@this, FrameworkElement.FlowDirectionProperty, FlowDirection.LeftToRight, true);
        }
 // Token: 0x06003834 RID: 14388 RVA: 0x000FA972 File Offset: 0x000F8B72
 internal static void _OnApplyProperty(TextEditor This, DependencyProperty formattingProperty, object propertyValue, bool applyToParagraphs)
 {
     TextEditorCharacters._OnApplyProperty(This, formattingProperty, propertyValue, applyToParagraphs, PropertyValueAction.SetValue);
 }
 // Token: 0x06003833 RID: 14387 RVA: 0x000FA966 File Offset: 0x000F8B66
 internal static void _OnApplyProperty(TextEditor This, DependencyProperty formattingProperty, object propertyValue)
 {
     TextEditorCharacters._OnApplyProperty(This, formattingProperty, propertyValue, false, PropertyValueAction.SetValue);
 }