when i connect for example 14 points with lines and try to move them its moving very very slow whats making it to move that slow?
<p>This is the paint event:</p>

<pre><code>private void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            SolidBrush brush;
            Pen p=null;
           Point connectionPointStart;
           Point connectionPointEnd;
           Graphics g = e.Graphics;
           g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
               brush = new SolidBrush(Color.Red);
               p = new Pen(brush);
               for (int idx = 0; idx &lt; wireObject1._point_X.Count; ++idx)
               {
                   Point dPoint = new Point((int)wireObject1._point_X[idx], (int)wireObject1._point_Y[idx]);
                   dPoint.X = dPoint.X - 5; // was - 2
                   dPoint.Y = dPoint.Y - 5; // was - 2
                   Rectangle rect = new Rectangle(dPoint, new Size(10, 10));
                   g.FillEllipse(brush, rect);


               }

               for (int i = 0; i &lt; wireObject1._connectionstart.Count; i++)
               {

                   int startIndex = wireObject1._connectionstart[i];
                   int endIndex = wireObject1._connectionend[i];



                   connectionPointStart = new Point((int)wireObject1._point_X[startIndex], (int)wireObject1._point_Y[startIndex]);
                   connectionPointEnd = new Point((int)wireObject1._point_X[endIndex], (int)wireObject1._point_Y[endIndex]);
                   p.Width = 4;
                   g.DrawLine(p, connectionPointStart, connectionPointEnd);
                   moveCounter++;
                   textBox1.Text = moveCounter.ToString();
               }

        }
</code></pre>

<p>On the loop in the bottom im running over the _connectionstart List wich is type of int.</p>

<p>I added a int variable i called it moveCounter to see how many time its calling this loop and drawing the lines.</p>

<p>If im adding two points over the pictureBox1 connect them with one line then drag one of the points around its moving smooth. Same thing with 3 connected points and with 7 connected points but when im getting to 9-10 points connected with many lines and try to move it drag it around or any point that is not connected everything is moving very very slow and as much as i add a new connected line between two points its getting slower.</p>

<p>So the problem can be a bug with my loop's in the paint event or that in the move event its doing so many time pictureBox1.refresh();</p>

<p>So i added a timer enabled it true in the designer and set it to 30 miliseconds. In the move event i raise a flag and in the timer tick event i check if the flag is on i make a pictureBox1.refresh(); and reset back the flag. The idea is that when i move the points or the connected points it will do it each 30 miliseconds.</p>

<p>But it didnt solve the problem. Still when i have 9-10 points connected with many lines between them everything is getting very slow.</p>

<p>This is the picturebox1 mouse move event:</p>

<pre><code>private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            if (mouseMove == true)
            {
                mouseDrag = true;
                Point NewPoint = e.Location;
                                  wireObject1.MovePoint(selectedIndex, NewPoint, NewPoint); // when moving a point dragging the other point is vanished deleted. To check why !

                    label1.Text = "{X = " + NewPoint.X + "}" + " " + "{Y = " + NewPoint.Y + "}";
                    refreshFlag = true;
                    timer2.Start();


            }
            else
            {
                label19.Text = "{X = " + e.X + "}" + " " + "{Y = " + e.Y + "}";
            }
        }
</code></pre>

<p>timer2 is another timer i added just to see how many times it moved in 5 seconds. So if timer1 set to 30 miliseconds i should see after 5 seconds something about 150 moves.</p>

<p>So in timer1 tick event i did:</p>

<pre><code>private void timer1_Tick(object sender, EventArgs e)
        {
            if (refreshFlag == true)
            {
                pictureBox1.Refresh();
                refreshFlag = false;
            }
        }
</code></pre>

<p>I was sure the timer1 idea should solve the problem but it didnt. So i wonder where the problem is maybe i did something wrong with the loop's in the paint event ?</p>

<p>The List _connectionstart contain indexs for example if i have two points connected with one line and i clicked on one point and drag this point around wich make the line the be longer or shorter then in _connectionstart for example i have one place/cell [0] wich contain index 0</p>

<p>In the List _point_X i have for example now two cells place in [0] 120.0 and in [1] 180.0 wich are the points coordinates same for the _point_Y List.</p>

<p>Now the question is where is the problem ? A bug in the paint event ? Something with the move event ? I cant figure out why its getting so slow when it have 9-10 points connecting with a lot of lines between them.</p>

<p>For example i tested now with two points connected with a line i moved one point around wich stretch the line longer or shorter and after 5 seconds the result was 160 moves counted then after another 5 seconds it was 323 and so on. So it seems to be working the timer1 and the 30 miliseconds or im wrong ?</p>
