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


C# KeyPressEventArgs类代码示例

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


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

示例1: OnKeyPress

 protected override void OnKeyPress(KeyPressEventArgs e)
 {
     if (char.IsLetterOrDigit(e.KeyChar))
       theKey = e.KeyChar;
     Invalidate();
     base.OnKeyPress(e);
 }
开发者ID:JnS-Software-LLC,项目名称:CSC153,代码行数:7,代码来源:TryKey+(1).cs

示例2: OnKeyPress

    protected override void OnKeyPress(KeyPressEventArgs e)
    {
        base.OnKeyPress(e);

        if (e.KeyChar == 27)
        {
            Exit();
        }

        switch (e.KeyChar)
        {
            case 'w':
                camera.Move(0f, 0.1f, 0f);
                break;
            case 'a':
                camera.Move(-0.1f, 0f, 0f);
                break;
            case 's':
                camera.Move(0f, -0.1f, 0f);
                break;
            case 'd':
                camera.Move(0.1f, 0f, 0f);
                break;
            case 'q':
                camera.Move(0f, 0f, 0.1f);
                break;
            case 'e':
                camera.Move(0f, 0f, -0.1f);
                break;
        }
    }
开发者ID:ItsToms,项目名称:Game2D,代码行数:31,代码来源:Game2D.cs

示例3: OnKeyPress

 protected override void OnKeyPress(KeyPressEventArgs e)
 {
     base.OnKeyPress(e);
     if (e.KeyChar == 'w' || e.KeyChar == 'W')
     {
         camera.Position += camera.Attitude.Direction;
     }
     else if (e.KeyChar == 's' || e.KeyChar == 'S')
     {
         camera.Position -= camera.Attitude.Direction;
     }
     else if (e.KeyChar == 'd' || e.KeyChar == 'D')
     {
         camera.Position += camera.Attitude.Side;
     }
     else if (e.KeyChar == 'a' || e.KeyChar == 'A')
     {
         camera.Position -= camera.Attitude.Side;
     }
     else if (e.KeyChar == 'u' || e.KeyChar == 'U')
     {
         camera.Position += camera.Attitude.Up;
     }
     else if (e.KeyChar == 'j' || e.KeyChar == 'J')
     {
         camera.Position -= camera.Attitude.Up;
     }
 }
开发者ID:Grimston,项目名称:ezterrain,代码行数:28,代码来源:RendererControl.cs

示例4: HandleKeyPressEvent

 //nie wiem, gdzie jest enter
 private void HandleKeyPressEvent(object o, KeyPressEventArgs args)
 {
     switch(args.Event.Key){
         case Gdk.Key.Escape:	CancelButton.Click();
                                 break;
         default:	break;
     }
 }
开发者ID:shark555,项目名称:Resources-Reservation-System,代码行数:9,代码来源:GUILogin.cs

示例5: PressKey

 public override void PressKey(KeyPressEventArgs e)
 {
     base.PressKey(e);
     if (e.KeyInfo.Key == ConsoleKey.Spacebar || e.KeyInfo.Key == ConsoleKey.Enter)
     {
         Press(e);
     }
 }
开发者ID:EntityFX,项目名称:ScoreboardUI,代码行数:8,代码来源:ButtonBase.cs

示例6: SendKey

		public void SendKey(Keys keyDown, char keyPressed, GuiWidget reciever)
		{
			KeyEventArgs keyDownEvent = new KeyEventArgs(keyDown);
			reciever.OnKeyDown(keyDownEvent);
			if (!keyDownEvent.SuppressKeyPress)
			{
				KeyPressEventArgs keyPressEvent = new KeyPressEventArgs(keyPressed);
				reciever.OnKeyPress(keyPressEvent);
			}
		}
开发者ID:CNCBrasil,项目名称:agg-sharp,代码行数:10,代码来源:TextEditTests.cs

示例7: KeyPressed

        private void KeyPressed(KeyPressEventArgs obj)
        {
            if (obj.Key == Game.InputKeys.PlayerBlock)
            {
                if (IsCastable)
                {

                }
            }
        }
开发者ID:Azarem,项目名称:RogueAPI,代码行数:10,代码来源:AbilityDefinition.cs

示例8: OnKeyPress

        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            //  Enter = 13, Escape = 27,
            if (e.KeyChar == 13 || e.KeyChar == 27)
            {
                OnLostFocus(e);
            }

            e.Handled = (this.Text.IndexOfAny(invalidChar) != -1);
            base.OnKeyPress(e);
        }
开发者ID:450640526,项目名称:HtmExplorer,代码行数:11,代码来源:WinTextBox.cs

示例9: OnKeyPress

    protected void OnKeyPress(object sender, KeyPressEventArgs a)
    {
        if (a.Event.Key == Gdk.Key.Return) {
            // Send Entry Value to Server
            string val = this.entry2.Text;
            this.entry2.Text = string.Empty;
            this.textview2.Buffer.Text += val + "\n";
            this.ConvertToTelegram (val);
            //Console.WriteLine (val);

        }
    }
开发者ID:TheOperator,项目名称:OperatorServer,代码行数:12,代码来源:MainWindow.cs

示例10: Press

 public virtual void Press(KeyPressEventArgs e)
 {
     EventHandler handler = Pressed;
     if (handler != null)
     {
         handler(this, new KeyPressEventArgs
         {
             KeyInfo = e.KeyInfo
         });
     }
     OnPressed(e);
 }
开发者ID:EntityFX,项目名称:ScoreboardUI,代码行数:12,代码来源:ButtonBase.cs

