ウィンドウのように線を描画する方法ペイントは固定された最初の点を1回クリックし、2番目の点(および線)はマウスで移動し、もう1回クリックすると線が固定されます。c#ドラッグして線を引く方法
int x = 0, y = 0;
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
// Create the graphics object
Graphics g = CreateGraphics();
// Create the pen that will draw the line
Pen p = new Pen(Color.Navy);
// Create the pen that will erase the line
Pen erase = new Pen(Color.White);
g.DrawLine(erase, 0, 0, x, y);
// Save the mouse coordinates
x = e.X; y = e.Y;
g.DrawLine(p, 0, 0, x, y);
}
クリックイベントの一部は正常であるが、上記のこの方法では、消去線は、実際には他の背景画像の上に重なって以前に青い線をプロットした白線です。
もっと管理しやすい方法がありますか?ありがとう
その後、結果の画像を保存しますか? – Takarii