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); }
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)); }
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); }
private void OpenDialog() { if (_hotkeySetting != null) { _hotkeySetting.Activate(); } else { _hotkeySetting = new HotkeySetting(); _hotkeySetting.Closed += (s, e) => { _hotkeySetting = null; }; _hotkeySetting.Show(); } }
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; }
public override void OnUnload() { _hotkeySetting?.Close(); _hotkeySetting = null; PluginData.GlobalInputEvent.thread.Abort(); }