waserek

waserek

  • NA
  • 5
  • 15.9k

GDI+, Somethimes Control is drawing with different Pen, Help

Jan 22 2011 9:06 PM
Hello Everybody!
 Strange things happen in my Win Forms App. I create a Custom LineControl, which simply draws full transparent control with line inside. Line is creating dynamically by User (with preview like in Win Paint). When i create new Line ones for a while it daws a dashed line. Like on picture above. I've drawn 4 line and suddenly 5th is dashed. I cant understard that. Thickness of dashed line is different. Always 1px.


Untitled.jpg

Pen p and SolidBrush  b used to draw Line are instantiated in constructor

   p = new Pen(col, thick);
p.DashStyle = DashStyle.Solid;
b = new SolidBrush(col);

OnPaint method looks like that:

  protected override void OnPaint(PaintEventArgs e)
{


base.OnPaint(e);
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
e.Graphics.FillPath(b, this.path);
e.Graphics.DrawPath(p, this.path);


this.Region = new Region(this.path);



}

Any ideas?



Answers (3)