Beispiel #1
0
        public static void UnregisterFormHotKey(Keys keys, Function<bool, Keys> callback)
        {
            if (hotkeyRegistrar != null)
            {
                Function<bool, Keys> theDelegate = hotkeyRegistrar[keys];
                theDelegate -= callback;
                hotkeyRegistrar[keys] = theDelegate;

                IComponent targetAsComponent = callback.Target as IComponent;
                if (targetAsComponent != null)
                {
                    targetAsComponent.Disposed -= TargetAsComponent_Disposed;
                }

                IHotKeyTarget targetAsHotKeyTarget = callback.Target as IHotKeyTarget;
                if (targetAsHotKeyTarget != null)
                {
                    targetAsHotKeyTarget.Disposed -= TargetAsHotKeyTarget_Disposed;
                }

                if (theDelegate.GetInvocationList().Length == 0)
                {
                    hotkeyRegistrar.Remove(keys);
                }

                if (hotkeyRegistrar.Count == 0)
                {
                    hotkeyRegistrar = null;
                }
            }
        }