private void MovementTimerTick(object sender, EventArgs e)
        {
            GenerateNewFigure(_nextFigureNumber, Board, 24, 24, 25);

            if (CurrentFigure == null)
            {
                return;
            }

            if (MovementHelper.CanMoveDown(CurrentFigure, Board))
            {
                MoveDown(CurrentFigure);
            }
            else
            {
                //finish the game if figure can't move down from start point
                if (CurrentFigure.Top <= 0)
                {
                    StopTheGame();
                }
                int lines;
                Score         = MovementHelper.CalculateScore(CurrentFigure, Board, Score, out lines);
                LinesCount   += lines;
                CurrentFigure = null;
                if (Properties.Settings.Default.WithAcceleration)
                {
                    SetMovementSpeed(Properties.Settings.Default.SpeedWithAcceleration);
                }
                else
                {
                    SetMovementSpeed(Properties.Settings.Default.SpeedNormal);
                }
            }
        }
 private void ButtonRotateRight_Click(object sender, RoutedEventArgs e)
 {
     MovementHelper.RotateRight(CurrentFigure, Board);
 }
 private void ButtonMoveLeft_Click(object sender, RoutedEventArgs e)
 {
     MovementHelper.MoveLeft(CurrentFigure, Board);
 }
        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if (CurrentState == (byte)States.Pause)
            {
                e.Handled = true;
            }

            if (e.KeyboardDevice.IsKeyDown(Key.LeftCtrl) || e.KeyboardDevice.IsKeyDown(Key.RightCtrl))
            {
                switch (e.Key)
                {
                //handle G key
                case Key.G:
                    SetStateFromCurrentState();
                    break;

                //handle R key
                case Key.R:
                    ResetCurrentState();
                    Board.Children.Clear();
                    TimerValue = Properties.Settings.Default.TimerInitialValue;
                    Score      = Properties.Settings.Default.ScoreInitialValue;
                    break;

                default:
                    e.Handled = true;
                    break;
                }
            }
            //handle F1 key
            if (e.Key == Key.F1)
            {
                MenuItemHelp_Click(sender, e);
                e.Handled = true;
            }

            if ((CurrentFigure == null) || (CurrentState == (byte)States.Continue))
            {
                return;
            }

            //rotate current figur to left
            if (e.Key == Key.Down)
            {
                MovementHelper.RotateLeft(CurrentFigure, Board);
            }
            //rotate current figure to right
            if (e.Key == Key.Up)
            {
                MovementHelper.RotateRight(CurrentFigure, Board);
            }

            //move current figure to left
            if (e.Key == Key.Left)
            {
                MovementHelper.MoveLeft(CurrentFigure, Board);
            }

            //move current figure to right
            if (e.Key == Key.Right)
            {
                MovementHelper.MoveRight(CurrentFigure, Board);
            }

            //move current figure to bottom of the board
            if (e.Key == Key.Space)
            {
                SetMovementSpeed(0);
            }
        }