Example #1
0
        /// <summary>
        /// Constructor that sets the controller to interact with the application model
        /// </summary>
        /// <param name="controller">The instance of the controller</param>
        public MainView(IController controller)
        {
            Application.EnableVisualStyles();

            this._controller          = controller;
            this._controller.MainView = this;

            // Create panels
            this._mainMenuPanel   = new MainMenuPanel(this);
            this._newGamePanel    = new NewGamePanel(this);
            this._playingPanel    = new PlayingPanel(this, this._controller);
            this._gamePausePanel  = new GamePausePanel(this);
            this._highscoresPanel = new HighscoresPanel(this);

            this.KeyPreview = true;
            this.KeyUp     += (s, e) =>
            {
                switch (e.KeyCode)
                {
                case Keys.C:
                    if (this._playingPanel.IsRunning)
                    {
                        this.LeftNoteHit();
                    }
                    break;

                case Keys.N:
                    if (this._playingPanel.IsRunning)
                    {
                        this.RightNoteHit();
                    }
                    break;

                case Keys.Escape:
                    if (this._playingPanel.IsRunning)
                    {
                        this.PauseGame();
                    }
                    break;
                }
            };

            this.InitializeComponent();
            this.ShowMainMenuView();

            Application.Run(this);
        }
Example #2
0
 /// <summary>
 /// Refresh the highscores panel after new records are added
 /// </summary>
 public void RefreshHighscores()
 {
     this._highscoresPanel = new HighscoresPanel(this);
     this.HighscoresPanelSetup();
 }