Example #1
0
        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;
            }
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        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());
        }
Example #5
0
 public void SelectAll()
 {
     Selection = new HexSelection(StartOffset, EndOffset);
     SetCaretPosition(MoveToEndOfSelection(CaretPosition));
 }
Example #6
0
 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);
 }
Example #7
0
 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);
 }
Example #8
0
 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);
 }
Example #9
0
 public SelectionState(HexSelection selection) => state = (byte)(selection.IsEmpty ? 1 : 0);