CancelEventArgs.cs 1.1 KB

12345678910111213141516171819202122232425262728
  1. #nullable enable
  2. using System.ComponentModel;
  3. namespace Terminal.Gui;
  4. /// <summary>
  5. /// <see cref="EventArgs"/> for events that convey changes to a property of type `T`.</summary>
  6. /// <remarks>
  7. /// Events that use this class can be cancellable. Where applicable, the <see cref="CancelEventArgs.Cancel"/> property should be set to
  8. /// <see langword="true"/> to prevent the state change from occurring.
  9. /// </remarks>
  10. public class CancelEventArgs<T> : CancelEventArgs
  11. {
  12. /// <summary>Initializes a new instance of the <see cref="CancelEventArgs{T}"/> class.</summary>
  13. /// <param name="currentValue">The current (old) value of the property.</param>
  14. /// <param name="newValue">The value the property will be set to if the event is not cancelled.</param>
  15. public CancelEventArgs (T currentValue, T newValue)
  16. {
  17. CurrentValue = currentValue;
  18. NewValue = newValue;
  19. }
  20. /// <summary>The value the property will be set to if the event is not cancelled.</summary>
  21. public T NewValue { get; set; }
  22. /// <summary>The current value of the property.</summary>
  23. public T CurrentValue { get; }
  24. }