Class HexView
Provides a hex editor with the left side
showing the hex values of the bytes in a Stream
and the right side showing the contents
(filtered
to printable Unicode glyphs).
public class HexView : View, IDisposable, ISupportInitializeNotification, ISupportInitialize, IDesignable
- Inheritance
-
HexView
- Implements
- Inherited Members
Remarks
Users can switch from one side to the other by using the tab key.
To enable editing, set ReadOnly to true. When ReadOnly is true the user can make changes to the hexadecimal values of the Stream. Any changes are tracked in the Edits property (a SortedDictionary<TKey, TValue>) indicating the position where the changes were made and the new values. A convenience method, ApplyEdits(Stream?) will apply the edits to the Stream.
Control the byte at the caret for editing by setting the Address property to an offset in the stream.
Constructors
- HexView(Stream?)
Initializes a HexView class.
Properties
- AddressWidth
Gets or sets the width of the Address column on the left. Set to 0 to hide. The default is 8.
- BytesPerLine
The bytes length per line.
- Edits
Gets a SortedDictionary<TKey, TValue> describing the edits done to the HexView. Each Key indicates an offset where an edit was made and the Value is the changed byte.
- ReadOnly
Gets or sets whether this HexView allows editing of the Stream of the underlying Stream. The default is false.
- Source
Sets or gets the Stream the HexView is operating on; the stream must support seeking ( CanSeek == true).
Methods
- ApplyEdits(Stream?)
Applies and edits made to the Stream and resets the contents of the Edits property.
- DiscardEdits()
Discards the edits made to the Stream by resetting the contents of the Edits property.
- GetCursor(long)
Gets cursor location, given an address.
- GetPosition(long)
Gets the current edit position.
- OnAdvancingFocus(NavigationDirection, TabBehavior?)
Called when AdvanceFocus(NavigationDirection, TabBehavior?) is about to advance focus.
- OnDrawingContent()
Called when the View's content is to be drawn. The default implementation does nothing.
- OnKeyDownNotHandled(Key)
Called when the user has pressed key it wasn't handled by KeyDown and was not bound to a key binding.
- OnPositionChanged(HexViewEventArgs)
Called when the position (see GetPosition(long)) and Address have changed.
- PositionCursor()
Positions the cursor in the right position based on the currently focused view in the chain.
- RaiseEdited(HexViewEditEventArgs)
Raises the Edited event.
- RaisePositionChanged()
Call this when the position (see GetPosition(long)) and Address have changed. Raises the PositionChanged event.
Events
- PositionChanged
Raised when the position (see GetPosition(long)) and Address have changed.