mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
StringEventArgs -> CancelEventArgs<string>
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Terminal.Gui;
|
||||
|
||||
/// <summary>Cancellable event args for string-based property change events.</summary>
|
||||
public class StringEventArgs : CancelEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="StringEventArgs"/>
|
||||
/// </summary>
|
||||
public StringEventArgs () {}
|
||||
|
||||
/// <summary>Initializes a new instance of <see cref="StringEventArgs"/></summary>
|
||||
/// <param name="oldString">The old string.</param>
|
||||
/// <param name="newString">The new string.</param>
|
||||
public StringEventArgs (string oldString, string newString)
|
||||
{
|
||||
OldValue = oldString;
|
||||
NewValue = newString;
|
||||
}
|
||||
/// <summary>The new string.</summary>
|
||||
public string NewValue { get; set; }
|
||||
|
||||
/// <summary>The old string.</summary>
|
||||
public string OldValue { get; set; }
|
||||
}
|
||||
@@ -64,8 +64,8 @@ namespace Terminal.Gui
|
||||
|
||||
/// <summary>Method that invoke the <see cref="TextChanged"/> event if it's defined.</summary>
|
||||
/// <param name="oldValue">The previous text before replaced.</param>
|
||||
/// <returns>Returns the <see cref="StringEventArgs"/></returns>
|
||||
void OnTextChanged (StringEventArgs oldValue);
|
||||
/// <returns>Returns the <see cref="CancelEventArgs{T}"/></returns>
|
||||
void OnTextChanged (CancelEventArgs<string> oldValue);
|
||||
|
||||
/// <summary>
|
||||
/// Changed event, raised when the text has changed.
|
||||
@@ -74,7 +74,7 @@ namespace Terminal.Gui
|
||||
/// <see cref="string"/> containing the old value.
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
event EventHandler<StringEventArgs> TextChanged;
|
||||
event EventHandler<CancelEventArgs<string>> TextChanged;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -125,7 +125,7 @@ namespace Terminal.Gui
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event EventHandler<StringEventArgs> TextChanged;
|
||||
public event EventHandler<CancelEventArgs<string>> TextChanged;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Text
|
||||
@@ -206,7 +206,7 @@ namespace Terminal.Gui
|
||||
|
||||
if (result)
|
||||
{
|
||||
OnTextChanged (new StringEventArgs { NewValue = oldValue });
|
||||
OnTextChanged (new CancelEventArgs<string> (oldValue, Text));
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -220,14 +220,14 @@ namespace Terminal.Gui
|
||||
|
||||
if (result)
|
||||
{
|
||||
OnTextChanged (new StringEventArgs { NewValue = oldValue });
|
||||
OnTextChanged (new CancelEventArgs<string> (oldValue, Text));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnTextChanged (StringEventArgs oldValue) { TextChanged?.Invoke (this, oldValue); }
|
||||
public void OnTextChanged (CancelEventArgs<string> args) { TextChanged?.Invoke (this, args); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -260,7 +260,7 @@ namespace Terminal.Gui
|
||||
public bool ValidateOnInput { get; set; } = true;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event EventHandler<StringEventArgs> TextChanged;
|
||||
public event EventHandler<CancelEventArgs<string>> TextChanged;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string Text
|
||||
@@ -333,7 +333,7 @@ namespace Terminal.Gui
|
||||
{
|
||||
string oldValue = Text;
|
||||
_text.RemoveAt (pos);
|
||||
OnTextChanged (new StringEventArgs { NewValue = Text, OldValue = oldValue });
|
||||
OnTextChanged (new CancelEventArgs<string> (oldValue, Text));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -349,7 +349,7 @@ namespace Terminal.Gui
|
||||
{
|
||||
string oldValue = Text;
|
||||
_text.Insert (pos, (Rune)ch);
|
||||
OnTextChanged (new StringEventArgs { NewValue = Text, OldValue = oldValue });
|
||||
OnTextChanged (new CancelEventArgs<string> (oldValue, Text));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -358,7 +358,7 @@ namespace Terminal.Gui
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void OnTextChanged (StringEventArgs oldValue) { TextChanged?.Invoke (this, oldValue); }
|
||||
public void OnTextChanged (CancelEventArgs<string> args) { TextChanged?.Invoke (this, args); }
|
||||
|
||||
/// <summary>Compiles the regex pattern for validation./></summary>
|
||||
private void CompileMask () { _regex = new Regex (StringExtensions.ToString (_pattern), RegexOptions.Compiled); }
|
||||
|
||||
@@ -61,7 +61,7 @@ public class Tile
|
||||
/// <param name="newTitle">The new <see cref="Title"/> to be replaced.</param>
|
||||
public virtual void OnTitleChanged (string oldTitle, string newTitle)
|
||||
{
|
||||
var args = new StringEventArgs (oldTitle, newTitle);
|
||||
var args = new CancelEventArgs<string> (oldTitle, newTitle);
|
||||
TitleChanged?.Invoke (this, args);
|
||||
}
|
||||
|
||||
@@ -74,18 +74,18 @@ public class Tile
|
||||
/// <returns><c>true</c> if an event handler cancelled the Title change.</returns>
|
||||
public virtual bool OnTitleChanging (string oldTitle, string newTitle)
|
||||
{
|
||||
var args = new StringEventArgs (oldTitle, newTitle);
|
||||
var args = new CancelEventArgs<string> (oldTitle, newTitle);
|
||||
TitleChanging?.Invoke (this, args);
|
||||
|
||||
return args.Cancel;
|
||||
}
|
||||
|
||||
/// <summary>Event fired after the <see cref="Title"/> has been changed.</summary>
|
||||
public event EventHandler<StringEventArgs> TitleChanged;
|
||||
public event EventHandler<CancelEventArgs<string>> TitleChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the <see cref="Title"/> is changing.
|
||||
/// <see cref="CancelEventArgs.Cancel"/> can be set to <c>true</c> to cancel the change.
|
||||
/// </summary>
|
||||
public event EventHandler<StringEventArgs> TitleChanging;
|
||||
public event EventHandler<CancelEventArgs<string>> TitleChanging;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user