Ejemplo n.º 1
0
        public override void HandleMouseDown(Point mousePos, MouseButtons mouseButtons)
        {
            int clickedVisibleLine = (mousePos.Y + textArea.VirtualTop.Y) / textArea.TextView.FontHeight;
            int lineNumber         = textArea.Document.GetFirstLogicalLine(clickedVisibleLine);

            if (textArea.Caret.Line != lineNumber)
            {
                textArea.Caret.Line = lineNumber;
            }

            IList <Bookmark> marks       = textArea.Document.BookmarkManager.Marks;
            List <Bookmark>  marksInLine = new List <Bookmark>();
            int oldBookCount             = marks.Count;

            foreach (Bookmark mark in marks)
            {
                if (mark.LineNumber == lineNumber)
                {
                    marksInLine.Add(mark);
                }
            }
            IList <Breakpoint> breaks       = textArea.Document.BreakpointManager.Marks;
            List <Breakpoint>  breaksInLine = new List <Breakpoint>();
            int oldBreakCount = breaks.Count;

            foreach (Breakpoint mark in breaks)
            {
                if (mark.LineNumber == lineNumber)
                {
                    breaksInLine.Add(mark);
                }
            }
            for (int i = marksInLine.Count - 1; i >= 0; i--)
            {
                Bookmark mark = marksInLine[i];
                if (!mark.Click(textArea, new MouseEventArgs(mouseButtons, 1, mousePos.X, mousePos.Y, 0)))
                {
                    continue;
                }
                if (oldBookCount != marks.Count)
                {
                    textArea.UpdateLine(lineNumber);
                }
                return;
            }
            for (int i = breaksInLine.Count - 1; i >= 0; i--)
            {
                Breakpoint mark = breaksInLine[i];
                if (!mark.Click(textArea, new MouseEventArgs(mouseButtons, 1, mousePos.X, mousePos.Y, 0)))
                {
                    continue;
                }
                if (oldBreakCount != marks.Count)
                {
                    textArea.UpdateLine(lineNumber);
                }
                return;
            }
            Breakpoint newBreak = new Breakpoint(textArea.Document, new TextLocation(0, lineNumber));

            newBreak.Click(textArea, new MouseEventArgs(mouseButtons, 1, mousePos.X, mousePos.Y, 0));
            textArea.UpdateLine(lineNumber);
            base.HandleMouseDown(mousePos, mouseButtons);
        }