ViewEventArgs.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. namespace Terminal.Gui {
  3. /// <summary>
  4. /// Args for events that relate to specific <see cref="View"/>
  5. /// </summary>
  6. public class ViewEventArgs : EventArgs {
  7. /// <summary>
  8. /// Creates a new instance of the <see cref="Terminal.Gui.View"/> class.
  9. /// </summary>
  10. /// <param name="view"></param>
  11. public ViewEventArgs (View view)
  12. {
  13. View = view;
  14. }
  15. /// <summary>
  16. /// The view that the event is about.
  17. /// </summary>
  18. /// <remarks>
  19. /// Can be different from the sender of the <see cref="EventHandler"/>
  20. /// for example if event describes the adding a child then sender may
  21. /// be the parent while <see cref="View"/> is the child
  22. /// being added.
  23. /// </remarks>
  24. public View View { get; }
  25. }
  26. /// <summary>
  27. /// Event arguments for the <see cref="View.LayoutComplete"/> event.
  28. /// </summary>
  29. public class LayoutEventArgs : EventArgs {
  30. /// <summary>
  31. /// The view-relative bounds of the <see cref="View"/> before it was laid out.
  32. /// </summary>
  33. public Rect OldBounds { get; set; }
  34. }
  35. /// <summary>
  36. /// Event args for draw events
  37. /// </summary>
  38. public class DrawEventArgs : EventArgs {
  39. /// <summary>
  40. /// Creates a new instance of the <see cref="DrawEventArgs"/> class.
  41. /// </summary>
  42. /// <param name="rect">Gets the view-relative rectangle describing the currently visible viewport into the <see cref="View"/>.</param>
  43. public DrawEventArgs (Rect rect)
  44. {
  45. Rect = rect;
  46. }
  47. /// <summary>
  48. /// Gets the view-relative rectangle describing the currently visible viewport into the <see cref="View"/>.
  49. /// </summary>
  50. public Rect Rect { get; }
  51. /// <summary>
  52. /// If set to true, the draw operation will be canceled, if applicable.
  53. /// </summary>
  54. public bool Cancel { get; set; }
  55. }
  56. /// <summary>
  57. /// Defines the event arguments for <see cref="View.SetFocus(View)"/>
  58. /// </summary>
  59. public class FocusEventArgs : EventArgs {
  60. /// <summary>
  61. /// Constructs.
  62. /// </summary>
  63. /// <param name="view">The view that gets or loses focus.</param>
  64. public FocusEventArgs (View view) { View = view; }
  65. /// <summary>
  66. /// Indicates if the current focus event has already been processed and the driver should stop notifying any other event subscriber.
  67. /// Its important to set this value to true specially when updating any View's layout from inside the subscriber method.
  68. /// </summary>
  69. public bool Handled { get; set; }
  70. /// <summary>
  71. /// Indicates the current view that gets or loses focus.
  72. /// </summary>
  73. public View View { get; set; }
  74. }
  75. }