title: C# WinForms Traffic Lights cannot be drawn everywhere in my window
body: <p>I made a program which can draw traffic lights. I put one traffic light at the upper left corner and the other traffic light approximately in the middle of the window. But it seems that there is a rectangular field in my program. Only there traffic lights can be drawn. This field begins at the upper left corner and goes to the center of the window. The result is that one traffic light can be seen but the other traffic light is cut at the end of this field. I don't know why</p>
  
  <p>My Code:</p>
  
  <pre><code>public partial class Form1 : Form
  {
      private Timer timer;
  
      private TrafficLight[] lights;
      private Panel[] light_panels;
  
      public Form1()
      {
          InitializeComponent();
          timer = new Timer();
  
          timer.Tick += timer_Tick;
  
          timer.Interval = 2000;
          timer.Enabled = true;
  
          timer.Start();
  
          lights = new TrafficLight[]
          {
              new TrafficLight(10, 10, 75, 150, 0),
              new TrafficLight(50, 50, 75, 150, 2)
          };
  
          light_panels = new Panel[]
          {
              new Panel(),
              new Panel()
          };
  
          for (int i = 0; i &lt; light_panels.Length; ++i)
          {
              light_panels[i].Width = lights[i].Width;
              light_panels[i].Height = lights[i].Height;
              light_panels[i].Location = new Point(lights[i].X, lights[i].Y);
              Controls.Add(light_panels[i]);
              light_panels[i].Paint += PLight_Paint;
          }
  
          CenterToScreen();
      }
  
      private void PLight_Paint(object sender, PaintEventArgs e)
      {
          Panel p = sender as Panel;
  
          int index = 0;
          for (int i = 0; i &lt; light_panels.Length; ++i)
          {
              if (Object.ReferenceEquals(light_panels[i], p))
              {
                  index = i;
                  break;
              }
          }
  
          e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
  
          e.Graphics.FillRectangle(new SolidBrush(Color.Gray), lights[index].X, lights[index].Y, lights[index].Width, lights[index].Height);
  
          switch (lights[index].State)
          {
              case 0:
                  e.Graphics.FillEllipse(new SolidBrush(Color.Red), lights[index].X + 10, lights[index].Y + 5, lights[index].Width - 30, lights[index].Height / 3 - 10);
                  e.Graphics.FillEllipse(new SolidBrush(Color.Black), lights[index].X + 10, lights[index].Y + lights[index].Height / 3, lights[index].Width - 30, lights[index].Height / 3 - 10);
                  e.Graphics.FillEllipse(new SolidBrush(Color.Black), lights[index].X + 10, lights[index].Y + lights[index].Height / 3 * 2 - 5, lights[index].Width - 30, lights[index].Height / 3 - 10);
                  break;
              case 1:
                  e.Graphics.FillEllipse(new SolidBrush(Color.Red), lights[index].X + 10, lights[index].Y + 5, lights[index].Width - 30, lights[index].Height / 3 - 10);
                  e.Graphics.FillEllipse(new SolidBrush(Color.Orange), lights[index].X + 10, lights[index].Y + lights[index].Height / 3, lights[index].Width - 30, lights[index].Height / 3 - 10);
                  e.Graphics.FillEllipse(new SolidBrush(Color.Black), lights[index].X + 10, lights[index].Y + lights[index].Height / 3 * 2 - 5, lights[index].Width - 30, lights[index].Height / 3 - 10);
                  break;
              case 2:
                  e.Graphics.FillEllipse(new SolidBrush(Color.Black), lights[index].X + 10, lights[index].Y + 5, lights[index].Width - 30, lights[index].Height / 3 - 10);
                  e.Graphics.FillEllipse(new SolidBrush(Color.Black), lights[index].X + 10, lights[index].Y + lights[index].Height / 3, lights[index].Width - 30, lights[index].Height / 3 - 10);
                  e.Graphics.FillEllipse(new SolidBrush(Color.Green), lights[index].X + 10, lights[index].Y + lights[index].Height / 3 * 2 - 5, lights[index].Width - 30, lights[index].Height / 3 - 10);
                  break;
              case 3:
                  e.Graphics.FillEllipse(new SolidBrush(Color.Black), lights[index].X + 10, lights[index].Y + 5, lights[index].Width - 30, lights[index].Height / 3 - 10);
                  e.Graphics.FillEllipse(new SolidBrush(Color.Orange), lights[index].X + 10, lights[index].Y + lights[index].Height / 3, lights[index].Width - 30, lights[index].Height / 3 - 10);
                  e.Graphics.FillEllipse(new SolidBrush(Color.Black), lights[index].X + 10, lights[index].Y + lights[index].Height / 3 * 2 - 5, lights[index].Width - 30, lights[index].Height / 3 - 10);
                  break;
          }
      }
  
      private void timer_Tick(object sender, EventArgs e)
      {
          for (int i = 0; i &lt; lights.Length; ++i)
          {
              lights[i].Switch();
              light_panels[i].Invalidate();
              light_panels[i].Update();
          }
      }
  
      private void Form1_Load(object sender, EventArgs e)
      {
  
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/aeM5m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aeM5m.png" alt="enter image description here"></a></p>
  
  <p>What can I do to solve this problem?
  Thanks for any help</p>