关于mousedown、mouseup、mousemove、C#
privatevoidtoolStripButton3_Click_1(objectsender,EventArgse){this.pbImg.MouseDown+=ne...
private void toolStripButton3_Click_1(object sender, EventArgs e)
{
this.pbImg.MouseDown += new MouseEventHandler(toolStripButton3_MouseDown);
this.pbImg.MouseUp += new MouseEventHandler(toolStripButton3_MouseUp);
this.pbImg.MouseMove += new MouseEventHandler(toolStripButton3_MouseMove);
private void FillCircle_Click(object sender, EventArgs e)
{
this.pbImg.MouseDown += new MouseEventHandler(FillCircle_MouseDown);
this.pbImg.MouseUp += new MouseEventHandler(FillCircle_MouseUp);
this.pbImg.MouseMove += new MouseEventHandler(FillCircle_MouseMove);
}
}
如何不让mouseup、mousedown、mousemove反复执行,画直线的时候就画直线,画矩形的时候就画矩形
错误的事例如下图矩形和直线同时画 展开
{
this.pbImg.MouseDown += new MouseEventHandler(toolStripButton3_MouseDown);
this.pbImg.MouseUp += new MouseEventHandler(toolStripButton3_MouseUp);
this.pbImg.MouseMove += new MouseEventHandler(toolStripButton3_MouseMove);
private void FillCircle_Click(object sender, EventArgs e)
{
this.pbImg.MouseDown += new MouseEventHandler(FillCircle_MouseDown);
this.pbImg.MouseUp += new MouseEventHandler(FillCircle_MouseUp);
this.pbImg.MouseMove += new MouseEventHandler(FillCircle_MouseMove);
}
}
如何不让mouseup、mousedown、mousemove反复执行,画直线的时候就画直线,画矩形的时候就画矩形
错误的事例如下图矩形和直线同时画 展开
2个回答
展开全部
在add之前先remove掉就行了:
private void toolStripButton3_Click_1(object sender, EventArgs e)
{
this.pbImg.MouseDown -= new MouseEventHandler(FillCircle_MouseDown);
this.pbImg.MouseUp -= new MouseEventHandler(FillCircle_MouseUp);
this.pbImg.MouseMove -= new MouseEventHandler(FillCircle_MouseMove);
this.pbImg.MouseDown += new MouseEventHandler(toolStripButton3_MouseDown);
this.pbImg.MouseUp += new MouseEventHandler(toolStripButton3_MouseUp);
this.pbImg.MouseMove += new MouseEventHandler(toolStripButton3_MouseMove);
}
private void FillCircle_Click(object sender, EventArgs e)
{
this.pbImg.MouseDown -= new MouseEventHandler(toolStripButton3_MouseDown);
this.pbImg.MouseUp -= new MouseEventHandler(toolStripButton3_MouseUp);
this.pbImg.MouseMove -= new MouseEventHandler(toolStripButton3_MouseMove);
this.pbImg.MouseDown += new MouseEventHandler(FillCircle_MouseDown);
this.pbImg.MouseUp += new MouseEventHandler(FillCircle_MouseUp);
this.pbImg.MouseMove += new MouseEventHandler(FillCircle_MouseMove);
}
}
private void toolStripButton3_Click_1(object sender, EventArgs e)
{
this.pbImg.MouseDown -= new MouseEventHandler(FillCircle_MouseDown);
this.pbImg.MouseUp -= new MouseEventHandler(FillCircle_MouseUp);
this.pbImg.MouseMove -= new MouseEventHandler(FillCircle_MouseMove);
this.pbImg.MouseDown += new MouseEventHandler(toolStripButton3_MouseDown);
this.pbImg.MouseUp += new MouseEventHandler(toolStripButton3_MouseUp);
this.pbImg.MouseMove += new MouseEventHandler(toolStripButton3_MouseMove);
}
private void FillCircle_Click(object sender, EventArgs e)
{
this.pbImg.MouseDown -= new MouseEventHandler(toolStripButton3_MouseDown);
this.pbImg.MouseUp -= new MouseEventHandler(toolStripButton3_MouseUp);
this.pbImg.MouseMove -= new MouseEventHandler(toolStripButton3_MouseMove);
this.pbImg.MouseDown += new MouseEventHandler(FillCircle_MouseDown);
this.pbImg.MouseUp += new MouseEventHandler(FillCircle_MouseUp);
this.pbImg.MouseMove += new MouseEventHandler(FillCircle_MouseMove);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |