public void OnWordMouseDown(ref WordMouseEventArgs e) { if (WordMouseDown != null) WordMouseDown(this, ref e); }
/// <summary> /// Overrides the default OnMouseDown /// </summary> /// <param name="e"></param> 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); }
public void OnWordMouseHover(ref WordMouseEventArgs e) { if (WordMouseHover != null) WordMouseHover(this, ref e); }
private void SetMouseCursor(int x, int y) { if (_SyntaxBox.LockCursorUpdate) { Cursor = _SyntaxBox.Cursor; return; } if (View.Action == EditAction.DragText) { Cursor = Cursors.Hand; //Cursor.Current = Cursors.Hand; } else { if (x < View.TotalMarginWidth) { if (x < View.GutterMarginWidth) { Cursor = Cursors.Arrow; } else { var ms = new MemoryStream(Properties.Resources.FlippedCursor); Cursor = new Cursor(ms); } } else { if (x > View.TextMargin - 8) { if (IsOverSelection(x, y)) Cursor = Cursors.Arrow; else { TextPoint tp = Painter.CharFromPixel(x, y); Word w = Document.GetWordFromPos(tp); if (w != null && w.Pattern != null && w.Pattern.Category != null) { var e = new WordMouseEventArgs { Pattern = w.Pattern, Button = MouseButtons.None, Cursor = Cursors.Hand, Word = w }; _SyntaxBox.OnWordMouseHover(ref e); Cursor = e.Cursor; } else Cursor = Cursors.IBeam; } } else { Cursor = Cursors.Arrow; } } } }