title: Draw multiple lines on mouse click but without overlapping
body: <p>this code is working for drawing multiple lines by mouse clicks. But the lines are overlapping or intersecting even if one line is already created.</p>
  
  <p>Can anyone help me how can i draw multiple lines [the working code for drawing multiple lines are given] without overlapping each other inestead it would find another round way to avoid conflicts to other lines.</p>
  
  <pre><code>    public partial class Form1 : Form
  {
      [STAThread]
      static void Main()
      {
          Application.EnableVisualStyles();
          Application.SetCompatibleTextRenderingDefault(false);
          Application.Run(new Form1());
      }
  
      private Point _setPointA, _setPointB;
      private static List&lt;Point&gt; PointList = new List&lt;Point&gt;();
      private Dictionary&lt;Point, Point&gt; PointDictionary = new Dictionary&lt;Point, Point&gt;();
  
      public Form1()
      {
          PointDictionary.Add(new Point { X = 10, Y = 10 }, new Point { X = 85, Y = 85 });
  
      }
      protected override void OnMouseClick(MouseEventArgs e)
      {
          if (e.Button == MouseButtons.Left)
          {
              if (!PointList.Any())
              {
                  _setPointA = e.Location;
                  PointList.Add(_setPointA);
              }
              else
              {
                  _setPointB = e.Location;
                  PointList.Add(_setPointB);
  
                  //check if not intersects
  
                  if (_setPointA.X &lt;= _setPointB.X)
                  {
                      PointDictionary.Add(_setPointA, _setPointB);
                  }
                  else
                  {
                      PointDictionary.Add(_setPointB, _setPointA);
                  }
                  Refresh();
              }
          }
          base.OnMouseClick(e);
      }
      protected override void OnPaint(PaintEventArgs e)
      {
          foreach (var v in PointDictionary)
          {
              e.Graphics.DrawLine(SystemPens.ControlDarkDark, v.Key, v.Value);
          }
  
          base.OnPaint(e);
          PointList.Clear();
      }
  }
  </code></pre>