Browse Source

Renamed StateChangedEventArgs

Tig 1 year ago
parent
commit
d7bd938664

+ 1 - 1
Terminal.Gui/Application/Application.cs

@@ -358,7 +358,7 @@ public static partial class Application
     /// <remarks>
     /// <remarks>
     ///     Intended to support unit tests that need to know when the application has been initialized.
     ///     Intended to support unit tests that need to know when the application has been initialized.
     /// </remarks>
     /// </remarks>
-    public static event EventHandler<StateEventArgs<bool>> InitializedChanged;
+    public static event EventHandler<CancelEventArgs<bool>> InitializedChanged;
 
 
     #endregion Initialization (Init/Shutdown)
     #endregion Initialization (Init/Shutdown)
 
 

+ 12 - 11
Terminal.Gui/View/StateEventArgs.cs

@@ -3,25 +3,26 @@ using System.ComponentModel;
 
 
 namespace Terminal.Gui;
 namespace Terminal.Gui;
 
 
-/// <summary><see cref="EventArgs"/> for events that convey state changes to a <see cref="View"/> class.</summary>
+/// <summary>
+/// <see cref="EventArgs"/> for events that convey changes to a property of type `T`.</summary>
 /// <remarks>
 /// <remarks>
-/// Events that use this class can be cancellable. The <see cref="CancelEventArgs.Cancel"/> property should be set to
+/// Events that use this class can be cancellable. Where applicable, the <see cref="CancelEventArgs.Cancel"/> property should be set to
 /// <see langword="true"/> to prevent the state change from occurring.
 /// <see langword="true"/> to prevent the state change from occurring.
 /// </remarks>
 /// </remarks>
-public class StateEventArgs<T> : CancelEventArgs
+public class CancelEventArgs<T> : CancelEventArgs
 {
 {
-    /// <summary>Creates a new instance of the <see cref="StateEventArgs{T}"/> class.</summary>
-    /// <param name="oldValue"></param>
-    /// <param name="newValue"></param>
-    public StateEventArgs (T oldValue, T newValue)
+    /// <summary>Initializes a new instance of the <see cref="CancelEventArgs{T}"/> class.</summary>
+    /// <param name="currentValue">The current (old) value of the property.</param>
+    /// <param name="newValue">The value the property will be set to if the event is not cancelled.</param>
+    public CancelEventArgs (T currentValue, T newValue)
     {
     {
-        OldValue = oldValue;
+        CurrentValue = currentValue;
         NewValue = newValue;
         NewValue = newValue;
     }
     }
 
 
-    /// <summary>The new state</summary>
+    /// <summary>The value the property will be set to if the event is not cancelled.</summary>
     public T NewValue { get; set; }
     public T NewValue { get; set; }
 
 
-    /// <summary>The previous state</summary>
-    public T OldValue { get; }
+    /// <summary>The current value of the property.</summary>
+    public T CurrentValue { get; }
 }
 }

+ 4 - 4
Terminal.Gui/View/View.cs

@@ -492,7 +492,7 @@ public partial class View : Responder, ISupportInitializeNotification
     /// <param name="newTitle">The new <see cref="View.Title"/> to be replaced.</param>
     /// <param name="newTitle">The new <see cref="View.Title"/> to be replaced.</param>
     public virtual void OnTitleChanged (string oldTitle, string newTitle)
     public virtual void OnTitleChanged (string oldTitle, string newTitle)
     {
     {
-        StateEventArgs<string> args = new (oldTitle, newTitle);
+        CancelEventArgs<string> args = new (oldTitle, newTitle);
         TitleChanged?.Invoke (this, args);
         TitleChanged?.Invoke (this, args);
     }
     }
 
 
@@ -505,20 +505,20 @@ public partial class View : Responder, ISupportInitializeNotification
     /// <returns>`true` if an event handler canceled the Title change.</returns>
     /// <returns>`true` if an event handler canceled the Title change.</returns>
     public virtual bool OnTitleChanging (string oldTitle, string newTitle)
     public virtual bool OnTitleChanging (string oldTitle, string newTitle)
     {
     {
-        StateEventArgs<string> args = new (oldTitle, newTitle);
+        CancelEventArgs<string> args = new (oldTitle, newTitle);
         TitleChanging?.Invoke (this, args);
         TitleChanging?.Invoke (this, args);
 
 
         return args.Cancel;
         return args.Cancel;
     }
     }
 
 
     /// <summary>Event fired after the <see cref="View.Title"/> has been changed.</summary>
     /// <summary>Event fired after the <see cref="View.Title"/> has been changed.</summary>
