// Token: 0x0600383D RID: 14397 RVA: 0x000FAEB0 File Offset: 0x000F90B0
        private static void OnDecreaseFontSize(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);
            if (textEditor.Selection.IsEmpty)
            {
                double num = (double)((TextSelection)textEditor.Selection).GetCurrentValue(TextElement.FontSizeProperty);
                if (num == 0.0)
                {
                    return;
                }
                if (num > 0.75)
                {
                    num -= 0.75;
                    if (num < 0.75)
                    {
                        num = 0.75;
                    }
                    TextEditorCharacters._OnApplyProperty(textEditor, TextElement.FontSizeProperty, num);
                    return;
                }
            }
            else
            {
                TextEditorCharacters._OnApplyProperty(textEditor, TextElement.FontSizeProperty, 0.75, false, PropertyValueAction.DecreaseByAbsoluteValue);
            }
        }
Beispiel #2
0
        /// <summary>
        /// OnApplyParagraphFlowDirectionRTL command event handler.
        /// </summary>
        private static void OnApplyParagraphFlowDirectionRTL(object sender, ExecutedRoutedEventArgs e)
        {
            TextEditor This = TextEditor._GetTextEditor(sender);

            TextEditorCharacters._OnApplyProperty(This, FrameworkElement.FlowDirectionProperty,
                                                  FlowDirection.RightToLeft, /*applyToParagraphs*/ true);
        }
Beispiel #3
0
        /// <summary>
        /// ToggleUnderline command event handler.
        /// </summary>
        private static void OnToggleUnderline(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(Inline.TextDecorationsProperty);
            TextDecorationCollection textDecorations = propertyValue != DependencyProperty.UnsetValue ? (TextDecorationCollection)propertyValue : null;

            TextDecorationCollection toggledTextDecorations;

            if (!TextSchema.HasTextDecorations(textDecorations))
            {
                toggledTextDecorations = TextDecorations.Underline;
            }
            else if (!textDecorations.TryRemove(TextDecorations.Underline, out toggledTextDecorations))
            {
                // TextDecorations.Underline was not present, so add it
                toggledTextDecorations.Add(TextDecorations.Underline);
            }

            TextEditorCharacters._OnApplyProperty(This, Inline.TextDecorationsProperty, toggledTextDecorations);
        }
Beispiel #4
0
        /// <summary>
        /// ApplyBackground command event handler.
        /// </summary>
        private static void OnApplyBackground(object target, ExecutedRoutedEventArgs args)
        {
            if (args.Parameter == null)
            {
                return; // Ignore the command if no argument provided
            }
            TextEditor This = TextEditor._GetTextEditor(target);

            TextEditorCharacters._OnApplyProperty(This, TextElement.BackgroundProperty, args.Parameter);
        }
Beispiel #5
0
        // Token: 0x0600388F RID: 14479 RVA: 0x000FDED0 File Offset: 0x000FC0D0
        private static void OnAlignJustify(object sender, ExecutedRoutedEventArgs e)
        {
            TextEditor textEditor = TextEditor._GetTextEditor(sender);

            if (textEditor == null)
            {
                return;
            }
            TextEditorCharacters._OnApplyProperty(textEditor, Block.TextAlignmentProperty, TextAlignment.Justify, true);
        }
        // Token: 0x06003841 RID: 14401 RVA: 0x000FB014 File Offset: 0x000F9214
        private static void OnApplyBackground(object target, ExecutedRoutedEventArgs args)
        {
            if (args.Parameter == null)
            {
                return;
            }
            TextEditor @this = TextEditor._GetTextEditor(target);

            TextEditorCharacters._OnApplyProperty(@this, TextElement.BackgroundProperty, args.Parameter);
        }
Beispiel #7
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);
        }
Beispiel #10
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();
        }
Beispiel #11
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);
        }
Beispiel #13
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);
        }
Beispiel #14
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);
 }