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


C# KeyEventArgs.SetHandled方法代码示例

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


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

示例1: OnKeyDown

 public override void OnKeyDown(Game game, KeyEventArgs args)
 {
     if (args.GetKeyCode() == game.GetKey(GlKeys.F12))
     {
         takeScreenshot = true;
         args.SetHandled(true);
     }
 }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:8,代码来源:Screenshot.ci.cs

示例2: 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);
//.........这里部分代码省略.........
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:101,代码来源:GuiChat.ci.cs

示例3: 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;
     }
 }
开发者ID:Matthewism,项目名称:manicdigger,代码行数:55,代码来源:Dialog.ci.cs

示例4: 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);
//.........这里部分代码省略.........
开发者ID:Matthewism,项目名称:manicdigger,代码行数:101,代码来源:GuiChat.ci.cs

示例5: 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);
             }
         }
     }
 }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:23,代码来源:GuiCrafting.ci.cs

示例6: 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);
     }
 }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:49,代码来源:GuiEscapeMenu.ci.cs

示例7: 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);
 }
开发者ID:MagistrAVSH,项目名称:manicdigger,代码行数:49,代码来源:GuiTextEditor.ci.cs


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