HexViewEventArgs.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // HexView.cs: A hexadecimal viewer
  3. //
  4. // TODO:
  5. // - Support searching and highlighting of the search result
  6. // - Bug showing the last line
  7. //
  8. using System;
  9. using System.IO;
  10. namespace Terminal.Gui {
  11. /// <summary>
  12. /// Defines the event arguments for <see cref="HexView.PositionChanged"/> event.
  13. /// </summary>
  14. public class HexViewEventArgs : EventArgs {
  15. /// <summary>
  16. /// Gets the current character position starting at one, related to the <see cref="Stream"/>.
  17. /// </summary>
  18. public long Position { get; private set; }
  19. /// <summary>
  20. /// Gets the current cursor position starting at one for both, line and column.
  21. /// </summary>
  22. public Point CursorPosition { get; private set; }
  23. /// <summary>
  24. /// The bytes length per line.
  25. /// </summary>
  26. public int BytesPerLine { get; private set; }
  27. /// <summary>
  28. /// Initializes a new instance of <see cref="HexViewEventArgs"/>
  29. /// </summary>
  30. /// <param name="pos">The character position.</param>
  31. /// <param name="cursor">The cursor position.</param>
  32. /// <param name="lineLength">Line bytes length.</param>
  33. public HexViewEventArgs (long pos, Point cursor, int lineLength)
  34. {
  35. Position = pos;
  36. CursorPosition = cursor;
  37. BytesPerLine = lineLength;
  38. }
  39. }
  40. /// <summary>
  41. /// Defines the event arguments for <see cref="HexView.Edited"/> event.
  42. /// </summary>
  43. public class HexViewEditEventArgs : EventArgs {
  44. /// <summary>
  45. /// Creates a new instance of the <see cref="HexViewEditEventArgs"/> class.
  46. /// </summary>
  47. /// <param name="position"></param>
  48. /// <param name="newValue"></param>
  49. public HexViewEditEventArgs (long position, byte newValue)
  50. {
  51. Position = position;
  52. NewValue = newValue;
  53. }
  54. /// <summary>
  55. /// Gets the location of the edit.
  56. /// </summary>
  57. public long Position { get; }
  58. /// <summary>
  59. /// Gets the new value for that <see cref="Position"/>.
  60. /// </summary>
  61. public byte NewValue { get; }
  62. }
  63. }