tauqeer

tauqeer

  • NA
  • 1
  • 0

window form control library

May 13 2010 9:35 AM
Hi I have a question .i want make trafic light user control in C# and i have design lights.
but i need to have a state property in window property editor which when change to red red color b painted in my elipse for trafic control light and when green  red will b again grey and blue will filled in elips.
i have already made control but dnt know how to handel lights with a state in propery

this is the paint method code for trafic light but i want to set a state property which havr three different states as i explained above. 

 private void UserControl1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = CreateGraphics();
            Pen p = new Pen(Color.White, 3);
           
            Rectangle r = new Rectangle();
            r.Height = 150;
            r.Width = 55;
            
            SolidBrush b = new SolidBrush(Color.Black);
            g.FillRectangle(b, r);
            SolidBrush br = new SolidBrush(Color.Gray);

            Rectangle rect = new Rectangle(9, 7, 40, 40);
            Rectangle re = new Rectangle(9, 50, 40, 40);
            Rectangle rec = new Rectangle(9, 95, 40, 40);
            // g.DrawEllipse(p, rect);
            g.FillEllipse(br, rect);
            g.FillEllipse(br, re);
            g.FillEllipse(br, rec);
        


        }


thanks in advance

Tauqeer