Beispiel #1
0
        /* This method is do reduce copy and pasting the switch statement to determine which arrow keys are pressed.
         * Since windows is forcing me to override methods for OnPreviewKeyDown and OnKeyDown for EVERY button on the
         * Windows form, I made this to make it a little more streamlined. */
        public void HandleArrowKeyPress(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            // Moves the map based on which arrow key is pressed.
            switch (e.KeyCode)
            {
            case Keys.Left:
                map.ScrollLeft();
                this.Refresh();     // Must call refresh or you won't see any change on screen.
                break;

            case Keys.Right:
                map.ScrollRight();
                this.Refresh();
                break;

            case Keys.Up:
                map.ScrollUp();
                this.Refresh();
                break;

            case Keys.Down:
                map.ScrollDown();
                this.Refresh();
                break;
            }
        }