Ejemplo n.º 1
0
 /// <inheritdoc />
 public bool IsRegistered(IMouseHookHotkey hotkey)
 {
     if (hotkey == null)
     {
         throw new ArgumentNullException(nameof(hotkey));
     }
     return(hotkey.MouseButton.HasValue && this.registeredHotkeys.Any(h => h.Action.Equals(hotkey.Action)));
 }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public void UnregisterHook(IMouseHookHotkey hotkey)
        {
            if (hotkey == null)
            {
                throw new ArgumentNullException(nameof(hotkey));
            }
            if (!hotkey.MouseButton.HasValue)
            {
                return;
            }

            this.registeredHotkeys.RemoveAll(h => h.Action.Equals(hotkey.Action));
            this.EnsureMouseHookEnabledIfNeeded();
        }
Ejemplo n.º 3
0
        /// <inheritdoc />
        public void RegisterHook(IMouseHookHotkey hotkey)
        {
            if (hotkey == null)
            {
                throw new ArgumentNullException(nameof(hotkey));
            }
            if (!hotkey.MouseButton.HasValue)
            {
                return;
            }

            this.registeredHotkeys.Add(hotkey);
            this.EnsureMouseHookEnabledIfNeeded();
        }
        public bool?TestRegistration(IMouseHookHotkey hotkey, Action <MouseHookHotkeyVisitor, IMouseHookHotkey> setup, Type exceptionType)
        {
            if (exceptionType != null)
            {
                Assert.Multiple(() =>
                {
                    if (setup != null)
                    {
                        Assert.Throws(exceptionType, () => setup.Invoke(this.visitor, hotkey));
                    }
                    Assert.Throws(exceptionType, () => this.visitor.IsRegistered(hotkey));
                });
                return(null);
            }

            setup?.Invoke(this.visitor, hotkey);
            return(this.visitor.IsRegistered(hotkey));
        }
 public void SetUp()
 {
     this.visitor    = new MouseHookHotkeyVisitor();
     this.fakeHotkey = A.Fake <IMouseHookHotkey>();
 }
Ejemplo n.º 6
0
 /// <inheritdoc />
 public void Visit(IMouseHookHotkey hotkey)
 {
     hotkey?.PerformAction();
 }