SampleApp.MainForm.GeneratePoints C# (CSharp) Method

GeneratePoints() private method

private GeneratePoints ( ) : void
return void
        private void GeneratePoints()
        {
            int width = pointsPanel.ClientRectangle.Width;
            int height = pointsPanel.ClientRectangle.Height;
            int diameter = groupRadius * 2;

            // generate groups of ten points
            for (int i = 0; i < pointsCount; )
            {
                int cx = rand.Next(width);
                int cy = rand.Next(height);

                // generate group
                for (int j = 0; (i < pointsCount) && (j < 10); )
                {
                    int x = cx + rand.Next(diameter) - groupRadius;
                    int y = cy + rand.Next(diameter) - groupRadius;

                    // check if wee are not out
                    if ((x < 0) || (y < 0) || (x >= width) || (y >= height))
                    {
                        continue;
                    }

                    // add point
                    points[i, 0] = x;
                    points[i, 1] = y;

                    j++;
                    i++;
                }
            }

            map = null;
            pointsPanel.Invalidate();
            mapPanel.Invalidate();
        }
MainForm