本文整理汇总了C#中SdlDotNet.Input.KeyboardEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# KeyboardEventArgs类的具体用法?C# KeyboardEventArgs怎么用?C# KeyboardEventArgs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyboardEventArgs类属于SdlDotNet.Input命名空间,在下文中一共展示了KeyboardEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: KeyboardDown
//Handles keyboard events.
// The 'Escape' and 'Q'keys will cause the app to exit
private void KeyboardDown(object sender, KeyboardEventArgs e)
{
if (e.Key == Key.Escape || e.Key == Key.Q)
{
Events.QuitApplication();
}
}
示例2: HandleSdlKeyDownEvent
/// <summary>
///
/// </summary>
/// <param name="args"></param>
public override void HandleSdlKeyDownEvent(KeyboardEventArgs args)
{
if (args == null)
{
throw new ArgumentNullException("args");
}
switch (args.Key)
{
case Key.Keypad2:
bs.Y += 10;
break;
case Key.Keypad8:
bs.Y -= 10;
break;
case Key.Keypad4:
bs.X -= 10;
break;
case Key.Keypad6:
bs.X += 10;
break;
default:
break;
}
}
示例3: KeyboardDown
public void KeyboardDown (KeyboardEventArgs args)
{
bool selection_changed = false;
/* navigation keys */
if (args.Key == Key.UpArrow) {
if (cursor > 0) {
cursor--;
selection_changed = true;
if (cursor < first_visible)
first_visible = cursor;
}
}
else if (args.Key == Key.DownArrow) {
if (cursor < items.Count - 1) {
cursor++;
selection_changed = true;
if (cursor >= first_visible + num_visible)
first_visible = cursor - num_visible + 1;
}
}
if (selection_changed) {
Invalidate ();
if (SelectionChanged != null)
SelectionChanged (cursor);
}
}
示例4: OnKeyboardDown
public override void OnKeyboardDown(CGameEngine game, KeyboardEventArgs e)
{
switch (e.Key) {
case Key.Escape:
case Key.Q:
Events.QuitApplication();
break;
case Key.UpArrow:
m_CurrentMap.Avatar.moveup = true;
break;
case Key.DownArrow:
m_CurrentMap.Avatar.movedown = true;
break;
case Key.LeftArrow:
m_CurrentMap.Avatar.moveleft = true;
break;
case Key.RightArrow:
m_CurrentMap.Avatar.moveright = true;
break;
case Key.F5:
Video.Screen.SaveBmp("screenshot.bmp");
break;
case Key.Backspace:
for (int i = 0; i < 10; i++)
m_CurrentMap.Actors.AddLast(new CActorCivilian(m_CurrentMap, 26, 13));
m_CurrentMap.Actors.AddLast(new CActorMonster(m_CurrentMap, 15, 15));
break;
case Key.Space:
int top = m_CurrentMap.Avatar.Top;
int left = m_CurrentMap.Avatar.Left;
m_CurrentMap.Weapons.AddLast(new CActorBullet(m_CurrentMap, left, top, m_CurrentMap.Avatar.Direction));
break;
}
}
示例5: Events_KeyboardDown
private void Events_KeyboardDown(object sender, KeyboardEventArgs e)
{
switch (e.Key)
{
case Key.Escape:
case Key.Q:
Events.QuitApplication();
break;
}
}
示例6: OnKeyboardDown
public override void OnKeyboardDown(CGameEngine game, KeyboardEventArgs e)
{
switch (e.Key) {
case Key.Escape:
case Key.Q:
Events.QuitApplication();
break;
case Key.Space:
game.ChangeState(CPlayState.Instance());
break;
}
}
示例7: OnKeyboardUp
public override void OnKeyboardUp(CGameEngine game, KeyboardEventArgs e)
{
switch (e.Key) {
case Key.UpArrow:
m_CurrentMap.Avatar.moveup = false;
break;
case Key.DownArrow:
m_CurrentMap.Avatar.movedown = false;
break;
case Key.LeftArrow:
m_CurrentMap.Avatar.moveleft = false;
break;
case Key.RightArrow:
m_CurrentMap.Avatar.moveright = false;
break;
}
}
示例8: setDirection
public void setDirection(KeyboardEventArgs key)
{
switch (key.Key) {
case Key.UpArrow:
m_direction = ActorDirection.Up;
break;
case Key.DownArrow:
m_direction = ActorDirection.Down;
break;
case Key.LeftArrow:
m_direction = ActorDirection.Left;
break;
case Key.RightArrow:
m_direction = ActorDirection.Right;
break;
}
}
示例9: KeyboardDown
public void KeyboardDown (KeyboardEventArgs args)
{
bool changed = false;
/* navigation keys */
if (args.Key == Key.LeftArrow) {
if (cursor > 0) cursor--;
}
else if (args.Key == Key.RightArrow) {
if (cursor < value.Length) cursor++;
}
else if (args.Key == Key.Home) {
cursor = 0;
}
else if (args.Key == Key.End) {
cursor = value.Length;
}
/* keys that modify the text */
else if (args.Key == Key.Backspace) {
if (value.Length > 0) {
value = value.Remove (cursor-1, 1);
cursor--;
changed = true;
}
}
else {
char[] cs = Encoding.ASCII.GetChars (new byte[] {(byte)args.Key});
foreach (char c in cs) {
if (!Char.IsLetterOrDigit (c) && c != ' ')
continue;
char cc;
if ((args.Mod & (ModifierKeys.RightShift | ModifierKeys.LeftShift)) != 0)
cc = Char.ToUpper (c);
else
cc = c;
value.Insert (cursor++, cc);
changed = true;
}
changed = true;
}
if (changed)
Text = Value;
}
示例10: keyPress
private void keyPress(object sender, KeyboardEventArgs k)
{
if (GameOver == true)
{
if (Win)
{
Win = false;
}
player = new MainBall();
for (int i = enemy.Count - 1; i >= 0; i--)
{
enemy.Remove(enemy[i]);
}
GameOver = false;
}
if (k.Key == Key.P)
{
if (Pause)
{
Pause = false;
}
else
{
Pause = true;
}
}
if (k.Key == Key.RightArrow)
{
rightArrow = true;
}
if (k.Key == Key.LeftArrow)
{
leftArrow = true;
}
if (k.Key == Key.UpArrow)
{
upArrow = true;
}
if (k.Key == Key.DownArrow)
{
downArrow = true;
}
}
示例11: KeyboardDown
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void KeyboardDown(object sender, KeyboardEventArgs e)
{
if (e.Key == Key.Escape || e.Key == Key.Q)
{
Events.QuitApplication();
}
else if (e.Key == Key.UpArrow)
{
eventManager.Publish(new EntityMoveRequestEventArgs(Direction.Up));
}
else if (e.Key == Key.DownArrow)
{
eventManager.Publish(new EntityMoveRequestEventArgs(Direction.Down));
}
else if (e.Key == Key.LeftArrow)
{
eventManager.Publish(new EntityMoveRequestEventArgs(Direction.Left));
}
else if (e.Key == Key.RightArrow)
{
eventManager.Publish(new EntityMoveRequestEventArgs(Direction.Right));
}
}
示例12: HandleTextKey
private string HandleTextKey(KeyboardEventArgs e)
{
if (e.Key == Key.Space)
{
return " ";
}
bool capsMod = e.Mod.HasFlag(ModifierKeys.Caps);
bool shiftMod = (e.Mod.HasFlag(ModifierKeys.LeftShift) || e.Mod.HasFlag(ModifierKeys.RightShift));
bool textShift = ((capsMod && !shiftMod) || (!capsMod && shiftMod));
string c = e.KeyboardCharacter;
// text shift applies only to alpha characters
if ((int)e.Key >= 97 && (int)e.Key <= 122)
{
return (textShift ? c.ToUpper() : c);
}
if (shiftMod)
{
// other characters are influenced by shift and ignore caps
if ((int)e.Key == 44 || (int)e.Key == 46 || (int)e.Key == 47)
{
return ((char)(e.Key + 16)).ToString();
}
else if ((int)e.Key >= 91 && (int)e.Key <= 93)
{
return ((char)(e.Key + 32)).ToString();
}
else
{
switch (e.Key)
{
case Key.One:
return "!";
case Key.Two:
return "@";
case Key.Three:
return "#";
case Key.Four:
return "$";
case Key.Five:
return "%";
case Key.Six:
return "^";
case Key.Seven:
return "&";
case Key.Eight:
return "*";
case Key.Nine:
return "(";
case Key.Zero:
return ")";
case Key.Minus:
return "_";
case Key.Equals:
return "+";
case Key.Semicolon:
return ":";
case Key.Quote:
return "\"";
case Key.BackQuote:
return "~";
}
}
}
return c;
}
示例13: Events_KeyboardUp
private void Events_KeyboardUp(object sender, KeyboardEventArgs e)
{
switch (e.Key)
{
case Key.UpArrow:
avatar.Velocity.Z = 0.0f;
m_objectsToDraw.MoveAvatarInTaskDesigner(avatar.Z);
break;
case Key.DownArrow:
avatar.Velocity.Z = 0.0f;
m_objectsToDraw.MoveAvatarInTaskDesigner(avatar.Z);
break;
case Key.LeftArrow:
avatar.Velocity.X = 0.0f;
break;
case Key.RightArrow:
avatar.Velocity.X = 0.0f;
break;
}
}
示例14: KeyUp
private void KeyUp(object sender, KeyboardEventArgs e)
{
if (_ChatBoxActive)
{
return;
}
switch (e.Key)
{
case Key.W:
case Key.S:
_Player.MoveZ = 0;
break;
case Key.A:
case Key.D:
_Player.MoveX = 0;
break;
case Key.Q:
break;
case Key.R:
break;
case Key.Space:
case Key.LeftControl:
_Player.MoveY = 0;
break;
}
}
示例15: KeyDown
private void KeyDown(object sender, KeyboardEventArgs e)
{
switch (e.Key)
{
case Key.Escape:
//Fire event to stop the application loop
Events.QuitApplication();
Events_Quit(this,new QuitEventArgs());
break;
case Key.F1:
ToggleFullscreen();
break;
case Key.F2:
//Toggle backface culling
if (m_backfaceCulling == false)
{
Gl.glEnable(Gl.GL_CULL_FACE);
Gl.glCullFace(Gl.GL_BACK);
m_backfaceCulling = true;
}
else if (m_backfaceCulling == true)
{
Gl.glDisable(Gl.GL_CULL_FACE);
m_backfaceCulling = false;
}
break;
case Key.F3:
{
if (m_walkBounce)
{
m_walkBounce = false;
}
else
{
m_walkBounce = true;
}
break;
}
case Key.F4:
{
if (m_drawCollisionModels)
{
m_drawCollisionModels = false;
}
else
{
m_drawCollisionModels = true;
}
break;
}
case Key.F5:
{
if (m_lightingEnabled)
{
m_lightingEnabled = false;
Gl.glDisable(Gl.GL_LIGHTING);
}
else
{
m_lightingEnabled = true;
Gl.glEnable(Gl.GL_LIGHTING);
}
break;
}
case Key.F6:
{
if (m_drawAvatar3D)
m_drawAvatar3D = false;
else m_drawAvatar3D = true;
break;
}
case Key.F7:
{
if (m_drawAvatar3D)
{
if (avatar3D.DrawJoints)
avatar3D.DrawJoints = false;
else avatar3D.DrawJoints = true;
}
break;
}
case Key.F11:
{
CaptureAndSendToTaskDesignerScreenShot();
break;
}
case Key.F12:
{
if (m_frmTaskDesigner_0 != null)
{
m_frmTaskDesigner_0.Show();
}
break;
}
case Key.Backspace:
{
InitialiseScene();
break;
}
//.........这里部分代码省略.........