public void HotkeyModifier_AltCtrl_IsValid()
        {
            var setting = new HotkeySetting {
                CommandTypeName = "Foo", HasAltModifier = true, HasCtrlModifier = true, Key1 = "I"
            };

            Assert.IsTrue(setting.IsValid);
        }
        public void HotkeyModifier_None_IsNotValid()
        {
            var setting = new HotkeySetting {
                CommandTypeName = "Foo", Key1 = "I"
            };

            Assert.IsFalse(setting.IsValid);
        }
        public void HotkeyModifier_Shift_IsNotValid()
        {
            var setting = new HotkeySetting {
                CommandTypeName = "Foo", HasShiftModifier = true, Key1 = "I"
            };

            Assert.IsFalse(setting.IsValid);
        }
Ejemplo n.º 4
0
        public Hotkey Create(HotkeySetting setting, IntPtr hWndVbe)
        {
            if (setting == null)
            {
                return(null);
            }

            var commandToBind = _commands.FirstOrDefault(command => command.GetType().Name == setting.CommandTypeName);

            return(commandToBind == null ? null : new Hotkey(hWndVbe, setting.ToString(), commandToBind));
        }
Ejemplo n.º 5
0
        public void CreatingHotkeyReturnsNullWhenNoMatchingCommandExists()
        {
            var mockCommand = new Mock <CommandBase>(null).Object;
            var factory     = new HotkeyFactory(new[] { mockCommand });
            var setting     = new HotkeySetting {
                CommandTypeName = "Foo"
            };

            var hotkey = factory.Create(setting, IntPtr.Zero);

            Assert.IsNull(hotkey);
        }
        public void DuplicateNamesAreIgnored()
        {
            var expected = new HotkeySetting {
                CommandTypeName = "FooCommand", IsEnabled = true, Key1 = "X"
            };
            var duplicate = new HotkeySetting {
                CommandTypeName = "FooCommand", IsEnabled = true, Key1 = "Y"
            };

            var settings = new HotkeySettings
            {
                Settings = new[] { expected, duplicate }
            };

            Assert.IsFalse(settings.Settings.Contains(duplicate));
        }
        public void DuplicateKeysAreDeactivated()
        {
            var duplicate1 = new HotkeySetting {
                CommandTypeName = "FooCommand", IsEnabled = true, Key1 = "X"
            };
            var duplicate2 = new HotkeySetting {
                CommandTypeName = "BarCommand", IsEnabled = true, Key1 = "X"
            };

            // ReSharper disable once UnusedVariable
            var settings = new HotkeySettings
            {
                Settings = new[] { duplicate1, duplicate2 }
            };

            Assert.IsFalse(duplicate1.IsEnabled == duplicate2.IsEnabled);
        }
Ejemplo n.º 8
0
        private void OpenDialog()
        {
            if (_hotkeySetting != null)
            {
                _hotkeySetting.Activate();
            }
            else
            {
                _hotkeySetting         = new HotkeySetting();
                _hotkeySetting.Closed += (s, e) =>
                {
                    _hotkeySetting = null;
                };

                _hotkeySetting.Show();
            }
        }
Ejemplo n.º 9
0
        public void CreatingHotkeyReturnsCorrectResult()
        {
            var mockCommand = new Mock <CommandBase>(null).Object;
            var factory     = new HotkeyFactory(new[] { mockCommand });
            var setting     = new HotkeySetting
            {
                CommandTypeName = mockCommand.GetType().Name,
                Key1            = "X",
                HasCtrlModifier = true
            };

            var hotkey = factory.Create(setting, IntPtr.Zero);

            Assert.Multiple(() => {
                Assert.AreEqual(mockCommand, hotkey.Command);
                Assert.AreEqual(setting.ToString(), hotkey.Key);
            });
        }
 public HotkeySettingViewModel(HotkeySetting wrapped)
 {
     this.wrapped = wrapped;
 }
Ejemplo n.º 11
0
 public override void OnUnload()
 {
     _hotkeySetting?.Close();
     _hotkeySetting = null;
     PluginData.GlobalInputEvent.thread.Abort();
 }