private void  OnApplicationIdle(object sender, EventArgs e)
        {
            if (User32Import.GetKeyState(Keys.Escape))
            {
                if (_pause)
                {
                    return;
                }
                _pause = true;
                //Cursor.Show();
                GameSettingsForm settingsForm   = new GameSettingsForm(new Settings("localhost", 4567));
                DialogResult     settingsResult = settingsForm.ShowDialog(this);
                if (settingsResult == DialogResult.Abort)
                {
                    Close();
                }
                else if (settingsResult == DialogResult.Cancel)
                {
                    _pause = false;
                }
                else if (settingsResult == DialogResult.OK)
                {
                    //_settings = settingsForm.GetSettings();
                    _pause = false;
                }
                //Cursor.Hide();
            }
            if (_pause)
            {
                return;
            }
            while (User32Import.AppStillIdle())
            {
                // LOOP
                TimeSpan timeElapsedNow      = stopWatch.Elapsed;
                TimeSpan timeElapsedFromLast = timeElapsedNow - _totalTimeElapsed;
                _totalTimeElapsed = timeElapsedNow;

                ProcessKeyState(timeElapsedFromLast);
                DoChange(timeElapsedFromLast);
                //CheckBounds(new RectangleF(0, 0, this.ClientSize.Width - size, this.ClientSize.Height - size));

                TimeSpan timeElapsedFromLastUpdateScreen = timeElapsedNow - _totalTimeElapsedWhenUpdateScreen;
                if (timeElapsedFromLastUpdateScreen.Milliseconds > 16)
                {
                    _totalTimeElapsedWhenUpdateScreen = timeElapsedNow;
                    UpdateScreen();
                }
            }
        }
 private void ProcessKeyState(TimeSpan aTimeElapsed)
 {
     if (User32Import.GetKeyState(Keys.Left))
     {
         _heroShip.RotateLeft(aTimeElapsed);
     }
     if (User32Import.GetKeyState(Keys.Right))
     {
         _heroShip.RotateRight(aTimeElapsed);
     }
     if (User32Import.GetKeyState(Keys.Up))
     {
         _heroShip.EngageForwardThrustors(aTimeElapsed);
     }
     if (User32Import.GetKeyState(Keys.Space) && (_totalTimeElapsed - _totalTimeElapsedWhenLastShot).Milliseconds > _heroShip.GetBulletDelay())
     {
         _heroShotList.Add(new Shot(_totalTimeElapsed, _heroShip.GetPosition(), _heroShip.GetDirection(), _heroShip.GetSpeedVector()));
         _totalTimeElapsedWhenLastShot = _totalTimeElapsed;
     }
 }