// Token: 0x06003888 RID: 14472 RVA: 0x000FDA94 File Offset: 0x000FBC94
        private static void UpdateCursor(TextEditor This, Point mouseMovePoint)
        {
            Invariant.Assert(This.TextView != null && This.TextView.IsValid);
            Cursor cursor = Cursors.IBeam;

            if (TextEditor.IsTableEditingEnabled && TextRangeEditTables.TableBorderHitTest(This.TextView, mouseMovePoint))
            {
                cursor = Cursors.SizeWE;
            }
            else if (This.Selection != null && !This.UiScope.IsMouseCaptured)
            {
                if (This.Selection.IsEmpty)
                {
                    UIElement uielementWhenMouseOver = TextEditorMouse.GetUIElementWhenMouseOver(This, mouseMovePoint);
                    if (uielementWhenMouseOver != null && uielementWhenMouseOver.IsEnabled)
                    {
                        cursor = Cursors.Arrow;
                    }
                }
                else if (This.UiScope.IsFocused && This.Selection.Contains(mouseMovePoint))
                {
                    cursor = Cursors.Arrow;
                }
            }
            if (cursor != This._cursor)
            {
                This._cursor = cursor;
                Mouse.UpdateCursor();
            }
        }
        // Token: 0x06003881 RID: 14465 RVA: 0x000FD4E4 File Offset: 0x000FB6E4
        internal static void OnMouseUp(object sender, MouseButtonEventArgs e)
        {
            TextEditor textEditor = TextEditor._GetTextEditor(sender);

            if (e.ChangedButton != MouseButton.Left)
            {
                return;
            }
            if (e.RightButton != MouseButtonState.Released)
            {
                return;
            }
            if (textEditor == null)
            {
                return;
            }
            if (!textEditor._IsEnabled)
            {
                return;
            }
            if (textEditor.TextView == null || !textEditor.TextView.IsValid)
            {
                return;
            }
            if (!textEditor.UiScope.IsMouseCaptured)
            {
                return;
            }
            e.Handled = true;
            textEditor.CancelExtendSelection();
            Point position = e.GetPosition(textEditor.TextView.RenderScope);

            TextEditorMouse.UpdateCursor(textEditor, position);
            if (textEditor._tableColResizeInfo != null)
            {
                using (textEditor.Selection.DeclareChangeBlock())
                {
                    textEditor._tableColResizeInfo.ResizeColumn(position);
                    textEditor._tableColResizeInfo = null;
                    goto IL_D5;
                }
            }
            using (textEditor.Selection.DeclareChangeBlock())
            {
                textEditor._dragDropProcess.DoMouseLeftButtonUp(e);
                textEditor._forceWordSelection      = false;
                textEditor._forceParagraphSelection = false;
            }
IL_D5:
            textEditor._mouseCapturingInProgress = true;
            try
            {
                textEditor.UiScope.ReleaseMouseCapture();
            }
            finally
            {
                textEditor._mouseCapturingInProgress = false;
            }
        }
        // Token: 0x06003882 RID: 14466 RVA: 0x000FD60C File Offset: 0x000FB80C
        internal static void OnQueryCursor(object sender, QueryCursorEventArgs e)
        {
            TextEditor textEditor = TextEditor._GetTextEditor(sender);

            if (textEditor == null)
            {
                return;
            }
            if (textEditor.TextView == null)
            {
                return;
            }
            if (TextEditorMouse.IsPointWithinInteractiveArea(textEditor, Mouse.GetPosition(textEditor.UiScope)))
            {
                e.Cursor  = textEditor._cursor;
                e.Handled = true;
            }
        }
        // Token: 0x0600387D RID: 14461 RVA: 0x000FD1BC File Offset: 0x000FB3BC
        internal static void SetCaretPositionOnMouseEvent(TextEditor This, Point mouseDownPoint, MouseButton changedButton, int clickCount)
        {
            ITextPointer textPositionFromPoint = This.TextView.GetTextPositionFromPoint(mouseDownPoint, true);

            if (textPositionFromPoint == null)
            {
                TextEditorMouse.MoveFocusToUiScope(This);
                return;
            }
            TextEditorSelection._ClearSuggestedX(This);
            TextEditorTyping._BreakTypingSequence(This);
            if (This.Selection is TextSelection)
            {
                ((TextSelection)This.Selection).ClearSpringloadFormatting();
            }
            This._forceWordSelection      = false;
            This._forceParagraphSelection = false;
            if (changedButton == MouseButton.Right || clickCount == 1)
            {
                if (changedButton != MouseButton.Left || !This._dragDropProcess.SourceOnMouseLeftButtonDown(mouseDownPoint))
                {
                    This.Selection.SetSelectionByMouse(textPositionFromPoint, mouseDownPoint);
                    return;
                }
            }
            else
            {
                if (clickCount == 2 && (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.None && This.Selection.IsEmpty)
                {
                    This._forceWordSelection      = true;
                    This._forceParagraphSelection = false;
                    This.Selection.SelectWord(textPositionFromPoint);
                    return;
                }
                if (clickCount == 3 && (Keyboard.Modifiers & ModifierKeys.Shift) == ModifierKeys.None && This.AcceptsRichContent)
                {
                    This._forceParagraphSelection = true;
                    This._forceWordSelection      = false;
                    This.Selection.SelectParagraph(textPositionFromPoint);
                }
            }
        }
        // Token: 0x0600387E RID: 14462 RVA: 0x000FD2A4 File Offset: 0x000FB4A4
        internal static bool IsPointWithinInteractiveArea(TextEditor textEditor, Point point)
        {
            bool flag = TextEditorMouse.IsPointWithinRenderScope(textEditor, point);

            if (flag)
            {
                flag = textEditor.TextView.IsValid;
                if (flag)
                {
                    GeneralTransform generalTransform = textEditor.UiScope.TransformToDescendant(textEditor.TextView.RenderScope);
                    if (generalTransform != null)
                    {
                        generalTransform.TryTransform(point, out point);
                    }
                    ITextPointer textPositionFromPoint = textEditor.TextView.GetTextPositionFromPoint(point, true);
                    flag = (textPositionFromPoint != null);
                }
            }
            return(flag);
        }
        // Token: 0x06003880 RID: 14464 RVA: 0x000FD490 File Offset: 0x000FB690
        internal static void OnMouseMove(object sender, MouseEventArgs e)
        {
            TextEditor textEditor = TextEditor._GetTextEditor(sender);

            if (textEditor == null)
            {
                return;
            }
            if (!textEditor._IsEnabled)
            {
                return;
            }
            if (textEditor.TextView == null || !textEditor.TextView.IsValid)
            {
                return;
            }
            if (textEditor.UiScope.IsKeyboardFocused)
            {
                TextEditorMouse.OnMouseMoveWithFocus(textEditor, e);
                return;
            }
            TextEditorMouse.OnMouseMoveWithoutFocus(textEditor, e);
        }
Exemplo n.º 7
0
        internal static void OnContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            TextEditor   This = TextEditor._GetTextEditor(sender);
            const double KeyboardInvokedSentinel = -1.0; // e.CursorLeft has this value when the menu is invoked with the keyboard.

            if (This == null || This.TextView == null)
            {
                return;
            }

            // Get the mouse position that base on RenderScope which we will set
            // the caret on the RenderScope.
            Point       renderScopeMouseDownPoint = Mouse.GetPosition(This.TextView.RenderScope);
            ContextMenu contextMenu = null;
            bool        startPositionCustomElementMenu = false;

            if (This.IsReadOnly)
            {
                // If the TextEditor is ReadOnly, only take action if
                // 1. The selection is non-empty AND
                // 2. The user clicked inside the selection.
                if ((e.CursorLeft != KeyboardInvokedSentinel && !This.Selection.Contains(renderScopeMouseDownPoint)) ||
                    (e.CursorLeft == KeyboardInvokedSentinel && This.Selection.IsEmpty))
                {
                    return;
                }
            }
            else if ((This.Selection.IsEmpty || e.TargetElement is TextElement) &&
                     e.TargetElement != null)
            {
                // Targeted element has its own ContextMenu, don't override it.
                contextMenu = (ContextMenu)e.TargetElement.GetValue(FrameworkElement.ContextMenuProperty);
            }
            else if (e.CursorLeft == KeyboardInvokedSentinel)
            {
                // If the menu was invoked from the keyboard, walk up the tree
                // from the selection.Start looking for a custom menu.
                TextPointer start = GetContentPosition(This.Selection.Start) as TextPointer;
                if (start != null)
                {
                    TextElement element = start.Parent as TextElement;

                    while (element != null)
                    {
                        contextMenu = (ContextMenu)element.GetValue(FrameworkElement.ContextMenuProperty);
                        if (contextMenu != null)
                        {
                            startPositionCustomElementMenu = true;
                            break;
                        }
                        element = element.Parent as TextElement;
                    }
                }
            }

            // Update the selection caret.
            //
            // A negative offset for e.CursorLeft means the user invoked
            // the menu with a hotkey (shift-F10).  Don't mess with the caret
            // unless the user right-clicked.
            if (e.CursorLeft != KeyboardInvokedSentinel)
            {
                if (!TextEditorMouse.IsPointWithinInteractiveArea(This, Mouse.GetPosition(This.UiScope)))
                {
                    // Don't bring up a context menu if the user clicked on non-editable space.
                    return;
                }

                // Don't update the selection caret if we're bringing up a custom UIElement
                // ContextMenu.
                if (contextMenu == null || !(e.TargetElement is UIElement))
                {
                    using (This.Selection.DeclareChangeBlock()) // NB: This raises a PUBLIC EVENT.
                    {
                        // If we're not over the selection, move the caret.
                        if (!This.Selection.Contains(renderScopeMouseDownPoint))
                        {
                            TextEditorMouse.SetCaretPositionOnMouseEvent(This, renderScopeMouseDownPoint, MouseButton.Right, 1 /* clickCount */);
                        }
                    }
                }
            }

            if (contextMenu == null)
            {
                // If someone explicitly set it null -- don't mess with it.
                if (This.UiScope.ReadLocalValue(FrameworkElement.ContextMenuProperty) == null)
                {
                    return;
                }

                // Grab whatever's set to the UiScope's ContextMenu property.
                contextMenu = This.UiScope.ContextMenu;
            }

            // If we are here, it means that either a custom context menu or our default context menu will be opened.
            // Setting this flag ensures that we dont loose selection highlight while the context menu is open.
            This.IsContextMenuOpen = true;

            // If it's not null, someone's overriding our default -- don't mess with it.
            if (contextMenu != null && !startPositionCustomElementMenu)
            {
                // If the user previously raised the ContextMenu with the keyboard,
                // we've left h/v offsets non-zero, and they need to be cleared now
                // for mouse placement to work.
                contextMenu.HorizontalOffset = 0;
                contextMenu.VerticalOffset   = 0;

                // Since ContextMenuService doesn't open the menu, it won't fire a ContextMenuClosing event.
                // We need to listen to the Closed event of the ContextMenu itself so we can clear the
                // IsContextMenuOpen flag.  We also do this for the default menu later in this method.
                contextMenu.Closed += new RoutedEventHandler(OnContextMenuClosed);
                return;
            }

            // Complete the composition before creating the editor context menu.
            This.CompleteComposition();

            if (contextMenu == null)
            {
                // It's a default null, so spin up a temporary ContextMenu now.
                contextMenu = new EditorContextMenu();
                ((EditorContextMenu)contextMenu).AddMenuItems(This, e.UserInitiated);
            }
            contextMenu.Placement       = PlacementMode.RelativePoint;
            contextMenu.PlacementTarget = This.UiScope;

            ITextPointer     position = null;
            LogicalDirection direction;

            // Position the ContextMenu.

            SpellingError spellingError = (contextMenu is EditorContextMenu) ? This.GetSpellingErrorAtSelection() : null;

            if (spellingError != null)
            {
                // If we have a matching speller error at the selection
                // start, position relative to the end of the error.
                position  = spellingError.End;
                direction = LogicalDirection.Backward;
            }
            else if (e.CursorLeft == KeyboardInvokedSentinel)
            {
                // A negative offset for e.CursorLeft means the user invoked
                // the menu with a hotkey (shift-F10).  Place the menu
                // relative to Selection.Start.
                position  = This.Selection.Start;
                direction = LogicalDirection.Forward;
            }
            else
            {
                direction = LogicalDirection.Forward;
            }

            // Calculate coordinats for the ContextMenu.
            // They must be set relative to UIScope - as EditorContextMenu constructor assumes.
            if (position != null && position.CreatePointer(direction).HasValidLayout)
            {
                double horizontalOffset;
                double verticalOffset;

                GetClippedPositionOffsets(This, position, direction, out horizontalOffset, out verticalOffset);

                contextMenu.HorizontalOffset = horizontalOffset;
                contextMenu.VerticalOffset   = verticalOffset;
            }
            else
            {
                Point uiScopeMouseDownPoint = Mouse.GetPosition(This.UiScope);

                contextMenu.HorizontalOffset = uiScopeMouseDownPoint.X;
                contextMenu.VerticalOffset   = uiScopeMouseDownPoint.Y;
            }

            // Since ContextMenuService doesn't open the menu, it won't fire a ContextMenuClosing event.
            // We need to listen to the Closed event of the ContextMenu itself so we can clear the
            // IsContextMenuOpen flag.
            contextMenu.Closed += new RoutedEventHandler(OnContextMenuClosed);

            // This line raises a public event.
            contextMenu.IsOpen = true;

            e.Handled = true;
        }
