Пример #1
0
 public virtual void KeyHandler(KeyEventArgs e, VisualMenuEntry sender)
 {
     if (DebugForm != null && sender != null)
     {
         DebugForm.WriteLine(sender.ToString() + " : " + e.KeyCode.ToString());
     }
 }
 public override void KeyHandler(KeyEventArgs e, VisualMenuEntry sender)
 {
     if (e.KeyCode == Keys.Down)
     {
         if (CurrentMenuItemIndex + 1 < Entries.Count)
         {
             CurrentMenuItemIndex++;
         }
     }
     else if (e.KeyCode == Keys.Up)
     {
         if (CurrentMenuItemIndex - 1 >= 0)
         {
             CurrentMenuItemIndex--;
         }
     }
     else if (e.KeyCode == Keys.Enter)
     {
         loadedProfile = new Profile(((VisualMenuEntryLoadProfileOption)Entries[CurrentMenuItemIndex]).LoadedProfile);
     }
 }
        public override void KeyHandler(KeyEventArgs e, VisualMenuEntry sender)
        {
            //Übergabe an base-methode für Debug-Output
            base.KeyHandler(e, sender);



            if (e.KeyCode >= Keys.A && e.KeyCode <= Keys.Z)
            {
                if (e.Modifiers == Keys.Shift)
                {
                    shift = true;
                }
                else
                {
                    shift = false;
                }
                //Übergabe der Keys an AppendName der VisualMenuEntryEnterNameOptions
                if (Entries[CurrentMenuItemIndex] != null)
                {
                    if (Entries[CurrentMenuItemIndex].GetType() == typeof(VisualMenuEntryEnterNameOption))
                    {
                        ((VisualMenuEntryEnterNameOption)Entries[CurrentMenuItemIndex]).AppendName((char)e.KeyCode, shift);
                        tempName = ((VisualMenuEntryEnterNameOption)Entries[CurrentMenuItemIndex]).Name;
                        CreatePlayer();
                    }
                }
            }

            shift = false;
            //Menübewegung
            if (e.KeyCode == Keys.Down)
            {
                if (CurrentMenuItemIndex + 1 < Entries.Count)
                {
                    CurrentMenuItemIndex++;
                }
            }
            else if (e.KeyCode == Keys.Up)
            {
                if (CurrentMenuItemIndex - 1 >= 0)
                {
                    CurrentMenuItemIndex--;
                }
            }


            else if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Add)
            {
                if (Entries[CurrentMenuItemIndex] != null)
                {
                    GesamtGraphic = Graphics.FromImage(Gesamt);
                    Entries[CurrentMenuItemIndex].Action(1, windowSize.Width / 4, CurrentMenuItemIndex * OptionButtonHeight, GesamtGraphic);

                    GesamtGraphic.Dispose();

                    if (Entries[CurrentMenuItemIndex].GetType() == typeof(VisualMenuEntryPlayerClassOption))
                    {
                        //gewählte Bitmap in Merker schreiben
                        //tempBitmap = ((VisualMenuEntryPlayerClassOption)entries[currentMenuItemIndex]).CurrBitmap;
                        //gewählte Spieler-Klasse in Merker schreiben
                        tempClass = ((VisualMenuEntryPlayerClassOption)Entries[CurrentMenuItemIndex]).CurrPlayerClass;
                        CreatePlayer();
                    }
                    else if (Entries[CurrentMenuItemIndex].GetType() == typeof(VisualMenuEntryChangeIntValueOption))
                    {
                        if (((VisualMenuEntryChangeIntValueOption)Entries[CurrentMenuItemIndex]).IsMasked)
                        {
                            if (DebugForm != null)
                            {
                                DebugForm.WriteLine("Neues Profil: " + assetHandler.Assets.PerformanceValues[((VisualMenuEntryChangeIntValueOption)Entries[CurrentMenuItemIndex]).Value]);
                            }
                        }

                        ChangeAndSaveConfig();
                    }
                    else if (Entries[CurrentMenuItemIndex].GetType() == typeof(VisualMenuEntryChangeTilesetOption))
                    {
                        tileset = ((VisualMenuEntryChangeTilesetOption)Entries[CurrentMenuItemIndex]).Tileset;
                        ChangeAndSaveConfig();
                    }
                }
            }
            else if (e.KeyCode == Keys.Back || e.KeyCode == Keys.Subtract)
            {
                if (Entries[CurrentMenuItemIndex] != null)
                {
                    GesamtGraphic = Graphics.FromImage(Gesamt);
                    //Action des Eintrags aufrufen
                    Entries[CurrentMenuItemIndex].Action(0, windowSize.Width / 4, CurrentMenuItemIndex * OptionButtonHeight, GesamtGraphic);


                    //Abfrage, ob EnterNameOption
                    if (Entries[CurrentMenuItemIndex].GetType() == typeof(VisualMenuEntryEnterNameOption))
                    {
                        //Name kürzen und in Merker schreiben
                        ((VisualMenuEntryEnterNameOption)Entries[CurrentMenuItemIndex]).ShortenName();
                        tempName = ((VisualMenuEntryEnterNameOption)Entries[CurrentMenuItemIndex]).Name;
                    }
                    if (Entries[CurrentMenuItemIndex].GetType() == typeof(VisualMenuEntryPlayerClassOption))
                    {
                        //gewählte Bitmap in Merker schreiben
                        //tempBitmap = ((VisualMenuEntryPlayerClassOption)entries[currentMenuItemIndex]).CurrBitmap;
                        //gewählte Klasse in Merker schreiben
                        tempClass = ((VisualMenuEntryPlayerClassOption)Entries[CurrentMenuItemIndex]).CurrPlayerClass;
                        CreatePlayer();
                    }
                    if (Entries[CurrentMenuItemIndex].GetType() == typeof(VisualMenuEntryChangeIntValueOption))
                    {
                        ChangeAndSaveConfig();
                    }
                    else if (Entries[CurrentMenuItemIndex].GetType() == typeof(VisualMenuEntryChangeTilesetOption))
                    {
                        tileset = ((VisualMenuEntryChangeTilesetOption)Entries[CurrentMenuItemIndex]).Tileset;
                        ChangeAndSaveConfig();
                    }

                    GesamtGraphic.Dispose();
                }
            }
            else if (e.KeyCode == Keys.Escape)
            {
                if (Entries[CurrentMenuItemIndex].GetType() == typeof(VisualMenuEntryPlayerClassOption))
                {
                }
            }
        }