Example #1
0
    private void Me_MouseDown(Object sender, MouseEventArgs e)
    {
        Focus();
        if (e.Button == MouseButtons.Right)
        {
            ContextMenu.Show(this, new System.Drawing.Point(e.X, e.Y));
            return;
        }
        Point pt          = new Point(e.X, e.Y);
        long  timeMessage = DateTime.Now.Ticks;

        //~ Console.Error.WriteLine("Mouse pressed " + e.X + "," + e.Y + " @ " + timeMessage);

        int posPoint = PositionFromLocation(pt);

        if (tv.ColumnTypeFromLocation(pt) == TextColumn.tcFold)
        {
            panel.FoldLine(panel.pdoc.pbuffer.LineFromPosition(posPoint), panel.fcDiscover);
            return;
        }
        bool altDown = (Control.ModifierKeys & Keys.Control) != 0;

        /*
         * if (panel.pstyleFeedBack.ValueAt(posPoint) != 0) {
         *      ShowFeedBack(posPoint, true, altDown);
         *      return;
         * }
         */
        mouseDragLast = pt;
        if (((timeMessage - timeLastClick) < doubleClickTime) &&
            (lastClickAt.DistanceSquared(pt) < 20))
        {
            selType = (selType + 1) % 3;
        }
        else
        {
            selType = 0;
        }
        if (selType == 0)
        {
            panel.MoveCaret(posPoint, false);
        }
        else if (selType == 1)                  // Word selection
        {
            panel.SetSelection(panel.pdoc.ExtendWordSelect(posPoint, -1),
                               panel.pdoc.ExtendWordSelect(posPoint, 1));
            Invalidate();
            panel.EnsureCaretVisible();
        }
        else if (selType == 2)                  // Line selection
        {
            int line = panel.pdoc.pbuffer.LineFromPosition(posPoint);
            panel.SetSelection(panel.pdoc.pbuffer.PositionFromLine(line),
                               panel.pdoc.pbuffer.LineEndPositionFromLine(line));
            Invalidate();
            panel.EnsureCaretVisible();
        }
        lastClickAt   = pt;
        timeLastClick = timeMessage;
    }