日期:2014-05-18  浏览次数:20980 次

Graphics绘图中rectangle的tooltip提示和鼠标双击相应问题。
我的情况是为了实现缩放和滚动条,form中建立了panel,panel中创建了pictrueBox,pictrueBox中新建一张空白bitmap,使用Graphics.FromImagg在这张空白bitmap上绘图。

图中根据需要用
C# code

Rectangle[,] RectArray = new Rectangle[111, 51];
            for (int x = 1; x <= 110; x++)
            {
                for (int y = 1; y <= 50; y++)
                {
                    RectArray[x, y] = new Rectangle(rounddoubletoint(12 * x * k - 4 * k), rounddoubletoint(12 * y * k - 4 * k), rounddoubletoint(8 * k), rounddoubletoint(8 * k));
                    gph.DrawEllipse(mypen1, RectArray[x, y]);
                    gph.FillEllipse(mySolidBrush1, RectArray[x, y]);

                }
            }

代码中gph为Graphics实例,k为1,rounddoubletoin()为转换double四舍五入到int。
绘制了5000多个圆形,现在我想鼠标移动在上面的时候,tooltip显示所处Rectangle在graphics中的坐标,并且双击的时候进行相应,不知道应该如何实现。

------解决方案--------------------
MouseMove事件
MouseDoubleClick事件