private void numericUpDown1_ValueChanged(object sender, EventArgs e) { int numberOfDots = Convert.ToInt32(numericUpDown1.Value); _movingDots = new MovingDots(numberOfDots, Math.Min(pictureBox1.Width / 2 - 10, pictureBox1.Height / 2 - 10)); timer1.Enabled = true; }
private void DrawDots(MovingDots movingDots) { Point[] currentPositions = movingDots.GetCurrentPositions(); pictureBox1.Refresh(); for (int i = 0; i < currentPositions.Length; i++) { Point currentPosition = currentPositions[i]; _graphics.FillEllipse(_brush, currentPosition.X - 5, currentPosition.Y - 5, 10, 10); if (i < currentPositions.Length - 1) { Point nextPosition = currentPositions[i + 1]; _graphics.DrawLine(_pen, currentPosition, nextPosition); } } }