-    public event EventHandler<StateEventArgs<string>> TitleChanged;
+    public event EventHandler<CancelEventArgs<string>> TitleChanged;
 
 
     /// <summary>
     /// <summary>
     ///     Event fired when the <see cref="View.Title"/> is changing. Set <see cref="CancelEventArgs.Cancel"/> to `true`
     ///     Event fired when the <see cref="View.Title"/> is changing. Set <see cref="CancelEventArgs.Cancel"/> to `true`
     ///     to cancel the Title change.
     ///     to cancel the Title change.
     /// </summary>
     /// </summary>
-    public event EventHandler<StateEventArgs<string>> TitleChanging;
+    public event EventHandler<CancelEventArgs<string>> TitleChanging;
 
 
     #endregion
     #endregion
 }
 }

+ 3 - 3
Terminal.Gui/View/ViewAdornments.cs

@@ -124,7 +124,7 @@ public partial class View
         get => Border?.LineStyle ?? LineStyle.Single;
         get => Border?.LineStyle ?? LineStyle.Single;
         set
         set
         {
         {
-            StateEventArgs<LineStyle> e = new (Border?.LineStyle ?? LineStyle.None, value);
+            CancelEventArgs<LineStyle> e = new (Border?.LineStyle ?? LineStyle.None, value);
             OnBorderStyleChanging (e);
             OnBorderStyleChanging (e);
 
 
         }
         }
@@ -137,7 +137,7 @@ public partial class View
     ///     Override <see cref="SetBorderStyle"/> to prevent the <see cref="BorderStyle"/> from changing.
     ///     Override <see cref="SetBorderStyle"/> to prevent the <see cref="BorderStyle"/> from changing.
     /// </remarks>
     /// </remarks>
     /// <param name="e"></param>
     /// <param name="e"></param>
