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


C# Keys.HasFlag方法代码示例

本文整理汇总了C#中Keys.HasFlag方法的典型用法代码示例。如果您正苦于以下问题:C# Keys.HasFlag方法的具体用法?C# Keys.HasFlag怎么用?C# Keys.HasFlag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Keys的用法示例。


在下文中一共展示了Keys.HasFlag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessCmdKey

 protected override bool ProcessCmdKey(ref Message m, Keys keyData)
 {
     if (keyData.HasFlag(Keys.Escape)) { RemoveIt(); return true; }
     if (keyData.HasFlag(Keys.Enter)) {
         Parent.GoToLine(TextBox.Text);
         RemoveIt();
     }
     return base.ProcessCmdKey(ref m, keyData);
 }
开发者ID:HTD,项目名称:TraxCodeEditor,代码行数:9,代码来源:GoToLineControl.cs

示例2: ConvertModifier

		public static swi.ModifierKeys ConvertModifier (Keys key)
		{
			key &= Keys.ModifierMask;
			swi.ModifierKeys val = swi.ModifierKeys.None;

			if (key.HasFlag (Keys.Alt)) val |= swi.ModifierKeys.Alt;
			if (key.HasFlag (Keys.Control)) val |= swi.ModifierKeys.Control;
			if (key.HasFlag (Keys.Shift)) val |= swi.ModifierKeys.Shift;
			if (key.HasFlag (Keys.Application)) val |= swi.ModifierKeys.Windows;
			return val;
		}
开发者ID:mhusen,项目名称:Eto,代码行数:11,代码来源:KeyMap.cs

示例3: KeysToModifierKeys

 /// <summary>
 ///     Translate Keys to ModifierKeys standard for GlobalHotkeys
 /// </summary>
 /// <param name="keys">Keys as ModifierKeys</param>
 /// <returns>ModifierKeys</returns>
 public static ModifierKeys KeysToModifierKeys(Keys keys)
 {
     var mfk = new ModifierKeys();
     if (keys.HasFlag(Keys.Shift))
         mfk |= ModifierKeys.Shift;
     if (keys.HasFlag(Keys.Control))
         mfk |= ModifierKeys.Control;
     if (keys.HasFlag(Keys.LWin | Keys.RWin))
         mfk |= ModifierKeys.Win;
     if (keys.HasFlag(Keys.Alt))
         mfk |= ModifierKeys.Alt;
     return mfk;
 }
开发者ID:jnnpsubm,项目名称:YAR-Auth,代码行数:18,代码来源:GlobalHotkeys.cs

示例4: ProcessCmdKey

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData.HasFlag(Keys.Control))
            {
                if (keyData.HasFlag(Keys.O))
                {
                    OpenMenuItem.PerformClick();
                    return true;
                }
                if (keyData.HasFlag(Keys.Alt) && keyData.HasFlag(Keys.Shift) && keyData.HasFlag(Keys.S))
                {
                    SaveDecryptedMenuItem.PerformClick();
                    return true;
                }
                if (keyData.HasFlag(Keys.Shift) && keyData.HasFlag(Keys.S))
                {
                    SaveEncryptedMenuItem.PerformClick();
                    return true;
                }
                if (keyData.HasFlag(Keys.S))
                {
                    SaveMenuItem.PerformClick();
                    return true;
                }
            }

            return m_tabPages.Any(tabPage => tabPage.OnHotkey(keyData)) || base.ProcessCmdKey(ref msg, keyData);
        }
开发者ID:ttgowings,项目名称:NFirmwareEditor,代码行数:28,代码来源:MainWindow.cs

示例5: KeyEquivalentModifierMask

		public static NSEventModifierMask KeyEquivalentModifierMask (Keys key)
		{
			key &= Keys.ModifierMask;
			var mask = (NSEventModifierMask)0;
			if (key.HasFlag(Keys.Shift))
				mask |= NSEventModifierMask.ShiftKeyMask;
			if (key.HasFlag(Keys.Alt))
				mask |= NSEventModifierMask.AlternateKeyMask;
			if (key.HasFlag(Keys.Control))
				mask |= NSEventModifierMask.ControlKeyMask;
			if (key.HasFlag(Keys.Application))
				mask |= NSEventModifierMask.CommandKeyMask;
			return mask;
		}
开发者ID:Exe0,项目名称:Eto,代码行数:14,代码来源:KeyMap.cs

