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


C# KeyPressEventArgs.GetKeyChar方法代码示例

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


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

示例1: 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

示例2: HandleKeyPress

 public void HandleKeyPress(KeyPressEventArgs e)
 {
     if (e.GetKeyChar() == 70 || e.GetKeyChar() == 102) // 'F', 'f'
     {
         filter += 1;
         if (filter == 3)
         {
             filter = 0;
         }
     }
     if (e.GetKeyChar() == 96) // '`'
     {
         screen.OnBackPressed();
     }
     screen.OnKeyPress(e);
 }
开发者ID:YoungGames,项目名称:manicdigger,代码行数:16,代码来源:MainMenu.ci.cs

示例3: 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)
                 {
                     if (menu.p.IsValidTypingChar(e.GetKeyChar()))
                     {
                         w.text = StringTools.StringAppend(menu.p, w.text, menu.CharToString(e.GetKeyChar()));
                     }
                 }
             }
         }
     }
 }
开发者ID:YoungGames,项目名称:manicdigger,代码行数:20,代码来源:MainMenu.ci.cs

示例4: OnKeyPress

 public override void OnKeyPress(Game game_, KeyPressEventArgs args)
 {
     if (game.guistate != GuiState.Inventory)
     {
         return;
     }
     int keyChar = args.GetKeyChar();
     if (keyChar == 49) { game.ActiveMaterial = 0; }
     if (keyChar == 50) { game.ActiveMaterial = 1; }
     if (keyChar == 51) { game.ActiveMaterial = 2; }
     if (keyChar == 52) { game.ActiveMaterial = 3; }
     if (keyChar == 53) { game.ActiveMaterial = 4; }
     if (keyChar == 54) { game.ActiveMaterial = 5; }
     if (keyChar == 55) { game.ActiveMaterial = 6; }
     if (keyChar == 56) { game.ActiveMaterial = 7; }
     if (keyChar == 57) { game.ActiveMaterial = 8; }
     if (keyChar == 48) { game.ActiveMaterial = 9; }
 }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:18,代码来源:GuiInventory.ci.cs

示例5: OnKeyPress

 public override void OnKeyPress(Game game_, KeyPressEventArgs args)
 {
     if (game.guistate != GuiState.Normal)
     {
         //Don't open chat when not in normal game
         return;
     }
     int eKeyChar = args.GetKeyChar();
     int chart = 116;
     int charT = 84;
     int chary = 121;
     int charY = 89;
     if ((eKeyChar == chart || eKeyChar == charT) && game.GuiTyping == TypingState.None)
     {
         game.GuiTyping = TypingState.Typing;
         game.GuiTypingBuffer = "";
         game.IsTeamchat = false;
         return;
     }
     if ((eKeyChar == chary || eKeyChar == charY) && game.GuiTyping == TypingState.None)
     {
         game.GuiTyping = TypingState.Typing;
         game.GuiTypingBuffer = "";
         game.IsTeamchat = true;
         return;
     }
     if (game.GuiTyping == TypingState.Typing)
     {
         int c = eKeyChar;
         if (game.platform.IsValidTypingChar(c))
         {
             game.GuiTypingBuffer = StringTools.StringAppend(game.platform, game.GuiTypingBuffer, game.CharToString(c));
         }
         int charTab = 9;
         //Handles player name autocomplete in chat
         if (c == charTab && game.platform.StringTrim(game.GuiTypingBuffer) != "")
         {
             for (int i = 0; i < game.entitiesCount; i++)
             {
                 Entity entity = game.entities[i];
                 if (entity == null) { continue; }
                 if (entity.drawName == null) { continue; }
                 if (!entity.drawName.ClientAutoComplete) { continue; }
                 DrawName p = entity.drawName;
                 //Use substring here because player names are internally in format &xNAME (so we need to cut first 2 characters)
                 if (game.platform.StringStartsWithIgnoreCase(StringTools.StringSubstringToEnd(game.platform, p.Name, 2), game.GuiTypingBuffer))
                 {
                     game.GuiTypingBuffer = StringTools.StringAppend(game.platform, StringTools.StringSubstringToEnd(game.platform, p.Name, 2), ": ");
                     break;
                 }
             }
         }
     }
 }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:54,代码来源:GuiChat.ci.cs

