RunnableEventArgs.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. namespace Terminal.Gui.App;
  2. /// <summary>
  3. /// Event args for <see cref="IRunnable"/> lifecycle events that provide information about the runnable.
  4. /// </summary>
  5. /// <remarks>
  6. /// Used for post-notification events that cannot be canceled:
  7. /// <see cref="IRunnable.Activated"/> and <see cref="IRunnable.Deactivated"/>.
  8. /// </remarks>
  9. public class RunnableEventArgs : EventArgs
  10. {
  11. /// <summary>
  12. /// Initializes a new instance of <see cref="RunnableEventArgs"/>.
  13. /// </summary>
  14. /// <param name="runnable">The runnable involved in the event.</param>
  15. public RunnableEventArgs (IRunnable runnable)
  16. {
  17. Runnable = runnable;
  18. }
  19. /// <summary>
  20. /// Gets the runnable involved in the event.
  21. /// </summary>
  22. public IRunnable Runnable { get; }
  23. }
  24. /// <summary>
  25. /// Event args for <see cref="IRunnable.Activating"/> event. Allows cancellation.
  26. /// </summary>
  27. /// <remarks>
  28. /// This event is raised when a runnable session is about to become active. It can be canceled
  29. /// by setting <see cref="System.ComponentModel.CancelEventArgs.Cancel"/> to <see langword="true"/>.
  30. /// </remarks>
  31. public class RunnableActivatingEventArgs : System.ComponentModel.CancelEventArgs
  32. {
  33. /// <summary>
  34. /// Initializes a new instance of <see cref="RunnableActivatingEventArgs"/>.
  35. /// </summary>
  36. /// <param name="activating">The runnable that is being activated.</param>
  37. /// <param name="deactivated">The runnable that is being deactivated, or null if none.</param>
  38. public RunnableActivatingEventArgs (IRunnable activating, IRunnable? deactivated)
  39. {
  40. Activating = activating;
  41. Deactivated = deactivated;
  42. }
  43. /// <summary>
  44. /// Gets the runnable that is being activated.
  45. /// </summary>
  46. public IRunnable Activating { get; }
  47. /// <summary>
  48. /// Gets the runnable that is being deactivated, or null if none.
  49. /// </summary>
  50. public IRunnable? Deactivated { get; }
  51. }
  52. /// <summary>
  53. /// Event args for <see cref="IRunnable.Deactivating"/> event. Allows cancellation.
  54. /// </summary>
  55. /// <remarks>
  56. /// This event is raised when a runnable session is about to cease being active. It can be canceled
  57. /// by setting <see cref="System.ComponentModel.CancelEventArgs.Cancel"/> to <see langword="true"/>.
  58. /// </remarks>
  59. public class RunnableDeactivatingEventArgs : System.ComponentModel.CancelEventArgs
  60. {
  61. /// <summary>
  62. /// Initializes a new instance of <see cref="RunnableDeactivatingEventArgs"/>.
  63. /// </summary>
  64. /// <param name="deactivating">The runnable that is being deactivated.</param>
  65. /// <param name="activated">The runnable that is being activated, or null if none.</param>
  66. public RunnableDeactivatingEventArgs (IRunnable deactivating, IRunnable? activated)
  67. {
  68. Deactivating = deactivating;
  69. Activated = activated;
  70. }
  71. /// <summary>
  72. /// Gets the runnable that is being deactivated.
  73. /// </summary>
  74. public IRunnable Deactivating { get; }
  75. /// <summary>
  76. /// Gets the runnable that is being activated, or null if none.
  77. /// </summary>
  78. public IRunnable? Activated { get; }
  79. }