读书人

在winform上怎么显示浮动标签效果

发布时间: 2012-07-28 12:25:13 作者: rapoo

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


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

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



[解决办法]
TatukGIS Developer Kernel.NET 10.3.1

MapDotNet UX 8.3.0

AspMap 4.6.2
[解决办法]
自己画

C# code
        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();        } 

读书人网 >C#

热点推荐