public void highlightCurrentPlayer(bool highlight) { if (playerHexSelection != null) { playerHexSelection.Dispose(); playerHexSelection = null; } if (highlight) { this.playerHexSelection = new HexSelection(this.lhg, CurrentPlayer.getCurrentHex(), HexSelection.Type.Pulsate, true, 15, Color.Yellow); this.playerHexSelection.Pulsate = true; } }
public void SelectAndMoveCaret(ulong fileOffset, ulong length) { ulong end = length == 0 ? fileOffset : fileOffset + length - 1 < fileOffset ? ulong.MaxValue : fileOffset + length - 1; if (length == 0) { Selection = null; } else { Selection = new HexSelection(end, fileOffset); } SetCaretPositionAndMakeVisible(fileOffset, end, true); }
public static HexBufferSpan GetLineAnchorSpan(HexSelection selection) { if (selection == null) { throw new ArgumentNullException(nameof(selection)); } if (selection.IsEmpty) { return(selection.HexView.Caret.ContainingHexViewLine.BufferSpan); } var anchorExtent = selection.HexView.GetHexViewLineContainingBufferPosition(selection.AnchorPoint).BufferSpan; if (selection.AnchorPoint >= selection.ActivePoint) { if (anchorExtent.Start == selection.AnchorPoint && selection.AnchorPoint > selection.HexView.BufferLines.BufferStart) { anchorExtent = selection.HexView.GetHexViewLineContainingBufferPosition(selection.AnchorPoint - 1).BufferSpan; } } return(anchorExtent); }
public static string GetText(this HexSelection selection) { var bufferLines = selection.HexView.BufferLines; var span = selection.StreamSelectionSpan; var sb = new StringBuilder(); var pos = span.Start; for (;;) { var line = bufferLines.GetLineFromPosition(pos); sb.AppendLine(line.GetText(span)); pos = line.BufferEnd; if (pos >= span.End) { break; } } return(sb.ToString()); }
public void SelectAll() { Selection = new HexSelection(StartOffset, EndOffset); SetCaretPosition(MoveToEndOfSelection(CaretPosition)); }
void UpdateCaptureMouseSelection(ulong? startOffset, HexBoxPosition position, HexPositionUI uiPos) { SetCaretPosition(position); if (startOffset == null) return; if (Selection != null || uiPos != mouseCaptureStartPosUI) Selection = new HexSelection(startOffset.Value, position.Offset); }
void SelectText(Action action) { var pos = CaretPosition; var oldSel = Selection; action(); Debug.Assert(oldSel == Selection); if (CaretPosition == pos) return; if (Selection == null) Selection = new HexSelection(pos.Offset, CaretPosition.Offset); else Selection = new HexSelection(Selection.Value.From, CaretPosition.Offset); }
public void SelectAndMoveCaret(ulong fileOffset, ulong length) { ulong end = length == 0 ? fileOffset : fileOffset + length - 1 < fileOffset ? ulong.MaxValue : fileOffset + length - 1; if (length == 0) Selection = null; else Selection = new HexSelection(end, fileOffset); SetCaretPositionAndMakeVisible(fileOffset, end, true); }
public SelectionState(HexSelection selection) => state = (byte)(selection.IsEmpty ? 1 : 0);