Migrate all controls to C# events

This commit is contained in:
Artyom
2020-09-23 01:13:52 +03:00
parent 28805f3c5c
commit bd7610df74
12 changed files with 21 additions and 21 deletions

View File

@@ -318,12 +318,12 @@ namespace Terminal.Gui {
/// <summary>
/// This event is raised when the selected item in the <see cref="ListView"/> has changed.
/// </summary>
public Action<ListViewItemEventArgs> SelectedItemChanged;
public event Action<ListViewItemEventArgs> SelectedItemChanged;
/// <summary>
/// This event is raised when the user Double Clicks on an item or presses ENTER to open the selected item.
/// </summary>
public Action<ListViewItemEventArgs> OpenSelectedItem;
public event Action<ListViewItemEventArgs> OpenSelectedItem;
///<inheritdoc/>
public override bool ProcessKey (KeyEvent kb)

View File

@@ -871,12 +871,12 @@ namespace Terminal.Gui {
/// <summary>
/// Raised as a menu is opening.
/// </summary>
public Action MenuOpening;
public event Action MenuOpening;
/// <summary>
/// Raised when a menu is closing.
/// </summary>
public Action MenuClosing;
public event Action MenuClosing;
internal Menu openMenu;
internal Menu openCurrentMenu;

View File

@@ -244,7 +244,7 @@ namespace Terminal.Gui {
/// <summary>
/// Invoked when the selected radio label has changed.
/// </summary>
public Action<SelectedItemChangedArgs> SelectedItemChanged;
public event Action<SelectedItemChangedArgs> SelectedItemChanged;
/// <summary>
/// The currently selected item from the list of radio labels

View File

@@ -60,7 +60,7 @@ namespace Terminal.Gui {
/// <summary>
/// This event is raised when the position on the scrollbar has changed.
/// </summary>
public Action ChangedPosition;
public event Action ChangedPosition;
/// <summary>
/// The position, relative to <see cref="Size"/>, to set the scrollbar at.

View File

@@ -41,7 +41,7 @@ namespace Terminal.Gui {
/// <remarks>
/// The passed <see cref="EventArgs"/> is a <see cref="ustring"/> containing the old value.
/// </remarks>
public Action<ustring> TextChanged;
public event Action<ustring> TextChanged;
/// <summary>
/// Initializes a new instance of the <see cref="TextField"/> class using <see cref="LayoutStyle.Computed"/> positioning.

View File

@@ -300,7 +300,7 @@ namespace Terminal.Gui {
/// <summary>
/// Raised when the <see cref="Text"/> of the <see cref="TextView"/> changes.
/// </summary>
public Action TextChanged;
public event Action TextChanged;
#if false
/// <summary>

View File

@@ -38,7 +38,7 @@ namespace Terminal.Gui {
/// <remarks>
/// The passed <see cref="EventArgs"/> is a <see cref="DateTimeEventArgs{T}"/> containing the old value, new value, and format string.
/// </remarks>
public Action<DateTimeEventArgs<TimeSpan>> TimeChanged;
public event Action<DateTimeEventArgs<TimeSpan>> TimeChanged;
/// <summary>
/// Initializes a new instance of <see cref="TimeField"/> using <see cref="LayoutStyle.Absolute"/> positioning.

View File

@@ -506,10 +506,10 @@ namespace Terminal.Gui {
X = Pos.Right (dirLabel),
Y = 1 + msgLines,
Width = Dim.Fill () - 1,
TextChanged = (e) => {
DirectoryPath = dirEntry.Text;
nameEntry.Text = ustring.Empty;
}
};
dirEntry.TextChanged += (e) => {
DirectoryPath = dirEntry.Text;
nameEntry.Text = ustring.Empty;
};
Add (dirLabel, dirEntry);

View File

@@ -133,8 +133,8 @@ namespace UICatalog {
_xRadioGroup = new RadioGroup (radioItems) {
X = 0,
Y = Pos.Bottom (label),
SelectedItemChanged = (selected) => DimPosChanged (_curView),
};
_xRadioGroup.SelectedItemChanged += (selected) => DimPosChanged (_curView);
_xText = new TextField ($"{_xVal}") { X = Pos.Right (label) + 1, Y = 0, Width = 4 };
_xText.TextChanged += (args) => {
try {
@@ -164,8 +164,8 @@ namespace UICatalog {
_yRadioGroup = new RadioGroup (radioItems) {
X = Pos.X (label),
Y = Pos.Bottom (label),
SelectedItemChanged = (selected) => DimPosChanged (_curView),
};
_yRadioGroup.SelectedItemChanged += (selected) => DimPosChanged (_curView);
_locationFrame.Add (_yRadioGroup);
_sizeFrame = new FrameView ("Size (Dim)") {
@@ -181,8 +181,8 @@ namespace UICatalog {
_wRadioGroup = new RadioGroup (radioItems) {
X = 0,
Y = Pos.Bottom (label),
SelectedItemChanged = (selected) => DimPosChanged (_curView)
};
_wRadioGroup.SelectedItemChanged += (selected) => DimPosChanged (_curView);
_wText = new TextField ($"{_wVal}") { X = Pos.Right (label) + 1, Y = 0, Width = 4 };
_wText.TextChanged += (args) => {
try {
@@ -212,8 +212,8 @@ namespace UICatalog {
_hRadioGroup = new RadioGroup (radioItems) {
X = Pos.X (label),
Y = Pos.Bottom (label),
SelectedItemChanged = (selected) => DimPosChanged (_curView),
};
_hRadioGroup.SelectedItemChanged += (selected) => DimPosChanged (_curView);
_sizeFrame.Add (_hRadioGroup);
_settingsPane.Add (_sizeFrame);

View File

@@ -62,7 +62,7 @@ namespace UICatalog {
jumpList.X = Pos.X (label);
jumpList.Y = Pos.Bottom (label);
jumpList.Width = Dim.Fill ();
jumpList.SelectedItemChanged = (args) => {
jumpList.SelectedItemChanged += (args) => {
_charMap.Start = radioItems[args.SelectedItem].start;
};

View File

@@ -498,12 +498,12 @@ namespace UICatalog {
SelectCurrentMenuBarItem ();
};
_lstMenus.SelectedItemChanged = (e) => {
_lstMenus.SelectedItemChanged += (e) => {
var menuBarItem = DataContext.Menus.Count > 0 ? DataContext.Menus [e.Item].MenuItem : null;
EditMenuBarItem (menuBarItem);
};
_lstMenus.OpenSelectedItem = (e) => {
_lstMenus.OpenSelectedItem += (e) => {
_currentMenuBarItem = DataContext.Menus [e.Item].MenuItem;
DataContext.Parent = _currentMenuBarItem.Title;
DataContext.Menus = new List<DynamicMenuItemList> ();

View File

@@ -40,7 +40,7 @@ namespace UICatalog {
ColorScheme = Colors.TopLevel,
Text = txt,
};
edit.TextChanged = () => {
edit.TextChanged += () => {
foreach (var alignment in alignments) {
singleLines [(int)alignment].Text = edit.Text;
multipleLines [(int)alignment].Text = edit.Text;