当前位置: 首页>>代码示例>>C#>>正文


C# ModifierKeys类代码示例

本文整理汇总了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();
 }
开发者ID:hosiminn,项目名称:StarryEyes,代码行数:7,代码来源:KeyAssign.cs

示例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));
        }
开发者ID:hungdluit,项目名称:bot,代码行数:7,代码来源:CommandKeyMapper.cs

示例3: OnLoading

 protected override void OnLoading()
 {
   base.OnLoading();
   var element = Controller.Element;
   _modifiersKeys = MouseWheel.GetVScrollModifiers(element);
   MouseWheel.VScrollModifiersProperty.AddValueChanged(element, OnModifierKeysYChanged);
 }
开发者ID:heartszhang,项目名称:WeiZhi3,代码行数:7,代码来源:MouseWheelFlowDocumentPageViewerScrollClient.cs

示例4: HotKey

 public HotKey(int id, Key key, ModifierKeys modifiers)
 {
     this.id = id;
     this.key = key;
     this.modifiers = modifiers;
     this.actions = new List<Action>();
 }
开发者ID:stufkan,项目名称:SimpleAudio,代码行数:7,代码来源:HotKey.cs

示例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);
        }
开发者ID:x-skywalker,项目名称:Tasks.Show,代码行数:28,代码来源:HotKeyHelper.cs

示例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.");
     }
 }
开发者ID:GoldRenard,项目名称:DMOAdvancedLauncher,代码行数:12,代码来源:HotkeyHook.cs

示例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;
     }
 }
开发者ID:e82eric,项目名称:Prompts,代码行数:26,代码来源:MultiSelector.cs

示例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;
        }
开发者ID:praveennet,项目名称:VsVim,代码行数:34,代码来源:KeyboardMap.cs

示例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;
        }
开发者ID:vetuomia,项目名称:rocket,代码行数:35,代码来源:KeyEventArgs.cs

示例10: KeyDescriptor

		KeyDescriptor (SpecialKey specialKey, char keyChar, ModifierKeys modifierKeys, object nativeKeyChar)
		{
			SpecialKey = specialKey;
			KeyChar = keyChar;
			ModifierKeys = modifierKeys;
			NativeKeyChar = nativeKeyChar;
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:7,代码来源:KeyDescriptor.cs

示例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;
        }
开发者ID:aevv,项目名称:qcmd,代码行数:7,代码来源:KeyboardHook.cs

示例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;
 }
开发者ID:ondryaso,项目名称:j2-client,代码行数:7,代码来源:SettingsKeyInterpreter.cs

示例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);
        }
开发者ID:ResQue1980,项目名称:ShiftLoL,代码行数:26,代码来源:Program.cs

示例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));
        }
开发者ID:amatukaze,项目名称:IntelligentNavalGun,代码行数:27,代码来源:Other.xaml.cs

示例15: VertexSelectedEventArgs

 public VertexSelectedEventArgs(VertexControl vc, MouseButtonEventArgs e, ModifierKeys keys)
     : base()
 {
     VertexControl = vc;
     MouseArgs = e;
     Modifiers = keys;
 }
开发者ID:KevinCathcart,项目名称:GraphX,代码行数:7,代码来源:VertexSelectedEventArgs.cs


注:本文中的ModifierKeys类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。