title: How can I get my graphics lines to match up properly on Winforms picturebox?
body: <p>I am trying to create a program where an image is processed (the details of that are irrelevant to this question, I think), and then the user can modify / "fine tune" the image by drawing lines wherever they may be needed.  For the sake of accuracy, I want the line to go from the point of one mouse click to the next.  I found a previously asked / answered question on Stack Overflow that seemed to provide a good template for me; here's my code:</p>
  
  <pre><code>private void imgPicture_MouseDown(object sender, MouseEventArgs e) {
          if (draw) {
              if (p1.X == 0) {
                  p1.X = e.X;
                  p1.Y = e.Y;
              }
              else {
                  p2.X = e.X;
                  p2.Y = e.Y;
  
                  p1List.Add(p1);
                  p2List.Add(p2);
  
                  imgPicture.Invalidate();
                  p1.X = 0;
              }
              Graphics pictureGraphic = Graphics.FromImage(imgPicture.Image);
              using (var p = new Pen(Color.Black, 4)) {
                  for (int x = 0; x &lt; p1List.Count; x++) {
                      pictureGraphic.DrawLine(p, p1List[x], p2List[x]);
                  }
              }
          }
      }
  </code></pre>
  
  <p>The problem is, the location where my clicks are registering are way off.  Here is a snip of my program; the blue line is about where I was TRYING to create the line, the red line is where it actually showed up.
  <img src="https://i.stack.imgur.com/izve7.jpg" alt="program image capture"></p>
  
  <p>It seems like the further I get from the top left corner of the screen, the farther off the capture is.</p>
  
  <p>Also, while I'm asking questions, does anyone know how I can permanently dispose of all the drawn lines that are created?  So that I can click a button and all the lines disappear?  </p>
  
  <p>Thanks for your help!  Stackoverflow is a life saver!</p>