瀏覽代碼

Switch `event Action` to `event EventHandler`

tznind 2 年之前
父節點
當前提交
6f5ef32fb7

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

@@ -61,7 +61,7 @@ namespace Terminal.Gui {
 			Position = new Point (x, y);
 		}
 
-		private void MenuBar_MenuAllClosed ()
+		private void MenuBar_MenuAllClosed (object sender, EventArgs e)
 		{
 			Dispose ();
 		}

+ 2 - 2
Terminal.Gui/Views/HexView.cs

@@ -108,7 +108,7 @@ namespace Terminal.Gui {
 		/// <summary>
 		/// Event to be invoked when the position and cursor position changes.
 		/// </summary>
-		public event Action<HexViewEventArgs> PositionChanged;
+		public event EventHandler<HexViewEventArgs> PositionChanged;
 
 		/// <summary>
 		/// Sets or gets the <see cref="Stream"/> the <see cref="HexView"/> is operating on; the stream must support seeking (<see cref="Stream.CanSeek"/> == true).
@@ -484,7 +484,7 @@ namespace Terminal.Gui {
 		/// </summary>
 		public virtual void OnPositionChanged ()
 		{
-			PositionChanged?.Invoke (new HexViewEventArgs (Position, CursorPosition, BytesPerLine));
+			PositionChanged?.Invoke (this, new HexViewEventArgs (Position, CursorPosition, BytesPerLine));
 		}
 
 		/// <inheritdoc/>

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

@@ -1206,12 +1206,12 @@ namespace Terminal.Gui {
 		/// <summary>
 		/// Raised when a menu is closing passing <see cref="MenuClosingEventArgs"/>.
 		/// </summary>
-		public event Action<MenuClosingEventArgs> MenuClosing;
+		public event EventHandler<MenuClosingEventArgs> MenuClosing;
 
 		/// <summary>
 		/// Raised when all the menu is closed.
 		/// </summary>
-		public event Action MenuAllClosed;
+		public event EventHandler MenuAllClosed;
 
 		internal Menu openMenu;
 		Menu ocm;
@@ -1275,7 +1275,7 @@ namespace Terminal.Gui {
 		public virtual MenuClosingEventArgs OnMenuClosing (MenuBarItem currentMenu, bool reopen, bool isSubMenu)
 		{
 			var ev = new MenuClosingEventArgs (currentMenu, reopen, isSubMenu);
-			MenuClosing?.Invoke (ev);
+			MenuClosing?.Invoke (this, ev);
 			return ev;
 		}
 
@@ -1284,7 +1284,7 @@ namespace Terminal.Gui {
 		/// </summary>
 		public virtual void OnMenuAllClosed ()
 		{
-			MenuAllClosed?.Invoke ();
+			MenuAllClosed?.Invoke (this, EventArgs.Empty);
 		}
 
 		View lastFocused;

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

@@ -16,7 +16,7 @@ namespace Terminal.Gui {
 	class TextModel {
 		List<List<Rune>> lines = new List<List<Rune>> ();
 
-		public event Action LinesLoaded;
+		public event EventHandler LinesLoaded;
 
 		public bool LoadFile (string file)
 		{
@@ -120,7 +120,7 @@ namespace Terminal.Gui {
 
 		void OnLinesLoaded ()
 		{
-			LinesLoaded?.Invoke ();
+			LinesLoaded?.Invoke (this, EventArgs.Empty);
 		}
 
 		public override string ToString ()
@@ -1383,7 +1383,7 @@ namespace Terminal.Gui {
 			ReplaceKeyBinding (e.OldKey, e.NewKey);
 		}
 
-		private void Model_LinesLoaded ()
+		private void Model_LinesLoaded (object sender, EventArgs e)
 		{
 			// This call is not needed. Model_LinesLoaded gets invoked when
 			// model.LoadString (value) is called. LoadString is called from one place

+ 1 - 1
UICatalog/Scenarios/HexEditor.cs

@@ -64,7 +64,7 @@ namespace UICatalog.Scenarios {
 			Application.Top.Add (statusBar);
 		}
 
-		private void _hexView_PositionChanged (HexView.HexViewEventArgs obj)
+		private void _hexView_PositionChanged (object sender, HexView.HexViewEventArgs obj)
 		{
 			siPositionChanged.Title = $"Position: {obj.Position} Line: {obj.CursorPosition.Y} Col: {obj.CursorPosition.X} Line length: {obj.BytesPerLine}";
 			statusBar.SetNeedsDisplay ();

+ 2 - 2
UnitTests/Menus/MenuTests.cs

@@ -128,7 +128,7 @@ namespace Terminal.Gui.MenuTests {
 				e.Action ();
 				Assert.Equal ("Copy", miAction);
 			};
-			menu.MenuClosing += (e) => {
+			menu.MenuClosing += (s,e) => {
 				Assert.False (isMenuClosed);
 				if (cancelClosing) {
 					e.Cancel = true;
@@ -383,7 +383,7 @@ Edit
 				miCurrent = e;
 				mCurrent = menu.openCurrentMenu;
 			};
-			menu.MenuClosing += (_) => {
+			menu.MenuClosing += (s,e) => {
 				mbiCurrent = null;
 				miCurrent = null;
 				mCurrent = null;

+ 1 - 1
UnitTests/Views/HexViewTests.cs

@@ -255,7 +255,7 @@ namespace Terminal.Gui.ViewTests {
 		{
 			var hv = new HexView (LoadStream ()) { Width = Dim.Fill (), Height = Dim.Fill () };
 			HexView.HexViewEventArgs hexViewEventArgs = null;
-			hv.PositionChanged += (e) => hexViewEventArgs = e;
+			hv.PositionChanged += (s, e) => hexViewEventArgs = e;
 			Application.Top.Add (hv);
 			Application.Begin (Application.Top);