GetFoldMarkerFromPosition() public method

returns line/column for a visual point position
public GetFoldMarkerFromPosition ( int visualPosX, int visualPosY ) : ICSharpCode.TextEditor.Document.FoldMarker
visualPosX int
visualPosY int
return ICSharpCode.TextEditor.Document.FoldMarker
        private void DoubleClickSelectionExtend()
        {
            Point point = this.textArea.mousepos;

            this.textArea.SelectionManager.ClearSelection();
            if (this.textArea.TextView.DrawingPosition.Contains(point.X, point.Y))
            {
                TextView   textView               = this.textArea.TextView;
                int        x                      = point.X - this.textArea.TextView.DrawingPosition.X;
                int        y                      = point.Y;
                Rectangle  drawingPosition        = this.textArea.TextView.DrawingPosition;
                FoldMarker foldMarkerFromPosition = textView.GetFoldMarkerFromPosition(x, y - drawingPosition.Y);
                if (foldMarkerFromPosition != null && foldMarkerFromPosition.IsFolded)
                {
                    foldMarkerFromPosition.IsFolded = false;
                    this.textArea.MotherTextAreaControl.AdjustScrollBars();
                }
                if (this.textArea.Caret.Offset < this.textArea.Document.TextLength)
                {
                    if (this.textArea.Document.GetCharAt(this.textArea.Caret.Offset) != '\"')
                    {
                        this.minSelection = this.textArea.Document.OffsetToPosition(this.FindWordStart(this.textArea.Document, this.textArea.Caret.Offset));
                        this.maxSelection = this.textArea.Document.OffsetToPosition(this.FindWordEnd(this.textArea.Document, this.textArea.Caret.Offset));
                    }
                    else if (this.textArea.Caret.Offset < this.textArea.Document.TextLength)
                    {
                        int num = this.FindNext(this.textArea.Document, this.textArea.Caret.Offset + 1, '\"');
                        this.minSelection = this.textArea.Caret.Position;
                        if (num > this.textArea.Caret.Offset && num < this.textArea.Document.TextLength)
                        {
                            num++;
                        }
                        this.maxSelection = this.textArea.Document.OffsetToPosition(num);
                    }
                    this.textArea.Caret.Position = this.maxSelection;
                    this.textArea.SelectionManager.ExtendSelection(this.minSelection, this.maxSelection);
                }
                if (this.textArea.SelectionManager.selectionCollection.Count > 0)
                {
                    ISelection item = this.textArea.SelectionManager.selectionCollection[0];
                    item.StartPosition = this.minSelection;
                    item.EndPosition   = this.maxSelection;
                    this.textArea.SelectionManager.SelectionStart = this.minSelection;
                }
                this.textArea.SetDesiredColumn();
                this.textArea.Refresh();
            }
        }
        private void OnToolTipRequest(object sender, ToolTipRequestEventArgs e)
        {
            if (e.ToolTipShown)
            {
                return;
            }
            Point      mousePosition          = e.MousePosition;
            TextView   textView               = this.textArea.TextView;
            int        x                      = mousePosition.X - this.textArea.TextView.DrawingPosition.X;
            int        y                      = mousePosition.Y;
            Rectangle  drawingPosition        = this.textArea.TextView.DrawingPosition;
            FoldMarker foldMarkerFromPosition = textView.GetFoldMarkerFromPosition(x, y - drawingPosition.Y);

            if (foldMarkerFromPosition == null || !foldMarkerFromPosition.IsFolded)
            {
                foreach (TextMarker marker in this.textArea.Document.MarkerStrategy.GetMarkers(e.LogicalPosition))
                {
                    if (marker.ToolTip == null)
                    {
                        continue;
                    }
                    e.ShowToolTip(marker.ToolTip.Replace("\t", "    "));
                    return;
                }
                return;
            }
            StringBuilder stringBuilder = new StringBuilder(foldMarkerFromPosition.InnerText);
            int           num           = 0;

            for (int i = 0; i < stringBuilder.Length; i++)
            {
                if (stringBuilder[i] == '\n')
                {
                    num++;
                    if (num >= 10)
                    {
                        stringBuilder.Remove(i + 1, stringBuilder.Length - i - 1);
                        stringBuilder.Append(Environment.NewLine);
                        stringBuilder.Append("...");
                        break;
                    }
                }
            }
            stringBuilder.Replace("\t", "    ");
            e.ShowToolTip(stringBuilder.ToString());
        }
        private void OnMouseDown(object sender, MouseEventArgs e)
        {
            this.textArea.mousepos = e.Location;
            Point location = e.Location;

            if (this.dodragdrop)
            {
                return;
            }
            if (this.doubleclick)
            {
                this.doubleclick = false;
                return;
            }
            if (this.textArea.TextView.DrawingPosition.Contains(location.X, location.Y))
            {
                this.gotmousedown = true;
                this.textArea.SelectionManager.selectFrom.@where = 2;
                this.button = e.Button;
                if (this.button == MouseButtons.Left && e.Clicks == 2)
                {
                    int num  = Math.Abs(this.lastmousedownpos.X - e.X);
                    int num1 = Math.Abs(this.lastmousedownpos.Y - e.Y);
                    if (num <= SystemInformation.DoubleClickSize.Width && num1 <= SystemInformation.DoubleClickSize.Height)
                    {
                        this.DoubleClickSelectionExtend();
                        this.lastmousedownpos = new Point(e.X, e.Y);
                        if (this.textArea.SelectionManager.selectFrom.@where == 1 && !this.minSelection.IsEmpty && !this.maxSelection.IsEmpty && this.textArea.SelectionManager.SelectionCollection.Count > 0)
                        {
                            this.textArea.SelectionManager.SelectionCollection[0].StartPosition = this.minSelection;
                            this.textArea.SelectionManager.SelectionCollection[0].EndPosition   = this.maxSelection;
                            this.textArea.SelectionManager.SelectionStart = this.minSelection;
                            this.minSelection = TextLocation.Empty;
                            this.maxSelection = TextLocation.Empty;
                        }
                        return;
                    }
                }
                this.minSelection = TextLocation.Empty;
                this.maxSelection = TextLocation.Empty;
                Point point  = new Point(e.X, e.Y);
                Point point1 = point;
                this.mousedownpos     = point;
                this.lastmousedownpos = point1;
                if (this.button == MouseButtons.Left)
                {
                    TextView   textView               = this.textArea.TextView;
                    int        x                      = location.X - this.textArea.TextView.DrawingPosition.X;
                    int        y                      = location.Y;
                    Rectangle  drawingPosition        = this.textArea.TextView.DrawingPosition;
                    FoldMarker foldMarkerFromPosition = textView.GetFoldMarkerFromPosition(x, y - drawingPosition.Y);
                    if (foldMarkerFromPosition != null && foldMarkerFromPosition.IsFolded)
                    {
                        if (this.textArea.SelectionManager.HasSomethingSelected)
                        {
                            this.clickedOnSelectedText = true;
                        }
                        TextLocation textLocation  = new TextLocation(foldMarkerFromPosition.StartColumn, foldMarkerFromPosition.StartLine);
                        TextLocation textLocation1 = new TextLocation(foldMarkerFromPosition.EndColumn, foldMarkerFromPosition.EndLine);
                        this.textArea.SelectionManager.SetSelection(new DefaultSelection(this.textArea.TextView.Document, textLocation, textLocation1));
                        this.textArea.Caret.Position = textLocation;
                        this.textArea.SetDesiredColumn();
                        this.textArea.Focus();
                        return;
                    }
                    if ((Control.ModifierKeys & Keys.Shift) != Keys.Shift)
                    {
                        TextView     textView1       = this.textArea.TextView;
                        int          x1              = location.X - this.textArea.TextView.DrawingPosition.X;
                        int          y1              = location.Y;
                        Rectangle    rectangle       = this.textArea.TextView.DrawingPosition;
                        TextLocation logicalPosition = textView1.GetLogicalPosition(x1, y1 - rectangle.Y);
                        this.clickedOnSelectedText = false;
                        int offset = this.textArea.Document.PositionToOffset(logicalPosition);
                        if (!this.textArea.SelectionManager.HasSomethingSelected || !this.textArea.SelectionManager.IsSelected(offset))
                        {
                            this.textArea.SelectionManager.ClearSelection();
                            if (location.Y > 0 && location.Y < this.textArea.TextView.DrawingPosition.Height)
                            {
                                TextLocation textLocation2 = new TextLocation()
                                {
                                    Y = Math.Min(this.textArea.Document.TotalNumberOfLines - 1, logicalPosition.Y),
                                    X = logicalPosition.X
                                };
                                this.textArea.Caret.Position = textLocation2;
                                this.textArea.SetDesiredColumn();
                            }
                        }
                        else
                        {
                            this.clickedOnSelectedText = true;
                        }
                    }
                    else
                    {
                        this.ExtendSelectionToMouse();
                    }
                }
                else if (this.button == MouseButtons.Right)
                {
                    TextView     textView2        = this.textArea.TextView;
                    int          x2               = location.X - this.textArea.TextView.DrawingPosition.X;
                    int          y2               = location.Y;
                    Rectangle    drawingPosition1 = this.textArea.TextView.DrawingPosition;
                    TextLocation logicalPosition1 = textView2.GetLogicalPosition(x2, y2 - drawingPosition1.Y);
                    int          offset1          = this.textArea.Document.PositionToOffset(logicalPosition1);
                    if (!this.textArea.SelectionManager.HasSomethingSelected || !this.textArea.SelectionManager.IsSelected(offset1))
                    {
                        this.textArea.SelectionManager.ClearSelection();
                        if (location.Y > 0 && location.Y < this.textArea.TextView.DrawingPosition.Height)
                        {
                            TextLocation textLocation3 = new TextLocation()
                            {
                                Y = Math.Min(this.textArea.Document.TotalNumberOfLines - 1, logicalPosition1.Y),
                                X = logicalPosition1.X
                            };
                            this.textArea.Caret.Position = textLocation3;
                            this.textArea.SetDesiredColumn();
                        }
                    }
                }
            }
            this.textArea.Focus();
        }