فهرست منبع

Refactor Action<Size> events to EventHandler<SizeChangedEventArgs>

tznind 2 سال پیش
والد
کامیت
17e2d1d341

+ 5 - 5
Terminal.Gui/ConsoleDrivers/WindowsDriver.cs

@@ -743,8 +743,8 @@ namespace Terminal.Gui {
 
 			mLoop.ProcessInput = (e) => ProcessInput (e);
 
-			mLoop.WinChanged = (e) => {
-				ChangeWin (e);
+			mLoop.WinChanged = (s,e) => {
+				ChangeWin (e.Size);
 			};
 		}
 
@@ -1868,8 +1868,8 @@ namespace Terminal.Gui {
 		/// <summary>
 		/// Invoked when the window is changed.
 		/// </summary>
-		public Action<Size> WinChanged;
-
+		public EventHandler<SizeChangedEventArgs> WinChanged;
+		
 		public WindowsMainLoop (ConsoleDriver consoleDriver = null)
 		{
 			this.consoleDriver = consoleDriver ?? throw new ArgumentNullException ("Console driver instance must be provided.");
@@ -1991,7 +1991,7 @@ namespace Terminal.Gui {
 			}
 			if (winChanged) {
 				winChanged = false;
-				WinChanged?.Invoke (windowSize);
+				WinChanged?.Invoke (this, new SizeChangedEventArgs(windowSize));
 			}
 		}
 	}

+ 1 - 1
Terminal.Gui/Core/Application.cs

@@ -1530,7 +1530,7 @@ namespace Terminal.Gui {
 				t.SetRelativeLayout (full);
 				t.LayoutSubviews ();
 				t.PositionToplevels ();
-				t.OnResized (full.Size);
+				t.OnResized (new SizeChangedEventArgs(full.Size));
 			}
 			Refresh ();
 		}

+ 0 - 0
Terminal.Gui/Core/EventArgs/HotKeyChangedEventArgs.cs → Terminal.Gui/Core/EventArgs/KeyChangedEventArgs.cs


+ 17 - 0
Terminal.Gui/Core/EventArgs/SizeChangedEventArgs.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Terminal.Gui{
+	public class SizeChangedEventArgs : EventArgs {
+
+		public SizeChangedEventArgs (Size size)
+		{
+			Size = size;
+		}
+
+		public Size Size { get; }
+	}
+}

+ 3 - 3
Terminal.Gui/Core/Toplevel.cs

@@ -111,11 +111,11 @@ namespace Terminal.Gui {
 		/// <summary>
 		/// Invoked when the terminal has been resized. The new <see cref="Size"/> of the terminal is provided.
 		/// </summary>
-		public event Action<Size> Resized;
+		public event EventHandler<SizeChangedEventArgs> Resized;
 
-		internal virtual void OnResized (Size size)
+		internal virtual void OnResized (SizeChangedEventArgs size)
 		{
-			Resized?.Invoke (size);
+			Resized?.Invoke (this, size);
 		}
 
 		internal virtual void OnChildUnloaded (Toplevel top)

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

@@ -145,7 +145,7 @@ namespace Terminal.Gui {
 			menuBar.OpenMenu ();
 		}
 
-		private void Container_Resized (Size obj)
+		private void Container_Resized (object sender, SizeChangedEventArgs e)
 		{
 			if (IsShow) {
 				Show ();