Пример #1
0
 /// <summary>
 /// Draws the gate onto the circuit, and any
 /// wires that may be connected to them.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Form1_Paint(object sender, PaintEventArgs e)
 {
     foreach (Gate g in gates)
     {
         g.Draw(e.Graphics);
     }
     foreach (Wire w in wires)
     {
         w.Draw(e.Graphics);
     }
     if (startPin != null)
     {
         e.Graphics.DrawLine(Pens.White, startPin.X, startPin.Y, currentX, currentY);
     }
     if (newGate != null)
     {
         // show the gate that we are dragging into the circuit
         newGate.MoveTo(currentX, currentY);
         newGate.Draw(e.Graphics);
     }
 }
Пример #2
0
 private void Form1_MouseMove(object sender, MouseEventArgs e)
 {
     if (startPin != null)
     {
         Debug.WriteLine("wire from " + startPin + " to " + e.X + "," + e.Y);
         currentX = e.X;
         currentY = e.Y;
         this.Invalidate();  // this will draw the line
     }
     else if (startX >= 0 && startY >= 0 && current != null)
     {
         Debug.WriteLine("mouse move to " + e.X + "," + e.Y);
         current.MoveTo(currentX + (e.X - startX), currentY + (e.Y - startY));
         this.Invalidate();
     }
     else if (newGate != null)
     {
         currentX = e.X;
         currentY = e.Y;
         this.Invalidate();
     }
 }