private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { bMouseDown = true; picBoard.Capture = true; }
private void picBoard_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) {
bMouseDown = false;
picBoard.Capture = false;
OldPos = new Point(-1,-1);
}
private void picBoard_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) {
if (bMouseDown){
Graphics g = picBoard.CreateGraphics();
g.SmoothingMode = SmoothingMode.AntiAlias; // mode antialiasing
Pen pen = new Pen(PenColor,3); // couleur courante, épaisseur 3
if (OldPos!=new Point(-1,-1)){
g.DrawLine(pen,OldPos,new Point(e.X,e.Y)); // tracé de la ligne
};
OldPos = new Point( e.X, e.Y );
};
}
private void button1_Click(object sender, System.EventArgs e) {
DlgColor.Color = PenColor;
if (DlgColor.ShowDialog() == DialogResult.OK)
PenColor = DlgColor.Color; // nouvelle couleur de dessin
}
|