C#可拖动的图形和图形包含 [英] C# drag able graphic and graphic contains

查看:57
本文介绍了C#可拖动的图形和图形包含的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何在窗体上画一条线,但我不知道如何使图形在面板中能够拖动,并且如果图形触摸该面板中的控件之类的东西,例如会发生某些事情.


I know how to draw a line on a form but I don''t know how to make that graphic drag able in a panel and if the graphic touches something like a control in that panel something will happen for example.


draw graphic = Gr

panel1 mouse_move
{
if (mouse = down)
Gr = mouse.X.Y
}

Gr_Move
{
if (Gr.contains(label1)
{
msgbox.show("Hey You got me!")
}
}



它不是正确的代码,也不是真正的代码,但这就是我要解决的问题,有点像带有图片框的拖动,但是这与图形有关,有人可以帮我构造这个吗?我确实有一个picurebox版本,没有绘制图形.



its not proper code, not really code at all, but thats just how i want to to work out, its kinda like the drag with a picturebox but this is with the graphic, can anyone please help me construct this? I do have a picurebox version of this with-out the drawn graphic.

推荐答案



您需要保留所有交互式对象的列表,其中包含x,y,宽度和高度或左,右,顶部和底部位置. System.Drawing.Rectangle对象会同时执行两个操作.

以下是一个简单的拖放教程,它将向您展示如何拖动图像.

简单的拖放方法示例 [ ^ ]

您需要扩展它以在拖动时检查图像的边缘是否与任何交互式控件重叠.
Hi,

You need to keep a list of all the interactive objects which contains the x, y, width and height or left, right, top and bottom positions. The System.Drawing.Rectangle object does both.

The following is a simple drag and drop tutorial which will show you how to drag an image.

A Simple Drag And Drop How To Example[^]

You''ll need to extend this to check, whilst dragging, if the edges of the image overlap with any of the interactive controls.


这篇关于C#可拖动的图形和图形包含的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