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


C# Keys类代码示例

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


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

示例1: ProcessDialogKey

        protected override bool ProcessDialogKey(Keys keyData) {
            if (keyData == Keys.Escape) {
                SelectedIndex = originalSelectedIndex;
            }

            return base.ProcessDialogKey(keyData);
        }
开发者ID:cagatayalkan,项目名称:VersionOne.Client.VisualStudio,代码行数:7,代码来源:PropertyGridListBox.cs

示例2: ModuleProperty

        public ModuleProperty(MacroList p, MacroModule mod, Keys shortcut)
        {
            _parent = p;
            _prevShortCut = shortcut;
            _module = mod==null? new MacroModule(0) : (MacroModule)mod.Clone();
            //
            // Windows �t�H�[�� �f�U�C�i �T�|�[�g�ɕK�v�ł��B
            //
            InitializeComponent();

            this._titleLabel.Text = GApp.Strings.GetString("Form.ModuleProperty._titleLabel");
            this._pathLabel.Text = GApp.Strings.GetString("Form.ModuleProperty._pathLabel");
            this._additionalAssemblyLabel.Text = GApp.Strings.GetString("Form.ModuleProperty._additionalAssemblyLabel");
            this._shortcutLabel.Text = GApp.Strings.GetString("Form.ModuleProperty._shortcutLabel");
            this._debugOption.Text = GApp.Strings.GetString("Form.ModuleProperty._debugOption");
            this._okButton.Text = GApp.Strings.GetString("Common.OK");
            this._cancelButton.Text = GApp.Strings.GetString("Common.Cancel");
            this.Text = GApp.Strings.GetString("Form.ModuleProperty.Text");

            if(mod!=null) {
                _title.Text = _module.Title;
                _path.Text = _module.Path;
                _additionalAssembly.Text = Concat(_module.AdditionalAssemblies);
                _debugOption.Checked = _module.DebugMode;
                _shortcut.Key = shortcut;
            }
        }
开发者ID:rfyiamcool,项目名称:solrex,代码行数:27,代码来源:ModuleProperty.cs

示例3: Update

    public void Update(GameTime gameTime, Keys k, Keys p)
    {
        if (Playertype == 0)
        {
            KeyboardState currentKeyboardState = Keyboard.GetState();
            if (currentKeyboardState.IsKeyDown(k)) // getal geeft bewegingssnelheid aan. k is voor omlaag bewegen. 
            {
                Position.Y += 6;
            }

            else if (currentKeyboardState.IsKeyDown(p)) // getal geeft bewegingssnelheid aan. p is voor omhoog bewegen. 
            {
                Position.Y -= 6;
            }
        }
        else if (Playertype == 1)
        {
            for (int i = 0; i <= 5; i++)
            {
                if (this.MiddlePaddle > Pong.getGameState.PlayingBall.MiddleBall)
                {
                    Position.Y -= 1;
                }
                else if (this.MiddlePaddle < Pong.getGameState.PlayingBall.MiddleBall)
                {
                    Position.Y += 1;
                }
            }
        }
        BoundsPaddle.X = (int)Position.X;
        BoundsPaddle.Y = (int)Position.Y;
    }
开发者ID:Lunaface,项目名称:Pong,代码行数:32,代码来源:Paddle.cs

示例4: Convert

        public string Convert(Keys[] keys)
        {
            string output = "";
            bool usesShift = (keys.Contains(Keys.LeftShift) || keys.Contains(Keys.RightShift));

            foreach (Keys key in keys)
            {
                if (key >= Keys.A && key <= Keys.Z)
                    output += key.ToString();
                else if (key >= Keys.NumPad0 && key <= Keys.NumPad9)
                    output += ((int)(key - Keys.NumPad0)).ToString();
                else if (key >= Keys.D0 && key <= Keys.D9)
                {
                    string num = ((int)(key - Keys.D0)).ToString();
                    output += num;
                }
                else if(key == Keys.Space)
                {
                    output += " ";
                }
                else if(key == Keys.OemPeriod)
                {
                    output += ".";
                }

                if (!usesShift) output = output.ToLower();
            }
            return output;
        }
开发者ID:LuckiiGoggy,项目名称:COMP7051Assignment3,代码行数:29,代码来源:Console.cs

