本文整理汇总了C#中KeyEventArgs.GetKeyCode方法的典型用法代码示例。如果您正苦于以下问题:C# KeyEventArgs.GetKeyCode方法的具体用法?C# KeyEventArgs.GetKeyCode怎么用?C# KeyEventArgs.GetKeyCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyEventArgs
的用法示例。
在下文中一共展示了KeyEventArgs.GetKeyCode方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnKeyDown
public override void OnKeyDown(KeyEventArgs e)
{
// debug
if (e.GetKeyCode() == GlKeys.F5)
{
menu.p.SinglePlayerServerDisable();
menu.StartGame(true, menu.p.PathCombine(menu.p.PathSavegames(), "Default.mdss"), null);
}
if (e.GetKeyCode() == GlKeys.F6)
{
menu.StartGame(true, menu.p.PathCombine(menu.p.PathSavegames(), "Default.mddbs"), null);
}
}
示例2: OnKeyDown
public override void OnKeyDown(Game game, KeyEventArgs args)
{
if (args.GetKeyCode() == game.GetKey(GlKeys.F12))
{
takeScreenshot = true;
args.SetHandled(true);
}
}
示例3: OnKeyDown
public override void OnKeyDown(Game game_, KeyEventArgs e)
{
if (e.GetKeyCode() == game.GetKey(GlKeys.F9))
{
visible = !visible;
}
if (!visible)
{
return;
}
if (e.GetKeyCode() == GlKeys.Escape)
{
visible = false;
}
if (e.GetKeyCode() == GlKeys.Left)
{
cursorColumn--;
}
if (e.GetKeyCode() == GlKeys.Right)
{
cursorColumn++;
}
if (e.GetKeyCode() == GlKeys.Up)
{
cursorLine--;
}
if (e.GetKeyCode() == GlKeys.Down)
{
cursorLine++;
}
if (e.GetKeyCode() == GlKeys.BackSpace)
{
cursorColumn--;
e.SetKeyCode(GlKeys.Delete);
}
if (cursorColumn < 0) { cursorColumn = 0; }
if (cursorLine < 0) { cursorLine = 0; }
if (cursorColumn >= maxColumns) { cursorColumn = maxColumns; }
if (cursorLine > maxLines) { cursorLine = maxLines; }
if (cursorColumn > LineLength(buffer[cursorLine])) { cursorColumn = LineLength(buffer[cursorLine]); }
if (e.GetKeyCode() == GlKeys.Delete)
{
for (int i = cursorColumn; i < maxColumns - 1; i++)
{
buffer[cursorLine][i] = buffer[cursorLine][i + 1];
}
}
e.SetHandled(true);
}
示例4: OnKeyDown
public override void OnKeyDown(Game game, KeyEventArgs args)
{
if (args.GetKeyCode() == GlKeys.F7)
{
if (!drawfpsgraph)
{
drawfpstext = true;
drawfpsgraph = true;
}
else
{
drawfpstext = false;
drawfpsgraph = false;
}
}
}
示例5: OnKeyDown
public override void OnKeyDown(Game game, KeyEventArgs args)
{
if (!(game.guistate == GuiState.Normal && game.GuiTyping == TypingState.None))
{
//Do nothing when in dialog or chat
return;
}
int eKey = args.GetKeyCode();
if (eKey == game.GetKey(GlKeys.R))
{
Packet_Item item = game.d_Inventory.RightHand[game.ActiveMaterial];
if (item != null && item.ItemClass == Packet_ItemClassEnum.Block
&& game.blocktypes[item.BlockId].IsPistol
&& game.reloadstartMilliseconds == 0)
{
int sound = game.rnd.Next() % game.blocktypes[item.BlockId].Sounds.ReloadCount;
game.AudioPlay(StringTools.StringAppend(game.platform, game.blocktypes[item.BlockId].Sounds.Reload[sound], ".ogg"));
game.reloadstartMilliseconds = game.platform.TimeMillisecondsFromStart();
game.reloadblock = item.BlockId;
game.SendPacketClient(ClientPackets.Reload());
}
}
}
示例6: HandleKeyUp
public void HandleKeyUp(KeyEventArgs e)
{
currentlyPressedKeys[e.GetKeyCode()] = false;
screen.OnKeyUp(e);
}
示例7: HandleKeyDown
public void HandleKeyDown(KeyEventArgs e)
{
currentlyPressedKeys[e.GetKeyCode()] = true;
screen.OnKeyDown(e);
}
示例8: KeyDown
void KeyDown(KeyEventArgs e)
{
for (int i = 0; i < WidgetCount; i++)
{
MenuWidget w = widgets[i];
if (w == null)
{
continue;
}
if (w.hasKeyboardFocus)
{
if (e.GetKeyCode() == GlKeys.Tab || e.GetKeyCode() == GlKeys.Enter)
{
if (w.type == WidgetType.Button && e.GetKeyCode() == GlKeys.Enter)
{
//Call OnButton when enter is pressed and widget is a button
OnButton(w);
return;
}
if (w.nextWidget != -1)
{
//Just switch focus otherwise
w.LoseFocus();
widgets[w.nextWidget].GetFocus();
return;
}
}
}
if (w.type == WidgetType.Textbox)
{
if (w.editing)
{
int key = e.GetKeyCode();
// pasting text from clipboard
if (e.GetCtrlPressed() && key == GlKeys.V)
{
if (menu.p.ClipboardContainsText())
{
w.text = StringTools.StringAppend(menu.p, w.text, menu.p.ClipboardGetText());
}
return;
}
// deleting characters using backspace
if (key == GlKeys.BackSpace)
{
if (menu.StringLength(w.text) > 0)
{
w.text = StringTools.StringSubstring(menu.p, w.text, 0, menu.StringLength(w.text) - 1);
}
return;
}
}
}
}
}
示例9: OnKeyDown
public override void OnKeyDown(Game game_, KeyEventArgs args)
{
if (game.guistate != GuiState.Normal)
{
//Don't open chat when not in normal game
return;
}
int eKey = args.GetKeyCode();
if (eKey == game.GetKey(GlKeys.Number7) && game.IsShiftPressed && game.GuiTyping == TypingState.None) // don't need to hit enter for typing commands starting with slash
{
game.GuiTyping = TypingState.Typing;
game.IsTyping = true;
game.GuiTypingBuffer = "";
game.IsTeamchat = false;
args.SetHandled(true);
return;
}
if (eKey == game.GetKey(GlKeys.PageUp) && game.GuiTyping == TypingState.Typing)
{
ChatPageScroll++;
args.SetHandled(true);
}
if (eKey == game.GetKey(GlKeys.PageDown) && game.GuiTyping == TypingState.Typing)
{
ChatPageScroll--;
args.SetHandled(true);
}
ChatPageScroll = MathCi.ClampInt(ChatPageScroll, 0, game.ChatLinesCount / ChatLinesMaxToDraw);
if (eKey == game.GetKey(GlKeys.Enter) || eKey == game.GetKey(GlKeys.KeypadEnter))
{
if (game.GuiTyping == TypingState.Typing)
{
game.typinglog[game.typinglogCount++] = game.GuiTypingBuffer;
game.typinglogpos = game.typinglogCount;
game.ClientCommand(game.GuiTypingBuffer);
game.GuiTypingBuffer = "";
game.IsTyping = false;
game.GuiTyping = TypingState.None;
game.platform.ShowKeyboard(false);
}
else if (game.GuiTyping == TypingState.None)
{
game.StartTyping();
}
else if (game.GuiTyping == TypingState.Ready)
{
game.platform.ConsoleWriteLine("Keyboard_KeyDown ready");
}
args.SetHandled(true);
return;
}
if (game.GuiTyping == TypingState.Typing)
{
int key = eKey;
if (key == game.GetKey(GlKeys.BackSpace))
{
if (StringTools.StringLength(game.platform, game.GuiTypingBuffer) > 0)
{
game.GuiTypingBuffer = StringTools.StringSubstring(game.platform, game.GuiTypingBuffer, 0, StringTools.StringLength(game.platform, game.GuiTypingBuffer) - 1);
}
args.SetHandled(true);
return;
}
if (game.keyboardStateRaw[game.GetKey(GlKeys.ControlLeft)] || game.keyboardStateRaw[game.GetKey(GlKeys.ControlRight)])
{
if (key == game.GetKey(GlKeys.V))
{
if (game.platform.ClipboardContainsText())
{
game.GuiTypingBuffer = StringTools.StringAppend(game.platform, game.GuiTypingBuffer, game.platform.ClipboardGetText());
}
args.SetHandled(true);
return;
}
}
if (key == game.GetKey(GlKeys.Up))
{
game.typinglogpos--;
if (game.typinglogpos < 0) { game.typinglogpos = 0; }
if (game.typinglogpos >= 0 && game.typinglogpos < game.typinglogCount)
{
game.GuiTypingBuffer = game.typinglog[game.typinglogpos];
}
args.SetHandled(true);
}
if (key == game.GetKey(GlKeys.Down))
{
game.typinglogpos++;
if (game.typinglogpos > game.typinglogCount) { game.typinglogpos = game.typinglogCount; }
if (game.typinglogpos >= 0 && game.typinglogpos < game.typinglogCount)
{
game.GuiTypingBuffer = game.typinglog[game.typinglogpos];
}
if (game.typinglogpos == game.typinglogCount)
{
game.GuiTypingBuffer = "";
}
args.SetHandled(true);
//.........这里部分代码省略.........
示例10: OnKeyDown
public override void OnKeyDown(Game game, KeyEventArgs args)
{
for (int i = 0; i < game.dialogsCount; i++)
{
if (game.dialogs[i] == null) { continue; }
game.dialogs[i].screen.OnKeyDown(game, args);
}
if (game.guistate == GuiState.Normal)
{
if (args.GetKeyCode() == game.GetKey(GlKeys.Escape))
{
for (int i = 0; i < game.dialogsCount; i++)
{
if (game.dialogs[i] == null)
{
continue;
}
VisibleDialog d = game.dialogs[i];
if (d.value.IsModal != 0)
{
game.dialogs[i] = null;
return;
}
}
game.ShowEscapeMenu();
args.SetHandled(true);
return;
}
}
if (game.guistate == GuiState.ModalDialog)
{
// Close modal dialogs when pressing ESC key
if (args.GetKeyCode() == game.GetKey(GlKeys.Escape))
{
for (int i = 0; i < game.dialogsCount; i++)
{
if (game.dialogs[i] == null) { continue; }
if (game.dialogs[i].value.IsModal != 0)
{
game.dialogs[i] = null;
}
}
game.SendPacketClient(ClientPackets.DialogClick("Esc", new string[0], 0));
game.GuiStateBackToGame();
args.SetHandled(true);
}
// Handle TAB key
if (args.GetKeyCode() == game.GetKey(GlKeys.Tab))
{
game.SendPacketClient(ClientPackets.DialogClick("Tab", new string[0], 0));
args.SetHandled(true);
}
return;
}
}
示例11: OnKeyDown
public override void OnKeyDown(Game game_, KeyEventArgs args)
{
if (game.guistate != GuiState.Normal)
{
//Don't open chat when not in normal game
return;
}
int eKey = args.GetKeyCode();
if (eKey == game.GetKey(GlKeys.Number7) && game.IsShiftPressed && game.GuiTyping == TypingState.None) // don't need to hit enter for typing commands starting with slash
{
game.GuiTyping = TypingState.Typing;
game.IsTyping = true;
game.GuiTypingBuffer = "";
game.IsTeamchat = false;
args.SetHandled(true);
return;
}
if (eKey == game.GetKey(GlKeys.PageUp) && game.GuiTyping == TypingState.Typing)
{
ChatPageScroll++;
args.SetHandled(true);
}
if (eKey == game.GetKey(GlKeys.PageDown) && game.GuiTyping == TypingState.Typing)
{
ChatPageScroll--;
args.SetHandled(true);
}
ChatPageScroll = MathCi.ClampInt(ChatPageScroll, 0, game.ChatLinesCount / ChatLinesMaxToDraw);
if (eKey == game.GetKey(GlKeys.Enter) || eKey == game.GetKey(GlKeys.KeypadEnter))
{
if (game.GuiTyping == TypingState.Typing)
{
game.typinglog[game.typinglogCount++] = game.GuiTypingBuffer;
game.typinglogpos = game.typinglogCount;
game.ClientCommand(game.GuiTypingBuffer);
game.GuiTypingBuffer = "";
game.IsTyping = false;
game.GuiTyping = TypingState.None;
game.platform.ShowKeyboard(false);
}
else if (game.GuiTyping == TypingState.None)
{
game.StartTyping();
}
else if (game.GuiTyping == TypingState.Ready)
{
game.platform.ConsoleWriteLine("Keyboard_KeyDown ready");
}
args.SetHandled(true);
return;
}
if (game.GuiTyping == TypingState.Typing)
{
int key = eKey;
if (key == game.GetKey(GlKeys.BackSpace))
{
if (StringTools.StringLength(game.platform, game.GuiTypingBuffer) > 0)
{
game.GuiTypingBuffer = StringTools.StringSubstring(game.platform, game.GuiTypingBuffer, 0, StringTools.StringLength(game.platform, game.GuiTypingBuffer) - 1);
}
args.SetHandled(true);
return;
}
if (game.keyboardStateRaw[game.GetKey(GlKeys.ControlLeft)] || game.keyboardStateRaw[game.GetKey(GlKeys.ControlRight)])
{
if (key == game.GetKey(GlKeys.V))
{
if (game.platform.ClipboardContainsText())
{
game.GuiTypingBuffer = StringTools.StringAppend(game.platform, game.GuiTypingBuffer, game.platform.ClipboardGetText());
}
args.SetHandled(true);
return;
}
}
if (key == game.GetKey(GlKeys.Up))
{
game.typinglogpos--;
if (game.typinglogpos < 0) { game.typinglogpos = 0; }
if (game.typinglogpos >= 0 && game.typinglogpos < game.typinglogCount)
{
game.GuiTypingBuffer = game.typinglog[game.typinglogpos];
}
args.SetHandled(true);
}
if (key == game.GetKey(GlKeys.Down))
{
game.typinglogpos++;
if (game.typinglogpos > game.typinglogCount) { game.typinglogpos = game.typinglogCount; }
if (game.typinglogpos >= 0 && game.typinglogpos < game.typinglogCount)
{
game.GuiTypingBuffer = game.typinglog[game.typinglogpos];
}
if (game.typinglogpos == game.typinglogCount)
{
game.GuiTypingBuffer = "";
}
args.SetHandled(true);
//.........这里部分代码省略.........
示例12: OnKeyDown
public override void OnKeyDown(Game game, KeyEventArgs args)
{
int eKey = args.GetKeyCode();
if (eKey == (game.GetKey(GlKeys.E)) && game.GuiTyping == TypingState.None)
{
if (!(game.SelectedBlockPositionX == -1 && game.SelectedBlockPositionY == -1 && game.SelectedBlockPositionZ == -1))
{
int posx = game.SelectedBlockPositionX;
int posy = game.SelectedBlockPositionZ;
int posz = game.SelectedBlockPositionY;
if (game.map.GetBlock(posx, posy, posz) == game.d_Data.BlockIdCraftingTable())
{
//draw crafting recipes list.
IntRef tableCount = new IntRef();
Vector3IntRef[] table = d_CraftingTableTool.GetTable(posx, posy, posz, tableCount);
IntRef onTableCount = new IntRef();
int[] onTable = d_CraftingTableTool.GetOnTable(table, tableCount.value, onTableCount);
CraftingRecipesStart(game, d_CraftingRecipes, d_CraftingRecipesCount, onTable, onTableCount.value, posx, posy, posz);
args.SetHandled(true);
}
}
}
}
示例13: OnKeyDown
public override void OnKeyDown(Game game_, KeyEventArgs args)
{
int eKey = args.GetKeyCode();
if (eKey == game.GetKey(GlKeys.Escape))
{
if (escapemenustate == EscapeMenuState.Graphics
|| escapemenustate == EscapeMenuState.Keys
|| escapemenustate == EscapeMenuState.Other)
{
SetEscapeMenuState(EscapeMenuState.Options);
}
else if (escapemenustate == EscapeMenuState.Options)
{
SaveOptions();
SetEscapeMenuState(EscapeMenuState.Main);
}
else
{
SetEscapeMenuState(EscapeMenuState.Main);
game.GuiStateBackToGame();
}
args.SetHandled(true);
}
if (escapemenustate == EscapeMenuState.Keys)
{
if (keyselectid != -1)
{
game.options.Keys[keyhelps()[keyselectid].DefaultKey] = eKey;
keyselectid = -1;
args.SetHandled(true);
}
}
if (eKey == game.GetKey(GlKeys.F11))
{
if (game.platform.GetWindowState() == WindowState.Fullscreen)
{
game.platform.SetWindowState(WindowState.Normal);
RestoreResolution();
SaveOptions();
}
else
{
game.platform.SetWindowState(WindowState.Fullscreen);
UseResolution();
SaveOptions();
}
args.SetHandled(true);
}
}
示例14: OnKeyUp
public override void OnKeyUp(KeyEventArgs e)
{
game.KeyUp(e.GetKeyCode());
}