本文整理汇总了C#中KeyInput类的典型用法代码示例。如果您正苦于以下问题:C# KeyInput类的具体用法?C# KeyInput怎么用?C# KeyInput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyInput类属于命名空间,在下文中一共展示了KeyInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompareTo1
public void CompareTo1()
{
var i1 = new KeyInput('c', KeyModifiers.None);
Assert.IsTrue(i1.CompareTo(new KeyInput('z', KeyModifiers.None)) < 0);
Assert.IsTrue(i1.CompareTo(new KeyInput('c', KeyModifiers.None)) == 0);
Assert.IsTrue(i1.CompareTo(new KeyInput('a', KeyModifiers.None)) > 0);
}
示例2: GetOneKeyShortcuts
public IEnumerable<ProviderAndCommand> GetOneKeyShortcuts(KeyInput keyInput) {
var keyShortcut = new KeyShortcut(keyInput, KeyInput.Default);
List<ProviderAndCommand> list;
if (dict.TryGetValue(keyShortcut, out list))
return list;
return Array.Empty<ProviderAndCommand>();
}
示例3: FindConflictingCommands3
public void FindConflictingCommands3()
{
var util = Create("::ctrl+z, h");
var inputs = new KeyInput[] { InputUtil.CharAndModifiersToKeyInput('z', KeyModifiers.Control) };
var list = util.FindConflictingCommandKeyBindings(new HashSet<KeyInput>(inputs));
Assert.AreEqual(1, list.Count);
}
示例4: VimKeyData
internal VimKeyData(KeyInput keyInput, string text)
{
Contract.Assert(keyInput != null);
KeyInputOptional = keyInput;
TextOptional = text;
IsDeadKey = false;
}
示例5: Run
public void Run(KeyInput keyInput)
{
Key key;
ModifierKeys modifierKeys;
if (!TryConvert(keyInput, out key, out modifierKeys))
{
throw new Exception(String.Format("Couldn't convert {0} to Wpf keys", keyInput));
}
try
{
_defaultKeyboardDevice.DownKeyModifiers = modifierKeys;
if (PreProcess(keyInput, key, modifierKeys))
{
return;
}
var text = keyInput.RawChar.IsSome()
? keyInput.Char.ToString()
: String.Empty;
Run(text, key, modifierKeys);
}
finally
{
_defaultKeyboardDevice.DownKeyModifiers = ModifierKeys.None;
}
}
示例6: TryConvert
internal bool TryConvert(Guid commandGroup, uint commandId, IntPtr pvaIn, out KeyInput kiOutput)
{
kiOutput = null;
// Don't ever process a command when we are in an automation function. Doing so will cause VsVim to
// intercept items like running Macros and certain wizard functionality
if (VsShellUtilities.IsInAutomationFunction(_serviceProvider))
{
return false;
}
EditCommand command;
if (!OleCommandUtil.TryConvert(commandGroup, commandId, pvaIn, out command))
{
return false;
}
// If the current state of the buffer cannot process the command then do not convert it
if (!_buffer.CanProcess(command.KeyInput))
{
return false;
}
kiOutput = command.KeyInput;
return true;
}
示例7: TryConvert
internal static bool TryConvert(Guid commandGroup, uint commandId, IntPtr variantIn, out KeyInput keyInput, out EditCommandKind kind, out bool isRawText)
{
if (VSConstants.GUID_VSStandardCommandSet97 == commandGroup)
{
return TryConvert((VSConstants.VSStd97CmdID)commandId, variantIn, out keyInput, out kind, out isRawText);
}
if (VSConstants.VSStd2K == commandGroup)
{
return TryConvert((VSConstants.VSStd2KCmdID)commandId, variantIn, out keyInput, out kind, out isRawText);
}
if (commandGroup == HiddenCommand.Group && commandId == HiddenCommand.Id)
{
keyInput = KeyInputUtil.CharWithControlToKeyInput(';');
kind = EditCommandKind.UserInput;
isRawText = true;
return true;
}
keyInput = null;
kind = EditCommandKind.UserInput;
isRawText = false;
return false;
}
示例8: FindConflictingCommands5
public void FindConflictingCommands5()
{
var util = Create("::a", "::ctrl+z, h");
var inputs = new KeyInput[] { KeyInputUtil.CharWithControlToKeyInput('z') };
var list = util.FindConflictingCommandKeyBindings(new HashSet<KeyInput>(inputs));
Assert.AreEqual(1, list.Count);
}
示例9: FindConflictingCommands4
public void FindConflictingCommands4()
{
Create("::h, z");
var inputs = new KeyInput[] { KeyInputUtil.CharToKeyInput('z') };
var list = _serviceRaw.FindConflictingCommandKeyBindings(_commandsSnapshot, new HashSet<KeyInput>(inputs));
Assert.Equal(0, list.Count);
}
示例10: HandleKeyPress
public override bool HandleKeyPress(KeyInput e)
{
if (world == null)
return false;
return ProcessInput(e);
}
示例11: TryGetKeyInput
/// <summary>
/// Try and get the KeyInput which corresponds to the given Key and modifiers
/// TODO: really think about this method
/// </summary>
internal bool TryGetKeyInput(Key key, ModifierKeys modifierKeys, out KeyInput keyInput)
{
// First just check and see if there is a direct mapping
var keyType = new KeyType(key, modifierKeys);
if (_cache.TryGetValue(keyType, out keyInput))
{
return true;
}
// Next consider only the shift key part of the requested modifier. We can
// re-apply the original modifiers later
keyType = new KeyType(key, modifierKeys & ModifierKeys.Shift);
if (_cache.TryGetValue(keyType, out keyInput))
{
// Reapply the modifiers
keyInput = KeyInputUtil.ChangeKeyModifiers(keyInput, ConvertToKeyModifiers(modifierKeys));
return true;
}
// Last consider it without any modifiers and reapply
keyType = new KeyType(key, ModifierKeys.None);
if (_cache.TryGetValue(keyType, out keyInput))
{
// Reapply the modifiers
keyInput = KeyInputUtil.ChangeKeyModifiers(keyInput, ConvertToKeyModifiers(modifierKeys));
return true;
}
return false;
}
示例12: FindConflictingCommands1
public void FindConflictingCommands1()
{
Create("::ctrl+h");
var inputs = new KeyInput[] { KeyInputUtil.CharWithControlToKeyInput('h') };
var list = _serviceRaw.FindConflictingCommandKeyBindings(_commandsSnapshot, new HashSet<KeyInput>(inputs));
Assert.Equal(1, list.Count);
}
示例13: TryGetSingleMapping
/// <summary>
/// Try and map a KeyInput to a single KeyInput value. This will only succeed for KeyInput
/// values which have no mapping or map to a single KeyInput value
/// </summary>
private bool TryGetSingleMapping(KeyInput original, out KeyInput mapped)
{
var result = _vimBuffer.GetKeyInputMapping(original);
if (result.IsNeedsMoreInput || result.IsRecursive || result.IsPartiallyMapped)
{
// No single mapping
mapped = null;
return false;
}
if (result.IsMapped)
{
var set = ((KeyMappingResult.Mapped)result).Item;
if (!set.IsOneKeyInput)
{
mapped = null;
return false;
}
mapped = set.FirstKeyInput.Value;
return true;
}
// Shouldn't get here because all cases of KeyMappingResult should be
// handled above
Contract.Assert(false);
mapped = null;
return false;
}
示例14: IsDisplayWindowKey
/// <summary>
/// Is this KeyInput intended to be processed by the active display window
/// </summary>
private bool IsDisplayWindowKey(KeyInput keyInput)
{
// Consider normal completion
if (_broker.IsCompletionActive)
{
return
keyInput.IsArrowKey ||
keyInput == KeyInputUtil.EnterKey ||
keyInput == KeyInputUtil.TabKey ||
keyInput.Key == VimKey.Back;
}
if (_broker.IsSmartTagSessionActive)
{
return
keyInput.IsArrowKey ||
keyInput == KeyInputUtil.EnterKey;
}
if (_broker.IsSignatureHelpActive)
{
return keyInput.IsArrowKey;
}
return false;
}
示例15: FindConflictingCommands4
public void FindConflictingCommands4()
{
var util = Create("::h, z");
var inputs = new KeyInput[] { new KeyInput('z') };
var list = util.FindConflictingCommandKeyBindings(new HashSet<KeyInput>(inputs));
Assert.AreEqual(0, list.Count);
}