示例6: OnKeyPress

 public override void OnKeyPress(Game game, KeyPressEventArgs args)
 {
     if (game.guistate != GuiState.ModalDialog
         && game.guistate != GuiState.Normal)
     {
         return;
     }
     for (int i = 0; i < game.dialogsCount; i++)
     {
         if (game.dialogs[i] == null) { continue; }
         game.dialogs[i].screen.OnKeyPress(game, args);
     }
     for (int k = 0; k < game.dialogsCount; k++)
     {
         if (game.dialogs[k] == null)
         {
             continue;
         }
         VisibleDialog d = game.dialogs[k];
         for (int i = 0; i < d.value.WidgetsCount; i++)
         {
             Packet_Widget w = d.value.Widgets[i];
             if (w == null)
             {
                 continue;
             }
             // Only typeable characters are handled by KeyPress (for special characters use KeyDown)
             string valid = "abcdefghijklmnopqrstuvwxyz1234567890\t ";
             if (game.platform.StringContains(valid, game.CharToString(w.ClickKey)))
             {
                 if (args.GetKeyChar() == w.ClickKey)
                 {
                     game.SendPacketClient(ClientPackets.DialogClick(w.Id, new string[0], 0));
                     return;
                 }
             }
         }
     }
 }
开发者ID:Matthewism,项目名称:manicdigger,代码行数:39,代码来源:Dialog.ci.cs

示例7: OnKeyPress

 public override void OnKeyPress(Game game_, KeyPressEventArgs args)
 {
     if (game.guistate != GuiState.Normal)
     {
         //Don't open chat when not in normal game
         return;
     }
     int eKeyChar = args.GetKeyChar();
     int chart = 116;
     int charT = 84;
     int chary = 121;
     int charY = 89;
     if ((eKeyChar == chart || eKeyChar == charT) && game.GuiTyping == TypingState.None)
     {
         game.GuiTyping = TypingState.Typing;
         game.GuiTypingBuffer = "";
         game.IsTeamchat = false;
         return;
     }
     if ((eKeyChar == chary || eKeyChar == charY) && game.GuiTyping == TypingState.None)
     {
         game.GuiTyping = TypingState.Typing;
         game.GuiTypingBuffer = "";
         game.IsTeamchat = true;
         return;
     }
     if (game.GuiTyping == TypingState.Typing)
     {
         int c = eKeyChar;
         if (game.platform.IsValidTypingChar(c))
         {
             game.GuiTypingBuffer = StringTools.StringAppend(game.platform, game.GuiTypingBuffer, game.CharToString(c));
         }
     }
 }
开发者ID:Matthewism,项目名称:manicdigger,代码行数:35,代码来源:GuiChat.ci.cs

