private void DrawBuilding(Graphics g, BuildingStyle style, Rectangle bounds)
        {
            using (Brush brush = new SolidBrush(style.Color))
            {
                g.FillRectangle(brush, bounds);
            }

            this.DrawLights(g, style, bounds);
        }
        private Rectangle[] GetNewBuildingBounds(BuildingStyle left, BuildingStyle right)
        {
            SimpleSkylineGeneratorSettings settings;
            int       leftW;
            int       rightW;
            int       h;
            int       x;
            int       y;
            int       maxH;
            int       maxX;
            Rectangle leftBounds;
            Rectangle rightBounds;

            settings = this.Settings;

            leftW  = this.GetBuildingWidth(left);
            rightW = right != null?this.GetBuildingWidth(right) : 0;

            maxH = settings.MaximumBuildingSize.Height / _buildingRandom.Next(1, 10);
            h    = maxH < settings.MinimumBuildingSize.Height ? settings.MinimumBuildingSize.Height : _buildingRandom.Next(settings.MinimumBuildingSize.Height, maxH);
            //h= _buildingRandom.Next(settings.MinimumBuildingSize.Height, settings.MaximumBuildingSize.Height);

            maxX = settings.Size.Width - (leftW + rightW);

            if (settings.Wrap)
            {
                x = _buildingRandom.Next(0, maxX);
            }
            else
            {
                x = _buildingRandom.Next(-settings.MaximumBuildingSize.Width, maxX + (settings.MaximumBuildingSize.Width * 2));
            }

            y = settings.Size.Height - h;

            leftBounds  = new Rectangle(x, y, leftW, h);
            rightBounds = new Rectangle(x + leftW, y, rightW, h);

            return(new[]
            {
                leftBounds, rightBounds
            });
        }
        private int GetBuildingWidth(BuildingStyle style)
        {
            SimpleSkylineGeneratorSettings settings;
            int offset;
            int result;

            //int maxW;

            settings = this.Settings;

            //maxW = settings.MaximumBuildingSize.Width / _buildingRandom.Next(1, 10);
            //result = maxW < settings.MinimumBuildingSize.Width ? settings.MinimumBuildingSize.Width : _buildingRandom.Next(settings.MinimumBuildingSize.Width, maxW);
            result = _buildingRandom.Next(settings.MinimumBuildingSize.Width, settings.MaximumBuildingSize.Width);

            offset  = result % style.WindowSize.Width;
            result += offset;

            return(result);
        }
        private void DrawBuilding(Graphics g, BuildingStyle left, BuildingStyle right)
        {
            SimpleSkylineGeneratorSettings settings;

            settings = this.Settings;

            if (settings.MinimumBuildingSize.Width < settings.MaximumBuildingSize.Width && settings.MinimumBuildingSize.Height < settings.MaximumBuildingSize.Height)
            {
                Rectangle[] bounds;

                bounds = this.GetNewBuildingBounds(left, right);

                this.DrawBuilding(g, left, bounds[0]);
                if (right != null)
                {
                    this.DrawBuilding(g, right, bounds[1]);
                }
            }
        }
        private void DrawLights(Graphics g, BuildingStyle style, Rectangle bounds)
        {
            SimpleSkylineGeneratorSettings settings;
            int windowWidth;
            int windowHeight;
            int right;

            settings = this.Settings;

            windowWidth  = style.WindowSize.Width;
            windowHeight = style.WindowSize.Height;
            right        = bounds.Right - windowWidth;

            using (Brush brush = new SolidBrush(style.LightColor))
            {
                for (int y = bounds.Top + windowHeight; y < bounds.Bottom; y += (windowHeight * 2))
                {
                    for (int x = bounds.Left + windowWidth; x < right; x += (windowWidth * 2))
                    {
                        bool lit;

                        lit = _lightingRandom.NextDouble() <= settings.LightingDensity;

                        if (lit)
                        {
                            bool doubleWidth;
                            int  w;

                            doubleWidth = style.GrowWindows && x + windowWidth <= right && _lightingRandom.NextDouble() >= 0.5;
                            w           = doubleWidth ? windowWidth * 2 : windowWidth;

                            g.FillRectangle(brush, x, y, w, windowHeight);
                        }
                    }
                }

                //g.FillRectangle(brush, bounds.Left + windowWidth, bounds.Top + windowHeight, bounds.Width - (windowWidth * 2), bounds.Height);
            }
        }