diff --git a/OnTopReplica/MessagePumpManager.cs b/OnTopReplica/MessagePumpManager.cs index 1ab23b7..7886e4e 100644 --- a/OnTopReplica/MessagePumpManager.cs +++ b/OnTopReplica/MessagePumpManager.cs @@ -4,6 +4,7 @@ using System.Text; using System.Reflection; using System.Windows.Forms; using OnTopReplica.Native; +using OnTopReplica.MessagePumpProcessors; namespace OnTopReplica { class MessagePumpManager : IDisposable { @@ -12,6 +13,15 @@ namespace OnTopReplica { public MainForm Form { get; private set; } + private void Register(IMessagePumpProcessor processor, MainForm form) { + _processors[processor.GetType()] = processor; + processor.Initialize(form); + +#if DEBUG + Console.WriteLine("Registered message pump processor: {0}", processor.GetType()); +#endif + } + /// /// Instantiates all message pump processors and registers them on the main form. /// @@ -29,18 +39,10 @@ namespace OnTopReplica { #endif } - foreach (var t in Assembly.GetExecutingAssembly().GetTypes()) { - if (typeof(IMessagePumpProcessor).IsAssignableFrom(t) && !t.IsAbstract) { - var instance = (IMessagePumpProcessor)Activator.CreateInstance(t); - instance.Initialize(form); - - _processors[t] = instance; - -#if DEBUG - Console.WriteLine("Registered message pump processor: {0}", t); -#endif - } - } + //Register message pump processors + Register(new WindowKeeper(), form); + Register(new HotKeyManager(), form); + Register(new GroupSwitchManager(), form); } /// diff --git a/OnTopReplica/MessagePumpProcessors/TitleSetter.cs b/OnTopReplica/MessagePumpProcessors/TitleSetter.cs deleted file mode 100644 index 23433bd..0000000 --- a/OnTopReplica/MessagePumpProcessors/TitleSetter.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; -using OnTopReplica.Native; -using System.Runtime.InteropServices; - -namespace OnTopReplica.MessagePumpProcessors { - class TitleSetter : BaseMessagePumpProcessor { - - const string Title = "OnTopReplica"; - - public override bool Process(ref Message msg) { - switch (msg.Msg) { - case WM.GETTEXT: { - Console.WriteLine("GetText"); - int maxLen = msg.WParam.ToInt32(); - byte[] strBytes = Encoding.UTF8.GetBytes(Title); - byte[] termBytes = new byte[strBytes.Length + 1]; - strBytes.CopyTo(termBytes, 0); - termBytes[strBytes.Length] = 0; - - Marshal.Copy(termBytes, 0, msg.LParam, Math.Min(maxLen, Title.Length + 1)); - } - goto case WM.GETTEXTLENGTH; - - case WM.GETTEXTLENGTH: - Console.WriteLine("GetTextLength"); - msg.Result = (IntPtr)Title.Length; - return true; - } - - return false; - } - - protected override void Shutdown() { - - } - - } -} diff --git a/OnTopReplica/OnTopReplica.csproj b/OnTopReplica/OnTopReplica.csproj index 6820fe6..99264a0 100644 --- a/OnTopReplica/OnTopReplica.csproj +++ b/OnTopReplica/OnTopReplica.csproj @@ -124,7 +124,6 @@ - @@ -149,6 +148,7 @@ GroupSwitchPanel.cs +