public override void OnMouseLeftButtonDown(object?sender, MouseButtonEventArgs e) { e.Handled = true; var mouseLoc = GetLocation(e); int clickCount = e.ClickCount; if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == ModifierKeys.Control) { clickCount = 2; } switch (clickCount) { default: case 1: bool isShift = (Keyboard.Modifiers & ModifierKeys.Shift) != 0; bool isAlt = (Keyboard.Modifiers & ModifierKeys.Alt) != 0; if (!isShift && !isAlt) { wpfTextView.Selection.Mode = TextSelectionMode.Stream; } SelectToMousePosition(mouseLoc, isShift, isAlt); break; case 2: editorOperations.MoveCaret(mouseLoc.TextViewLine, mouseLoc.Point.X, false); editorOperations.SelectCurrentWord(); break; case 3: editorOperations.SelectLine(mouseLoc.TextViewLine, false); // Seems to match VS behavior var end = mouseLoc.TextViewLine.TextRight; if (mouseLoc.TextViewLine.IsLastTextViewLineForSnapshotLine) { end += wpfTextView.FormattedLineSource.ColumnWidth; } if (mouseLoc.Point.X < end) { wpfTextView.Caret.MoveTo(mouseLoc.TextViewLine.Start); } break; } wpfTextView.Caret.EnsureVisible(); mouseLeftDownInfo = new MouseLeftDownInfo(GetSelectionOrCaretIfNoSelection(), mouseLoc.Point, clickCount, wpfTextView.TextSnapshot.Version); }
public override void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { e.Handled = true; var mouseLoc = GetLocation(e); bool isOffsetColumn = mouseLoc.HexViewLine.BufferLine.GetLinePositionInfo(mouseLoc.Position).IsOffset; int clickCount = e.ClickCount; if (isOffsetColumn) { clickCount = 3; } else if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == ModifierKeys.Control) { clickCount = 2; } switch (clickCount) { default: case 1: bool isShift = (Keyboard.Modifiers & ModifierKeys.Shift) != 0; SelectToMousePosition(mouseLoc, isShift); break; case 2: editorOperations.MoveCaret(mouseLoc.HexViewLine, mouseLoc.Point.X, false, hexMoveToFlags); editorOperations.SelectCurrentWord(); break; case 3: editorOperations.SelectLine(mouseLoc.HexViewLine, false); // Seems to match VS behavior var end = mouseLoc.HexViewLine.TextRight; end += wpfHexView.FormattedLineSource.ColumnWidth; if (mouseLoc.Point.X < end) { wpfHexView.Caret.MoveTo(mouseLoc.HexViewLine.BufferStart); } break; } wpfHexView.Caret.EnsureVisible(); mouseLeftDownInfo = new MouseLeftDownInfo(GetSelectionOrCaretIfNoSelection(), mouseLoc.Point, clickCount, wpfHexView.BufferLines); }
public override void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { e.Handled = true; var mouseLoc = GetLocation(e); int clickCount = e.ClickCount; if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == ModifierKeys.Control) clickCount = 2; switch (clickCount) { default: case 1: bool isShift = (Keyboard.Modifiers & ModifierKeys.Shift) != 0; bool isAlt = (Keyboard.Modifiers & ModifierKeys.Alt) != 0; if (!isShift && !isAlt) wpfTextView.Selection.Mode = TextSelectionMode.Stream; SelectToMousePosition(mouseLoc, isShift, isAlt); break; case 2: editorOperations.MoveCaret(mouseLoc.TextViewLine, mouseLoc.Point.X, false); editorOperations.SelectCurrentWord(); break; case 3: editorOperations.SelectLine(mouseLoc.TextViewLine, false); // Seems to match VS behavior var end = mouseLoc.TextViewLine.TextRight; if (mouseLoc.TextViewLine.IsLastTextViewLineForSnapshotLine) end += wpfTextView.FormattedLineSource.ColumnWidth; if (mouseLoc.Point.X < end) wpfTextView.Caret.MoveTo(mouseLoc.TextViewLine.Start); break; } wpfTextView.Caret.EnsureVisible(); mouseLeftDownInfo = new MouseLeftDownInfo(GetSelectionOrCaretIfNoSelection(), mouseLoc.Point, clickCount, wpfTextView.TextSnapshot.Version); }
public override void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { e.Handled = true; var mouseLoc = GetLocation(e); bool isOffsetColumn = mouseLoc.HexViewLine.BufferLine.GetLinePositionInfo(mouseLoc.Position).IsOffset; int clickCount = e.ClickCount; if (isOffsetColumn) clickCount = 3; else if ((Keyboard.Modifiers & (ModifierKeys.Control | ModifierKeys.Shift)) == ModifierKeys.Control) clickCount = 2; switch (clickCount) { default: case 1: bool isShift = (Keyboard.Modifiers & ModifierKeys.Shift) != 0; SelectToMousePosition(mouseLoc, isShift); break; case 2: editorOperations.MoveCaret(mouseLoc.HexViewLine, mouseLoc.Point.X, false, hexMoveToFlags); editorOperations.SelectCurrentWord(); break; case 3: editorOperations.SelectLine(mouseLoc.HexViewLine, false); // Seems to match VS behavior var end = mouseLoc.HexViewLine.TextRight; end += wpfHexView.FormattedLineSource.ColumnWidth; if (mouseLoc.Point.X < end) wpfHexView.Caret.MoveTo(mouseLoc.HexViewLine.BufferStart); break; } wpfHexView.Caret.EnsureVisible(); mouseLeftDownInfo = new MouseLeftDownInfo(GetSelectionOrCaretIfNoSelection(), mouseLoc.Point, clickCount, wpfHexView.BufferLines); }