title: How do i add Points coordinates to a List of PointF of only one side of the rectangle?
body: <p>I'm drawing a rectangle and while drawing the rectangle in real time it also padding each rectangle edge left,right,up,down with green points on each edge.
  Now i set it to 36 points each rectangle edge:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  
  namespace mws
  {
      public partial class PaddingPoints : Form
      {
          private List&lt;PointF&gt; points = new List&lt;PointF&gt;();
          private Point RectStartPoint;
          private Image img;
          private Image imgClone;
          private Pen myPen;
          private int n = 36; //number of points
          private Bitmap _bmpBU = null;
  
          public PaddingPoints()
          {
              InitializeComponent();
  
              this.DoubleBuffered = true;
              _bmpBU = new Bitmap(@"D:\MyWeatherStation-Images-And-Icons\radar090.PNG");
  
              myPen = new Pen(Brushes.Red, 2);
              //Bitmap to hold the picturebox image
              img = new Bitmap(pictureBox1.Width, pictureBox1.Height);
              Graphics g;
              using (g = Graphics.FromImage(img))
              {
                  g.DrawImage(_bmpBU, 0, 0, pictureBox1.Width, pictureBox1.Height);
              }
  
              //image to hold the original picturebox. We need it to clear img to the original 
              //picturebox image
              imgClone = (Bitmap)img.Clone();
  
              //We draw always on img and then we invalidate
              pictureBox1.Image = img;
          }
  
          private void PaddingPoints_Load(object sender, EventArgs e)
          {
  
          }
  
          private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
          {
              RectStartPoint = e.Location;
          }
  
          private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
          {
              if (e.Button == MouseButtons.Left &amp;&amp; e.Location != RectStartPoint)
              {
                  DrawRectangle(e.Location);
              }
          }
  
          private void DrawRectangle(Point pnt)
          {
              Graphics g = Graphics.FromImage(img);
              int width, height, i, x, y;
  
              g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
  
              //Clear img from the rectangle we drawn previously
              g.DrawImage(imgClone, 0, 0);
  
  
              if (pnt.X == RectStartPoint.X || pnt.Y == RectStartPoint.Y)
              {
                  g.DrawLine(myPen, RectStartPoint.X, RectStartPoint.Y, pnt.X, pnt.Y);
              }
              else
              {
                  g.DrawRectangle(myPen, Math.Min(RectStartPoint.X, pnt.X), Math.Min(RectStartPoint.Y, pnt.Y),
                                  Math.Abs(RectStartPoint.X - pnt.X), Math.Abs(RectStartPoint.Y - pnt.Y));
  
                  //width of spaces between points
                  width = (int)((Math.Abs(RectStartPoint.X - pnt.X)) / (n - 1));
                  //height of spaces between points
                  height = (int)((Math.Abs(RectStartPoint.Y - pnt.Y)) / (n - 1));
                  //we always want the upper left x, y coordinates as a reference drawing clockwise
                  x = Math.Min(RectStartPoint.X, pnt.X);
                  y = Math.Min(RectStartPoint.Y, pnt.Y);
  
                  //Drawing the points. change the 3, 6 values for larger ones
                  for (i = 0; i &lt; n - 1; i++)
                  {
                      //Up side
                      g.FillEllipse(Brushes.Green, new Rectangle(x - 3, Math.Min(RectStartPoint.Y, pnt.Y) - 3, 6, 6));
                      //Right side
                      g.FillEllipse(Brushes.Green, new Rectangle(Math.Min(RectStartPoint.X, pnt.X) + Math.Abs(RectStartPoint.X - pnt.X) - 3, y - 3, 6, 6));
                      //Bottom side
                      g.FillEllipse(Brushes.Green, new Rectangle(x - 3, Math.Min(RectStartPoint.Y, pnt.Y) + Math.Abs(RectStartPoint.Y - pnt.Y) - 3, 6, 6));
                      //Left side
                      g.FillEllipse(Brushes.Green, new Rectangle(Math.Min(RectStartPoint.X, pnt.X) - 3, y - 3, 6, 6));
                      PointF pointf = new PointF(Math.Min(RectStartPoint.X, pnt.X) - 3, y - 3);
                      points.Add(pointf);
                      x += width;
                      y += height;
                  }
                  g.FillEllipse(Brushes.Green, new Rectangle(Math.Min(RectStartPoint.X, pnt.X) + Math.Abs(RectStartPoint.X - pnt.X) - 3,
                                Math.Min(RectStartPoint.Y, pnt.Y) - 3, 6, 6));
                  g.FillEllipse(Brushes.Green, new Rectangle(Math.Min(RectStartPoint.X, pnt.X) + Math.Abs(RectStartPoint.X - pnt.X) - 3,
                               Math.Min(RectStartPoint.Y, pnt.Y) + Math.Abs(RectStartPoint.Y - pnt.Y) - 3, 6, 6));
              }
  
              g.Dispose();
  
              //draw img to picturebox
              pictureBox1.Invalidate();
          }
  
          private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
          {
              int t = points.Count;
          }
      }
  }
  </code></pre>
  
  <p>The result is:</p>
  
  <p><img src="https://i.stack.imgur.com/wYmPg.jpg" alt="Rectangle with green points"></p>
  
  <p>Now i want to do two thing in the pictureBox1 mouse up event:</p>
  
  <p>To have a List of PointF with the coordinates of one of the rectangle edges.
  For example if it's the left edge so the List should contain 36 coordinates X,Y for each point.
  If it's the Top edge then also 36 points and same for bottom and right edges.
  But only to get in the List one edge each time points.</p>
  
  <p>And also to have a variable that will hold the distance from one edge otthe other one:
  For example if i'm adding to the List points the 36 points of the left edge i want to get in int variable the distance between the left edge and the eight edge.
  If i added to the List points the 36 points of the right edge then the int variable should hold the distance from the right edge to the left. Same for up and down edges.</p>
  
  <p>Depending on what edge i get the points from.</p>
  
  <p>For the List of Points i added to the top:</p>
  
  <pre><code>private List&lt;PointF&gt; points = new List&lt;PointF&gt;();
  </code></pre>
  
  <p>Then in the DrawRectangle method i added:</p>
  
  <pre><code>PointF pointf = new PointF(Math.Min(RectStartPoint.X, pnt.X) - 3, y - 3);
  points.Add(pointf);
  </code></pre>
  
  <p>Then in the mouse up event when i'm using a breakpoint there i see that the List points have more then 4000 points coordinates inside many of them are the same.</p>
  
  <p>I need to get for example only the left edge of the rectangle green points coordinates so points should have in the end 36 coordinates only and the distance from one edge to the other.</p>