本文整理汇总了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);
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例5: PressKey
public override void PressKey(KeyPressEventArgs e)
{
base.PressKey(e);
if (e.KeyInfo.Key == ConsoleKey.Spacebar || e.KeyInfo.Key == ConsoleKey.Enter)
{
Press(e);
}
}
示例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);
}
}
示例7: KeyPressed
private void KeyPressed(KeyPressEventArgs obj)
{
if (obj.Key == Game.InputKeys.PlayerBlock)
{
if (IsCastable)
{
}
}
}
示例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);
}
示例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);
}
}
示例10: Press
public virtual void Press(KeyPressEventArgs e)
{
EventHandler handler = Pressed;
if (handler != null)
{
handler(this, new KeyPressEventArgs
{
KeyInfo = e.KeyInfo
});
}
OnPressed(e);
}
示例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();
}
示例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);
}
}
}
}
}
}
示例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();
}
}
示例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;
}
}
}
}
示例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);
}
}
}