示例11: PressKey

        public override void PressKey(KeyPressEventArgs e)
        {
            base.PressKey(e);

            char character = e.KeyInfo.KeyChar;

            int length = Text.Length;
            if (!Char.IsControl(character) && length <= MaxTextSize)
            {
                Text += character;
            }
            else
            {
                if (character == '\b' && length > 0)
                {
                    Text = Text.Remove(length - 1, 1);
                }
            }
            ReRender();
        }
开发者ID:EntityFX,项目名称:ScoreboardUI,代码行数:20,代码来源:TextBox.cs

示例12: KeyPress

 void KeyPress(KeyPressEventArgs e)
 {
     for (int i = 0; i < WidgetCount; i++)
     {
         MenuWidget w = widgets[i];
         if (w != null)
         {
             if (w.type == WidgetType.Textbox)
             {
                 if (w.editing)
                 {
                     string s = CharToString(e.GetKeyChar());
                     if (e.GetKeyChar() == 8) // backspace
                     {
                         if (StringTools.StringLength(game.platform, w.text) > 0)
                         {
                             w.text = StringTools.StringSubstring(game.platform, w.text, 0, StringTools.StringLength(game.platform, w.text) - 1);
                         }
                         return;
                     }
                     if (e.GetKeyChar() == 9 || e.GetKeyChar() == 13) // tab, enter
                     {
                         return;
                     }
                     if (e.GetKeyChar() == 22) //paste
                     {
                         if (game.platform.ClipboardContainsText())
                         {
                             w.text = StringTools.StringAppend(game.platform, w.text, game.platform.ClipboardGetText());
                         }
                         return;
                     }
                     if (game.platform.IsValidTypingChar(e.GetKeyChar()))
                     {
                         w.text = StringTools.StringAppend(game.platform, w.text, s);
                     }
                 }
             }
         }
     }
 }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:41,代码来源:GameMisc.ci.cs

示例13: OnKeyPress

    // Restricts the entry of characters to digits (including hex), the negative sign,
    // the decimal point, and editing keystrokes (backspace).
    protected override void OnKeyPress(KeyPressEventArgs e)
    {
        base.OnKeyPress(e);

        NumberFormatInfo numberFormatInfo = System.Globalization.CultureInfo.CurrentCulture.NumberFormat;
        string decimalSeparator = numberFormatInfo.NumberDecimalSeparator;
        string groupSeparator = numberFormatInfo.NumberGroupSeparator;
        string negativeSign = numberFormatInfo.NegativeSign;

        string keyInput = e.KeyChar.ToString();

        if (Char.IsDigit(e.KeyChar))
        {
            // Digits are OK
        }
        else if (keyInput.Equals(decimalSeparator) || keyInput.Equals(groupSeparator) ||
         keyInput.Equals(negativeSign))
        {
            // Decimal separator is OK
        }
        else if (e.KeyChar == '\b')
        {
            // Backspace key is OK
        }
        //    else if ((ModifierKeys & (Keys.Control | Keys.Alt)) != 0)
        //    {
        //     // Let the edit control handle control and alt key combinations
        //    }
        else if (this.allowSpace && e.KeyChar == ' ')
        {

        }
        else
        {
            // Consume this invalid key and beep
            e.Handled = true;
            //    MessageBeep();
        }
    }
开发者ID:polserver,项目名称:poltools,代码行数:41,代码来源:NumericTextBox.cs

示例14: OnKeyPress

            protected override void OnKeyPress(KeyPressEventArgs e)
            {
                base.OnKeyPress(e);

                if (!Char.IsDigit(e.KeyChar))
                {
                    if
                    (
                       !(
                          ('A' <= e.KeyChar && 'F' >= e.KeyChar) ||
                          ('a' <= e.KeyChar && 'f' >= e.KeyChar)
                        )
                    )
                    {
                        if (!Char.IsControl(e.KeyChar))
                        {
                            Console.Beep();

                            e.Handled = true;
                        }
                    }
                }
            }
开发者ID:mti-rfid,项目名称:RFID_Explorer,代码行数:23,代码来源:HexNumberTextBox.cs

示例15: m_TxtPassword_KeyPress

        /// <summary>
        /// Event handler for the TextBox KeyPress event. Checks if the user entered a [CR] and, if so, starts processing the input.
        /// </summary>
        /// <param name="sender">Reference to the object that raised the event.</param>
        /// <param name="e">Parameter passed from the object that raised the event.</param>
        private void m_TxtPassword_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar.Equals('\r'))
            {
                // Check if the number of attempts at logging on has expired.
                m_Attempts++;
                if (m_Attempts >= MaxAttempts)
                {
                    MessageBox.Show(Resources.MBTSecurityLoginFailed, Resources.MBCaptionWarning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Close();
                    return;
                }

                // Get the hash code corresponding to the entered password.
				m_Hashcode = Security.GetHashCode(m_TextBoxPassword.Text);

                // Check whether the password is valid.
                if (m_Hashcode == Security.HashCodeLevel1)
                {
                    Security.SecurityLevelCurrent = SecurityLevel.Level1;
                    MainWindow.ShowSecurityLevelChange(Security);
                    Close();
                }
                else if (m_Hashcode == Security.HashCodeLevel2)
                {
                    Security.SecurityLevelCurrent = SecurityLevel.Level2;
                    MainWindow.ShowSecurityLevelChange(Security);
                    Close();
                }
                else if (m_Hashcode == Security.HashCodeLevel3)
                {
                    Security.SecurityLevelCurrent = SecurityLevel.Level3;
                    MainWindow.ShowSecurityLevelChange(Security);
                    Close();
                }
                else
                {
                    m_TextBoxPassword.Text = "";
                    MessageBox.Show(Resources.MBTSecurityPasswordIncorrect, Resources.MBCaptionInformation, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
开发者ID:SiGenixDave,项目名称:PtuPCNew,代码行数:47,代码来源:FormLogin.cs


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