title: How can i check if two points are connected on the pictureBox then enable true button4?
body: <p>This is the code in Form1 of the pictureBox1 mouse down event:</p>
  
  <pre><code>private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
          {
              if (e.Button == MouseButtons.Left)
              {
                  label1.Visible = true;
                  label4.Visible = true;
                  if (wireObject1 == null)
                  {
                  }
                  else
                  {
                      float t = wireObject1.GetIndexByXY(e.X, e.Y, 5);
  
                      if (t == -1)
                      {
                          button3.Enabled = false;
                      }
                      else
                      {
                          if (pointDeletion == false)
                          {
                              button3.Enabled = true;
                          }
                          else
                          {
                              button3.Enabled = false;
                          }
                          {
                              selectedIndex = t;
                              mouseMove = true;
                              OriginalX = wireObject1._point_X[(int)selectedIndex];
                              OriginalY = wireObject1._point_Y[(int)selectedIndex];
  
  
  
                              if (cyclicSelectedIndex.Count() == 2)
                              {
  
                                  cyclicSelectedIndex[currentCyclicIndex] = (int)selectedIndex;
                                  currentCyclicIndex++;
                                  if (currentCyclicIndex == 2)
                                  {
                                      currentCyclicIndex = 0;
                                  }
                                  if ((cyclicSelectedIndex[0] == cyclicSelectedIndex[1]) || (cyclicSelectedIndex[0] == -1) || (cyclicSelectedIndex[1] == -1))
                                  {
                                      button2.Enabled = false;
                                  }
                                  else
                                  {
                                      button2.Enabled = true;
                                  }
  
                                  for (int i = 0; i &lt; wireObject1._connectionstart.Count; i++)
                                  {
                                      if ((wireObject1._connectionstart[i] == cyclicSelectedIndex[0] &amp;&amp; wireObject1._connectionend[i] == cyclicSelectedIndex[1]) ||
                                         (wireObject1._connectionstart[i] == cyclicSelectedIndex[1] &amp;&amp; wireObject1._connectionend[i] == cyclicSelectedIndex[0]) ||
                                          wireObject1._connectionstart[i] == cyclicSelectedIndex[0] || wireObject1._connectionend[i] == cyclicSelectedIndex[1] ||
                                           wireObject1._connectionstart[i] == cyclicSelectedIndex[1] || wireObject1._connectionend[i] == cyclicSelectedIndex[0])
                                      {
                                          button3.Enabled = false;
                                      }
  
                                      if ((wireObject1._connectionstart[i] == cyclicSelectedIndex[0] &amp;&amp; wireObject1._connectionend[i] == cyclicSelectedIndex[1]) ||
                                         (wireObject1._connectionstart[i] == cyclicSelectedIndex[1] &amp;&amp; wireObject1._connectionend[i] == cyclicSelectedIndex[0]))
                                      {
                                          button2.Enabled = false;
                                      }
  
                                      if ((wireObject1._connectionstart[i] == cyclicSelectedIndex[0]) &amp;&amp; (wireObject1._connectionend[i] == cyclicSelectedIndex[1]) ||
                                          (wireObject1._connectionstart[i] == cyclicSelectedIndex[1]) &amp;&amp; (wireObject1._connectionend[i] == cyclicSelectedIndex[1]) ||
                                          (wireObject1._connectionstart[i] == cyclicSelectedIndex[0]) &amp;&amp; (wireObject1._connectionend[i] == cyclicSelectedIndex[0]) ||
                                          (wireObject1._connectionstart[i] == cyclicSelectedIndex[1]) &amp;&amp; (wireObject1._connectionend[i] == cyclicSelectedIndex[0]))
                                      {
                                          button4.Enabled = true;
  
                                      }
                                      else
                                      {
                                          button4.Enabled = false;
                                      }  
                                  }
                                  label13.Text = selectedIndex.ToString();
                                  label13.Visible = true;
                                  label14.Visible = true;
                                  listView1.Items.Add(selectedIndex.ToString()).EnsureVisible();
                              }
                          }
                      }
                  }
              }
          }
  </code></pre>
  
  <p>I have a button click event, and when i click it's adding(drawing) a point on the <code>pictureBox1</code>.
  So i add/click 6 times and add 6 points.
  Now i can drag them around the <code>pictureBox1</code> area.
  Then i click on another button to draw a line between two selected points.
  When i make the click on a point in the <code>pictureBox</code> mouse down event i select a point then select second point and click to connect them with a line.</p>
  
  <p>In the end i have 6 points with 3 lines each two points are connected between them with a drawn line.</p>
  
  <p>Now what i want to do in the <code>pictureBox</code> mouse down event is that when ever i select two points which are connected with a line between them turn <code>button4.enabled = true</code>.
  If i clicked on any point which is not connect turn <code>button4.enabled = false</code>.</p>
  
  <p>So i tried to do it like this:</p>
  
  <pre><code>if ((wireObject1._connectionstart[i] == cyclicSelectedIndex[0]) &amp;&amp; (wireObject1._connectionend[i] == cyclicSelectedIndex[1]) ||
                                          (wireObject1._connectionstart[i] == cyclicSelectedIndex[1]) &amp;&amp; (wireObject1._connectionend[i] == cyclicSelectedIndex[1]) ||
                                          (wireObject1._connectionstart[i] == cyclicSelectedIndex[0]) &amp;&amp; (wireObject1._connectionend[i] == cyclicSelectedIndex[0]) ||
                                          (wireObject1._connectionstart[i] == cyclicSelectedIndex[1]) &amp;&amp; (wireObject1._connectionend[i] == cyclicSelectedIndex[0]))
                                      {
                                          button4.Enabled = true;
  
                                      }
                                      else
                                      {
                                          button4.Enabled = false;
                                      }  
  </code></pre>
  
  <p>But its not working in all cases .</p>
  
  <p>Now:</p>
  
  <p><code>wireObject1._connectionstart</code> is a <code>List&lt;int&gt;</code> and also <code>wireObject1._connectionend</code> is a <code>List&lt;int&gt;</code> they are containing the starting and ending of each connected/line between two points.</p>
  
  <p><code>cyclicSelectedIndex</code> is <code>List&lt;int&gt;</code>. [0] contain the first clicked/selected point and [1] the second selected/clicked point.</p>
  
  <p>What i did when i click on a point so its doing : wireObject1.GetIndexByXY
  which find the nearest center of the point i clicked so i know i selected this point i wanted and not one near it .</p>
  
  <hr>
  
  <p>In the end what i need is to check when click/select two points if they are connected with a line(connection) between them <code>button4.enabled = true</code> ELSE <code>button4.enabled = false</code>.</p>
  
  <p>( I know the code and descriptions are long tried to make it shortest as i can sorry )</p>