Exemplo n.º 8
0
        internal static void OnContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            TextEditor textEditor = TextEditor._GetTextEditor(sender);

            if (textEditor == null || textEditor.TextView == null)
            {
                return;
            }
            Point       position    = Mouse.GetPosition(textEditor.TextView.RenderScope);
            ContextMenu contextMenu = null;
            bool        flag        = false;

            if (textEditor.IsReadOnly)
            {
                if ((e.CursorLeft != -1.0 && !textEditor.Selection.Contains(position)) || (e.CursorLeft == -1.0 && textEditor.Selection.IsEmpty))
                {
                    return;
                }
            }
            else if ((textEditor.Selection.IsEmpty || e.TargetElement is TextElement) && e.TargetElement != null)
            {
                contextMenu = (ContextMenu)e.TargetElement.GetValue(FrameworkElement.ContextMenuProperty);
            }
            else if (e.CursorLeft == -1.0)
            {
                TextPointer textPointer = TextEditorContextMenu.GetContentPosition(textEditor.Selection.Start) as TextPointer;
                if (textPointer != null)
                {
                    for (TextElement textElement = textPointer.Parent as TextElement; textElement != null; textElement = (textElement.Parent as TextElement))
                    {
                        contextMenu = (ContextMenu)textElement.GetValue(FrameworkElement.ContextMenuProperty);
                        if (contextMenu != null)
                        {
                            flag = true;
                            break;
                        }
                    }
                }
            }
            if (e.CursorLeft != -1.0)
            {
                if (!TextEditorMouse.IsPointWithinInteractiveArea(textEditor, Mouse.GetPosition(textEditor.UiScope)))
                {
                    return;
                }
                if (contextMenu == null || !(e.TargetElement is UIElement))
                {
                    using (textEditor.Selection.DeclareChangeBlock())
                    {
                        if (!textEditor.Selection.Contains(position))
                        {
                            TextEditorMouse.SetCaretPositionOnMouseEvent(textEditor, position, MouseButton.Right, 1);
                        }
                    }
                }
            }
            if (contextMenu == null)
            {
                if (textEditor.UiScope.ReadLocalValue(FrameworkElement.ContextMenuProperty) == null)
                {
                    return;
                }
                contextMenu = textEditor.UiScope.ContextMenu;
            }
            textEditor.IsContextMenuOpen = true;
            if (contextMenu != null && !flag)
            {
                contextMenu.HorizontalOffset = 0.0;
                contextMenu.VerticalOffset   = 0.0;
                contextMenu.Closed          += TextEditorContextMenu.OnContextMenuClosed;
                return;
            }
            textEditor.CompleteComposition();
            if (contextMenu == null)
            {
                contextMenu = new TextEditorContextMenu.EditorContextMenu();
                ((TextEditorContextMenu.EditorContextMenu)contextMenu).AddMenuItems(textEditor, e.UserInitiated);
            }
            contextMenu.Placement       = PlacementMode.RelativePoint;
            contextMenu.PlacementTarget = textEditor.UiScope;
            ITextPointer     textPointer2  = null;
            SpellingError    spellingError = (contextMenu is TextEditorContextMenu.EditorContextMenu) ? textEditor.GetSpellingErrorAtSelection() : null;
            LogicalDirection logicalDirection;

            if (spellingError != null)
            {
                textPointer2     = spellingError.End;
                logicalDirection = LogicalDirection.Backward;
            }
            else if (e.CursorLeft == -1.0)
            {
                textPointer2     = textEditor.Selection.Start;
                logicalDirection = LogicalDirection.Forward;
            }
            else
            {
                logicalDirection = LogicalDirection.Forward;
            }
            if (textPointer2 != null && textPointer2.CreatePointer(logicalDirection).HasValidLayout)
            {
                double horizontalOffset;
                double verticalOffset;
                TextEditorContextMenu.GetClippedPositionOffsets(textEditor, textPointer2, logicalDirection, out horizontalOffset, out verticalOffset);
                contextMenu.HorizontalOffset = horizontalOffset;
                contextMenu.VerticalOffset   = verticalOffset;
            }
            else
            {
                Point position2 = Mouse.GetPosition(textEditor.UiScope);
                contextMenu.HorizontalOffset = position2.X;
                contextMenu.VerticalOffset   = position2.Y;
            }
            contextMenu.Closed += TextEditorContextMenu.OnContextMenuClosed;
            contextMenu.IsOpen  = true;
            e.Handled           = true;
        }