示例8: OnKeyPress

 public override void OnKeyPress(Game game_, KeyPressEventArgs args)
 {
     if (game.guistate != GuiState.Normal)
     {
         //Don't open chat when not in normal game
         return;
     }
     int eKeyChar = args.GetKeyChar();
     int chart = 116;
     int charT = 84;
     int chary = 121;
     int charY = 89;
     if ((eKeyChar == chart || eKeyChar == charT) && game.GuiTyping == TypingState.None)
     {
         game.GuiTyping = TypingState.Typing;
         game.GuiTypingBuffer = "";
         game.IsTeamchat = false;
         return;
     }
     if ((eKeyChar == chary || eKeyChar == charY) && game.GuiTyping == TypingState.None)
     {
         game.GuiTyping = TypingState.Typing;
         game.GuiTypingBuffer = "";
         game.IsTeamchat = true;
         return;
     }
     if (game.GuiTyping == TypingState.Typing)
     {
         int c = eKeyChar;
         if (game.platform.IsValidTypingChar(c))
         {
             game.GuiTypingBuffer = StringTools.StringAppend(game.platform, game.GuiTypingBuffer, game.CharToString(c));
         }
         int charTab = 9;
         //Handles player name autocomplete in chat
         if (c == charTab && game.platform.StringTrim(game.GuiTypingBuffer) != "")
         {
             IntRef partsLength = new IntRef();
             string[] parts = game.platform.StringSplit(game.GuiTypingBuffer, " ", partsLength);
             string completed = DoAutocomplete(parts[partsLength.value - 1]);
             if (completed == "")
             {
                 //No completion available. Abort.
                 return;
             }
             else if (partsLength.value == 1)
             {
                 //Part is first word. Format as "<name>: "
                 game.GuiTypingBuffer = StringTools.StringAppend(game.platform, completed, ": ");
             }
             else
             {
                 //Part is not first. Just complete "<name> "
                 parts[partsLength.value - 1] = completed;
                 game.GuiTypingBuffer = StringTools.StringAppend(game.platform, game.platform.StringJoin(parts, " "), " ");
             }
         }
     }
 }
开发者ID:samuto,项目名称:manicdigger,代码行数:59,代码来源:GuiChat.ci.cs

示例9: OnKeyPress

 public override void OnKeyPress(Game game_, KeyPressEventArgs e)
 {
     if (!visible)
     {
         return;
     }
     if (e.GetKeyChar() == 8) // backspace
     {
         return;
     }
     for (int i = maxColumns - 1; i > cursorColumn; i--)
     {
         buffer[cursorLine][i] = buffer[cursorLine][i - 1];
     }
     buffer[cursorLine][cursorColumn] = e.GetKeyChar();
     cursorColumn++;
     e.SetHandled(true);
 }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:18,代码来源:GuiTextEditor.ci.cs

示例10: KeyPress

 void KeyPress(KeyPressEventArgs e)
 {
     for (int i = 0; i < WidgetCount; i++)
     {
         MenuWidget w = widgets[i];
         if (w != null)
         {
             if (w.hasKeyboardFocus)
             {
                 if (e.GetKeyChar() == 9 || e.GetKeyChar() == 13) // tab, enter
                 {
                     if (w.type == WidgetType.Button && e.GetKeyChar() == 13)
                     {
                         //Call OnButton when enter is pressed and widget is a button
                         OnButton(w);
                         return;
                     }
                     else if (w.nextWidget != -1)
                     {
                         //Just switch focus otherwise
                         w.LoseFocus();
                         widgets[w.nextWidget].GetFocus();
                         return;
                     }
                 }
             }
             if (w.type == WidgetType.Textbox)
             {
                 if (w.editing)
                 {
                     string s = menu.CharToString(e.GetKeyChar());
                     if (e.GetKeyChar() == 8) // backspace
                     {
                         if (menu.StringLength(w.text) > 0)
                         {
                             w.text = StringTools.StringSubstring(menu.p, w.text, 0, menu.StringLength(w.text) - 1);
                         }
                         return;
                     }
                     if (e.GetKeyChar() == 22) //paste
                     {
                         if (menu.p.ClipboardContainsText())
                         {
                             w.text = StringTools.StringAppend(menu.p, w.text, menu.p.ClipboardGetText());
                         }
                         return;
                     }
                     if (menu.p.IsValidTypingChar(e.GetKeyChar()))
                     {
                         w.text = StringTools.StringAppend(menu.p, w.text, s);
                     }
                 }
             }
         }
     }
 }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:56,代码来源:MainMenu.ci.cs

示例11: OnKeyPress

 public override void OnKeyPress(KeyPressEventArgs e)
 {
     game.KeyPress(e.GetKeyChar());
 }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:4,代码来源:GameScreen.ci.cs


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