diff --git a/Designer/Program.cs b/Designer/Program.cs index 34a9e688d..143159350 100644 --- a/Designer/Program.cs +++ b/Designer/Program.cs @@ -85,10 +85,10 @@ namespace Designer { HotNormal = Attribute.Make(Color.Red, Color.BrightRed), }, }; - loginText.MouseEnter += LoginText_MouseEnter; - loginText.MouseLeave += LoginText_MouseLeave; - loginText.Enter += LoginText_Enter; - loginText.Leave += LoginText_Leave; + loginText.MouseEnter += (e) => Text_MouseEnter (e, loginText); + loginText.MouseLeave += (e) => Text_MouseLeave (e, loginText); + loginText.Enter += (e) => Text_Enter (e, loginText); + loginText.Leave += (e) => Text_Leave (e, loginText); var passText = new TextField ("") { Secret = true, @@ -102,30 +102,34 @@ namespace Designer { Y = Pos.Top (test), Width = Dim.Width (loginText) }; + testText.MouseEnter += (e) => Text_MouseEnter (e, testText); + testText.MouseLeave += (e) => Text_MouseLeave (e, testText); + testText.Enter += (e) => Text_Enter (e, testText); + testText.Leave += (e) => Text_Leave (e, testText); surface.Add (login, password, test, loginText, passText, testText); Application.Top.Add (menu, surface); Application.Run (); } - private static void LoginText_Leave (object sender, EventArgs e) + private static void Text_Leave (View.FocusEventArgs e, TextField view) { - ((TextField)sender).Text = $"Leaving from: {sender}"; + view.Text = $"Leaving from: {view}"; } - private static void LoginText_Enter (object sender, EventArgs e) + private static void Text_Enter (View.FocusEventArgs e, TextField view) { - ((TextField)sender).Text = $"Entering in: {sender}"; + view.Text = $"Entering in: {view}"; } - private static void LoginText_MouseLeave (object sender, View.MouseEventEventArgs e) + private static void Text_MouseLeave (View.MouseEventEventArgs e, TextField view) { - ((TextField)sender).Text = $"Mouse leave at X: {e.MouseEvent.X}; Y: {e.MouseEvent.Y} HasFocus: {e.MouseEvent.View.HasFocus}"; + view.Text = $"Mouse leave at X: {e.MouseEvent.X}; Y: {e.MouseEvent.Y} HasFocus: {e.MouseEvent.View.HasFocus}"; } - private static void LoginText_MouseEnter (object sender, View.MouseEventEventArgs e) + private static void Text_MouseEnter (View.MouseEventEventArgs e, TextField view) { - ((TextField)sender).Text = $"Mouse enter at X: {e.MouseEvent.X}; Y: {e.MouseEvent.Y} HasFocus: {e.MouseEvent.View.HasFocus}"; + view.Text = $"Mouse enter at X: {e.MouseEvent.X}; Y: {e.MouseEvent.Y} HasFocus: {e.MouseEvent.View.HasFocus}"; } } } diff --git a/Example/demo.cs b/Example/demo.cs index 5c161a3ac..0a78162ae 100644 --- a/Example/demo.cs +++ b/Example/demo.cs @@ -90,7 +90,7 @@ static class Demo { Width = Dim.Fill (), Height = Dim.Fill () }; - container.KeyUp += (sender, e) => { + container.KeyUp += (e) => { if (e.KeyEvent.Key == Key.Esc) container.Running = false; }; @@ -335,17 +335,16 @@ static class Demo { $"{mi.Title.ToString ()} selected. Is from submenu: {mi.GetMenuBarItem ()}", "Ok"); } - static void MenuKeysStyle_Toggled (object sender, bool e) + static void MenuKeysStyle_Toggled (bool e) { menu.UseKeysUpDownAsKeysLeftRight = menuKeysStyle.Checked; } - static void MenuAutoMouseNav_Toggled (object sender, bool e) + static void MenuAutoMouseNav_Toggled (bool e) { menu.WantMousePositionReports = menuAutoMouseNav.Checked; } - static void Copy () { TextField textField = menu.LastFocused as TextField; @@ -501,10 +500,9 @@ static class Demo { listView.MoveDown (); } - - container.KeyDown += (o, e) => KeyDownPressUp (e.KeyEvent, "Down"); - container.KeyPress += (o, e) => KeyDownPressUp (e.KeyEvent, "Press"); - container.KeyUp += (o, e) => KeyDownPressUp (e.KeyEvent, "Up"); + container.KeyDown += (e) => KeyDownPressUp (e.KeyEvent, "Down"); + container.KeyPress += (e) => KeyDownPressUp (e.KeyEvent, "Press"); + container.KeyUp += (e) => KeyDownPressUp (e.KeyEvent, "Up"); Application.Run (container); } #endregion @@ -638,7 +636,7 @@ static class Demo { var bottom2 = new Label ("This should go on the bottom of another top-level!"); top.Add (bottom2); - top.LayoutComplete += (sender, e) => { + top.LayoutComplete += (e) => { bottom.X = win.X; bottom.Y = Pos.Bottom (win) - Pos.Top (win) - margin; bottom2.X = Pos.Left (win); @@ -648,14 +646,13 @@ static class Demo { win.KeyPress += Win_KeyPress; - top.Add (win); //top.Add (menu); top.Add (menu, statusBar); Application.Run (); } - private static void Win_KeyPress (object sender, View.KeyEventEventArgs e) + private static void Win_KeyPress (View.KeyEventEventArgs e) { if (e.KeyEvent.Key == Key.ControlT) { if (menu.IsMenuOpen) diff --git a/Terminal.Gui/Core/Application.cs b/Terminal.Gui/Core/Application.cs index 750292929..476976d15 100644 --- a/Terminal.Gui/Core/Application.cs +++ b/Terminal.Gui/Core/Application.cs @@ -92,7 +92,7 @@ namespace Terminal.Gui { /// /// See also /// - public static event EventHandler Iteration; + public static event Action Iteration; /// /// Returns a rectangle that is centered in the screen for the provided size. @@ -416,7 +416,7 @@ namespace Terminal.Gui { /// This event is fired once when the application is first loaded. The dimensions of the /// terminal are provided. /// - public static event EventHandler Loaded; + public static event Action Loaded; /// /// Building block API: Prepares the provided for execution. @@ -452,7 +452,7 @@ namespace Terminal.Gui { if (toplevel.LayoutStyle == LayoutStyle.Computed) toplevel.SetRelativeLayout (new Rect (0, 0, Driver.Cols, Driver.Rows)); toplevel.LayoutSubviews (); - Loaded?.Invoke (null, new ResizedEventArgs () { Rows = Driver.Rows, Cols = Driver.Cols }); + Loaded?.Invoke (new ResizedEventArgs () { Rows = Driver.Rows, Cols = Driver.Cols }); toplevel.WillPresent (); Redraw (toplevel); toplevel.PositionCursor (); @@ -572,7 +572,7 @@ namespace Terminal.Gui { firstIteration = false; MainLoop.MainIteration (); - Iteration?.Invoke (null, EventArgs.Empty); + Iteration?.Invoke (); } else if (wait == false) return; if (state.Toplevel.NeedDisplay != null && (!state.Toplevel.NeedDisplay.IsEmpty || state.Toplevel.childNeedsDisplay)) { @@ -678,12 +678,12 @@ namespace Terminal.Gui { /// /// Invoked when the terminal was resized. The new size of the terminal is provided. /// - public static event EventHandler Resized; + public static event Action Resized; static void TerminalResized () { var full = new Rect (0, 0, Driver.Cols, Driver.Rows); - Resized?.Invoke (null, new ResizedEventArgs () { Cols = full.Width, Rows = full.Height }); + Resized?.Invoke (new ResizedEventArgs () { Cols = full.Width, Rows = full.Height }); Driver.Clip = full; foreach (var t in toplevels) { t.PositionToplevels (); diff --git a/Terminal.Gui/Core/Toplevel.cs b/Terminal.Gui/Core/Toplevel.cs index 46b2a99d9..8a5b37177 100644 --- a/Terminal.Gui/Core/Toplevel.cs +++ b/Terminal.Gui/Core/Toplevel.cs @@ -53,14 +53,14 @@ namespace Terminal.Gui { /// Subscribe to this event to perform tasks when the has been laid out and focus has been set. /// changes. A Ready event handler is a good place to finalize initialization after calling `(topLevel)`. /// - public event EventHandler Ready; + public event Action Ready; /// /// Called from after the has entered it's first iteration of the loop. /// internal virtual void OnReady () { - Ready?.Invoke (this, EventArgs.Empty); + Ready?.Invoke (); } /// diff --git a/Terminal.Gui/Core/View.cs b/Terminal.Gui/Core/View.cs index 796701168..af199e0e5 100644 --- a/Terminal.Gui/Core/View.cs +++ b/Terminal.Gui/Core/View.cs @@ -124,27 +124,27 @@ namespace Terminal.Gui { /// /// Event fired when the view gets focus. /// - public event EventHandler Enter; + public event Action Enter; /// /// Event fired when the view looses focus. /// - public event EventHandler Leave; + public event Action Leave; /// /// Event fired when the view receives the mouse event for the first time. /// - public event EventHandler MouseEnter; + public event Action MouseEnter; /// /// Event fired when the view receives a mouse event for the last time. /// - public event EventHandler MouseLeave; + public event Action MouseLeave; /// /// Event fired when a mouse event is generated. /// - public event EventHandler MouseClick; + public event Action MouseClick; internal Direction FocusDirection { get => SuperView?.FocusDirection ?? focusDirection; @@ -840,7 +840,7 @@ namespace Terminal.Gui { public override bool OnEnter () { FocusEventArgs args = new FocusEventArgs (); - Enter?.Invoke (this, args); + Enter?.Invoke (args); if (args.Handled) return true; if (base.OnEnter ()) @@ -853,7 +853,7 @@ namespace Terminal.Gui { public override bool OnLeave () { FocusEventArgs args = new FocusEventArgs (); - Leave?.Invoke (this, args); + Leave?.Invoke (args); if (args.Handled) return true; if (base.OnLeave ()) @@ -988,7 +988,7 @@ namespace Terminal.Gui { /// Rect provides the view-relative rectangle describing the currently visible viewport into the . /// /// - public event EventHandler DrawContent; + public event Action DrawContent; /// /// Enables overrides to draw infinitely scrolled content and/or a background behind added controls. @@ -999,7 +999,7 @@ namespace Terminal.Gui { /// public virtual void OnDrawContent (Rect viewport) { - DrawContent?.Invoke (this, viewport); + DrawContent?.Invoke (viewport); } /// @@ -1058,14 +1058,14 @@ namespace Terminal.Gui { /// /// Invoked when a character key is pressed and occurs after the key up event. /// - public event EventHandler KeyPress; + public event Action KeyPress; /// public override bool ProcessKey (KeyEvent keyEvent) { KeyEventEventArgs args = new KeyEventEventArgs (keyEvent); - KeyPress?.Invoke (this, args); + KeyPress?.Invoke (args); if (args.Handled) return true; if (Focused?.ProcessKey (keyEvent) == true) @@ -1078,7 +1078,7 @@ namespace Terminal.Gui { public override bool ProcessHotKey (KeyEvent keyEvent) { KeyEventEventArgs args = new KeyEventEventArgs (keyEvent); - KeyPress?.Invoke (this, args); + KeyPress?.Invoke (args); if (args.Handled) return true; if (subviews == null || subviews.Count == 0) @@ -1093,7 +1093,7 @@ namespace Terminal.Gui { public override bool ProcessColdKey (KeyEvent keyEvent) { KeyEventEventArgs args = new KeyEventEventArgs (keyEvent); - KeyPress?.Invoke (this, args); + KeyPress?.Invoke (args); if (args.Handled) return true; if (subviews == null || subviews.Count == 0) @@ -1107,13 +1107,13 @@ namespace Terminal.Gui { /// /// Invoked when a key is pressed /// - public event EventHandler KeyDown; + public event Action KeyDown; /// Contains the details about the key that produced the event. public override bool OnKeyDown (KeyEvent keyEvent) { KeyEventEventArgs args = new KeyEventEventArgs (keyEvent); - KeyDown?.Invoke (this, args); + KeyDown?.Invoke (args); if (args.Handled) return true; if (subviews == null || subviews.Count == 0) @@ -1128,13 +1128,13 @@ namespace Terminal.Gui { /// /// Invoked when a key is released /// - public event EventHandler KeyUp; + public event Action KeyUp; /// Contains the details about the key that produced the event. public override bool OnKeyUp (KeyEvent keyEvent) { KeyEventEventArgs args = new KeyEventEventArgs (keyEvent); - KeyUp?.Invoke (this, args); + KeyUp?.Invoke (args); if (args.Handled) return true; if (subviews == null || subviews.Count == 0) @@ -1386,14 +1386,14 @@ namespace Terminal.Gui { /// /// Subscribe to this event to perform tasks when the has been resized or the layout has otherwise changed. /// - public event EventHandler LayoutComplete; + public event Action LayoutComplete; /// /// Raises the event. Called from after all sub-views have been laid out. /// internal virtual void OnLayoutComplete (LayoutEventArgs args) { - LayoutComplete?.Invoke (this, args); + LayoutComplete?.Invoke (args); } /// @@ -1483,7 +1483,7 @@ namespace Terminal.Gui { public override bool OnMouseEnter (MouseEvent mouseEvent) { MouseEventEventArgs args = new MouseEventEventArgs (mouseEvent); - MouseEnter?.Invoke (this, args); + MouseEnter?.Invoke (args); if (args.Handled) return true; if (base.OnMouseEnter (mouseEvent)) @@ -1496,7 +1496,7 @@ namespace Terminal.Gui { public override bool OnMouseLeave (MouseEvent mouseEvent) { MouseEventEventArgs args = new MouseEventEventArgs (mouseEvent); - MouseLeave?.Invoke (this, args); + MouseLeave?.Invoke (args); if (args.Handled) return true; if (base.OnMouseLeave (mouseEvent)) @@ -1514,7 +1514,7 @@ namespace Terminal.Gui { public virtual bool OnMouseEvent (MouseEvent mouseEvent) { MouseEventEventArgs args = new MouseEventEventArgs (mouseEvent); - MouseClick?.Invoke (this, args); + MouseClick?.Invoke (args); if (args.Handled) return true; if (MouseEvent (mouseEvent)) diff --git a/Terminal.Gui/Views/Checkbox.cs b/Terminal.Gui/Views/Checkbox.cs index 8f68f9823..0f54605e6 100644 --- a/Terminal.Gui/Views/Checkbox.cs +++ b/Terminal.Gui/Views/Checkbox.cs @@ -25,14 +25,14 @@ namespace Terminal.Gui { /// raised when the is activated either with /// the mouse or the keyboard. The passed bool contains the previous state. /// - public event EventHandler Toggled; + public event Action Toggled; /// /// Called when the property changes. Invokes the event. /// public virtual void OnToggled (bool previousChecked) { - Toggled?.Invoke (this, previousChecked); + Toggled?.Invoke (previousChecked); } /// diff --git a/Terminal.Gui/Views/ComboBox.cs b/Terminal.Gui/Views/ComboBox.cs index 64d62a95b..d40075082 100644 --- a/Terminal.Gui/Views/ComboBox.cs +++ b/Terminal.Gui/Views/ComboBox.cs @@ -22,7 +22,7 @@ namespace Terminal.Gui { /// Client code can hook up to this event, it is /// raised when the selection has been confirmed. /// - public event EventHandler Changed; + public event Action Changed; IList listsource; IList searchset; diff --git a/Terminal.Gui/Views/DateField.cs b/Terminal.Gui/Views/DateField.cs index b2f7df16d..e0bcae775 100644 --- a/Terminal.Gui/Views/DateField.cs +++ b/Terminal.Gui/Views/DateField.cs @@ -80,7 +80,7 @@ namespace Terminal.Gui { Changed += DateField_Changed; } - void DateField_Changed (object sender, ustring e) + void DateField_Changed (ustring e) { try { if (!DateTime.TryParseExact (GetDate (Text).ToString (), GetInvarianteFormat (), CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime result)) diff --git a/Terminal.Gui/Views/ListView.cs b/Terminal.Gui/Views/ListView.cs index 460918bc5..13a7632d1 100644 --- a/Terminal.Gui/Views/ListView.cs +++ b/Terminal.Gui/Views/ListView.cs @@ -307,12 +307,12 @@ namespace Terminal.Gui { /// /// This event is raised when the selected item in the has changed. /// - public event EventHandler SelectedChanged; + public event Action SelectedChanged; /// /// This event is raised when the user Double Clicks on an item or presses ENTER to open the selected item. /// - public event EventHandler OpenSelectedItem; + public event Action OpenSelectedItem; /// public override bool ProcessKey (KeyEvent kb) @@ -469,7 +469,7 @@ namespace Terminal.Gui { { if (selected != lastSelectedItem) { var value = source.ToList () [selected]; - SelectedChanged?.Invoke (this, new ListViewItemEventArgs (selected, value)); + SelectedChanged?.Invoke (new ListViewItemEventArgs (selected, value)); lastSelectedItem = selected; return true; } @@ -484,7 +484,7 @@ namespace Terminal.Gui { public virtual bool OnOpenSelectedItem () { var value = source.ToList () [selected]; - OpenSelectedItem?.Invoke (this, new ListViewItemEventArgs (selected, value)); + OpenSelectedItem?.Invoke (new ListViewItemEventArgs (selected, value)); return true; } diff --git a/Terminal.Gui/Views/Menu.cs b/Terminal.Gui/Views/Menu.cs index 7b482cbb3..5a1eb1c3b 100644 --- a/Terminal.Gui/Views/Menu.cs +++ b/Terminal.Gui/Views/Menu.cs @@ -691,14 +691,14 @@ namespace Terminal.Gui { } /// - /// Raised as a menu is opened. + /// Raised as a menu is opening. /// - public event EventHandler OnOpenMenu; + public event Action MenuOpening; /// /// Raised when a menu is closing. /// - public event EventHandler OnCloseMenu; + public event Action MenuClosing; internal Menu openMenu; Menu openCurrentMenu; @@ -712,6 +712,22 @@ namespace Terminal.Gui { /// public bool IsMenuOpen { get; protected set; } + /// + /// Virtual method that will invoke the + /// + public virtual void OnMenuOpening () + { + MenuOpening?.Invoke (); + } + + /// + /// Virtual method that will invoke the + /// + public virtual void OnMenuClosing () + { + MenuClosing?.Invoke (); + } + View lastFocused; /// @@ -722,7 +738,7 @@ namespace Terminal.Gui { internal void OpenMenu (int index, int sIndex = -1, MenuBarItem subMenu = null) { isMenuOpening = true; - OnOpenMenu?.Invoke (this, null); + OnMenuOpening (); int pos = 0; switch (subMenu) { case null: @@ -800,7 +816,7 @@ namespace Terminal.Gui { internal void CloseMenu (bool reopen = false, bool isSubMenu = false) { isMenuClosing = true; - OnCloseMenu?.Invoke (this, null); + OnMenuClosing (); switch (isSubMenu) { case false: if (openMenu != null) diff --git a/Terminal.Gui/Views/ScrollView.cs b/Terminal.Gui/Views/ScrollView.cs index f93de4c22..5bb3626a2 100644 --- a/Terminal.Gui/Views/ScrollView.cs +++ b/Terminal.Gui/Views/ScrollView.cs @@ -389,12 +389,12 @@ namespace Terminal.Gui { SetNeedsLayout (); } - void View_MouseLeave (object sender, MouseEventEventArgs e) + void View_MouseLeave (MouseEventEventArgs e) { Application.UngrabMouse (); } - void View_MouseEnter (object sender, MouseEventEventArgs e) + void View_MouseEnter (MouseEventEventArgs e) { Application.GrabMouse (this); } diff --git a/Terminal.Gui/Views/StatusBar.cs b/Terminal.Gui/Views/StatusBar.cs index 93d205ea5..baf44035f 100644 --- a/Terminal.Gui/Views/StatusBar.cs +++ b/Terminal.Gui/Views/StatusBar.cs @@ -125,7 +125,7 @@ namespace Terminal.Gui { Width = Dim.Fill (); Height = 1; - LayoutComplete += (sender, e) => { + LayoutComplete += (e) => { X = 0; Height = 1; #if SNAP_TO_TOP diff --git a/Terminal.Gui/Views/TextField.cs b/Terminal.Gui/Views/TextField.cs index f390e2a59..09277a5e8 100644 --- a/Terminal.Gui/Views/TextField.cs +++ b/Terminal.Gui/Views/TextField.cs @@ -41,7 +41,7 @@ namespace Terminal.Gui { /// /// The passed is a containing the old value. /// - public event EventHandler Changed; + public event Action Changed; /// /// Initializes a new instance of the class using positioning. @@ -145,7 +145,7 @@ namespace Terminal.Gui { historyText.Add (ustring.Make (text)); idxhistoryText++; } - Changed?.Invoke (this, oldText); + Changed?.Invoke (oldText); if (point > text.Count) point = Math.Max (DisplaySize (text, 0) - 1, 0); diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs index 0f272bd40..c11521ad7 100644 --- a/Terminal.Gui/Views/TextView.cs +++ b/Terminal.Gui/Views/TextView.cs @@ -285,7 +285,7 @@ namespace Terminal.Gui { /// /// Raised when the of the changes. /// - public event EventHandler TextChanged; + public event Action TextChanged; #if false /// @@ -295,7 +295,7 @@ namespace Terminal.Gui { /// Client code can hook up to this event, it is /// raised when the text in the entry changes. /// - public event EventHandler Changed; + public event Action Changed; #endif /// /// Initalizes a on the specified area, with absolute position and size. @@ -334,7 +334,7 @@ namespace Terminal.Gui { set { ResetPosition (); model.LoadString (value); - TextChanged?.Invoke(this, new EventArgs()); + TextChanged?.Invoke (); SetNeedsDisplay (); } } diff --git a/Terminal.Gui/Views/TimeField.cs b/Terminal.Gui/Views/TimeField.cs index af5141fd5..5c979caca 100644 --- a/Terminal.Gui/Views/TimeField.cs +++ b/Terminal.Gui/Views/TimeField.cs @@ -80,7 +80,7 @@ namespace Terminal.Gui { Changed += TimeField_Changed; } - void TimeField_Changed (object sender, ustring e) + void TimeField_Changed (ustring e) { try { if (!TimeSpan.TryParseExact (Text.ToString ().Trim (), Format.Trim (), CultureInfo.CurrentCulture, TimeSpanStyles.None, out TimeSpan result)) diff --git a/UICatalog/Scenarios/AllViewsTester.cs b/UICatalog/Scenarios/AllViewsTester.cs index 306f2284d..bcee24f6f 100644 --- a/UICatalog/Scenarios/AllViewsTester.cs +++ b/UICatalog/Scenarios/AllViewsTester.cs @@ -91,10 +91,10 @@ namespace UICatalog { AllowsMarking = false, ColorScheme = Colors.TopLevel, }; - _classListView.OpenSelectedItem += (o, a) => { + _classListView.OpenSelectedItem += (a) => { Top.SetFocus (_settingsPane); }; - _classListView.SelectedChanged += (sender, args) => { + _classListView.SelectedChanged += (args) => { ClearClass (_curView); _curView = CreateClass (_viewClasses.Values.ToArray () [_classListView.SelectedItem]); }; @@ -109,7 +109,7 @@ namespace UICatalog { ColorScheme = Colors.TopLevel, }; _computedCheckBox = new CheckBox ("Computed Layout", true) { X = 0, Y = 0 }; - _computedCheckBox.Toggled += (sender, previousState) => { + _computedCheckBox.Toggled += (previousState) => { if (_curView != null) { _curView.LayoutStyle = previousState ? LayoutStyle.Absolute : LayoutStyle.Computed; _hostPane.LayoutSubviews (); @@ -134,7 +134,7 @@ namespace UICatalog { SelectionChanged = (selected) => DimPosChanged (_curView), }; _xText = new TextField ($"{_xVal}") { X = Pos.Right (label) + 1, Y = 0, Width = 4 }; - _xText.Changed += (sender, args) => { + _xText.Changed += (args) => { try { _xVal = int.Parse (_xText.Text.ToString ()); DimPosChanged (_curView); @@ -150,7 +150,7 @@ namespace UICatalog { label = new Label ("y:") { X = Pos.Right (_xRadioGroup) + 1, Y = 0 }; _locationFrame.Add (label); _yText = new TextField ($"{_yVal}") { X = Pos.Right (label) + 1, Y = 0, Width = 4 }; - _yText.Changed += (sender, args) => { + _yText.Changed += (args) => { try { _yVal = int.Parse (_yText.Text.ToString ()); DimPosChanged (_curView); @@ -182,7 +182,7 @@ namespace UICatalog { SelectionChanged = (selected) => DimPosChanged (_curView) }; _wText = new TextField ($"{_wVal}") { X = Pos.Right (label) + 1, Y = 0, Width = 4 }; - _wText.Changed += (sender, args) => { + _wText.Changed += (args) => { try { _wVal = int.Parse (_wText.Text.ToString ()); DimPosChanged (_curView); @@ -197,7 +197,7 @@ namespace UICatalog { label = new Label ("height:") { X = Pos.Right (_wRadioGroup) + 1, Y = 0 }; _sizeFrame.Add (label); _hText = new TextField ($"{_hVal}") { X = Pos.Right (label) + 1, Y = 0, Width = 4 }; - _hText.Changed += (sender, args) => { + _hText.Changed += (args) => { try { _hVal = int.Parse (_hText.Text.ToString ()); DimPosChanged (_curView); diff --git a/UICatalog/Scenarios/Buttons.cs b/UICatalog/Scenarios/Buttons.cs index ac41cb149..b494dd5b4 100644 --- a/UICatalog/Scenarios/Buttons.cs +++ b/UICatalog/Scenarios/Buttons.cs @@ -149,7 +149,7 @@ namespace UICatalog { ColorScheme = Colors.TopLevel }; - lvTextAlig.SelectedChanged += (o, e) => { + lvTextAlig.SelectedChanged += (e) => { switch (e.Value) { case "Left": sizeBtn.TextAlignment = TextAlignment.Left; diff --git a/UICatalog/Scenarios/CharacterMap.cs b/UICatalog/Scenarios/CharacterMap.cs index 96288504d..ddd47c44d 100644 --- a/UICatalog/Scenarios/CharacterMap.cs +++ b/UICatalog/Scenarios/CharacterMap.cs @@ -81,7 +81,7 @@ namespace UICatalog { ContentSize = new Size (CharMap.RowWidth, MaxCodePointVal / 16); ShowVerticalScrollIndicator = true; ShowHorizontalScrollIndicator = false; - LayoutComplete += (sender, args) => { + LayoutComplete += (args) => { if (Bounds.Width <= RowWidth) { ShowHorizontalScrollIndicator = true; } else { @@ -93,7 +93,7 @@ namespace UICatalog { } #if true - private void CharMap_DrawContent (object sender, Rect viewport) + private void CharMap_DrawContent (Rect viewport) { for (int header = 0; header < 16; header++) { Move (viewport.X + RowHeaderWidth + 1 + (header * 3), 0); diff --git a/UICatalog/Scenarios/ComputedLayout.cs b/UICatalog/Scenarios/ComputedLayout.cs index f5e87df87..7fde004d4 100644 --- a/UICatalog/Scenarios/ComputedLayout.cs +++ b/UICatalog/Scenarios/ComputedLayout.cs @@ -57,7 +57,7 @@ namespace UICatalog { ColorScheme = Colors.Error }; - Win.LayoutComplete += (sender, a) => { + Win.LayoutComplete += (a) => { horizontalRuler.Text = rule.Repeat ((int)Math.Ceiling ((double)(horizontalRuler.Bounds.Width) / (double)rule.Length)) [0..(horizontalRuler.Bounds.Width)]; verticalRuler.Text = vrule.Repeat ((int)Math.Ceiling ((double)(verticalRuler.Bounds.Height * 2) / (double)rule.Length)) [0..(verticalRuler.Bounds.Height * 2)]; }; diff --git a/UICatalog/Scenarios/Keys.cs b/UICatalog/Scenarios/Keys.cs index 8e1142b4b..7688dafb5 100644 --- a/UICatalog/Scenarios/Keys.cs +++ b/UICatalog/Scenarios/Keys.cs @@ -92,7 +92,7 @@ namespace UICatalog { }; Win.Add (labelKeypress); - Win.KeyPress += (sender, a) => labelKeypress.Text = a.KeyEvent.ToString (); + Win.KeyPress += (a) => labelKeypress.Text = a.KeyEvent.ToString (); // Key stroke log: var keyLogLabel = new Label ("Key stroke log:") { @@ -163,9 +163,9 @@ namespace UICatalog { Height = Dim.Fill (), }; - Win.KeyDown += (sender, a) => KeyDownPressUp (a.KeyEvent, "Down"); - Win.KeyPress += (sender, a) => KeyDownPressUp (a.KeyEvent, "Press"); - Win.KeyUp += (sender, a) => KeyDownPressUp (a.KeyEvent, "Up"); + Win.KeyDown += (a) => KeyDownPressUp (a.KeyEvent, "Down"); + Win.KeyPress += (a) => KeyDownPressUp (a.KeyEvent, "Press"); + Win.KeyUp += (a) => KeyDownPressUp (a.KeyEvent, "Up"); void KeyDownPressUp (KeyEvent keyEvent, string updown) { diff --git a/UICatalog/Scenarios/Progress.cs b/UICatalog/Scenarios/Progress.cs index 1db61a335..c763375b3 100644 --- a/UICatalog/Scenarios/Progress.cs +++ b/UICatalog/Scenarios/Progress.cs @@ -167,7 +167,7 @@ namespace UICatalog { systemTimerDemo.PulseProgressBar.Fraction = 1F; }; systemTimerDemo.Speed.Text = $"{_systemTimerTick}"; - systemTimerDemo.Speed.Changed += (sender, a) => { + systemTimerDemo.Speed.Changed += (a) => { uint result; if (uint.TryParse (systemTimerDemo.Speed.Text.ToString(), out result)) { _systemTimerTick = result; @@ -210,7 +210,7 @@ namespace UICatalog { }; mainLoopTimeoutDemo.Speed.Text = $"{_mainLooopTimeoutTick}"; - mainLoopTimeoutDemo.Speed.Changed += (sender, a) => { + mainLoopTimeoutDemo.Speed.Changed += (a) => { uint result; if (uint.TryParse (mainLoopTimeoutDemo.Speed.Text.ToString (), out result)) { _mainLooopTimeoutTick = result; diff --git a/UICatalog/Scenarios/Scrolling.cs b/UICatalog/Scenarios/Scrolling.cs index 27425d61d..66c0bee0f 100644 --- a/UICatalog/Scenarios/Scrolling.cs +++ b/UICatalog/Scenarios/Scrolling.cs @@ -122,7 +122,7 @@ namespace UICatalog { }; scrollView.Add (verticalRuler); - Win.LayoutComplete += (sender, a) => { + Win.LayoutComplete += (a) => { horizontalRuler.Text = rule.Repeat ((int)Math.Ceiling ((double)(horizontalRuler.Bounds.Width) / (double)rule.Length)) [0..(horizontalRuler.Bounds.Width)] + "\n" + "| ".Repeat ((int)Math.Ceiling ((double)(horizontalRuler.Bounds.Width) / (double)rule.Length)) [0..(horizontalRuler.Bounds.Width)]; verticalRuler.Text = vrule.Repeat ((int)Math.Ceiling ((double)(verticalRuler.Bounds.Height * 2) / (double)rule.Length)) [0..(verticalRuler.Bounds.Height * 2)]; @@ -182,8 +182,8 @@ namespace UICatalog { X = Pos.X(scrollView), Y = Pos.Bottom(scrollView) + 1, }; - hCheckBox.Toggled += (sender, previousChecked) => { - scrollView.ShowHorizontalScrollIndicator = ((CheckBox)sender).Checked; + hCheckBox.Toggled += (previousChecked) => { + scrollView.ShowHorizontalScrollIndicator = hCheckBox.Checked; }; Win.Add (hCheckBox); @@ -191,8 +191,8 @@ namespace UICatalog { X = Pos.Right (hCheckBox) + 3, Y = Pos.Bottom (scrollView) + 1, }; - vCheckBox.Toggled += (sender, previousChecked) => { - scrollView.ShowVerticalScrollIndicator = ((CheckBox)sender).Checked; + vCheckBox.Toggled += (previousChecked) => { + scrollView.ShowVerticalScrollIndicator = vCheckBox.Checked; }; Win.Add (vCheckBox); diff --git a/UICatalog/UICatalog.cs b/UICatalog/UICatalog.cs index 7e7888132..e65cde97c 100644 --- a/UICatalog/UICatalog.cs +++ b/UICatalog/UICatalog.cs @@ -111,7 +111,7 @@ namespace UICatalog { _top.Add (_rightPane); _top.Add (_statusBar); - _top.Ready += (o, a) => { + _top.Ready += () => { if (_runningScenario != null) { _top.SetFocus (_rightPane); _runningScenario = null; @@ -192,7 +192,7 @@ namespace UICatalog { AllowsMarking = false, CanFocus = true, }; - _categoryListView.OpenSelectedItem += (o, a) => { + _categoryListView.OpenSelectedItem += (a) => { _top.SetFocus (_rightPane); }; _categoryListView.SelectedChanged += CategoryListView_SelectedChanged; @@ -244,7 +244,7 @@ namespace UICatalog { }); } - private static void _scenarioListView_OpenSelectedItem (object sender, EventArgs e) + private static void _scenarioListView_OpenSelectedItem (EventArgs e) { if (_runningScenario is null) { var source = _scenarioListView.Source as ScenarioListDataSource; @@ -306,7 +306,7 @@ namespace UICatalog { /// to not be impacted. Same as for tabs. /// /// - private static void KeyDownHandler (object sender, View.KeyEventEventArgs a) + private static void KeyDownHandler (View.KeyEventEventArgs a) { if (a.KeyEvent.Key == Key.Tab || a.KeyEvent.Key == Key.BackTab) { // BUGBUG: Work around Issue #434 by implementing our own TAB navigation @@ -341,7 +341,7 @@ namespace UICatalog { } } - private static void CategoryListView_SelectedChanged (object sender, ListViewItemEventArgs e) + private static void CategoryListView_SelectedChanged (ListViewItemEventArgs e) { var item = _categories [_categoryListView.SelectedItem]; List newlist;