Пример #1
0
            private DoxTokenTag FindSpanTag(System.Windows.Input.MouseEventArgs args)
            {
                try
                {
                    // find canavas
                    var    over   = System.Windows.Input.Mouse.PrimaryDevice.DirectlyOver;
                    Canvas canvas = over as Canvas;
                    if (canvas == null)
                    {
                        System.Windows.FrameworkElement elem = over as System.Windows.FrameworkElement;
                        while (elem != null && elem.Parent != null)
                        {
                            canvas = elem as Canvas;
                            if (canvas != null)
                            {
                                break;
                            }
                            elem = elem.Parent as System.Windows.FrameworkElement;
                        }
                    }
                    if (canvas == null)
                    {
                        return(null);
                    }

                    // get mouse position relative to canavas
                    System.Windows.Point pos = args.GetPosition(canvas);
                    // HitTestResult hitRes = VisualTreeHelper.HitTest(canvas, pos);

                    // find the line where the mouse hovers
                    var lines = this.WpfTextView.TextViewLines;
                    Microsoft.VisualStudio.Text.Formatting.ITextViewLine hitLine = null;
                    foreach (var line in lines)
                    {
                        if (line.Left < pos.X && line.Right > pos.X && line.Top < pos.Y && line.Bottom > pos.Y)
                        {
                            hitLine = line;
                            break;
                        }
                    }
                    if (hitLine == null)
                    {
                        return(null);
                    }

                    // find the positon in the line where the mouse hovers
                    SnapshotPoint?snapPt = hitLine.GetBufferPositionFromXCoordinate(pos.X);
                    if (snapPt == null)
                    {
                        return(null);
                    }

                    // find doxygen tag
                    DoxTokenTag spanInfo = DoxTokenTaggerHelper.TagHitTest(this.Aggregator, this.WpfTextView.TextSnapshot, snapPt.Value);
                    return(spanInfo);
                }
                catch { }
                return(null);
            }
Пример #2
0
        /// <summary>
        /// Given an IWpfTextView, find the position of the caret and report its column number
        /// The column number is 0-based
        /// </summary>
        /// <param name="textView">The text view containing the caret</param>
        /// <returns>The column number of the caret's position. When the caret is at the leftmost column, the return value is zero.</returns>
        private static int GetCaretColumn(IWpfTextView textView)
        {
            // This is the code the editor uses to populate the status bar. Thanks, Jack!
            Microsoft.VisualStudio.Text.Formatting.ITextViewLine caretViewLine = textView.Caret.ContainingTextViewLine;
            double columnWidth = textView.FormattedLineSource.ColumnWidth;

            return((int)(Math.Round((textView.Caret.Left - caretViewLine.Left) / columnWidth)));
        }
Пример #3
0
 public Microsoft.VisualStudio.Text.VirtualSnapshotSpan?GetSelectionOnTextViewLine(Microsoft.VisualStudio.Text.Formatting.ITextViewLine line)
 {
     throw new NotImplementedException();
 }
Пример #4
0
 public CaretPosition MoveTo(Microsoft.VisualStudio.Text.Formatting.ITextViewLine textLine, double xCoordinate, bool captureHorizontalPosition)
 {
     throw new System.NotImplementedException();
 }
Пример #5
0
 public CaretPosition MoveTo(Microsoft.VisualStudio.Text.Formatting.ITextViewLine textLine)
 {
     throw new System.NotImplementedException();
 }