示例5: KeyboardCombo

 public KeyboardCombo(Keys key, bool alt, bool control, bool shift)
 {
     Key = key;
     Alt = alt;
     Control = control;
     Shift = shift;
 }
开发者ID:almx,项目名称:ExRep,代码行数:7,代码来源:KeyboardShortcutHandler.cs

示例6: Arrow

        public Arrow(Keys lastKey, object obj)
        {
            Image = new Image();
            switch (lastKey)
            {
                case Keys.W:
                    Image.Path = "Gameplay/Projectiles/arrow_up";
                    break;
                case Keys.S:
                    Image.Path = "Gameplay/Projectiles/arrow_down";
                    break;
                case Keys.A:
                    Image.Path = "Gameplay/Projectiles/arrow_left";
                    break;
                case Keys.D:
                    Image.Path = "Gameplay/Projectiles/arrow_right";
                    break;
            }

            DirectionKey = lastKey;

            if (obj.GetType() == typeof(Player))
            {
                Player p = (Player)obj;
                Image.Position = p.Image.Position;
            }
            MoveSpeed = 250f;
            Image.Scale = new Vector2(1, 2);
            Image.LoadContent();
        }
开发者ID:tmen13,项目名称:Avalon,代码行数:30,代码来源:Arrow.cs

示例7: ProcessCmdKey

 protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     if ((keyData == Keys.PageDown))
     {
         dataGridView1.ClearSelection();
         dataGridView4.ClearSelection();
         dataGridView4.Focus();
         dataGridView4.Rows[0].Selected = true;
         showDetail(dataGridView4.Rows[0].Cells[1].Value.ToString());
         return true;
     }
     else if (keyData == Keys.PageUp)
     {
         dataGridView1.ClearSelection();
         dataGridView4.ClearSelection();
         dataGridView1.Focus();
         dataGridView1.Rows[0].Selected = true;
         showDetail(dataGridView1.Rows[0].Cells[1].Value.ToString());
         return true;
     }
     else
     {
         return base.ProcessCmdKey(ref msg, keyData);
     }
 }
开发者ID:itktc,项目名称:projectktc-v2,代码行数:25,代码来源:MainSalePos.cs

示例8: KeyToString

        /// <summary>
        /// キー情報から文字を取得する
        /// </summary>
        /// <param name="key">押下されたキー</param>
        /// <param name="shitKeyPressed">シフトキーが押されていたか?</param>
        /// <param name="character">キー入力から変換された文字</param>
        /// <returns>文字取得が成功した場合trueを返す</returns>
        public static bool KeyToString(Keys key, bool shitKeyPressed,
                                                                    out char character)
        {
            bool result = false;
            character = ' ';
            CharPair charPair;

            if ((Keys.A <= key && key <= Keys.Z) || key == Keys.Space)
            {
                // A~Z、スペースキーはそのまま文字コードとして使用する
                character = (shitKeyPressed) ? (char)key : Char.ToLower((char)key);
                result = true;
            }
            else if (keyMap.TryGetValue(key, out charPair))
            {
                // それ以外の場合はKeyMapの情報を元に変換する
                if (!shitKeyPressed)
                {
                    character = charPair.NormalChar;
                    result = true;
                }
                else if (charPair.ShiftChar.HasValue)
                {
                    character = charPair.ShiftChar.Value;
                    result = true;
                }
            }

            return result;
        }
开发者ID:himapo,项目名称:ccm,代码行数:37,代码来源:KeyboardUtils.cs

示例9: IsKeyDown

 public static bool IsKeyDown(Keys key)
 {
     if (kbState.IsKeyDown(key))
         return true;
     else
         return false;
 }
开发者ID:Neckronis,项目名称:GameTemplate,代码行数:7,代码来源:InputManager.cs

示例10: Unregister

        public virtual Action<KeyboardState, GameTime> Unregister(Keys key)
        {
            Action<KeyboardState, GameTime> action = _keyboardInput[key];
            _keyboardInput.Remove(key);

            return action;
        }
开发者ID:hanjos,项目名称:gameoflife-xna,代码行数:7,代码来源:Input.cs

