Question

What brush should i use to draw rectangles with white interior of the line and lines for the perimeter of the rectangle like the elevations below.

The form1 winform is what i am working on and the image behind the winform is how i need to the rectangles to look in my winform.

To make the question easier, how can i fill the interior portion of the rectangles with white?

How do i fill the LINES of the rectangle with white? I do not need to fill the inside of the rectangle, I need to fill a portion of the 4 lines that make up the rectangle with white.

CAD Example

       void BuildShopDrawing(ElevationResponse elevation)
    {

        float penWidth = (float)((2f / 12f) * PIXELS_PER_FOOT);
        Pen blackPen = new Pen(Color.FromArgb(40, 84, 149), penWidth);
        Bitmap canvas = new Bitmap((((int)elevation.TotalWidthFeet) * PIXELS_PER_FOOT) + 55, (((int)elevation.TotalHeightFeet) * PIXELS_PER_FOOT) + 25);
        Graphics dc = Graphics.FromImage(canvas);

        RectangleF[] bays = new RectangleF[elevation.Bays.Count];
        float x = 10F;
        float width = 0F;
        float height = 0F;

        for (int i = 0; i < elevation.Bays.Count; i++)
        {
            if (i > 0)
            {
                x += (float)((elevation.Bays[i - 1].WidthInches / 12) * PIXELS_PER_FOOT);
            }
            width = (float)(elevation.Bays[i].WidthInches / 12) * PIXELS_PER_FOOT;
            height = (float)(elevation.Bays[i].HeightInches / 12) * PIXELS_PER_FOOT;
            bays[i] =
                 new RectangleF(new PointF(x, 10),
                 new SizeF(width, height));
        }

        dc.DrawRectangles(blackPen, bays);
        this.picBx.Image = canvas;
        this.Size = new System.Drawing.Size(canvas.Width + 10, canvas.Height + 50);
    }
Was it helpful?

Solution

You need to look a bit more thoroughly at the Pen Class more specifically the CompoundArray Property, it will give you something like you are wanting, You will need to play around some other of the Pen Class properties to get your transitions right. And as a side note when you post example code that depends on external custom classes you make it harder for someone to help, it is always best to make sure that the code can run by itself.

Try adding this after you declare your pen.

float[] cmpArray = new float[4]{0.0F, 0.2F, 0.7F, 1.0F};
blackPen.CompoundArray = cmpArray;

It looks something like this:

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top