mirror of
				https://github.com/chylex/TweetDuck.git
				synced 2025-10-31 18:17:15 +01:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			1.25
			...
			1c1aa5ea44
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 1c1aa5ea44 | 
| @@ -45,6 +45,7 @@ namespace TweetDuck { | |||||||
| 		internal static void SetupWinForms() { | 		internal static void SetupWinForms() { | ||||||
| 			Win.Application.EnableVisualStyles(); | 			Win.Application.EnableVisualStyles(); | ||||||
| 			Win.Application.SetCompatibleTextRenderingDefault(false); | 			Win.Application.SetCompatibleTextRenderingDefault(false); | ||||||
|  | 			Win.LegacyWinForms.EnsureValid(); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		[STAThread] | 		[STAThread] | ||||||
|   | |||||||
| @@ -4,10 +4,16 @@ using System.Reflection; | |||||||
| namespace System.Windows.Forms { | namespace System.Windows.Forms { | ||||||
| 	internal sealed class Command2 { | 	internal sealed class Command2 { | ||||||
| 		private static readonly Type Type = typeof(Form).Assembly.GetType("System.Windows.Forms.Command"); | 		private static readonly Type Type = typeof(Form).Assembly.GetType("System.Windows.Forms.Command"); | ||||||
| 		private static readonly ConstructorInfo Constructor = Type.GetConstructor(new Type[] { typeof(ICommandExecutor) }) ?? throw new NullReferenceException(); | 		private static readonly ConstructorInfo Constructor = Type.GetConstructor(new Type[] { typeof(ICommandExecutor) }); | ||||||
| 		private static readonly MethodInfo DisposeMethod = Type.GetMethod("Dispose", BindingFlags.Instance | BindingFlags.Public) ?? throw new NullReferenceException(); | 		private static readonly MethodInfo DisposeMethod = Type.GetMethod("Dispose", BindingFlags.Instance | BindingFlags.Public); | ||||||
| 		private static readonly PropertyInfo IDProperty = Type.GetProperty("ID") ?? throw new NullReferenceException(); | 		private static readonly PropertyInfo IDProperty = Type.GetProperty("ID"); | ||||||
| 
 | 
 | ||||||
|  | 		internal static void EnsureValid() { | ||||||
|  | 			if (Constructor == null || DisposeMethod == null || IDProperty == null) { | ||||||
|  | 				throw new InvalidOperationException(); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
| 		public int ID { get; } | 		public int ID { get; } | ||||||
| 
 | 
 | ||||||
| 		private readonly object cmd; | 		private readonly object cmd; | ||||||
|   | |||||||
| @@ -7,8 +7,14 @@ using System.Runtime.InteropServices; | |||||||
| 
 | 
 | ||||||
| namespace System.Windows.Forms { | namespace System.Windows.Forms { | ||||||
| 	public sealed class ContextMenu : Menu { | 	public sealed class ContextMenu : Menu { | ||||||
| 		private static readonly FieldInfo NotifyIconWindowField = typeof(NotifyIcon).GetField("window", BindingFlags.Instance | BindingFlags.NonPublic) ?? throw new InvalidOperationException(); | 		private static readonly FieldInfo NotifyIconWindowField = typeof(NotifyIcon).GetField("_window", BindingFlags.Instance | BindingFlags.NonPublic); | ||||||
| 			 | 
 | ||||||
|  | 		internal static void EnsureValid() { | ||||||
|  | 			if (NotifyIconWindowField == null) { | ||||||
|  | 				throw new InvalidOperationException(); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 		public event EventHandler Popup; | 		public event EventHandler Popup; | ||||||
| 
 | 
 | ||||||
| 		public void Show(Control control, Point pos) { | 		public void Show(Control control, Point pos) { | ||||||
|   | |||||||
| @@ -0,0 +1,8 @@ | |||||||
|  | namespace System.Windows.Forms;  | ||||||
|  | 
 | ||||||
|  | public static class LegacyWinForms { | ||||||
|  | 	public static void EnsureValid() { | ||||||
|  | 		Command2.EnsureValid(); | ||||||
|  | 		ContextMenu.EnsureValid(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user