浏览代码

Refactor `Action<bool?> Toggled` to `EventHandler<ToggleEventArgs>`

tznind 2 年之前
父节点
当前提交
17a33f3b11

+ 34 - 0
Terminal.Gui/Core/EventArgs/ToggleEventArgs.cs

@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Terminal.Gui {
+	/// <summary>
+	/// <see cref="EventArgs"/> for the <see cref="CheckBox.Toggled"/> event
+	/// </summary>
+	public class ToggleEventArgs : EventArgs {
+
+		/// <summary>
+		/// Creates a new instance of the <see cref="ToggleEventArgs"/> class.
+		/// </summary>
+		/// <param name="oldValue"></param>
+		/// <param name="newValue"></param>
+		public ToggleEventArgs (bool? oldValue, bool? newValue)
+		{
+			OldValue = oldValue;
+			NewValue = newValue;
+		}
+
+		/// <summary>
+		/// The previous checked state
+		/// </summary>
+		public bool? OldValue { get; }
+
+		/// <summary>
+		/// The new checked state
+		/// </summary>
+		public bool? NewValue { get; }
+	}
+}

+ 5 - 4
Terminal.Gui/Views/CheckBox.cs

@@ -27,14 +27,14 @@ namespace Terminal.Gui {
 		///   raised when the <see cref="CheckBox"/> is activated either with
 		///   raised when the <see cref="CheckBox"/> is activated either with
 		///   the mouse or the keyboard. The passed <c>bool</c> contains the previous state. 
 		///   the mouse or the keyboard. The passed <c>bool</c> contains the previous state. 
 		/// </remarks>
 		/// </remarks>
-		public event Action<bool?> Toggled;
+		public event EventHandler<ToggleEventArgs> Toggled;
 
 
 		/// <summary>
 		/// <summary>
 		/// Called when the <see cref="Checked"/> property changes. Invokes the <see cref="Toggled"/> event.
 		/// Called when the <see cref="Checked"/> property changes. Invokes the <see cref="Toggled"/> event.
 		/// </summary>
 		/// </summary>
-		public virtual void OnToggled (bool? previousChecked)
+		public virtual void OnToggled (ToggleEventArgs e)
 		{
 		{
-			Toggled?.Invoke (previousChecked);
+			Toggled?.Invoke (this, e);
 		}
 		}
 
 
 		/// <summary>
 		/// <summary>
@@ -203,7 +203,8 @@ namespace Terminal.Gui {
 			} else {
 			} else {
 				Checked = !Checked;
 				Checked = !Checked;
 			}
 			}
-			OnToggled (previousChecked);
+			
+			OnToggled (new ToggleEventArgs (previousChecked, Checked));
 			SetNeedsDisplay ();
 			SetNeedsDisplay ();
 			return true;
 			return true;
 		}
 		}

+ 2 - 2
UICatalog/Scenarios/AllViewsTester.cs

@@ -101,9 +101,9 @@ namespace UICatalog.Scenarios {
 				ColorScheme = Colors.TopLevel,
 				ColorScheme = Colors.TopLevel,
 			};
 			};
 			_computedCheckBox = new CheckBox ("Computed Layout", true) { X = 0, Y = 0 };
 			_computedCheckBox = new CheckBox ("Computed Layout", true) { X = 0, Y = 0 };
-			_computedCheckBox.Toggled += (previousState) => {
+			_computedCheckBox.Toggled += (s,e) => {
 				if (_curView != null) {
 				if (_curView != null) {
-					_curView.LayoutStyle = previousState == true ? LayoutStyle.Absolute : LayoutStyle.Computed;
+					_curView.LayoutStyle = e.OldValue == true ? LayoutStyle.Absolute : LayoutStyle.Computed;
 					_hostPane.LayoutSubviews ();
 					_hostPane.LayoutSubviews ();
 				}
 				}
 			};
 			};

+ 4 - 4
UICatalog/Scenarios/AutoSizeAndDirectionText.cs

@@ -44,7 +44,7 @@ namespace UICatalog.Scenarios {
 				X = Pos.Center (),
 				X = Pos.Center (),
 				Y = Pos.Center () + 3
 				Y = Pos.Center () + 3
 			};
 			};
