public void spawn(int posX, int posY)
 {
     this.posX  = posX;
     this.posY  = posY;
     directionX = BallDirection.RandomDirection();
     directionY = BallDirection.Direction.Positive;
     Canvas.SetLeft(rectangle, posX);
     Canvas.SetTop(rectangle, posY);
 }
 public void bounce(WallPlane plane)
 {
     if (plane.Equals(WallPlane.Vertical))
     {
         directionX = BallDirection.SwitchDirection(directionX);
     }
     if (plane.Equals(WallPlane.Horizontal))
     {
         directionY = BallDirection.SwitchDirection(directionY);
     }
 }
        public Ball(Canvas canvas)
        {
            this.canvas = canvas;
            SolidColorBrush color = new SolidColorBrush();

            directionX       = BallDirection.RandomDirection();
            directionY       = BallDirection.Direction.Positive;
            color.Color      = Color.FromRgb(255, 0, 0);
            rectangle.Fill   = color;
            rectangle.Width  = size;
            rectangle.Height = size;
            canvas.Children.Add(rectangle);
        }