Create() public static method

public static Create ( IWpfTextView wpfTextView, System.Windows.Input.MouseEventArgs e, bool insertionPosition ) : MouseLocation
wpfTextView IWpfTextView
e System.Windows.Input.MouseEventArgs
insertionPosition bool
return MouseLocation
Beispiel #1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (mouseCaptured)
            {
                var mouseLoc = MouseLocation.Create(wpfTextViewHost.TextView, e, insertionPosition: false);
                var line     = mouseLoc.TextViewLine;
                editorOperations.SelectLine(line, true);
                // Needed or the scrolling will stop
                if (mouseLoc.Point.Y <= wpfTextViewHost.TextView.ViewportTop)
                {
                    editorOperations.ScrollUpAndMoveCaretIfNecessary();
                }
                else if (mouseLoc.Point.Y >= wpfTextViewHost.TextView.ViewportBottom)
                {
                    var lastVisLine = wpfTextViewHost.TextView.TextViewLines.LastVisibleLine;
                    if (!lastVisLine.IsLastDocumentLine() || lastVisLine.VisibilityState != VisibilityState.FullyVisible)
                    {
                        editorOperations.ScrollDownAndMoveCaretIfNecessary();
                    }
                }
                e.Handled = true;
                return;
            }

            base.OnMouseMove(e);
        }
Beispiel #2
0
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            if (CaptureMouse())
            {
                var line = MouseLocation.Create(wpfTextViewHost.TextView, e, insertionPosition: false).TextViewLine;
                editorOperations.SelectLine(line, (Keyboard.Modifiers & ModifierKeys.Shift) != 0);
                mouseCaptured = true;
                e.Handled     = true;
                return;
            }

            base.OnMouseLeftButtonDown(e);
        }
Beispiel #3
0
        IMappingTagSpan <IUrlTag> GetUriSpan(MouseEventArgs e)
        {
            if (!IsControlDown)
            {
                return(null);
            }
            var loc = MouseLocation.Create(wpfTextView, e, insertionPosition: false);

            if (loc.Position.VirtualSpaces > 0)
            {
                return(null);
            }
            return(UriHelper.GetUri(viewTagAggregatorFactoryService, wpfTextView, loc.Position.Position));
        }
Beispiel #4
0
        SnapshotSpan?GetUriSpan(MouseEventArgs e)
        {
            if (!IsControlDown)
            {
                return(null);
            }
            var loc = MouseLocation.Create(wpfTextView, e);

            if (loc.Position.VirtualSpaces > 0)
            {
                return(null);
            }
            return(UriHelper.GetUri(viewTagAggregatorFactoryService, wpfTextView, loc.Position.Position));
        }
        static TextEditorPosition GetTextEditorPositionFromMouse(IWpfTextView textView)
        {
            if (!textView.VisualElement.IsVisible)
            {
                return(null);
            }
            var loc = MouseLocation.Create(textView, new MouseEventArgs(Mouse.PrimaryDevice, 0), insertionPosition: true);

            if (loc.Point.Y < textView.ViewportTop || loc.Point.Y >= textView.ViewportBottom)
            {
                return(null);
            }
            if (loc.Point.X < textView.ViewportLeft || loc.Point.X >= textView.ViewportRight)
            {
                return(null);
            }
            return(new TextEditorPosition(loc.Position));
        }
 MouseLocation GetLocation(MouseEventArgs e) => MouseLocation.Create(wpfTextView, e, insertionPosition: true);
Beispiel #7
0
 MouseLocation GetLocation(MouseEventArgs e) => MouseLocation.Create(wpfTextView, e);