示例6: GetFlags

 private static HotkeyFlags GetFlags(Keys hotkey, bool noRepeat)
 {
     var noMod = hotkey & ~Keys.Modifiers;
     var flags = HotkeyFlags.None;
     if (hotkey.HasFlag(Keys.Alt))
         flags |= HotkeyFlags.Alt;
     if (hotkey.HasFlag(Keys.Control))
         flags |= HotkeyFlags.Control;
     if (hotkey.HasFlag(Keys.Shift))
         flags |= HotkeyFlags.Shift;
     if (noMod == Keys.LWin || noMod == Keys.RWin)
         flags |= HotkeyFlags.Windows;
     if (noRepeat)
         flags |= HotkeyFlags.NoRepeat;
     return flags;
 }
开发者ID:razvann,项目名称:NHotkey,代码行数:16,代码来源:HotkeyManager.cs

示例7: AssertAKeyPress

        private void AssertAKeyPress(Keys key)
        {
            int neededInputs = 2;
            var modifiers = new Keys?[3];
            if (key.HasFlag(Keys.Shift))
            {
                modifiers[0] = Keys.ShiftKey;
                neededInputs += 2;
            }
            if (key.HasFlag(Keys.Control))
            {
                modifiers[1] = Keys.ControlKey;
                neededInputs += 2;
            }
            if (key.HasFlag(Keys.Alt))
            {
                modifiers[2] = Keys.Menu;
                neededInputs += 2;
            }

            Assert.AreEqual(neededInputs, _inputs.Count);

            int currentInput = 0;
            foreach (var modifier in modifiers)
            {
                if (modifier.HasValue)
                {
                    AssertIsKeyDownInputFor(modifier.Value, _inputs[currentInput++]);
                }
            }

            AssertIsKeyDownInputFor(key, _inputs[currentInput++]);
            AssertIsKeyUpInputFor(key, _inputs[currentInput++]);

            foreach (var modifier in modifiers)
            {
                if (modifier.HasValue)
                {
                    AssertIsKeyUpInputFor(modifier.Value, _inputs[currentInput++]);
                }
            }
        }
开发者ID:sgraf812,项目名称:Keyboard,代码行数:42,代码来源:SendInputKeyboardTest.cs

示例8: ProcessCmdKey

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (waitLabel != null)
            {
                if (!keyData.HasFlag(Keys.Control) && !keyData.HasFlag(Keys.Alt) && !keyData.HasFlag(Keys.Shift))
                {
                    switch (waitKey)
                    {
                        case GameInput.Up: GameInputKeys.Up = keyData; break;
                        case GameInput.Down: GameInputKeys.Down = keyData; break;
                        case GameInput.Left: GameInputKeys.Left = keyData; break;
                        case GameInput.Right: GameInputKeys.Right = keyData; break;
                        case GameInput.Jump: GameInputKeys.Jump = keyData; break;
                        case GameInput.Shoot: GameInputKeys.Shoot = keyData; break;
                        case GameInput.Start: GameInputKeys.Start = keyData; break;
                        case GameInput.Select: GameInputKeys.Select = keyData; break;
                    }
                    waitLabel.Text = keyData.ToString();
                    waitLabel = null;
                    return true;   // Needs to be here, so if a key picked like up, selected button must not be changed.
                }
                else
                {
                    string key = "";

                    if (keyData.HasFlag(Keys.Control)) key = "ctrl";
                    else if (keyData.HasFlag(Keys.Alt)) key = "Alt";
                    else if (keyData.HasFlag(Keys.Shift)) key = "Shift";

                    MessageBox.Show(this, "Key " + key + " is not allowed.", "Unhauthorized key", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1);
                }
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }
开发者ID:Tesserex,项目名称:C--MegaMan-Engine,代码行数:34,代码来源:Keyboard.cs

示例9: ModifierExtractor

 public ModifierExtractor(Keys modifiedKey)
 {
     _shift = modifiedKey.HasFlag(Keys.Shift);
     _ctrl = modifiedKey.HasFlag(Keys.Control);
     _alt = modifiedKey.HasFlag(Keys.Alt);
 }
开发者ID:sgraf812,项目名称:Keyboard,代码行数:6,代码来源:ModifierExtractor.cs

示例10: ProcessKeyDown

 internal bool ProcessKeyDown(Keys pKeys)
 {
     if(pKeys == (Keys.Control | Keys.X))
         m_session.Gui_ClearSelectedLayer();
     else if(pKeys == (Keys.Control | Keys.Z))
         m_session.Gui_Undo();
     else if (pKeys.HasFlag(Keys.Shift))
         m_zoomTool.Enabled = true;
     else if (pKeys.HasFlag(Keys.Alt))
         m_panTool.Enabled = true;
     else if (pKeys.HasFlag(Keys.Oemplus))
         SetZoom(m_magnification * 1.5f, true);
     else if (pKeys.HasFlag(Keys.OemMinus))
         SetZoom(m_magnification / 1.5f, true);
      else
         return false;
     return true;
 }
