Beispiel #1
0
 public void DrawSort()
 {
     for (int i = 0; i < Balls.Length; i++)
     {
         for (int j = i + 1; j < Balls.Length; j++)
         {
             if (Balls[i].Numer > Balls[j].Numer)
             {
                 Change(i, j);
                 BallWithNumber swap = Balls[i];
                 Balls[i] = Balls[j];
                 Balls[j] = swap;
             }
         }
     }
 }
Beispiel #2
0
        private void DrawBallsButton_Click(object sender, EventArgs e)
        {
            const int maxNumber     = 10;
            const int topBalls      = 100;
            const int otstupOtKraya = 20;
            const int ballsRadius   = 30;

            int n = Convert.ToInt32(numberElementTextBox.Text);

            if (n <= maxNumber && n >= 1)
            {
                Balls = new BallWithNumber[n];
                for (int i = 0; i < n; i++)
                {
                    Balls[i]        = new BallWithNumber();
                    Balls[i].Y      = topBalls;
                    Balls[i].X      = otstupOtKraya + i * (2 * ballsRadius);
                    Balls[i].Color  = Color.Black;
                    Balls[i].Radius = ballsRadius;
                }
                FillRandom();
            }
            MyDraw();
        }