/*
Copyright (C) 2014-2019 de4dot@gmail.com
This file is part of dnSpy
dnSpy is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
dnSpy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with dnSpy. If not, see .
*/
using System;
using System.Collections.Generic;
using dnSpy.Contracts.Hex.Formatting;
using VST = Microsoft.VisualStudio.Text;
namespace dnSpy.Contracts.Hex.Editor {
///
/// Hex selection
///
public abstract class HexSelection {
///
/// Constructor
///
protected HexSelection() { }
///
/// Gets the hex view
///
public abstract HexView HexView { get; }
///
/// Selects a span
///
/// Span
/// true if the anchor point is the end point of
/// true to align the span to include all bytes of the cells
public abstract void Select(HexBufferSpan selectionSpan, bool isReversed, bool alignPoints);
///
/// Select a span
///
/// Anchor point
/// Active point
/// true to align the span to include all bytes of the cells
public abstract void Select(HexBufferPoint anchorPoint, HexBufferPoint activePoint, bool alignPoints);
///
/// Gets all selected spans
///
public abstract NormalizedHexBufferSpanCollection SelectedSpans { get; }
///
/// Gets the slection on a line
///
/// Line
///
public abstract IEnumerable GetSelectionOnHexViewLine(HexViewLine line);
///
/// Gets the selected span
///
public HexBufferSpan StreamSelectionSpan => new HexBufferSpan(Start, End);
///
/// true if the selection is reversed
///
public bool IsReversed => ActivePoint < AnchorPoint;
///
/// Clears the selection
///
public abstract void Clear();
///
/// true if the selection is empty
///
public bool IsEmpty => AnchorPoint == ActivePoint;
///
/// true if the selection is active, false if it's inactive
///
public abstract bool IsActive { get; set; }
///
/// true if gets updated when the hex view gets and loses focus
///
public abstract bool ActivationTracksFocus { get; set; }
///
/// Raised when the selection is changed
///
public abstract event EventHandler? SelectionChanged;
///
/// Gets the active point
///
public abstract HexBufferPoint ActivePoint { get; }
///
/// Gets the anchor point
///
public abstract HexBufferPoint AnchorPoint { get; }
///
/// Gets the start position
///
public HexBufferPoint Start => AnchorPoint < ActivePoint ? AnchorPoint : ActivePoint;
///
/// Gets the end position
///
public HexBufferPoint End => AnchorPoint < ActivePoint ? ActivePoint : AnchorPoint;
}
}