-    protected void OnBorderStyleChanging (StateEventArgs<LineStyle> e)
+    protected void OnBorderStyleChanging (CancelEventArgs<LineStyle> e)
     {
     {
         if (Border is null)
         if (Border is null)
         {
         {
@@ -193,7 +193,7 @@ public partial class View
     /// <summary>
     /// <summary>
     ///     Fired when the <see cref="BorderStyle"/> is changing. Allows the event to be cancelled.
     ///     Fired when the <see cref="BorderStyle"/> is changing. Allows the event to be cancelled.
     /// </summary>
     /// </summary>
-    public event EventHandler<StateEventArgs<LineStyle>> BorderStyleChanging;
+    public event EventHandler<CancelEventArgs<LineStyle>> BorderStyleChanging;
 
 
     /// <summary>
     /// <summary>
     ///     The <see cref="Adornment"/> inside of the view that offsets the <see cref="Viewport"/>
     ///     The <see cref="Adornment"/> inside of the view that offsets the <see cref="Viewport"/>

+ 2 - 2
Terminal.Gui/View/ViewText.cs

@@ -80,13 +80,13 @@ public partial class View
     /// <param name="newValue"></param>
     /// <param name="newValue"></param>
     public void OnTextChanged (string oldValue, string newValue)
     public void OnTextChanged (string oldValue, string newValue)
     {
     {
-        TextChanged?.Invoke (this, new StateEventArgs<string> (oldValue, newValue));
+        TextChanged?.Invoke (this, new CancelEventArgs<string> (oldValue, newValue));
     }
     }
 
 
     /// <summary>
     /// <summary>
     ///     Text changed event, raised when the text has changed.
     ///     Text changed event, raised when the text has changed.
     /// </summary>
     /// </summary>
-    public event EventHandler<StateEventArgs<string>> TextChanged;
+    public event EventHandler<CancelEventArgs<string>> TextChanged;
 
 
     /// <summary>
     /// <summary>
     ///     Gets or sets how the View's <see cref="Text"/> is aligned horizontally when drawn. Changing this property will
     ///     Gets or sets how the View's <see cref="Text"/> is aligned horizontally when drawn. Changing this property will

+ 1 - 1
Terminal.Gui/Views/Button.cs

@@ -110,7 +110,7 @@ public class Button : View
         e.Handled = InvokeCommand (Command.HotKey) == true;
         e.Handled = InvokeCommand (Command.HotKey) == true;
     }
     }
 
 
-    private void Button_TitleChanged (object sender, StateEventArgs<string> e)
+    private void Button_TitleChanged (object sender, CancelEventArgs<string> e)
     {
     {
         base.Text = e.NewValue;
         base.Text = e.NewValue;
         TextFormatter.HotKeySpecifier = HotKeySpecifier;
         TextFormatter.HotKeySpecifier = HotKeySpecifier;

+ 3 - 3
Terminal.Gui/Views/CheckBox.cs

@@ -42,7 +42,7 @@ public class CheckBox : View
         e.Handled = OnToggled () == true;
         e.Handled = OnToggled () == true;
     }
     }
 
 
-    private void Checkbox_TitleChanged (object? sender, StateEventArgs<string> e)
+    private void Checkbox_TitleChanged (object? sender, CancelEventArgs<string> e)
     {
     {
         base.Text = e.NewValue;
         base.Text = e.NewValue;
         TextFormatter.HotKeySpecifier = HotKeySpecifier;
         TextFormatter.HotKeySpecifier = HotKeySpecifier;
@@ -99,7 +99,7 @@ public class CheckBox : View
     /// <returns>If <see langword="true"/> the <see cref="Toggled"/> event was canceled.</returns>
     /// <returns>If <see langword="true"/> the <see cref="Toggled"/> event was canceled.</returns>
     public bool? OnToggled ()
     public bool? OnToggled ()
     {
     {
-        StateEventArgs<bool?> e = new (Checked, false);
+        CancelEventArgs<bool?> e = new (Checked, false);
 
 
         if (AllowNullChecked)
         if (AllowNullChecked)
         {
         {
@@ -147,7 +147,7 @@ public class CheckBox : View
     ///    This event can be cancelled. If cancelled, the <see cref="CheckBox"/> will not change its state.
     ///    This event can be cancelled. If cancelled, the <see cref="CheckBox"/> will not change its state.
     /// </para>
     /// </para>
     /// </remarks>
     /// </remarks>
-    public event EventHandler<StateEventArgs<bool?>>? Toggled;
+    public event EventHandler<CancelEventArgs<bool?>>? Toggled;
 
 
     /// <inheritdoc/>
     /// <inheritdoc/>
     protected override void UpdateTextFormatterText ()
     protected override void UpdateTextFormatterText ()

+ 4 - 4
Terminal.Gui/Views/ComboBox.cs

@@ -68,7 +68,7 @@ public class ComboBox : View
 
 
                      SetNeedsLayout ();
                      SetNeedsLayout ();
                      SetNeedsDisplay ();
                      SetNeedsDisplay ();
-                     Search_Changed (this, new StateEventArgs<string> (string.Empty, Text));
+                     Search_Changed (this, new CancelEventArgs<string> (string.Empty, Text));
                  };
                  };
 
 
         // Things this view knows how to do
         // Things this view knows how to do
@@ -187,7 +187,7 @@ public class ComboBox : View
             {
             {
                 SelectedItem = -1;
                 SelectedItem = -1;
                 _search.Text = string.Empty;
                 _search.Text = string.Empty;
-                Search_Changed (this, new StateEventArgs<string> (string.Empty, _search.Text));
+                Search_Changed (this, new CancelEventArgs<string> (string.Empty, _search.Text));
                 SetNeedsDisplay ();
                 SetNeedsDisplay ();
             }
             }
         }
         }
@@ -660,7 +660,7 @@ public class ComboBox : View
     // Tell TextField to handle Accept Command (Enter)
     // Tell TextField to handle Accept Command (Enter)
     void Search_Accept (object sender, HandledEventArgs e) { e.Handled = true; }
     void Search_Accept (object sender, HandledEventArgs e) { e.Handled = true; }
 
 
-    private void Search_Changed (object sender, StateEventArgs<string> e)
+    private void Search_Changed (object sender, CancelEventArgs<string> e)
     {
     {
         if (_source is null)
         if (_source is null)
         {
         {
@@ -730,7 +730,7 @@ public class ComboBox : View
 
 
         SetValue (_listview.SelectedItem > -1 ? _searchSet [_listview.SelectedItem] : _text);
         SetValue (_listview.SelectedItem > -1 ? _searchSet [_listview.SelectedItem] : _text);
         _search.CursorPosition = _search.Text.GetColumns ();
         _search.CursorPosition = _search.Text.GetColumns ();
-        Search_Changed (this, new StateEventArgs<string> (_search.Text, _search.Text));
+        Search_Changed (this, new CancelEventArgs<string> (_search.Text, _search.Text));
         OnOpenSelectedItem ();
         OnOpenSelectedItem ();
         Reset (true);
         Reset (true);
         HideList ();
         HideList ();

+ 1 - 1
Terminal.Gui/Views/DateField.cs

@@ -182,7 +182,7 @@ public class DateField : TextField
         }
         }
     }
     }
 
 
-    private void DateField_Changing (object sender, StateEventArgs<string> e)
+    private void DateField_Changing (object sender, CancelEventArgs<string> e)
     {
     {
         try
         try
         {
         {

+ 1 - 1
Terminal.Gui/Views/Label.cs

@@ -31,7 +31,7 @@ public class Label : View
         e.Handled = InvokeCommand (Command.HotKey) == true;
         e.Handled = InvokeCommand (Command.HotKey) == true;
     }
     }
 
 
-    private void Label_TitleChanged (object sender, StateEventArgs<string> e)
+    private void Label_TitleChanged (object sender, CancelEventArgs<string> e)
     {
     {
         base.Text = e.NewValue;
         base.Text = e.NewValue;
         TextFormatter.HotKeySpecifier = HotKeySpecifier;
         TextFormatter.HotKeySpecifier = HotKeySpecifier;

+ 1 - 1
Terminal.Gui/Views/Shortcut.cs

@@ -446,7 +446,7 @@ public class Shortcut : View
     CommandView.Y = 0; //Pos.Center ();
     CommandView.Y = 0; //Pos.Center ();
 }
 }
 
 
-private void Shortcut_TitleChanged (object sender, StateEventArgs<string> e)
+private void Shortcut_TitleChanged (object sender, CancelEventArgs<string> e)
 {
 {
     // If the Title changes, update the CommandView text.
     // If the Title changes, update the CommandView text.
     // This is a helper to make it easier to set the CommandView text.
     // This is a helper to make it easier to set the CommandView text.

+ 4 - 4
Terminal.Gui/Views/TextField.cs

@@ -532,7 +532,7 @@ public class TextField : View
                 return;
                 return;
             }
             }
 
 
-            StateEventArgs<string> newText = OnTextChanging (value.Replace ("\t", "").Split ("\n") [0]);
+            CancelEventArgs<string> newText = OnTextChanging (value.Replace ("\t", "").Split ("\n") [0]);
 
 
             if (newText.Cancel)
             if (newText.Cancel)
             {
             {
@@ -1103,9 +1103,9 @@ public class TextField : View
     /// <summary>Virtual method that invoke the <see cref="TextChanging"/> event if it's defined.</summary>
     /// <summary>Virtual method that invoke the <see cref="TextChanging"/> event if it's defined.</summary>
     /// <param name="newText">The new text to be replaced.</param>
     /// <param name="newText">The new text to be replaced.</param>
     /// <returns>Returns the <see cref="StringEventArgs"/></returns>
     /// <returns>Returns the <see cref="StringEventArgs"/></returns>
-    public virtual StateEventArgs<string> OnTextChanging (string newText)
+    public virtual CancelEventArgs<string> OnTextChanging (string newText)
     {
     {
-        StateEventArgs<string> ev = new (string.Empty, newText);
+        CancelEventArgs<string> ev = new (string.Empty, newText);
         TextChanging?.Invoke (this, ev);
         TextChanging?.Invoke (this, ev);
 
 
         return ev;
         return ev;
@@ -1195,7 +1195,7 @@ public class TextField : View
     //public event EventHandler<StateEventArgs<string>> TextChanged;
     //public event EventHandler<StateEventArgs<string>> TextChanged;
 
 
     /// <summary>Changing event, raised before the <see cref="Text"/> changes and can be canceled or changing the new text.</summary>
     /// <summary>Changing event, raised before the <see cref="Text"/> changes and can be canceled or changing the new text.</summary>
-    public event EventHandler<StateEventArgs<string>> TextChanging;
+    public event EventHandler<CancelEventArgs<string>> TextChanging;
 
 
     /// <summary>Undoes the latest changes.</summary>
     /// <summary>Undoes the latest changes.</summary>
     public void Undo ()
     public void Undo ()

+ 1 - 1
Terminal.Gui/Views/TimeField.cs

@@ -430,7 +430,7 @@ public class TimeField : TextField
         return true;
         return true;
     }
     }
 
 
-    private void TextField_TextChanging (object sender, StateEventArgs<string> e)
+    private void TextField_TextChanging (object sender, CancelEventArgs<string> e)
     {
     {
         try
         try
         {
         {

+ 1 - 1
Terminal.Gui/Views/Wizard/Wizard.cs

@@ -562,7 +562,7 @@ public class Wizard : Dialog
         // gets the first step if CurrentStep == null
         // gets the first step if CurrentStep == null
     }
     }
 
 
-    private void Wizard_TitleChanged (object sender, StateEventArgs<string> e)
+    private void Wizard_TitleChanged (object sender, CancelEventArgs<string> e)
     {
     {
         if (string.IsNullOrEmpty (_wizardTitle))
         if (string.IsNullOrEmpty (_wizardTitle))
         {
         {

+ 4 - 4
UICatalog/Scenarios/AdornmentEditor.cs

@@ -186,7 +186,7 @@ public class AdornmentEditor : View
                };
                };
     }
     }
 
 
-    private void Top_ValueChanging (object sender, StateEventArgs<int> e)
+    private void Top_ValueChanging (object sender, CancelEventArgs<int> e)
     {
     {
         if (e.NewValue < 0 || AdornmentToEdit is null)
         if (e.NewValue < 0 || AdornmentToEdit is null)
         {
         {
@@ -198,7 +198,7 @@ public class AdornmentEditor : View
         AdornmentToEdit.Thickness = new (AdornmentToEdit.Thickness.Left, e.NewValue, AdornmentToEdit.Thickness.Right, AdornmentToEdit.Thickness.Bottom);
         AdornmentToEdit.Thickness = new (AdornmentToEdit.Thickness.Left, e.NewValue, AdornmentToEdit.Thickness.Right, AdornmentToEdit.Thickness.Bottom);
     }
     }
 
 
-    private void Left_ValueChanging (object sender, StateEventArgs<int> e)
+    private void Left_ValueChanging (object sender, CancelEventArgs<int> e)
     {
     {
         if (e.NewValue < 0 || AdornmentToEdit is null)
         if (e.NewValue < 0 || AdornmentToEdit is null)
         {
         {
@@ -210,7 +210,7 @@ public class AdornmentEditor : View
         AdornmentToEdit.Thickness = new (e.NewValue, AdornmentToEdit.Thickness.Top, AdornmentToEdit.Thickness.Right, AdornmentToEdit.Thickness.Bottom);
         AdornmentToEdit.Thickness = new (e.NewValue, AdornmentToEdit.Thickness.Top, AdornmentToEdit.Thickness.Right, AdornmentToEdit.Thickness.Bottom);
     }
     }
 
 
-    private void Right_ValueChanging (object sender, StateEventArgs<int> e)
+    private void Right_ValueChanging (object sender, CancelEventArgs<int> e)
     {
     {
         if (e.NewValue < 0 || AdornmentToEdit is null)
         if (e.NewValue < 0 || AdornmentToEdit is null)
         {
         {
@@ -222,7 +222,7 @@ public class AdornmentEditor : View
         AdornmentToEdit.Thickness = new (AdornmentToEdit.Thickness.Left, AdornmentToEdit.Thickness.Top, e.NewValue, AdornmentToEdit.Thickness.Bottom);
         AdornmentToEdit.Thickness = new (AdornmentToEdit.Thickness.Left, AdornmentToEdit.Thickness.Top, e.NewValue, AdornmentToEdit.Thickness.Bottom);
     }
     }
 
 
-    private void Bottom_ValueChanging (object sender, StateEventArgs<int> e)
+    private void Bottom_ValueChanging (object sender, CancelEventArgs<int> e)
     {
     {
         if (e.NewValue < 0 || AdornmentToEdit is null)
         if (e.NewValue < 0 || AdornmentToEdit is null)
         {
         {

+ 1 - 1
UICatalog/Scenarios/BorderEditor.cs

@@ -81,6 +81,6 @@ public class BorderEditor : AdornmentEditor
             LayoutSubviews ();
             LayoutSubviews ();
         }
         }
 
 
-        void OnCkbTitleOnToggled (object sender, StateEventArgs<bool?> args) { ((Border)AdornmentToEdit).ShowTitle = args.NewValue!.Value; }
+        void OnCkbTitleOnToggled (object sender, CancelEventArgs<bool?> args) { ((Border)AdornmentToEdit).ShowTitle = args.NewValue!.Value; }
     }
     }
 }
 }

+ 5 - 5
UICatalog/Scenarios/Buttons.cs

@@ -341,7 +341,7 @@ public class Buttons : Scenario
         };
         };
         numericUpDown.ValueChanged += NumericUpDown_ValueChanged;
         numericUpDown.ValueChanged += NumericUpDown_ValueChanged;
 
 
-        void NumericUpDown_ValueChanged (object sender, StateEventArgs<int> e) { }
+        void NumericUpDown_ValueChanged (object sender, CancelEventArgs<int> e) { }
 
 
         main.Add (label, numericUpDown);
         main.Add (label, numericUpDown);
 
 
@@ -518,7 +518,7 @@ public class Buttons : Scenario
                 }
                 }
 
 
                 T oldValue = value;
                 T oldValue = value;
-                StateEventArgs<T> args = new StateEventArgs<T> (_value, value);
+                CancelEventArgs<T> args = new CancelEventArgs<T> (_value, value);
                 ValueChanging?.Invoke (this, args);
                 ValueChanging?.Invoke (this, args);
 
 
                 if (args.Cancel)
                 if (args.Cancel)
@@ -533,16 +533,16 @@ public class Buttons : Scenario
         }
         }
 
 
         /// <summary>
         /// <summary>
-        /// Fired when the value is about to change. Set <see cref="StateEventArgs{T}.Cancel"/> to true to prevent the change.
+        /// Fired when the value is about to change. Set <see cref="CancelEventArgs{T}.Cancel"/> to true to prevent the change.
         /// </summary>
         /// </summary>
         [CanBeNull]
         [CanBeNull]
-        public event EventHandler<StateEventArgs<T>> ValueChanging;
+        public event EventHandler<CancelEventArgs<T>> ValueChanging;
 
 
         /// <summary>
         /// <summary>
         /// Fired when the value has changed.
         /// Fired when the value has changed.
         /// </summary>
         /// </summary>
         [CanBeNull]
         [CanBeNull]
-        public event EventHandler<StateEventArgs<T>> ValueChanged;
+        public event EventHandler<CancelEventArgs<T>> ValueChanged;
 
 
         /// <summary>
         /// <summary>
         /// The number of digits to display. The <see cref="View.Viewport"/> will be resized to fit this number of characters plus the buttons. The default is 3.
         /// The number of digits to display. The <see cref="View.Viewport"/> will be resized to fit this number of characters plus the buttons. The default is 3.

+ 1 - 1
UICatalog/Scenarios/CharacterMap.cs

@@ -240,7 +240,7 @@ public class CharacterMap : Scenario
         return item;
         return item;
     }
     }
 
 
-    private void JumpEdit_TextChanged (object sender, StateEventArgs<string> e)
+    private void JumpEdit_TextChanged (object sender, CancelEventArgs<string> e)
     {
     {
         var jumpEdit = sender as TextField;
         var jumpEdit = sender as TextField;
 
 

+ 8 - 8
UICatalog/Scenarios/ContentScrolling.cs

@@ -138,7 +138,7 @@ public class ContentScrolling : Scenario
         cbAllowNegativeX.Checked = view.ViewportSettings.HasFlag (ViewportSettings.AllowNegativeX);
         cbAllowNegativeX.Checked = view.ViewportSettings.HasFlag (ViewportSettings.AllowNegativeX);
         cbAllowNegativeX.Toggled += AllowNegativeX_Toggled;
         cbAllowNegativeX.Toggled += AllowNegativeX_Toggled;
 
 
-        void AllowNegativeX_Toggled (object sender, StateEventArgs<bool?> e)
+        void AllowNegativeX_Toggled (object sender, CancelEventArgs<bool?> e)
         {
         {
             if (e.NewValue == true)
             if (e.NewValue == true)
             {
             {
@@ -162,7 +162,7 @@ public class ContentScrolling : Scenario
         cbAllowNegativeY.Checked = view.ViewportSettings.HasFlag (ViewportSettings.AllowNegativeY);
         cbAllowNegativeY.Checked = view.ViewportSettings.HasFlag (ViewportSettings.AllowNegativeY);
         cbAllowNegativeY.Toggled += AllowNegativeY_Toggled;
         cbAllowNegativeY.Toggled += AllowNegativeY_Toggled;
 
 
-        void AllowNegativeY_Toggled (object sender, StateEventArgs<bool?> e)
+        void AllowNegativeY_Toggled (object sender, CancelEventArgs<bool?> e)
         {
         {
             if (e.NewValue == true)
             if (e.NewValue == true)
             {
             {
@@ -185,7 +185,7 @@ public class ContentScrolling : Scenario
         cbAllowXGreaterThanContentWidth.Checked = view.ViewportSettings.HasFlag (ViewportSettings.AllowXGreaterThanContentWidth);
         cbAllowXGreaterThanContentWidth.Checked = view.ViewportSettings.HasFlag (ViewportSettings.AllowXGreaterThanContentWidth);
         cbAllowXGreaterThanContentWidth.Toggled += AllowXGreaterThanContentWidth_Toggled;
         cbAllowXGreaterThanContentWidth.Toggled += AllowXGreaterThanContentWidth_Toggled;
 
 
-        void AllowXGreaterThanContentWidth_Toggled (object sender, StateEventArgs<bool?> e)
+        void AllowXGreaterThanContentWidth_Toggled (object sender, CancelEventArgs<bool?> e)
         {
         {
             if (e.NewValue == true)
             if (e.NewValue == true)
             {
             {
@@ -209,7 +209,7 @@ public class ContentScrolling : Scenario
         cbAllowYGreaterThanContentHeight.Checked = view.ViewportSettings.HasFlag (ViewportSettings.AllowYGreaterThanContentHeight);
         cbAllowYGreaterThanContentHeight.Checked = view.ViewportSettings.HasFlag (ViewportSettings.AllowYGreaterThanContentHeight);
         cbAllowYGreaterThanContentHeight.Toggled += AllowYGreaterThanContentHeight_Toggled;
         cbAllowYGreaterThanContentHeight.Toggled += AllowYGreaterThanContentHeight_Toggled;
 
 
-        void AllowYGreaterThanContentHeight_Toggled (object sender, StateEventArgs<bool?> e)
+        void AllowYGreaterThanContentHeight_Toggled (object sender, CancelEventArgs<bool?> e)
         {
         {
             if (e.NewValue == true)
             if (e.NewValue == true)
             {
             {
@@ -237,7 +237,7 @@ public class ContentScrolling : Scenario
         };
         };
         contentSizeWidth.ValueChanging += ContentSizeWidth_ValueChanged;
         contentSizeWidth.ValueChanging += ContentSizeWidth_ValueChanged;
 
 
-        void ContentSizeWidth_ValueChanged (object sender, StateEventArgs<int> e)
+        void ContentSizeWidth_ValueChanged (object sender, CancelEventArgs<int> e)
         {
         {
             if (e.NewValue < 0)
             if (e.NewValue < 0)
             {
             {
@@ -265,7 +265,7 @@ public class ContentScrolling : Scenario
         };
         };
         contentSizeHeight.ValueChanging += ContentSizeHeight_ValueChanged;
         contentSizeHeight.ValueChanging += ContentSizeHeight_ValueChanged;
 
 
-        void ContentSizeHeight_ValueChanged (object sender, StateEventArgs<int> e)
+        void ContentSizeHeight_ValueChanged (object sender, CancelEventArgs<int> e)
         {
         {
             if (e.NewValue < 0)
             if (e.NewValue < 0)
             {
             {
@@ -287,7 +287,7 @@ public class ContentScrolling : Scenario
         cbClearOnlyVisible.Checked = view.ViewportSettings.HasFlag (ViewportSettings.ClearContentOnly);
         cbClearOnlyVisible.Checked = view.ViewportSettings.HasFlag (ViewportSettings.ClearContentOnly);
         cbClearOnlyVisible.Toggled += ClearVisibleContentOnly_Toggled;
         cbClearOnlyVisible.Toggled += ClearVisibleContentOnly_Toggled;
 
 
-        void ClearVisibleContentOnly_Toggled (object sender, StateEventArgs<bool?> e)
+        void ClearVisibleContentOnly_Toggled (object sender, CancelEventArgs<bool?> e)
         {
         {
             if (e.NewValue == true)
             if (e.NewValue == true)
             {
             {
@@ -309,7 +309,7 @@ public class ContentScrolling : Scenario
         cbDoNotClipContent.Checked = view.ViewportSettings.HasFlag (ViewportSettings.ClipContentOnly);
         cbDoNotClipContent.Checked = view.ViewportSettings.HasFlag (ViewportSettings.ClipContentOnly);
         cbDoNotClipContent.Toggled += ClipVisibleContentOnly_Toggled;
         cbDoNotClipContent.Toggled += ClipVisibleContentOnly_Toggled;
 
 
-        void ClipVisibleContentOnly_Toggled (object sender, StateEventArgs<bool?> e)
+        void ClipVisibleContentOnly_Toggled (object sender, CancelEventArgs<bool?> e)
         {
         {
             if (e.NewValue == true)
             if (e.NewValue == true)
             {
             {

+ 1 - 1
UICatalog/Scenarios/CsvEditor.cs

@@ -565,7 +565,7 @@ public class CsvEditor : Scenario
         }
         }
     }
     }
 
 
-    private void SelectedCellLabel_TextChanged (object sender, StateEventArgs<string> e)
+    private void SelectedCellLabel_TextChanged (object sender, CancelEventArgs<string> e)
     {
     {
         // if user is in the text control and editing the selected cell
         // if user is in the text control and editing the selected cell
         if (!_selectedCellTextField.HasFocus)
         if (!_selectedCellTextField.HasFocus)

+ 2 - 2
UICatalog/Scenarios/ExpanderButton.cs

@@ -136,7 +136,7 @@ public class ExpanderButton : Button
     /// <returns>True of the event was cancelled.</returns>
     /// <returns>True of the event was cancelled.</returns>
     protected virtual bool OnCollapsedChanging (bool newValue)
     protected virtual bool OnCollapsedChanging (bool newValue)
     {
     {
-        StateEventArgs<bool> args = new (Collapsed, newValue);
+        CancelEventArgs<bool> args = new (Collapsed, newValue);
         CollapsedChanging?.Invoke (this, args);
         CollapsedChanging?.Invoke (this, args);
 
 
         if (!args.Cancel)
         if (!args.Cancel)
@@ -168,7 +168,7 @@ public class ExpanderButton : Button
     ///     Fired when the orientation has changed. Can be cancelled by setting
     ///     Fired when the orientation has changed. Can be cancelled by setting
     ///     <see cref="OrientationEventArgs.Cancel"/> to true.
     ///     <see cref="OrientationEventArgs.Cancel"/> to true.
     /// </summary>
     /// </summary>
-    public event EventHandler<StateEventArgs<bool>> CollapsedChanging;
+    public event EventHandler<CancelEventArgs<bool>> CollapsedChanging;
 
 
     /// <summary>
     /// <summary>
     ///     Collapses or Expands the view.
     ///     Collapses or Expands the view.

+ 3 - 3
UICatalog/Scenarios/ListViewWithSelection.cs

@@ -118,7 +118,7 @@ public class ListViewWithSelection : Scenario
         Application.Shutdown ();
         Application.Shutdown ();
     }
     }
 
 
-    private void _customRenderCB_Toggled (object sender, StateEventArgs<bool?> stateEventArgs)
+    private void _customRenderCB_Toggled (object sender, CancelEventArgs<bool?> stateEventArgs)
     {
     {
         if (stateEventArgs.OldValue == true)
         if (stateEventArgs.OldValue == true)
         {
         {
@@ -132,14 +132,14 @@ public class ListViewWithSelection : Scenario
         _appWindow.SetNeedsDisplay ();
         _appWindow.SetNeedsDisplay ();
     }
     }
 
 
-    private void AllowMarkingCB_Toggled (object sender, [NotNull] StateEventArgs<bool?> stateEventArgs)
+    private void AllowMarkingCB_Toggled (object sender, [NotNull] CancelEventArgs<bool?> stateEventArgs)
     {
     {
         _listView.AllowsMarking = (bool)!stateEventArgs.OldValue;
         _listView.AllowsMarking = (bool)!stateEventArgs.OldValue;
         _allowMultipleCB.Visible = _listView.AllowsMarking;
         _allowMultipleCB.Visible = _listView.AllowsMarking;
         _appWindow.SetNeedsDisplay ();
         _appWindow.SetNeedsDisplay ();
     }
     }
 
 
-    private void AllowMultipleCB_Toggled (object sender, [NotNull] StateEventArgs<bool?> stateEventArgs)
+    private void AllowMultipleCB_Toggled (object sender, [NotNull] CancelEventArgs<bool?> stateEventArgs)
     {
     {
         _listView.AllowsMultipleSelection = (bool)!stateEventArgs.OldValue;
         _listView.AllowsMultipleSelection = (bool)!stateEventArgs.OldValue;
         _appWindow.SetNeedsDisplay ();
         _appWindow.SetNeedsDisplay ();

+ 1 - 1
UICatalog/Scenarios/Text.cs

@@ -35,7 +35,7 @@ public class Text : Scenario
         textField.Autocomplete.SuggestionGenerator = singleWordGenerator;
         textField.Autocomplete.SuggestionGenerator = singleWordGenerator;
         textField.TextChanging += TextField_TextChanging;
         textField.TextChanging += TextField_TextChanging;
 
 
-        void TextField_TextChanging (object sender, StateEventArgs<string> e)
+        void TextField_TextChanging (object sender, CancelEventArgs<string> e)
         {
         {
             singleWordGenerator.AllSuggestions = Regex.Matches (e.NewValue, "\\w+")
             singleWordGenerator.AllSuggestions = Regex.Matches (e.NewValue, "\\w+")
                                                       .Select (s => s.Value)
                                                       .Select (s => s.Value)

+ 2 - 2
UnitTests/Application/ApplicationTests.cs

@@ -295,7 +295,7 @@ public class ApplicationTests
 
 
         return;
         return;
 
 
-        void OnApplicationOnInitializedChanged (object s, StateEventArgs<bool> a)
+        void OnApplicationOnInitializedChanged (object s, CancelEventArgs<bool> a)
         {
         {
             if (a.NewValue)
             if (a.NewValue)
             {
             {
@@ -1151,7 +1151,7 @@ public class ApplicationTests
 
 
         return;
         return;
 
 
-        void OnApplicationOnInitializedChanged (object s, StateEventArgs<bool> a)
+        void OnApplicationOnInitializedChanged (object s, CancelEventArgs<bool> a)
         {
         {
             if (a.NewValue)
             if (a.NewValue)
             {
             {

+ 1 - 1
UnitTests/Application/KeyboardTests.cs

@@ -129,7 +129,7 @@ public class KeyboardTests
 
 
         return;
         return;
 
 
-        void OnApplicationOnInitializedChanged (object s, StateEventArgs<bool> a)
+        void OnApplicationOnInitializedChanged (object s, CancelEventArgs<bool> a)
         {
         {
             _output.WriteLine ("OnApplicationOnInitializedChanged: {0}", a.NewValue);
             _output.WriteLine ("OnApplicationOnInitializedChanged: {0}", a.NewValue);
             if (a.NewValue)
             if (a.NewValue)

+ 1 - 1
UnitTests/UICatalog/ScenarioTests.cs

@@ -73,7 +73,7 @@ public class ScenarioTests : TestsAllViews
 
 
         return;
         return;
 
 
-        void OnApplicationOnInitializedChanged (object s, StateEventArgs<bool> a)
+        void OnApplicationOnInitializedChanged (object s, CancelEventArgs<bool> a)
         {
         {
             if (a.NewValue)
             if (a.NewValue)
             {
             {

+ 1 - 1
UnitTests/Views/TextFieldTests.cs

@@ -363,7 +363,7 @@ public class TextFieldTests (ITestOutputHelper output)
 
 
         _textField.TextChanging += _textField_TextChanging;
         _textField.TextChanging += _textField_TextChanging;
 
 
-        void _textField_TextChanging (object sender, StateEventArgs<string> e)
+        void _textField_TextChanging (object sender, CancelEventArgs<string> e)
         {
         {
             if (e.NewValue.GetRuneCount () > 11)
             if (e.NewValue.GetRuneCount () > 11)
             {
             {