Exemplo n.º 9
0
        // MouseMoveEvent handler.
        private static void OnMouseMoveWithFocus(TextEditor This, MouseEventArgs e)
        {
            // Ignore the event if it was caused by us capturing the mouse
            if (This._mouseCapturingInProgress)
            {
                return;
            }

            // Clear a flag indicating that Shift key was pressed without any following key
            // This flag is necessary for KeyUp(RightShift/LeftShift) processing.
            TextEditor._ThreadLocalStore.PureControlShift = false;

            // Get the mouse move point.
            Point mouseMovePoint = e.GetPosition(This.TextView.RenderScope);

            // Update mouse cursor shape
            TextEditorMouse.UpdateCursor(This, mouseMovePoint);

            // For
            Invariant.Assert(This.Selection != null);

            // We're only interested in moves when the left button is down.
            if (e.LeftButton != MouseButtonState.Pressed)
            {
                return;
            }

            // We didn't get the original mouse down event, perhaps a listener
            // handled it.
            if (!This.UiScope.IsMouseCaptured)
            {
                return;
            }

            // Scale back any background layout in progress.
            This.TextView.ThrottleBackgroundTasksForUserInput();

            if (This._tableColResizeInfo != null)
            {
                This._tableColResizeInfo.UpdateAdorner(mouseMovePoint);
            }
            else
            {
                // Consider event handled
                e.Handled = true;

                // For
                Invariant.Assert(This.Selection != null);

                // Find a text position for this mouse point
                ITextPointer snappedCursorPosition = This.TextView.GetTextPositionFromPoint(mouseMovePoint, /*snapToText:*/ true);

                // For
                Invariant.Assert(This.Selection != null);

                if (snappedCursorPosition == null)
                {
                    This.RequestExtendSelection(mouseMovePoint);
                }
                else
                {
                    This.CancelExtendSelection();

                    // For
                    Invariant.Assert(This.Selection != null);

                    if (!This._dragDropProcess.SourceOnMouseMove(mouseMovePoint))
                    {
                        // Auto-scrolling behavior during selection guesture -
                        // works when the mouse is outside of scroller's viewport.
                        // In such case we artificially increase coordinates to
                        // get to farther text position - which would speed-up scrolling
                        // in particular direction.
                        FrameworkElement scroller = This._Scroller;
                        if (scroller != null && This.UiScope is TextBoxBase)
                        {
                            ITextPointer acceleratedCursorPosition = null; // cursorPosition corrected to accelerate scrolling

                            Point targetPoint   = new Point(mouseMovePoint.X, mouseMovePoint.Y);
                            Point pointScroller = e.GetPosition((IInputElement)scroller);

                            double pageHeight    = (double)((TextBoxBase)This.UiScope).ViewportHeight;
                            double slowAreaDelta = ScrollViewer._scrollLineDelta;

                            // Auto scrolling up/down page for the page height if the mouse Y
                            // position is out of viewport.
                            if (pointScroller.Y < 0 - slowAreaDelta)
                            {
                                Rect targetRect = This.TextView.GetRectangleFromTextPosition(snappedCursorPosition);
                                targetPoint = new Point(targetPoint.X, targetRect.Bottom - pageHeight);
                                acceleratedCursorPosition = This.TextView.GetTextPositionFromPoint(targetPoint, /*snapToText:*/ true);
                            }
                            else if (pointScroller.Y > pageHeight + slowAreaDelta)
                            {
                                Rect targetRect = This.TextView.GetRectangleFromTextPosition(snappedCursorPosition);
                                targetPoint = new Point(targetPoint.X, targetRect.Top + pageHeight);
                                acceleratedCursorPosition = This.TextView.GetTextPositionFromPoint(targetPoint, /*snapToText:*/ true);
                            }

                            double pageWidth = (double)((TextBoxBase)This.UiScope).ViewportWidth;

                            // Auto scrolling to left/right scroll delta amount if the mouse X position
                            // is out of viewport area.
                            if (pointScroller.X < 0)
                            {
                                targetPoint = new Point(targetPoint.X - slowAreaDelta, targetPoint.Y);
                                acceleratedCursorPosition = This.TextView.GetTextPositionFromPoint(targetPoint, /*snapToText:*/ true);
                            }
                            else if (pointScroller.X > pageWidth)
                            {
                                targetPoint = new Point(targetPoint.X + slowAreaDelta, targetPoint.Y);
                                acceleratedCursorPosition = This.TextView.GetTextPositionFromPoint(targetPoint, /*snapToText:*/ true);
                            }

                            // Use acceleratedcursorPosition instead of real one to make scrolling reasonable faster
                            if (acceleratedCursorPosition != null)
                            {
                                snappedCursorPosition = acceleratedCursorPosition;
                            }
                        }

                        using (This.Selection.DeclareChangeBlock())
                        {
                            // Check end-of-container condition
                            if (snappedCursorPosition.GetNextInsertionPosition(LogicalDirection.Forward) == null &&
                                snappedCursorPosition.ParentType != null) //
                            {
                                // We are at the end of text container. Check whether mouse is farther than a last character
                                Rect lastCharacterRect = snappedCursorPosition.GetCharacterRect(LogicalDirection.Backward);
                                if (mouseMovePoint.X > lastCharacterRect.X + lastCharacterRect.Width)
                                {
                                    snappedCursorPosition = This.TextContainer.End;
                                }
                            }

                            // Move the caret/selection to match the cursor position.
                            This.Selection.ExtendSelectionByMouse(snappedCursorPosition, This._forceWordSelection, This._forceParagraphSelection);
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        //------------------------------------------------------
        //
        //  Private Methods
        //
        //------------------------------------------------------

        #region Private Methods

        // ................................................................
        //
        // Event Handlers: Selection Building
        //
        // ................................................................

        // MouseMoveEvent handler.
        private static void OnMouseMoveWithoutFocus(TextEditor This, MouseEventArgs e)
        {
            // Note that position can be null here, because we did not request to snap it to text
            TextEditorMouse.UpdateCursor(This, e.GetPosition(This.TextView.RenderScope));
        }
Exemplo n.º 11
0
        // MouseUpEvent handler.
        internal static void OnMouseUp(object sender, MouseButtonEventArgs e)
        {
            TextEditor This = TextEditor._GetTextEditor(sender);

            if (e.ChangedButton != MouseButton.Left)
            {
                return;
            }

            if (e.RightButton != MouseButtonState.Released)
            {
                return;
            }

            if (This == null)
            {
                return;
            }

            // Ignore the event if the editor has been detached from its scope
            if (!This._IsEnabled)
            {
                return;
            }

            if (This.TextView == null || !This.TextView.IsValid)
            {
                return;
            }

            if (!This.UiScope.IsMouseCaptured)
            {
                return;
            }

            // Consider event handled
            e.Handled = true;

            This.CancelExtendSelection();

            // Calculate coordinates of mouse poinnt
            Point mousePoint = e.GetPosition(This.TextView.RenderScope);

            //
            TextEditorMouse.UpdateCursor(This, mousePoint);

            if (This._tableColResizeInfo != null)
            {
                // Apply resizing and dispose table resizing adorner
                using (This.Selection.DeclareChangeBlock())
                {
                    This._tableColResizeInfo.ResizeColumn(mousePoint);
                    This._tableColResizeInfo = null;
                }
            }
            else
            {
                using (This.Selection.DeclareChangeBlock())
                {
                    // Check for deferred selection (in case if mouse down was within selection)
                    This._dragDropProcess.DoMouseLeftButtonUp(e);

                    This._forceWordSelection      = false;
                    This._forceParagraphSelection = false;
                }
            }

            // Release mouse capture. TextView can be not valid by calling ReleaseMouseCapture()
            // if someone chnage the content(or background) by listening mouse movement.
            This._mouseCapturingInProgress = true;
            try
            {
                This.UiScope.ReleaseMouseCapture();
            }
            finally
            {
                This._mouseCapturingInProgress = false;
            }
        }
        // Token: 0x0600387F RID: 14463 RVA: 0x000FD304 File Offset: 0x000FB504
        internal static void OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            TextEditor textEditor = TextEditor._GetTextEditor(sender);

            if (textEditor == null)
            {
                return;
            }
            textEditor.CloseToolTip();
            if (!textEditor._IsEnabled)
            {
                return;
            }
            if (!textEditor.UiScope.Focusable)
            {
                return;
            }
            if (e.ButtonState == MouseButtonState.Released)
            {
                return;
            }
            e.Handled = true;
            TextEditorMouse.MoveFocusToUiScope(textEditor);
            if (textEditor.UiScope != Keyboard.FocusedElement)
            {
                return;
            }
            if (e.ChangedButton != MouseButton.Left)
            {
                return;
            }
            if (textEditor.TextView == null)
            {
                return;
            }
            textEditor.CompleteComposition();
            if (!textEditor.TextView.IsValid)
            {
                textEditor.TextView.RenderScope.UpdateLayout();
                if (textEditor.TextView == null || !textEditor.TextView.IsValid)
                {
                    return;
                }
            }
            if (!TextEditorMouse.IsPointWithinInteractiveArea(textEditor, e.GetPosition(textEditor.UiScope)))
            {
                return;
            }
            textEditor.TextView.ThrottleBackgroundTasksForUserInput();
            Point position = e.GetPosition(textEditor.TextView.RenderScope);

            if (TextEditor.IsTableEditingEnabled && TextRangeEditTables.TableBorderHitTest(textEditor.TextView, position))
            {
                textEditor._tableColResizeInfo = TextRangeEditTables.StartColumnResize(textEditor.TextView, position);
                Invariant.Assert(textEditor._tableColResizeInfo != null);
                textEditor._mouseCapturingInProgress = true;
                try
                {
                    textEditor.UiScope.CaptureMouse();
                    return;
                }
                finally
                {
                    textEditor._mouseCapturingInProgress = false;
                }
            }
            textEditor.Selection.BeginChange();
            try
            {
                TextEditorMouse.SetCaretPositionOnMouseEvent(textEditor, position, e.ChangedButton, e.ClickCount);
                textEditor._mouseCapturingInProgress = true;
                textEditor.UiScope.CaptureMouse();
            }
            finally
            {
                textEditor._mouseCapturingInProgress = false;
                textEditor.Selection.EndChange();
            }
        }
        // Token: 0x06003884 RID: 14468 RVA: 0x000FD66C File Offset: 0x000FB86C
        private static void OnMouseMoveWithFocus(TextEditor This, MouseEventArgs e)
        {
            if (This._mouseCapturingInProgress)
            {
                return;
            }
            TextEditor._ThreadLocalStore.PureControlShift = false;
            Point position = e.GetPosition(This.TextView.RenderScope);

            TextEditorMouse.UpdateCursor(This, position);
            Invariant.Assert(This.Selection != null);
            if (e.LeftButton != MouseButtonState.Pressed)
            {
                return;
            }
            if (!This.UiScope.IsMouseCaptured)
            {
                return;
            }
            This.TextView.ThrottleBackgroundTasksForUserInput();
            if (This._tableColResizeInfo != null)
            {
                This._tableColResizeInfo.UpdateAdorner(position);
                return;
            }
            e.Handled = true;
            Invariant.Assert(This.Selection != null);
            ITextPointer textPointer = This.TextView.GetTextPositionFromPoint(position, true);

            Invariant.Assert(This.Selection != null);
            if (textPointer == null)
            {
                This.RequestExtendSelection(position);
                return;
            }
            This.CancelExtendSelection();
            Invariant.Assert(This.Selection != null);
            if (!This._dragDropProcess.SourceOnMouseMove(position))
            {
                FrameworkElement scroller = This._Scroller;
                if (scroller != null && This.UiScope is TextBoxBase)
                {
                    ITextPointer textPointer2 = null;
                    Point        point        = new Point(position.X, position.Y);
                    Point        position2    = e.GetPosition(scroller);
                    double       num          = ((TextBoxBase)This.UiScope).ViewportHeight;
                    double       num2         = 16.0;
                    if (position2.Y < 0.0 - num2)
                    {
                        Rect rectangleFromTextPosition = This.TextView.GetRectangleFromTextPosition(textPointer);
                        point        = new Point(point.X, rectangleFromTextPosition.Bottom - num);
                        textPointer2 = This.TextView.GetTextPositionFromPoint(point, true);
                    }
                    else if (position2.Y > num + num2)
                    {
                        Rect rectangleFromTextPosition2 = This.TextView.GetRectangleFromTextPosition(textPointer);
                        point        = new Point(point.X, rectangleFromTextPosition2.Top + num);
                        textPointer2 = This.TextView.GetTextPositionFromPoint(point, true);
                    }
                    double num3 = ((TextBoxBase)This.UiScope).ViewportWidth;
                    if (position2.X < 0.0)
                    {
                        point        = new Point(point.X - num2, point.Y);
                        textPointer2 = This.TextView.GetTextPositionFromPoint(point, true);
                    }
                    else if (position2.X > num3)
                    {
                        point        = new Point(point.X + num2, point.Y);
                        textPointer2 = This.TextView.GetTextPositionFromPoint(point, true);
                    }
                    if (textPointer2 != null)
                    {
                        textPointer = textPointer2;
                    }
                }
                using (This.Selection.DeclareChangeBlock())
                {
                    if (textPointer.GetNextInsertionPosition(LogicalDirection.Forward) == null && textPointer.ParentType != null)
                    {
                        Rect characterRect = textPointer.GetCharacterRect(LogicalDirection.Backward);
                        if (position.X > characterRect.X + characterRect.Width)
                        {
                            textPointer = This.TextContainer.End;
                        }
                    }
                    This.Selection.ExtendSelectionByMouse(textPointer, This._forceWordSelection, This._forceParagraphSelection);
                }
            }
        }
 // Token: 0x06003883 RID: 14467 RVA: 0x000FD653 File Offset: 0x000FB853
 private static void OnMouseMoveWithoutFocus(TextEditor This, MouseEventArgs e)
 {
     TextEditorMouse.UpdateCursor(This, e.GetPosition(This.TextView.RenderScope));
 }