示例11: ProcessKeyPreview

        public static void ProcessKeyPreview(ref Message m, Keys ModifierKeys)
        {
            const int WM_KEYDOWN = 0x100;
            //const int WM_KEYUP = 0x101;
            const int WM_CHAR = 0x102;
            const int WM_SYSCHAR = 0x106;
            const int WM_SYSKEYDOWN = 0x104;
            //const int WM_SYSKEYUP = 0x105;
            const int WM_IME_CHAR = 0x286;

            KeyEventArgs e = null;

            if ((m.Msg != WM_CHAR) && (m.Msg != WM_SYSCHAR) && (m.Msg != WM_IME_CHAR))
            {
                e = new KeyEventArgs(((Keys)((int)((long)m.WParam))) | ModifierKeys);
                if ((m.Msg == WM_KEYDOWN) || (m.Msg == WM_SYSKEYDOWN))
                    control.TrappedKeyDown(e);

                // Remove any WM_CHAR type messages if supresskeypress is true.
                if (e.SuppressKeyPress)
                {
                    RemovePendingMessages(WM_CHAR, WM_CHAR);
                    RemovePendingMessages(WM_SYSCHAR, WM_SYSCHAR);
                    RemovePendingMessages(WM_IME_CHAR, WM_IME_CHAR);
                }
            }
        }
开发者ID:MikhailoMMX,项目名称:AspectMarkup,代码行数:27,代码来源:KeyboardShortcutHelper.cs

示例12: Update

        public void Update(GameTime time)
        {
            oldState = currentState;
            currentState = Microsoft.Xna.Framework.Input.Keyboard.GetState();
            shiftDown = currentState.IsKeyDown(Keys.LeftShift) || currentState.IsKeyDown(Keys.RightShift);

            currentlyPressed = currentState.GetPressedKeys();
            previouslyPressed = oldState.GetPressedKeys();

            if (currentlyPressed.Length != previouslyPressed.Length)
            {
                keyHoldTimer = 0.0f;
                keyHeld = false;
                lastKeyHeld = FindLastKeyPressed();
            }

            if (!keyHeld && currentlyPressed.Length > 0)
            {
                keyHoldTimer += (float)time.ElapsedGameTime.TotalMilliseconds;
                if (keyHoldTimer > keyHoldWait)
                {
                    keyHeld = true;
                }
            }
        }
开发者ID:idaohang,项目名称:Helicopter-Autopilot-Simulator,代码行数:25,代码来源:UIKeyboard.cs

示例13: 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

示例14: Wait

            /// <summary>
            /// Wait until the key gets pressed.
            /// </summary>
            /// <param name="k"></param>
            public void Wait(Keys k)
            {
                if (k == Keys.None)
                    throw new ArgumentException("Must submit valid Key definition!");
                _endKey = k;

                if (this.TimeOutVal.HasValue)
                {
                    _timeoutTimer = new System.Threading.Timer(new System.Threading.TimerCallback(OnTimoutTick));
                    _timeoutTimer.Change(this.TimeOutVal.Value, Timeout.Infinite);
                }
                _keyboardHook.IAKeyEvent += OnKeyEvent;

                while (true)
                {
                    lock (abortLock)
                    {
                        if (abort)
                            break;
                    }
                    Application.DoEvents(); // This is necessary if the Wait Method gets called on the Main GUI Thread
                    Thread.Sleep(2);
                }
                _keyboardHook.IAKeyEvent -= OnKeyEvent;
            }
开发者ID:Tyelpion,项目名称:IronAHK,代码行数:29,代码来源:KeyWaitCommand.cs

示例15: LoadFromJson

 public void LoadFromJson(JObject jsonData)
 {
     string tempTriggerKey = (string)jsonData["trigger key"];         // Load String from json
     VirtualKeyCode vkCode = KeyTranslater.GetKeyCode(tempTriggerKey); // Convert the string to a keycode using the Keytranslator
     triggerKey = (Keys)vkCode;                                        // Cast the Vkeycode to a key and save to the class
     commandWord = (string)jsonData["command word"];
 }
开发者ID:AlexanderMcNeill,项目名称:voxvisio,代码行数:7,代码来源:KeyPressCommand.cs


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