[Mono-bugs] [Bug 338985] New: When drawing rectangles using Pen, the Alignment property does not work correctly.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Nov 4 06:12:44 EST 2007


https://bugzilla.novell.com/show_bug.cgi?id=338985

           Summary: When drawing rectangles using Pen, the Alignment
                    property does not work correctly.
           Product: Mono: Class Libraries
           Version: unspecified
          Platform: Other
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Drawing.
        AssignedTo: mono-bugs at ximian.com
        ReportedBy: vlad.dimitrov at gmail.com
         QAContact: mono-bugs at ximian.com
          Found By: ---


When trying to draw a rectangle with a Pen object with Alignment property set
to PenAlignment.Inset, the actual result does not differ from the result with
Alignment set to PenAlignment.Center.

The expected result would be to draw the border of the rectangle growing to the
inside.

The folowing code fragment demonstrates the issue. The same example can run on
MS.NET so you can notice the difference.

using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace DrawInsetRectangle
{
    public partial class Form1 : Form
    {
        public Form1 ()
        {
            InitializeComponent ();

            Paint += Form1_Paint;
        }

        void Form1_Paint (object sender, PaintEventArgs e)
        {
            DrawFilledRect (e.Graphics, 10, 10, 30, 10, 1,
PenAlignment.Center);
            DrawFilledRect (e.Graphics, 50, 10, 30, 10, 2,
PenAlignment.Center);
            DrawFilledRect (e.Graphics, 90, 10, 30, 10, 3,
PenAlignment.Center);
            DrawFilledRect (e.Graphics, 130, 10, 30, 10, 4,
PenAlignment.Center);

            DrawFilledRect (e.Graphics, 10, 30, 30, 10, 1, PenAlignment.Inset);
            DrawFilledRect (e.Graphics, 50, 30, 30, 10, 2, PenAlignment.Inset);
            DrawFilledRect (e.Graphics, 90, 30, 30, 10, 3, PenAlignment.Inset);
            DrawFilledRect (e.Graphics, 130, 30, 30, 10, 4,
PenAlignment.Inset);
        }

        private void DrawFilledRect (Graphics g, float x, float y, float width,
float height, float border, PenAlignment pAlign)
        {
            Region savedClip = g.Clip;
            g.Clip = new Region (new RectangleF (x, y, width, height));

            using (Pen pen = new Pen (Color.Black, border)) {
                pen.Alignment = pAlign;
                g.DrawRectangle (pen, x, y, width, height);
            }

            g.Clip = savedClip;
        }

    }
}


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list