• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# KeyPressEventArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: FormAccount_KeyPress

 /// <summary>
 /// Event handler for the KeyPress event. Check if the user has depressed the escape key and if so close the form.
 /// </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 FormAccount_KeyPress(object sender, KeyPressEventArgs e)
 {
     byte keyChar = (byte)e.KeyChar;
     if (keyChar == CommonConstants.AsciiEscape)
     {
         Close();
     }
 }
开发者ID:SiGenixDave,项目名称:PtuPCNew,代码行数:13,代码来源:FormLogin.cs


示例17: OnKeyPress

 protected virtual void OnKeyPress(KeyPressEventArgs args)
 {
     if (this.KeyPress != null)
     {
         this.KeyPress(this, args);
     }
 }
开发者ID:powerumc,项目名称:vsgesture,代码行数:7,代码来源:VsNativeWindow.cs


示例18: KeyboardProc

        /// <summary>
        /// Recieves the actual unsafe keyboard hook procedure
        /// </summary>
        /// <param name="code"></param>
        /// <param name="wParam"></param>
        /// <param name="lParam"></param>
        /// <returns></returns>
        private int KeyboardProc(int code, IntPtr wParam, IntPtr lParam)
        {
            WinApi.KeyboardLLHookStruct hookStruct = (WinApi.KeyboardLLHookStruct)Marshal.PtrToStructure(lParam, typeof(WinApi.KeyboardLLHookStruct));

            int msg = wParam.ToInt32();
            bool handled = false;

            if (msg == WinApi.WM_KEYDOWN || msg == WinApi.WM_SYSKEYDOWN)
            {
                KeyEventArgs e = new KeyEventArgs((Keys)hookStruct.vkCode);
                OnKeyDown(e);
                handled = e.Handled;
            }
            else if (msg == WinApi.WM_KEYUP || msg == WinApi.WM_SYSKEYUP)
            {
                KeyEventArgs e = new KeyEventArgs((Keys)hookStruct.vkCode);
                OnKeyUp(e);
                handled = e.Handled;
            }

            if (msg == WinApi.WM_KEYDOWN && KeyPress != null)
            {
                byte[] keyState = new byte[256];
                byte[] buffer = new byte[2];
                WinApi.GetKeyboardState(keyState);
                int conversion = WinApi.ToAscii(hookStruct.vkCode, hookStruct.scanCode, keyState, buffer, hookStruct.flags);

                if (conversion == 1 || conversion == 2)
                {
                    bool shift = (WinApi.GetKeyState(WinApi.VK_SHIFT) & 0x80) == 0x80;
                    bool capital = WinApi.GetKeyState(WinApi.VK_CAPITAL) != 0;
                    char c = (char)buffer[0];
                    if ((shift ^ capital) && Char.IsLetter(c))
                    {
                        c = Char.ToUpper(c);
                    }
                    KeyPressEventArgs e = new KeyPressEventArgs(c);
                    OnKeyPress(e);
                    handled |= e.Handled;
                }
            }

            return handled ? 1 : WinApi.CallNextHookEx(Handle, code, wParam, lParam);
        }
开发者ID:daywrite,项目名称:EApp,代码行数:51,代码来源:GlobalHook.cs


示例19: OnKeyPress

 /// <summary>
 /// Raises the <see cref="KeyPress"/> event
 /// </summary>
 /// <param name="e">Event Data</param>
 protected virtual void OnKeyPress(KeyPressEventArgs e)
 {
     if (KeyPress != null)
     {
         KeyPress(this, e);
     }
 }
开发者ID:daywrite,项目名称:EApp,代码行数:11,代码来源:GlobalHook.cs


示例20: txtSendData_KeyPress

 private void txtSendData_KeyPress(object sender, KeyPressEventArgs e)
 { 
     e.Handled = KeyHandled; 
 }
开发者ID:devehe,项目名称:crazepony-host-client,代码行数:4,代码来源:Form1.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# KeyRange类代码示例发布时间:2022-05-24
下一篇:
C# KeyModifiers类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap