做一个有类似画图板的界面(部分功能)
操作鼠标,在picturebox的图片上,画线,且能够保存。当前已经可以画线,但是出了一点问题。
按下鼠标左键,拉动鼠标,没有先出现,放开鼠标左键,还是没有线,最后在picturebox上随便找个地方点击左键,刚才那个line直线就出来了,
为什么会这样啊。。
这个是picturebox的paint事件,
private void pb_Pic_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
//Graphics displayGraphics = e.Graphics;
Graphics displayGraphics = Graphics.FromImage(this.pb_Pic.Image);
//Graphics displayGraphics = this.pb_Pic.CreateGraphics();
switch (newType)
{
case ImageType.Line:
displayGraphics.DrawLine(new Pen(newColor, lineWidth), newPoint.StartP, newPoint.EndP);
break;
}
drawingList.DrawList(displayGraphics);
}
这个事鼠标的下压事件mousedown事件
private void pb_Pic_MouseDown_Modify(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
return;
newPoint = new MousePoint(e.X, e.Y);
switch (newType)
{
case ImageType.Text:
newForm.Show();
break;
}
}
这个是mousemove事件
<