开发者ID:pyro-dragon,项目名称:AwesomeCanvas,代码行数:18,代码来源:CanvasWindow.cs

示例11: SetHotkeyText

		public static void SetHotkeyText(Keys keyData)
		{
			if (keyData.HasFlag(Alt))
			{
				HotkeyText = "Alt";
				return;
			}

			var converter = new KeysConverter();
			string keyText = converter.ConvertToString(keyData);

			// show the [ ] ~ etc keys instead of Oem<whatever>
			if (keyText.StartsWith("Oem", StringComparison.Ordinal))
			{
				uint nonVirtualKey = MapVirtualKey((uint)keyData, 2) & 0x7fffffff;
				char mappedChar = Convert.ToChar(nonVirtualKey);
				HotkeyText = mappedChar == '\0' ? keyText : mappedChar.ToString();
			}
			else
			{
				HotkeyText = keyText;
			}
		}
开发者ID:RobinHood70,项目名称:wGemCombiner,代码行数:23,代码来源:SettingsHandler.cs

示例12: KeyEventMatcher

            public KeyEventMatcher(Keys key)
            {
                _shift = key.HasFlag(Keys.Shift);
                _control = key.HasFlag(Keys.Control);
                _alt = key.HasFlag(Keys.Alt);

                _keyCode = key & Keys.KeyCode;
            }
开发者ID:sgraf812,项目名称:Keyboard,代码行数:8,代码来源:TestWindowAdapter.cs

示例13: ProcessCmdKey

		protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
		{
			if (keyData.HasFlag(Keys.Up) || keyData.HasFlag(Keys.Down) || keyData.HasFlag(Keys.Left) || keyData.HasFlag(Keys.Right) || keyData.HasFlag(Keys.Tab))
			{
				KeyEventArgs args = new KeyEventArgs(keyData);
				args.Handled = false;
				this.OnKeyDown(args);
				if (args.Handled) return true;
			}
			return base.ProcessCmdKey(ref msg, keyData);
		}
开发者ID:Andrea,项目名称:duality-withsvn-history,代码行数:11,代码来源:PropertyGrid.cs

示例14: HasPressed

 /// <summary>
 ///     Checks if <see cref="Keys" /> have been pressed.
 /// </summary>
 /// <param name="newKeys">New <see cref="Keys" />.</param>
 /// <param name="oldKeys">Old <see cref="Keys" />.</param>
 /// <param name="keys">The <see cref="Keys" /> to check for.</param>
 /// <returns>Whether the <see cref="Keys" /> have been pressed.</returns>
 public static bool HasPressed(Keys newKeys, Keys oldKeys, Keys keys)
 {
     return newKeys.HasFlag(keys) && !oldKeys.HasFlag(keys);
 }
开发者ID:Xalphox,项目名称:SampSharp,代码行数:11,代码来源:KeyUtils.cs

示例15: ToStringWithModifiers

        /// <summary>
        ///   Gives a formatted version of the key listing all active
        ///   modifiers, the key name and the likely value for the key.
        /// </summary>
        /// 
        public string ToStringWithModifiers(Keys key)
        {
            StringBuilder builder = new StringBuilder(100);

            bool shift = key.HasFlag(Keys.Shift);
            bool alt = key.HasFlag(Keys.Alt);
            bool ctrl = key.HasFlag(Keys.Control);
            bool win = key.HasFlag(KeysExtensions.Windows);

            key = key.RemoveModifiers();

            if (shift)
            {
                builder.Append("Shift");
            }

            if (ctrl)
            {
                if (builder.Length > 0)
                    builder.Append(" + ");
                builder.Append("Control");
            }

            if (alt)
            {
                if (builder.Length > 0)
                    builder.Append(" + ");
                builder.Append("Alt");
            }

            if (win)
            {
                if (builder.Length > 0)
                    builder.Append(" + ");
                builder.Append("Win");
            }

            if (key != Keys.None)
            {
                if (builder.Length > 0)
                    builder.Append(" + ");

                string raw = ToKeyNameString(key);

                if (raw == null)
                    return builder.ToString();

                string mod = ToUnicodeCharString(key, shift, alt);

                builder.Append(raw);

                if (raw != mod && !String.IsNullOrWhiteSpace(mod))
                    builder.AppendFormat(" ({0})", mod);
            }

            return builder.ToString();
        }
开发者ID:damy90,项目名称:Telerik-all,代码行数:62,代码来源:CustomKeysConverter.cs


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