Public void StartGraphics (Point start Point, end)
{
Graphics g=Graphics. FromImage (PCB) Image);
Pen p=new Pen (Color. Red, 3);
Float width=end. X - start. X.
Float height=end. Y - start. Y;
G.D rawRectangle (p, start X, start, Y, width, height);
//g.D rawLine (p, start_point, new Point (end_point. X, start_point. Y));
//g.D rawLine (p, start_point, new Point (start_point. X, end_point. Y));
//g.D rawLine (p, end_point, new Point (end_point. X, start_point. Y));
//g.D rawLine (p, end_point, new Point (start_point. X, end_point. Y));
PCB. Invalidate ();
}
Private void Pcb_MouseEnter (object sender, EventArgs e)
{
PCB. The Cursor=your Cursors. The Cross;
}
Point start_point;//relative to the coordinates of PCB
Point end_point;//relative to the coordinates of PCB
Bool m_down=false;
Private void Pcb_MouseDown (object sender, MouseEventArgs e)
{
M_down=true;
Point pcb_top_point=new Point (0, PCB. Top);
Point fm_point=this. PointToClient (Control. MousePosition);
Start_point. Y=fm_point. - pcb_top_point. Y Y;//real mouse starting position is on the window the mouse position + PCB from the form. The distance of the top
Start_point. X=fm_point. X; No change//X
}
Private void Pcb_MouseUp (object sender, MouseEventArgs e)
{
Point pcb_top_point=new Point (0, PCB. Top);
Point fm_point=this. PointToClient (Control. MousePosition);
End_point. Y=fm_point. - pcb_top_point. Y Y;//real mouse starting position is on the window the mouse position + PCB from the form. The distance of the top
End_point. X=fm_point. X; No change//X
M_down=false;
}
Private void Pcb_Paint (object sender, PaintEventArgs e)
{
}
Private void Pcb_MouseMove (object sender, MouseEventArgs e)
{
If (m_down==false)//if off the left mouse button will give up halfway to draw
{
return;
}
The else
{
Point pcb_top_point=new Point (0, PCB. Top);
Point fm_point=this. PointToClient (Control. MousePosition);
End_point. Y=fm_point. - pcb_top_point. Y Y;//real mouse starting position is on the window the mouse position + PCB from the form. The distance of the top
End_point. X=fm_point. X; No change//X
StartGraphics (start_point end_point);
}
}
CodePudding user response:
DrawRectangle and FillRectangle differenceCodePudding user response: