Ejemplo n.º 1
0
        private void Form1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (!AllBalls.isLocationSet)
                {
                    AllBalls.isLocationSet   = true;
                    AllBalls.CurrentLocation = e.Location;
                }
                else if (AllBalls.isLocationSet)
                {
                    AllBalls.CurrentRadius = AllBalls.pointsDistance(AllBalls.CurrentLocation, e.Location);
                    AllBalls.AddCircle();
                    AllBalls.CurrentLocation = Point.Empty;
                    AllBalls.CurrentRadius   = default(int);
                    AllBalls.isLocationSet   = false;

                    tssNumOfCirc.Text = AllBalls.Balls.Count.ToString();
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                AllBalls.SetSelected(e.Location);
            }

            Invalidate(true);
        }
Ejemplo n.º 2
0
 public static void ValidateCaughtBall(PBEItem value)
 {
     if (!AllBalls.Contains(value))
     {
         throw new ArgumentOutOfRangeException(nameof(value));
     }
 }
Ejemplo n.º 3
0
 private void Form1_MouseMove(object sender, MouseEventArgs e)
 {
     if (AllBalls.isLocationSet)
     {
         AllBalls.UpdateRadius(e.Location);
         Invalidate(true);
     }
 }
Ejemplo n.º 4
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape)
     {
         if (AllBalls.isLocationSet)
         {
             AllBalls.isLocationSet   = false;
             AllBalls.CurrentLocation = Point.Empty;
             AllBalls.CurrentRadius   = default(int);
             Invalidate(true);
         }
     }
     else if (e.KeyCode == Keys.Up)
     {
         Ball Ball = AllBalls.getSelected();
         if (!(Ball is null))
         {
             Ball.Location = new Point(Ball.Location.X, Ball.Location.Y - 2);
             Invalidate(true);
         }
     }
     else if (e.KeyCode == Keys.Down)
     {
         Ball Ball = AllBalls.getSelected();
         if (!(Ball is null))
         {
             Ball.Location = new Point(Ball.Location.X, Ball.Location.Y + 2);
             Invalidate(true);
         }
     }
     else if (e.KeyCode == Keys.Left)
     {
         Ball Ball = AllBalls.getSelected();
         if (!(Ball is null))
         {
             Ball.Location = new Point(Ball.Location.X - 2, Ball.Location.Y);
             Invalidate(true);
         }
     }
     else if (e.KeyCode == Keys.Right)
     {
         Ball Ball = AllBalls.getSelected();
         if (!(Ball is null))
         {
             Ball.Location = new Point(Ball.Location.X + 2, Ball.Location.Y);
             Invalidate(true);
         }
     }
     AllBalls.Colision();
     tssNumOfCirc.Text = AllBalls.Balls.Count.ToString();
     Invalidate(true);
 }
Ejemplo n.º 5
0
 public ValidateResult InitBalls()
 {
     if (!ValidateBase().Validate)
     {
         return(ValidateResult.Error("总球个数与坏球个数不得为空!"));
     }
     for (int i = 0; i < AllQty; i++)
     {
         var ball = new Ball();
         ball.BallIndex = (i + 1).ToString();
         ball.IsNormal  = !BadIndexs.Values.Contains(i + 1);
         ball.Weight    = (BallWeightType)BadBallType;
         AllBalls.Add(ball);
     }
     return(ValidateResult.Success());
 }
Ejemplo n.º 6
0
        private Ball getRandomBall(BallColor ballColor)
        {
            Ball result = AllBalls.Find(b => b.BallColor == ballColor && !b.IsKinematic);

            return(result);
        }
Ejemplo n.º 7
0
 private void Form1_Paint(object sender, PaintEventArgs e)
 {
     e.Graphics.Clear(Color.White);
     AllBalls.Draw(e.Graphics);
 }