예제 #1
0
        /// <summary>
        /// Rereshes the user interface.
        /// </summary>
        public void RefreshUserInterface()
        {
            GameUserIterface.ActiveTetromino = Model.ActiveTetromino;
            if (GameUserIterface.InvokeRequired)
            {
                RefreshScreen rs = new RefreshScreen(RefreshUserInterface);
                try
                {
                    GameUserIterface.Invoke(rs);
                }
#pragma warning disable CS0168 // Variable is declared but never used
                catch (ObjectDisposedException e)
#pragma warning restore CS0168 // Variable is declared but never used
                {
                    //The program has exited, no point in updating the screen
                }
#pragma warning disable CS0168 // Variable is declared but never used
                catch (System.ComponentModel.InvalidAsynchronousStateException e)
#pragma warning restore CS0168 // Variable is declared but never used
                {
                    //The program has exited, no point in updating the screen
                }
#pragma warning disable CS0168 // Variable is declared but never used
                catch (Exception e)
#pragma warning restore CS0168 // Variable is declared but never used
                {
                    //General catch to catch other thread related errors that rarely happens and are hard to force.
                }
            }
            else
            {
                GameUserIterface.Refresh();
            }
        }
예제 #2
0
 /// <summary>
 /// Handles logic when Game Over occures.
 /// </summary>
 public void GameOver()
 {
     if (GameUserIterface.InvokeRequired)
     {
         ShowGameOverScreen go = new ShowGameOverScreen(GameUserIterface.DisplayGameOverScreen);
         try
         {
             GameUserIterface.Invoke(go);
         }
         catch (ObjectDisposedException)
         {
             //The program has exited
         }
     }
     else
     {
         GameUserIterface.DisplayGameOverScreen();
     }
 }