C#画线问题

acui145 2012-04-10 10:06:06
System.Drawing.Point startPoint;
System.Drawing.Point endPoint;
Graphics g;
Pen p = new Pen(Color.Red, 4);
int i;
private void 画线ToolStripMenuItem_Click(object sender, EventArgs e)
{
i = 0;
g = axMapControl1.CreateGraphics();
}
private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
{
if (i == 0)
{
startPoint = new System.Drawing.Point();
startPoint.X = (int)e.mapX;
startPoint.Y = (int)e.mapY;
//startPoint.X = e.x;
//startPoint.Y = e.y;

i++;
return;
}
if (i == 1)
{
endPoint = new System.Drawing.Point();
endPoint.X =(int) e.mapX;
endPoint.Y = (int)e.mapY;
//endPoint.X = e.x;
//endPoint.Y = e.y;
i--;
g.DrawLine(p, startPoint,endPoint);
}
}
在安axmapcontrol1中画线,现在出现几个问题,在图上点两个点,可是线出现的其他的地方了;还有就是一刷新线就不在了……
...全文
160 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
nvshenxp 2012-04-17
  • 打赏
  • 举报
回复
你的坐标没有计算正确吧,另外,如果想直线一直显示的话要写到控件的重绘函数中去。
  • 打赏
  • 举报
回复
http://blog.csdn.net/xianfajushi/article/details/3100404嘿嘿
upc_xiaowei 2012-04-10
  • 打赏
  • 举报
回复
一刷新当然会没了啊,你得在控件的paint事件里写才行,或者用picturebox这个控件,一般不会没有了。
ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e这是什么东西啊,我没见过
shashengduguzhe 2012-04-10
  • 打赏
  • 举报
回复
刷新后直线不存在,是因为相关的划线代码存放的触发事件不对。 线出现在其他位置是因为相对的坐标点数据计算错误。

111,125

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