c# 如何制作屏幕画笔
2016-02-01
展开全部
//鼠标按下时开始标记
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();
}
追问
请问 SingleImageShowForm是指什么,是form1吗?
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2016-01-31
展开全部
大致思路就是 弄个笔的模型 然后使用GDI+
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询