本文整理汇总了C#中ModifierKeys类的典型用法代码示例。如果您正苦于以下问题:C# ModifierKeys类的具体用法?C# ModifierKeys怎么用?C# ModifierKeys使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModifierKeys类属于命名空间,在下文中一共展示了ModifierKeys类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: KeyAssign
public KeyAssign(Key key, ModifierKeys modifiers, IEnumerable<KeyAssignActionDescription> actions, bool handlePreview = false)
{
Key = key;
Modifiers = modifiers;
HandlePreview = handlePreview;
Actions = actions.ToArray();
}
示例2: AddKeyBinding
public void AddKeyBinding(ICommand command, object param, Key key, ModifierKeys modifierKeys = ModifierKeys.None)
{
Contract.Requires(command != null);
var binding = new KeyBinding(key, modifierKeys);
m_keyBindings.Add(binding, new CommandParamPair(command, param));
}
示例3: OnLoading
protected override void OnLoading()
{
base.OnLoading();
var element = Controller.Element;
_modifiersKeys = MouseWheel.GetVScrollModifiers(element);
MouseWheel.VScrollModifiersProperty.AddValueChanged(element, OnModifierKeysYChanged);
}
示例4: HotKey
public HotKey(int id, Key key, ModifierKeys modifiers)
{
this.id = id;
this.key = key;
this.modifiers = modifiers;
this.actions = new List<Action>();
}
示例5: HookHotKey
public static void HookHotKey(Window window, Key key,
ModifierKeys modifiers, int keyId, EventHandler hookHandler)
{
HwndSourceHook hook = delegate(IntPtr hwnd, int msg, IntPtr wParam,
IntPtr lParam, ref bool handled)
{
if (msg == HotKeyHelper.WM_HOTKEY)
{
// TODO: parse out the lParam to see if it is actually the one registered
// see http://msdn.microsoft.com/en-us/library/ms646279(VS.85).aspx
hookHandler(window, EventArgs.Empty);
handled = true;
}
return IntPtr.Zero;
};
HwndSource source = PresentationSource.FromVisual(window) as HwndSource;
if (source == null)
{
throw new ApplicationException("window doesn't have a source yet. Did you wait till after the SourceInitialized event?");
}
source.AddHook(hook);
RegisterHotKey(window, key, modifiers, keyId);
}
示例6: RegisterHotKey
/// <summary>
/// Регистрация хоткея в системе
/// </summary>
/// <param name="modifier">Модификатор хоткея.</param>
/// <param name="key">Клавиша хоткея.</param>
public void RegisterHotKey(ModifierKeys modifier, Keys key)
{
_currentId = _currentId + 1;
if (!NativeMethods.RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)key)) {
throw new InvalidOperationException("Couldn’t register the hot key.");
}
}
示例7: Select
public void Select(ModifierKeys modifierKey, ICollection<ITreeItem> rootTreeItems, ITreeItem newSelectedItem, ITreeItem oldSelectedItem)
{
switch (modifierKey)
{
case ModifierKeys.Shift:
if(_previousSelectionWasShift)
{
_rangeSelector.Select(rootTreeItems, newSelectedItem, _previousShiftSelection);
}
else
{
_rangeSelector.Select(rootTreeItems, newSelectedItem, oldSelectedItem);
_previousShiftSelection = oldSelectedItem;
}
_previousSelectionWasShift = true;
break;
case ModifierKeys.Control:
_previousSelectionWasShift = false;
_inverseSelector.Select(rootTreeItems, newSelectedItem);
break;
default:
_previousSelectionWasShift = false;
_nullSelector.Select(rootTreeItems, newSelectedItem);
break;
}
}
示例8: 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;
}
示例9: Match
/// <summary>
/// Determines whether the event arguments match the specified key combination.
/// </summary>
/// <param name="key">The key.</param>
/// <param name="modifierKeys">The modifier keys.</param>
/// <returns>True if the event arguments match the specified key combination, otherwise false.</returns>
public bool Match(Key key, ModifierKeys modifierKeys = ModifierKeys.None)
{
if (this.Key == key)
{
if (key == Keyboard.LeftControl || key == Keyboard.RightControl)
{
return (this.ModifierKeys | ModifierKeys.Control) == (modifierKeys | ModifierKeys.Control);
}
if (key == Keyboard.LeftAlt || key == Keyboard.RightAlt)
{
return (this.ModifierKeys | ModifierKeys.Alt) == (modifierKeys | ModifierKeys.Alt);
}
if (key == Keyboard.LeftShift || key == Keyboard.RightShift)
{
return (this.ModifierKeys | ModifierKeys.Shift) == (modifierKeys | ModifierKeys.Shift);
}
if (key == Keyboard.LeftWindows || key == Keyboard.RightWindows)
{
return (this.ModifierKeys | ModifierKeys.Windows) == (modifierKeys | ModifierKeys.Windows);
}
return this.ModifierKeys == modifierKeys;
}
return false;
}
示例10: KeyDescriptor
KeyDescriptor (SpecialKey specialKey, char keyChar, ModifierKeys modifierKeys, object nativeKeyChar)
{
SpecialKey = specialKey;
KeyChar = keyChar;
ModifierKeys = modifierKeys;
NativeKeyChar = nativeKeyChar;
}
示例11: RegisterHotKey
public int RegisterHotKey(ModifierKeys mods, Keys key)
{
if (!RegisterHotKey(_window.Handle, ++_currentId, (uint) mods, (uint) key))
throw new Exception("Key register failed");
return _currentId;
}
示例12: SaveKeys
public void SaveKeys(ModifierKeys[] modifiers, Key key, ref String to)
{
String s = "";
modifiers.ToList().ForEach(k => s += k.ToString() + "+");
s += key.ToString();
to = s;
}
示例13: ConvertFromString
public static Tuple<Keys, ModifierKeys> ConvertFromString(string keysString)
{
Keys mainKey = new Keys();
ModifierKeys modKeys = new ModifierKeys();
var keys = keysString.Split('+');
foreach (string keyString in keys)
{
Keys key = (Keys)(new KeysConverter()).ConvertFromString(keyString);
if (key == Keys.Alt || key == Keys.LWin || key == Keys.Shift || key == Keys.Control)
{
switch (key)
{
case Keys.Alt: modKeys = modKeys | ModifierKeys.Alt; break;
case Keys.LWin: modKeys = modKeys | ModifierKeys.Win; break;
case Keys.Shift: modKeys = modKeys | ModifierKeys.Shift; break;
case Keys.Control: modKeys = modKeys | ModifierKeys.Control; break;
}
}
else
{
mainKey = key;
}
}
return new Tuple<Keys, ModifierKeys>(mainKey, (ModifierKeys)modKeys);
}
示例14: PanicKey_PreviewKeyDown
void PanicKey_PreviewKeyDown(object sender, KeyEventArgs e)
{
e.Handled = true;
var rKey = e.Key;
switch (rKey)
{
case Key.LWin:
case Key.RWin:
case Key.NumLock:
case Key.LeftShift:
case Key.RightShift:
case Key.LeftCtrl:
case Key.RightCtrl:
case Key.LeftAlt:
case Key.RightAlt:
return;
}
if (r_OldKey == rKey && r_OldModifierKeys == Keyboard.Modifiers)
return;
r_OldKey = rKey;
r_OldModifierKeys = Keyboard.Modifiers;
Preference.Instance.Other.PanicKey.UpdateKey((int)Keyboard.Modifiers, KeyInterop.VirtualKeyFromKey(rKey));
}
示例15: VertexSelectedEventArgs
public VertexSelectedEventArgs(VertexControl vc, MouseButtonEventArgs e, ModifierKeys keys)
: base()
{
VertexControl = vc;
MouseArgs = e;
Modifiers = keys;
}