-			ckbDirection.Toggled += (_) => {
+			ckbDirection.Toggled += (s,e) => {
 				if (labelH.TextDirection == TextDirection.LeftRight_TopBottom) {
 				if (labelH.TextDirection == TextDirection.LeftRight_TopBottom) {
 					labelH.TextDirection = TextDirection.TopBottom_LeftRight;
 					labelH.TextDirection = TextDirection.TopBottom_LeftRight;
 					labelV.TextDirection = TextDirection.LeftRight_TopBottom;
 					labelV.TextDirection = TextDirection.LeftRight_TopBottom;
@@ -60,7 +60,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Center () + 5,
 				Y = Pos.Center () + 5,
 				Checked = labelH.AutoSize = labelV.AutoSize
 				Checked = labelH.AutoSize = labelV.AutoSize
 			};
 			};
-			ckbAutoSize.Toggled += (_) => labelH.AutoSize = labelV.AutoSize = (bool)ckbAutoSize.Checked;
+			ckbAutoSize.Toggled += (s,e) => labelH.AutoSize = labelV.AutoSize = (bool)ckbAutoSize.Checked;
 			Win.Add (ckbAutoSize);
 			Win.Add (ckbAutoSize);
 
 
 			var ckbPreserveTrailingSpaces = new CheckBox ("Preserve Trailing Spaces") {
 			var ckbPreserveTrailingSpaces = new CheckBox ("Preserve Trailing Spaces") {
@@ -68,7 +68,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Center () + 7,
 				Y = Pos.Center () + 7,
 				Checked = labelH.PreserveTrailingSpaces = labelV.PreserveTrailingSpaces
 				Checked = labelH.PreserveTrailingSpaces = labelV.PreserveTrailingSpaces
 			};
 			};
-			ckbPreserveTrailingSpaces.Toggled += (_) =>
+			ckbPreserveTrailingSpaces.Toggled += (s, e) =>
 					labelH.PreserveTrailingSpaces = labelV.PreserveTrailingSpaces = (bool)ckbPreserveTrailingSpaces.Checked;
 					labelH.PreserveTrailingSpaces = labelV.PreserveTrailingSpaces = (bool)ckbPreserveTrailingSpaces.Checked;
 			Win.Add (ckbPreserveTrailingSpaces);
 			Win.Add (ckbPreserveTrailingSpaces);
 
 
@@ -76,7 +76,7 @@ namespace UICatalog.Scenarios {
 				X = Pos.Center (),
 				X = Pos.Center (),
 				Y = Pos.Center () + 9
 				Y = Pos.Center () + 9
 			};
 			};
-			ckbWideText.Toggled += (_) => {
+			ckbWideText.Toggled += (s, e) => {
 				if (ckbWideText.Checked == true) {
 				if (ckbWideText.Checked == true) {
 					labelH.Text = labelV.Text = editText.Text = wideText;
 					labelH.Text = labelV.Text = editText.Text = wideText;
 					labelH.Width = 14;
 					labelH.Width = 14;

+ 3 - 3
UICatalog/Scenarios/Borders.cs

@@ -206,7 +206,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Y (replacePadding) + 1,
 				Y = Pos.Y (replacePadding) + 1,
 				Checked = smartPanel.UsePanelFrame
 				Checked = smartPanel.UsePanelFrame
 			};
 			};
-			cbUseUsePanelFrame.Toggled += (e) => smartPanel.UsePanelFrame = (bool)!e;
+			cbUseUsePanelFrame.Toggled += (s,e) => smartPanel.UsePanelFrame = (bool)!e.OldValue;
 			Win.Add (cbUseUsePanelFrame);
 			Win.Add (cbUseUsePanelFrame);
 
 
 			Win.Add (new Label ("Border:") {
 			Win.Add (new Label ("Border:") {
@@ -337,7 +337,7 @@ namespace UICatalog.Scenarios {
 				Y = 0,
 				Y = 0,
 				Width = 5
 				Width = 5
 			};
 			};
-			cbDrawMarginFrame.Toggled += (e) => {
+			cbDrawMarginFrame.Toggled += (s,e) => {
 				try {
 				try {
 					smartPanel.Child.Border.DrawMarginFrame = cbDrawMarginFrame.Checked == true;
 					smartPanel.Child.Border.DrawMarginFrame = cbDrawMarginFrame.Checked == true;
 					smartLabel.Border.DrawMarginFrame = cbDrawMarginFrame.Checked == true;
 					smartLabel.Border.DrawMarginFrame = cbDrawMarginFrame.Checked == true;
@@ -420,7 +420,7 @@ namespace UICatalog.Scenarios {
 			effect3DOffsetY.Text = $"{smartLabel.Border.Effect3DOffset.Y}";
 			effect3DOffsetY.Text = $"{smartLabel.Border.Effect3DOffset.Y}";
 			Win.Add (effect3DOffsetY);
 			Win.Add (effect3DOffsetY);
 
 
-			cbEffect3D.Toggled += (e) => {
+			cbEffect3D.Toggled += (s,e) => {
 				try {
 				try {
 					smartPanel.Child.Border.Effect3D = smartLabel.Border.Effect3D = effect3DOffsetX.Enabled =
 					smartPanel.Child.Border.Effect3D = smartLabel.Border.Effect3D = effect3DOffsetX.Enabled =
 						effect3DOffsetY.Enabled = cbEffect3D.Checked == true;
 						effect3DOffsetY.Enabled = cbEffect3D.Checked == true;

+ 2 - 2
UICatalog/Scenarios/BordersOnContainers.cs

@@ -262,7 +262,7 @@ namespace UICatalog.Scenarios {
 				Y = 0,
 				Y = 0,
 				Width = 5
 				Width = 5
 			};
 			};
-			cbDrawMarginFrame.Toggled += (e) => {
+			cbDrawMarginFrame.Toggled += (s, e) => {
 				try {
 				try {
 					smartView.Border.DrawMarginFrame = (bool)cbDrawMarginFrame.Checked;
 					smartView.Border.DrawMarginFrame = (bool)cbDrawMarginFrame.Checked;
 					if (cbDrawMarginFrame.Checked != smartView.Border.DrawMarginFrame) {
 					if (cbDrawMarginFrame.Checked != smartView.Border.DrawMarginFrame) {
@@ -337,7 +337,7 @@ namespace UICatalog.Scenarios {
 			effect3DOffsetY.Text = $"{smartView.Border.Effect3DOffset.Y}";
 			effect3DOffsetY.Text = $"{smartView.Border.Effect3DOffset.Y}";
 			Add (effect3DOffsetY);
 			Add (effect3DOffsetY);
 
 
-			cbEffect3D.Toggled += (e) => {
+			cbEffect3D.Toggled += (s, e) => {
 				try {
 				try {
 					smartView.Border.Effect3D = effect3DOffsetX.Enabled =
 					smartView.Border.Effect3D = effect3DOffsetX.Enabled =
 						effect3DOffsetY.Enabled = (bool)cbEffect3D.Checked;
 						effect3DOffsetY.Enabled = (bool)cbEffect3D.Checked;

+ 3 - 3
UICatalog/Scenarios/DynamicMenuBar.cs

@@ -789,7 +789,7 @@ namespace UICatalog.Scenarios {
 				};
 				};
 				Add (_btnShortcut);
 				Add (_btnShortcut);
 
 
-				_ckbIsTopLevel.Toggled += (e) => {
+				_ckbIsTopLevel.Toggled += (s, e) => {
 					if ((_menuItem != null && _menuItem.Parent != null && (bool)_ckbIsTopLevel.Checked) ||
 					if ((_menuItem != null && _menuItem.Parent != null && (bool)_ckbIsTopLevel.Checked) ||
 						_menuItem == null && hasParent && (bool)_ckbIsTopLevel.Checked) {
 						_menuItem == null && hasParent && (bool)_ckbIsTopLevel.Checked) {
 						MessageBox.ErrorQuery ("Invalid IsTopLevel", "Only menu bar can have top level menu item!", "Ok");
 						MessageBox.ErrorQuery ("Invalid IsTopLevel", "Only menu bar can have top level menu item!", "Ok");
@@ -814,7 +814,7 @@ namespace UICatalog.Scenarios {
 						_txtAction.Enabled = false;
 						_txtAction.Enabled = false;
 					}
 					}
 				};
 				};
-				_ckbSubMenu.Toggled += (e) => {
+				_ckbSubMenu.Toggled += (s, e) => {
 					if ((bool)_ckbSubMenu.Checked) {
 					if ((bool)_ckbSubMenu.Checked) {
 						_ckbIsTopLevel.Checked = false;
 						_ckbIsTopLevel.Checked = false;
 						_ckbIsTopLevel.SetNeedsDisplay ();
 						_ckbIsTopLevel.SetNeedsDisplay ();
@@ -835,7 +835,7 @@ namespace UICatalog.Scenarios {
 						_txtShortcut.Enabled = _ckbIsTopLevel.Checked == false && _ckbSubMenu.Checked == false;
 						_txtShortcut.Enabled = _ckbIsTopLevel.Checked == false && _ckbSubMenu.Checked == false;
 					}
 					}
 				};
 				};
-				_ckbNullCheck.Toggled += (e) => {
+				_ckbNullCheck.Toggled += (s,e) => {
 					if (_menuItem != null) {
 					if (_menuItem != null) {
 						_menuItem.AllowNullChecked = (bool)_ckbNullCheck.Checked;
 						_menuItem.AllowNullChecked = (bool)_ckbNullCheck.Checked;
 					}
 					}

+ 4 - 4
UICatalog/Scenarios/Editor.cs

@@ -837,7 +837,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Top (txtToFind) + 2,
 				Y = Pos.Top (txtToFind) + 2,
 				Checked = _matchCase
 				Checked = _matchCase
 			};
 			};
-			ckbMatchCase.Toggled += (e) => _matchCase = (bool)ckbMatchCase.Checked;
+			ckbMatchCase.Toggled += (s, e) => _matchCase = (bool)ckbMatchCase.Checked;
 			d.Add (ckbMatchCase);
 			d.Add (ckbMatchCase);
 
 
 			var ckbMatchWholeWord = new CheckBox ("Match _whole word") {
 			var ckbMatchWholeWord = new CheckBox ("Match _whole word") {
@@ -845,7 +845,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Top (ckbMatchCase) + 1,
 				Y = Pos.Top (ckbMatchCase) + 1,
 				Checked = _matchWholeWord
 				Checked = _matchWholeWord
 			};
 			};
-			ckbMatchWholeWord.Toggled += (e) => _matchWholeWord = (bool)ckbMatchWholeWord.Checked;
+			ckbMatchWholeWord.Toggled += (s, e) => _matchWholeWord = (bool)ckbMatchWholeWord.Checked;
 			d.Add (ckbMatchWholeWord);
 			d.Add (ckbMatchWholeWord);
 
 
 			d.Width = label.Width + txtToFind.Width + btnFindNext.Width + 2;
 			d.Width = label.Width + txtToFind.Width + btnFindNext.Width + 2;
@@ -958,7 +958,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Top (txtToFind) + 2,
 				Y = Pos.Top (txtToFind) + 2,
 				Checked = _matchCase
 				Checked = _matchCase
 			};
 			};
-			ckbMatchCase.Toggled += (e) => _matchCase = (bool)ckbMatchCase.Checked;
+			ckbMatchCase.Toggled += (s, e) => _matchCase = (bool)ckbMatchCase.Checked;
 			d.Add (ckbMatchCase);
 			d.Add (ckbMatchCase);
 
 
 			var ckbMatchWholeWord = new CheckBox ("Match _whole word") {
 			var ckbMatchWholeWord = new CheckBox ("Match _whole word") {
@@ -966,7 +966,7 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Top (ckbMatchCase) + 1,
 				Y = Pos.Top (ckbMatchCase) + 1,
 				Checked = _matchWholeWord
 				Checked = _matchWholeWord
 			};
 			};
-			ckbMatchWholeWord.Toggled += (e) => _matchWholeWord = (bool)ckbMatchWholeWord.Checked;
+			ckbMatchWholeWord.Toggled += (s, e) => _matchWholeWord = (bool)ckbMatchWholeWord.Checked;
 			d.Add (ckbMatchWholeWord);
 			d.Add (ckbMatchWholeWord);
 
 
 			d.Width = lblWidth + txtToFind.Width + btnFindNext.Width + 2;
 			d.Width = lblWidth + txtToFind.Width + btnFindNext.Width + 2;

+ 7 - 7
UICatalog/Scenarios/ListViewWithSelection.cs

@@ -93,7 +93,7 @@ namespace UICatalog.Scenarios {
 				X = Pos.AnchorEnd (k.Length + 3),
 				X = Pos.AnchorEnd (k.Length + 3),
 				Y = 0,
 				Y = 0,
 			};
 			};
-			keepCheckBox.Toggled += (_) => _scrollBar.KeepContentAlwaysInViewport = (bool)keepCheckBox.Checked;
+			keepCheckBox.Toggled += (s,e) => _scrollBar.KeepContentAlwaysInViewport = (bool)keepCheckBox.Checked;
 			Win.Add (keepCheckBox);
 			Win.Add (keepCheckBox);
 		}
 		}
 
 
@@ -113,9 +113,9 @@ namespace UICatalog.Scenarios {
 			}
 			}
 		}
 		}
 
 
-		private void _customRenderCB_Toggled (bool? prev)
+		private void _customRenderCB_Toggled (object sender, ToggleEventArgs e)
 		{
 		{
-			if (prev == true) {
+			if (e.OldValue == true) {
 				_listView.SetSource (_scenarios);
 				_listView.SetSource (_scenarios);
 			} else {
 			} else {
 				_listView.Source = new ScenarioListDataSource (_scenarios);
 				_listView.Source = new ScenarioListDataSource (_scenarios);
@@ -124,16 +124,16 @@ namespace UICatalog.Scenarios {
 			Win.SetNeedsDisplay ();
 			Win.SetNeedsDisplay ();
 		}
 		}
 
 
-		private void AllowMarkingCB_Toggled (bool? prev)
+		private void AllowMarkingCB_Toggled (object sender, ToggleEventArgs e)
 		{
 		{
-			_listView.AllowsMarking = (bool)!prev;
+			_listView.AllowsMarking = (bool)!e.OldValue;
 			_allowMultipleCB.Visible = _listView.AllowsMarking;
 			_allowMultipleCB.Visible = _listView.AllowsMarking;
 			Win.SetNeedsDisplay ();
 			Win.SetNeedsDisplay ();
 		}
 		}
 
 
-		private void AllowMultipleCB_Toggled (bool? prev)
+		private void AllowMultipleCB_Toggled (object sender, ToggleEventArgs e)
 		{
 		{
-			_listView.AllowsMultipleSelection = (bool)!prev;
+			_listView.AllowsMultipleSelection = (bool)!e.OldValue;
 			Win.SetNeedsDisplay ();
 			Win.SetNeedsDisplay ();
 		}
 		}
 
 

+ 2 - 2
UICatalog/Scenarios/MessageBoxes.cs

@@ -147,8 +147,8 @@ namespace UICatalog.Scenarios {
 				X = Pos.Right (label) + 1,
 				X = Pos.Right (label) + 1,
 				Y = Pos.Top (label) + 2
 				Y = Pos.Top (label) + 2
 			};
 			};
-			ckbEffect3D.Toggled += (e) => {
-				border.Effect3D = (bool)!e;
+			ckbEffect3D.Toggled += (s,e) => {
+				border.Effect3D = (bool)!e.OldValue;
 			};
 			};
 			frame.Add (ckbEffect3D);
 			frame.Add (ckbEffect3D);
 
 

+ 2 - 2
UICatalog/Scenarios/ProgressBarStyles.cs

@@ -120,8 +120,8 @@ namespace UICatalog.Scenarios {
 				marqueesContinuousPB.ProgressBarFormat = (ProgressBarFormat)e.SelectedItem;
 				marqueesContinuousPB.ProgressBarFormat = (ProgressBarFormat)e.SelectedItem;
 			};
 			};
 
 
-			ckbBidirectional.Toggled += (e) => {
-				ckbBidirectional.Checked = marqueesBlocksPB.BidirectionalMarquee = marqueesContinuousPB.BidirectionalMarquee = (bool)!e;
+			ckbBidirectional.Toggled += (s,e) => {
+				ckbBidirectional.Checked = marqueesBlocksPB.BidirectionalMarquee = marqueesContinuousPB.BidirectionalMarquee = (bool)!e.OldValue;
 			};
 			};
 
 
 			_pulseTimer = new Timer ((_) => {
 			_pulseTimer = new Timer ((_) => {

+ 4 - 4
UICatalog/Scenarios/Scrolling.cs

@@ -236,7 +236,7 @@ namespace UICatalog.Scenarios {
 				X = Pos.Left (scrollView) + (scrollView.Bounds.Width / 2) - (k.Length / 2),
 				X = Pos.Left (scrollView) + (scrollView.Bounds.Width / 2) - (k.Length / 2),
 				Y = Pos.Bottom (scrollView) + 4,
 				Y = Pos.Bottom (scrollView) + 4,
 			};
 			};
-			hCheckBox.Toggled += (_) => {
+			hCheckBox.Toggled += (s, e) => {
 				if (ahCheckBox.Checked == false) {
 				if (ahCheckBox.Checked == false) {
 					scrollView.ShowHorizontalScrollIndicator = (bool)hCheckBox.Checked;
 					scrollView.ShowHorizontalScrollIndicator = (bool)hCheckBox.Checked;
 				} else {
 				} else {
@@ -244,7 +244,7 @@ namespace UICatalog.Scenarios {
 					MessageBox.Query ("Message", "Disable Auto Hide Scrollbars first.", "Ok");
 					MessageBox.Query ("Message", "Disable Auto Hide Scrollbars first.", "Ok");
 				}
 				}
 			};
 			};
-			vCheckBox.Toggled += (_) => {
+			vCheckBox.Toggled += (s, e) => {
 				if (ahCheckBox.Checked == false) {
 				if (ahCheckBox.Checked == false) {
 					scrollView.ShowVerticalScrollIndicator = (bool)vCheckBox.Checked;
 					scrollView.ShowVerticalScrollIndicator = (bool)vCheckBox.Checked;
 				} else {
 				} else {
@@ -252,14 +252,14 @@ namespace UICatalog.Scenarios {
 					MessageBox.Query ("Message", "Disable Auto Hide Scrollbars first.", "Ok");
 					MessageBox.Query ("Message", "Disable Auto Hide Scrollbars first.", "Ok");
 				}
 				}
 			};
 			};
-			ahCheckBox.Toggled += (_) => {
+			ahCheckBox.Toggled += (s, e) => {
 				scrollView.AutoHideScrollBars = (bool)ahCheckBox.Checked;
 				scrollView.AutoHideScrollBars = (bool)ahCheckBox.Checked;
 				hCheckBox.Checked = true;
 				hCheckBox.Checked = true;
 				vCheckBox.Checked = true;
 				vCheckBox.Checked = true;
 			};
 			};
 			Win.Add (ahCheckBox);
 			Win.Add (ahCheckBox);
 
 
-			keepCheckBox.Toggled += (_) => scrollView.KeepContentAlwaysInViewport = (bool)keepCheckBox.Checked;
+			keepCheckBox.Toggled += (s,e) => scrollView.KeepContentAlwaysInViewport = (bool)keepCheckBox.Checked;
 			Win.Add (keepCheckBox);
 			Win.Add (keepCheckBox);
 
 
 			var scrollView2 = new ScrollView (new Rect (55, 2, 20, 8)) {
 			var scrollView2 = new ScrollView (new Rect (55, 2, 20, 8)) {

+ 5 - 5
UICatalog/Scenarios/Text.cs

@@ -87,14 +87,14 @@ namespace UICatalog.Scenarios {
 				Y = Pos.Bottom (textView),
 				Y = Pos.Bottom (textView),
 				Checked = true
 				Checked = true
 			};
 			};
-			chxMultiline.Toggled += (b) => textView.Multiline = (bool)b;
+			chxMultiline.Toggled += (s,e) => textView.Multiline = (bool)e.OldValue;
 			Win.Add (chxMultiline);
 			Win.Add (chxMultiline);
 
 
 			var chxWordWrap = new CheckBox ("Word Wrap") {
 			var chxWordWrap = new CheckBox ("Word Wrap") {
 				X = Pos.Right (chxMultiline) + 2,
 				X = Pos.Right (chxMultiline) + 2,
 				Y = Pos.Top (chxMultiline)
 				Y = Pos.Top (chxMultiline)
 			};
 			};
-			chxWordWrap.Toggled += (b) => textView.WordWrap = (bool)b;
+			chxWordWrap.Toggled += (s,e) => textView.WordWrap = (bool)e.OldValue;
 			Win.Add (chxWordWrap);
 			Win.Add (chxWordWrap);
 
 
 			// TextView captures Tabs (so users can enter /t into text) by default;
 			// TextView captures Tabs (so users can enter /t into text) by default;
@@ -108,15 +108,15 @@ namespace UICatalog.Scenarios {
 
 
 			Key keyTab = textView.GetKeyFromCommand (Command.Tab);
 			Key keyTab = textView.GetKeyFromCommand (Command.Tab);
 			Key keyBackTab = textView.GetKeyFromCommand (Command.BackTab);
 			Key keyBackTab = textView.GetKeyFromCommand (Command.BackTab);
-			chxCaptureTabs.Toggled += (b) => {
-				if (b == true) {
+			chxCaptureTabs.Toggled += (s,e) => {
+				if (e.OldValue == true) {
 					textView.AddKeyBinding (keyTab, Command.Tab);
 					textView.AddKeyBinding (keyTab, Command.Tab);
 					textView.AddKeyBinding (keyBackTab, Command.BackTab);
 					textView.AddKeyBinding (keyBackTab, Command.BackTab);
 				} else {
 				} else {
 					textView.ClearKeybinding (keyTab);
 					textView.ClearKeybinding (keyTab);
 					textView.ClearKeybinding (keyBackTab);
 					textView.ClearKeybinding (keyBackTab);
 				}
 				}
-				textView.WordWrap = (bool)b;
+				textView.WordWrap = (bool)e.OldValue;
 			};
 			};
 			Win.Add (chxCaptureTabs);
 			Win.Add (chxCaptureTabs);
 
 

+ 3 - 3
UICatalog/Scenarios/TextAlignments.cs

@@ -98,10 +98,10 @@ namespace UICatalog.Scenarios {
 				label = multipleLines [(int)alignment];
 				label = multipleLines [(int)alignment];
 			}
 			}
 
 
-			enableHotKeyCheckBox.Toggled += (previous) => {
+			enableHotKeyCheckBox.Toggled += (s,e) => {
 				foreach (var alignment in alignments) {
 				foreach (var alignment in alignments) {
-					singleLines [(int)alignment].HotKeySpecifier = previous == true ? (Rune)0xffff : (Rune)'_';
-					multipleLines [(int)alignment].HotKeySpecifier = previous == true ? (Rune)0xffff : (Rune)'_';
+					singleLines [(int)alignment].HotKeySpecifier = e.OldValue == true ? (Rune)0xffff : (Rune)'_';
+					multipleLines [(int)alignment].HotKeySpecifier = e.OldValue == true ? (Rune)0xffff : (Rune)'_';
 				}
 				}
 				Win.SetNeedsDisplay ();
 				Win.SetNeedsDisplay ();
 				Win.LayoutSubviews ();
 				Win.LayoutSubviews ();

+ 2 - 2
UICatalog/Scenarios/TextAlignmentsAndDirection.cs

@@ -141,8 +141,8 @@ namespace UICatalog.Scenarios {
 				Height = 1
 				Height = 1
 			};
 			};
 
 
-			justifyCheckbox.Toggled += (prevtoggled) => {
-				if (prevtoggled == true) {
+			justifyCheckbox.Toggled += (s,e) => {
+				if (e.OldValue == true) {
 					foreach (var t in mtxts) {
 					foreach (var t in mtxts) {
 						t.TextAlignment = (TextAlignment)((dynamic)t.Data).h;
 						t.TextAlignment = (TextAlignment)((dynamic)t.Data).h;
 						t.VerticalTextAlignment = (VerticalTextAlignment)((dynamic)t.Data).v;
 						t.VerticalTextAlignment = (VerticalTextAlignment)((dynamic)t.Data).v;

+ 3 - 3
UICatalog/Scenarios/TextFormatterDemo.cs

@@ -80,10 +80,10 @@ namespace UICatalog.Scenarios {
 				label = multipleLines [(int)alignment];
 				label = multipleLines [(int)alignment];
 			}
 			}
 
 
-			unicodeCheckBox.Toggled += (previous) => {
+			unicodeCheckBox.Toggled += (s,e) => {
 				foreach (var alignment in alignments) {
 				foreach (var alignment in alignments) {
-					singleLines [(int)alignment].Text = previous == true ? text : unicode;
-					multipleLines [(int)alignment].Text = previous == true ? text : unicode;
+					singleLines [(int)alignment].Text = e.OldValue == true ? text : unicode;
+					multipleLines [(int)alignment].Text = e.OldValue == true ? text : unicode;
 				}
 				}
 			};
 			};
 		}
 		}

+ 4 - 4
UICatalog/Scenarios/TileViewNesting.cs

@@ -42,22 +42,22 @@ namespace UICatalog.Scenarios {
 			cbHorizontal = new CheckBox ("Horizontal") {
 			cbHorizontal = new CheckBox ("Horizontal") {
 				X = Pos.Right (textField) + 1
 				X = Pos.Right (textField) + 1
 			};
 			};
-			cbHorizontal.Toggled += (s) => SetupTileView ();
+			cbHorizontal.Toggled += (s, e) => SetupTileView ();
 
 
 			cbBorder = new CheckBox ("Border") {
 			cbBorder = new CheckBox ("Border") {
 				X = Pos.Right (cbHorizontal) + 1
 				X = Pos.Right (cbHorizontal) + 1
 			};
 			};
-			cbBorder.Toggled += (s) => SetupTileView ();
+			cbBorder.Toggled += (s, e) => SetupTileView ();
 
 
 			cbTitles = new CheckBox ("Titles") {
 			cbTitles = new CheckBox ("Titles") {
 				X = Pos.Right (cbBorder) + 1
 				X = Pos.Right (cbBorder) + 1
 			};
 			};
-			cbTitles.Toggled += (s) => SetupTileView ();
+			cbTitles.Toggled += (s,e) => SetupTileView ();
 
 
 			cbUseLabels = new CheckBox ("Use Labels") {
 			cbUseLabels = new CheckBox ("Use Labels") {
 				X = Pos.Right (cbTitles) + 1
 				X = Pos.Right (cbTitles) + 1
 			};
 			};
-			cbUseLabels.Toggled += (s) => SetupTileView ();
+			cbUseLabels.Toggled += (s, e) => SetupTileView ();
 
 
 			workArea = new View {
 			workArea = new View {
 				X = 0,
 				X = 0,

+ 1 - 1
UICatalog/Scenarios/Unicode.cs

@@ -62,7 +62,7 @@ namespace UICatalog.Scenarios {
 			Win.Add (label);
 			Win.Add (label);
 			var checkBox = new CheckBox (gitString) { X = 20, Y = Pos.Y (label), Width = Dim.Percent (50) };
 			var checkBox = new CheckBox (gitString) { X = 20, Y = Pos.Y (label), Width = Dim.Percent (50) };
 			var ckbAllowNull = new CheckBox ("Allow null checked") { X = Pos.Right (checkBox) + 1, Y = Pos.Y (label) };
 			var ckbAllowNull = new CheckBox ("Allow null checked") { X = Pos.Right (checkBox) + 1, Y = Pos.Y (label) };
-			ckbAllowNull.Toggled += (e) => checkBox.AllowNullChecked = (bool)!e;
+			ckbAllowNull.Toggled += (s,e) => checkBox.AllowNullChecked = (bool)!e.OldValue;
 			Win.Add (checkBox, ckbAllowNull);
 			Win.Add (checkBox, ckbAllowNull);
 
 
 			label = new Label ("ComboBox:") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };
 			label = new Label ("ComboBox:") { X = Pos.X (label), Y = Pos.Bottom (label) + 1 };

+ 2 - 2
UICatalog/Scenarios/Wizards.cs

@@ -202,7 +202,7 @@ namespace UICatalog.Scenarios {
 					};
 					};
 					thirdStep.Add (progLbl, progressBar);
 					thirdStep.Add (progLbl, progressBar);
 					thirdStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked;
 					thirdStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked;
-					thirdStepEnabledCeckBox.Toggled += (args) => {
+					thirdStepEnabledCeckBox.Toggled += (s, e) => {
 						thirdStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked;
 						thirdStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked;
 					};
 					};
 
 
@@ -277,7 +277,7 @@ namespace UICatalog.Scenarios {
 					wizard.AddStep (finalFinalStep);
 					wizard.AddStep (finalFinalStep);
 					finalFinalStep.HelpText = "This step only shows if it was enabled on the other last step.";
 					finalFinalStep.HelpText = "This step only shows if it was enabled on the other last step.";
 					finalFinalStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked;
 					finalFinalStep.Enabled = (bool)thirdStepEnabledCeckBox.Checked;
-					finalFinalStepEnabledCeckBox.Toggled += (args) => {
+					finalFinalStepEnabledCeckBox.Toggled += (s, e) => {
 						finalFinalStep.Enabled = (bool)finalFinalStepEnabledCeckBox.Checked;
 						finalFinalStep.Enabled = (bool)finalFinalStepEnabledCeckBox.Checked;
 					};
 					};
 
 

+ 2 - 2
UnitTests/UICatalog/ScenarioTests.cs

@@ -303,9 +303,9 @@ namespace UICatalog.Tests {
 				_curView = CreateClass (_viewClasses.Values.ToArray () [_classListView.SelectedItem]);
 				_curView = CreateClass (_viewClasses.Values.ToArray () [_classListView.SelectedItem]);
 			};
 			};
 
 
-			_computedCheckBox.Toggled += (previousState) => {
+			_computedCheckBox.Toggled += (s,e) => {
 				if (_curView != null) {
 				if (_curView != null) {
-					_curView.LayoutStyle = previousState == true ? LayoutStyle.Absolute : LayoutStyle.Computed;
+					_curView.LayoutStyle = e.OldValue == true ? LayoutStyle.Absolute : LayoutStyle.Computed;
 					_hostPane.LayoutSubviews ();
 					_hostPane.LayoutSubviews ();
 				}
 				}
 			};
 			};

+ 1 - 1
UnitTests/Views/CheckBoxTests.cs

@@ -61,7 +61,7 @@ namespace Terminal.Gui.ViewTests {
 		{
 		{
 			var isChecked = false;
 			var isChecked = false;
 			CheckBox ckb = new CheckBox ();
 			CheckBox ckb = new CheckBox ();
-			ckb.Toggled += (e) => isChecked = true;
+			ckb.Toggled += (s, e) => isChecked = true;
 			Application.Top.Add (ckb);
 			Application.Top.Add (ckb);
 			Application.Begin (Application.Top);
 			Application.Begin (Application.Top);