3个回答
展开全部
//鼠标按下时开始标记
private void SingleImageShowForm_MouseDown(object sender, MouseEventArgs e)
{
//设置鼠标图象为铅笔图象
Cursor signCursor = new Cursor(Application.StartupPath + "\\pen.ico");
this.Cursor = signCursor;
//设置开始标记的点
mobjStartPoint = new Point(e.X - 8, e.Y + 8);
mobjPointsArray = new ArrayList();
Pen pen = new Pen(MobjPen.Color,MobjPen.Width);
mobjPointsArray.Add(pen);
mobjPointsArray.Add(mobjStartPoint);
MblStartDrawing = true;
}
//记录移动的点
private void SingleImageShowForm_MouseMove(object sender, MouseEventArgs e)
{
try
{
//移动中进行画图
if (MblStartDrawing)
{
//path.StartFigure();
Point currentPoint = new Point(e.X - 10, e.Y + 10);
mobjPointsArray.Add(currentPoint);
this.CreateGraphics().DrawLine(MobjPen, mobjStartPoint, currentPoint);
mobjStartPoint = currentPoint;
}
else
{
if (Cursor.Position.X >= MobjToolBarForm.Left - 5 && Cursor.Position.X <= MobjToolBarForm.Right + 5 &&
Cursor.Position.Y >= MobjToolBarForm.Top - 5 && Cursor.Position.Y <= MobjToolBarForm.Bottom + 5)
{
MobjToolBarForm.Focus(); //如果鼠标位于工具栏上,转移焦点到工具栏
}
else
{
this.Focus(); //转移焦点到窗口
}
}
}
catch(Exception ex)
{
if (MessageBox.Show("画图错误,错误信息:\"" + ex.Message + "\"") == DialogResult.OK)
{
this.Close();
}
}
}
//松开鼠标时画图结束
private void SingleImageShowForm_MouseUp(object sender, MouseEventArgs e)
{
this.Cursor = Cursors.Arrow;
MblStartDrawing = false;
MobjPointsArrayContainer.Add(mobjPointsArray);
mobjPointsArray = null;
Invalidate();
}
如还有问题欢迎探讨.
private void SingleImageShowForm_MouseDown(object sender, MouseEventArgs e)
{
//设置鼠标图象为铅笔图象
Cursor signCursor = new Cursor(Application.StartupPath + "\\pen.ico");
this.Cursor = signCursor;
//设置开始标记的点
mobjStartPoint = new Point(e.X - 8, e.Y + 8);
mobjPointsArray = new ArrayList();
Pen pen = new Pen(MobjPen.Color,MobjPen.Width);
mobjPointsArray.Add(pen);
mobjPointsArray.Add(mobjStartPoint);
MblStartDrawing = true;
}
//记录移动的点
private void SingleImageShowForm_MouseMove(object sender, MouseEventArgs e)
{
try
{
//移动中进行画图
if (MblStartDrawing)
{
//path.StartFigure();
Point currentPoint = new Point(e.X - 10, e.Y + 10);
mobjPointsArray.Add(currentPoint);
this.CreateGraphics().DrawLine(MobjPen, mobjStartPoint, currentPoint);
mobjStartPoint = currentPoint;
}
else
{
if (Cursor.Position.X >= MobjToolBarForm.Left - 5 && Cursor.Position.X <= MobjToolBarForm.Right + 5 &&
Cursor.Position.Y >= MobjToolBarForm.Top - 5 && Cursor.Position.Y <= MobjToolBarForm.Bottom + 5)
{
MobjToolBarForm.Focus(); //如果鼠标位于工具栏上,转移焦点到工具栏
}
else
{
this.Focus(); //转移焦点到窗口
}
}
}
catch(Exception ex)
{
if (MessageBox.Show("画图错误,错误信息:\"" + ex.Message + "\"") == DialogResult.OK)
{
this.Close();
}
}
}
//松开鼠标时画图结束
private void SingleImageShowForm_MouseUp(object sender, MouseEventArgs e)
{
this.Cursor = Cursors.Arrow;
MblStartDrawing = false;
MobjPointsArrayContainer.Add(mobjPointsArray);
mobjPointsArray = null;
Invalidate();
}
如还有问题欢迎探讨.
展开全部
把窗体设置为画板,并且设为透明色,启动时最大化且至于底层。然后只需要用Move事件和鼠标单击事件作为路径画画就可以啦。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-04-01
展开全部
f="http://hi.baidu.com/qiujiejia/blog/item/5ec37482819e41af6c811991.html" target="_blank">http://hi.baidu.com/qiujiejia/blog/item/5ec37482819e41af6c811991.html
另外,虚机团上产品团购,超级便宜
另外,虚机团上产品团购,超级便宜
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询