コード例 #1
0
ファイル: Form1.cs プロジェクト: StojanovicMilos/Katas
        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;
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: StojanovicMilos/Katas
        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);
                }
            }
        }