protected override void OnMouseDown(MouseEventArgs e)
{
MouseX = e.X;
MouseY = e.Y;
SetFocus();
base.OnMouseDown(e);
TextPoint pos = Painter.CharFromPixel(e.X, e.Y);
Row row = null;
if (pos.Y >= 0 && pos.Y < Document.Count)
row = Document[pos.Y];
#region RowEvent
var rea = new RowMouseEventArgs {Row = row, Button = e.Button, MouseX = MouseX, MouseY = MouseY};
if (e.X >= View.TextMargin - 7)
{
rea.Area = RowArea.TextArea;
}
else if (e.X < View.GutterMarginWidth)
{
rea.Area = RowArea.GutterArea;
}
else if (e.X < View.LineNumberMarginWidth +
View.GutterMarginWidth)
{
rea.Area = RowArea.LineNumberArea;
}
else if (e.X < View.TextMargin - 7)
{
rea.Area = RowArea.FoldingArea;
}
OnRowMouseDown(rea);
#endregion
try
{
Row r2 = Document[pos.Y];
if (r2 != null)
{
if (e.X >= r2.Expansion_PixelEnd && r2.IsCollapsed)
{
if (r2.expansion_StartSpan != null)
{
if (r2.expansion_StartSpan.StartRow != null &&
r2.expansion_StartSpan.EndRow != null &&
r2.expansion_StartSpan.Expanded == false)
{
if (!IsOverSelection(e.X, e.Y))
{
Caret.Position.X = pos.X;
Caret.Position.Y = pos.Y;
Selection.ClearSelection();
Row r3 = r2.Expansion_EndRow;
int x3 = r3.Expansion_StartChar;
Caret.Position.X = x3;
Caret.Position.Y = r3.Index;
Selection.MakeSelection();
Redraw();
View.Action = EditAction.SelectText;
return;
}
}
}
}
}
}
catch
{
//this is untested code...
}
bool shift = NativeMethods.IsKeyPressed(Keys.ShiftKey);
if (e.X > View.TotalMarginWidth)
{
if (e.X > View.TextMargin - 8)
{
if (!IsOverSelection(e.X, e.Y))
{
//selecting
if (e.Button == MouseButtons.Left)
{
if (!shift)
{
TextPoint tp = pos;
Word w = Document.GetWordFromPos(tp);
if (w != null && w.Pattern != null && w.Pattern.Category !=
null)
{
var pe = new WordMouseEventArgs
{
Pattern = w.Pattern,
Button = e.Button,
Cursor = Cursors.Hand,
Word = w
};
_SyntaxBox.OnWordMouseDown(ref pe);
Cursor = pe.Cursor;
return;
}
View.Action = EditAction.SelectText;
Caret.SetPos(pos);
Selection.ClearSelection();
Caret.Blink = true;
Redraw();
}
else
{
View.Action = EditAction.SelectText;
Caret.SetPos(pos);
Selection.MakeSelection();
Caret.Blink = true;
Redraw();
}
}
}
}
else
{
if (row != null)
if (row.expansion_StartSpan != null)
{
Caret.SetPos(new TextPoint(0, pos.Y));
Selection.ClearSelection();
Document.ToggleRow(row);
Redraw();
}
}
}
else
{
if (e.X < View.GutterMarginWidth)
{
if (_SyntaxBox.AllowBreakPoints)
{
Row r = Document[Painter.CharFromPixel(e.X, e.Y).Y];
r.Breakpoint = !r.Breakpoint;
Redraw();
}
else
{
Row r = Document[Painter.CharFromPixel(e.X, e.Y).Y];
r.Breakpoint = false;
Redraw();
}
}
else
{
View.Action = EditAction.SelectText;
Caret.SetPos(Painter.CharFromPixel(0, e.Y));
Selection.ClearSelection();
Caret.MoveDown(true);
Redraw();
}
}
SetMouseCursor(e.X, e.Y);
}