在winform下,如何显示浮动标签效果

abutwang 2012-05-29 06:53:24


要求类似GIS,有颜色的标签可以任意移动,但是和测点的连线根据标签的位置自动改变,图像放大或者缩小不会改变表示

考虑用类似gis实现,但是winform里没做过类似效果,请各位指点下,应该用什么控件

...全文
252 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
abutwang 2012-05-29
  • 打赏
  • 举报
回复
自己顶下
bdmh 2012-05-29
  • 打赏
  • 举报
回复
自己画

Point p = new Point(0, 0); //这个是测点,根据需要改
Rectangle rect = new Rectangle(10, 10, 50, 50);//浮动框的初始位置
bool _mousedown = false;//鼠标是否按下
int _x, _y;//初始x,y坐标

//自画事件,先画矩形,然后划一根线,和矩形的左下角相连
private void Form2_Paint(object sender, PaintEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Red, this.rect);
e.Graphics.DrawLine(Pens.Red, this.p, new Point(this.rect.Left,this.rect.Bottom));
}

//以下是鼠标动作,当鼠标点在rect范围内时,有效,可以拖动
private void Form2_MouseDown(object sender, MouseEventArgs e)
{
if (this.rect.Contains(e.Location))
{
this._mousedown = true;
this._x = e.X;
this._y = e.Y;
}
}

private void Form2_MouseUp(object sender, MouseEventArgs e)
{
this._mousedown = false;
}

private void Form2_MouseMove(object sender, MouseEventArgs e)
{
if (!this._mousedown) return;
//重置拖动区域的位置
this.rect.Location = new Point(e.X - this._x,e.Y - this._y);
this.Invalidate();
}
abutwang 2012-05-29
  • 打赏
  • 举报
回复
abutwang 2012-05-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]
TatukGIS Developer Kernel.NET 10.3.1

MapDotNet UX 8.3.0

AspMap 4.6.2
[/Quote]

有无破解啊,呵呵

110,534

社区成员

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

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

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