private void UpdateSelectionInProgress(MouseEventArgs e) { int selectionCharIndex = selectionSnapPosition.CharIndex; if (selectionSnapPosition.Kind == SnapKind.Trailing) { selectionCharIndex += 1; } SnapPosition currentSnapPosition = GetSnapPositionAtPoint(MousePositionToLayout(e.Location)); if (currentSnapPosition.Kind == SnapKind.None) { InternalSetSelection(selectionCharIndex, 0); } else { int currentCharIndex = currentSnapPosition.CharIndex; if (currentSnapPosition.Kind == SnapKind.Trailing) { currentCharIndex += 1; } if (selectionCharIndex <= currentCharIndex) { InternalSetSelection(selectionCharIndex, currentCharIndex - selectionCharIndex); } else { InternalSetSelection(currentCharIndex, selectionCharIndex - currentCharIndex); } } }
/// <inheritdoc /> protected override void OnMouseDown(MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (!selectionInProgress) { selectionSnapPosition = GetSnapPositionAtPoint(MousePositionToLayout(e.Location)); SelectNone(); } } base.OnMouseDown(e); }