实现 MS Access 风格的“关系” 图形用户界面
我不知道这种 UI 风格的正确名称是什么。 在 MS Access 中,“关系”工具将数据库表显示为可以用线链接的可移动小框。 Visio 和一些音频应用程序也是如此 - 可移动的框,包含可以以有意义的方式连接在一起的文本行。
我如何使用 Visual Studio 2008 和 C# 在 .NET 中创建类似的东西? 我以前从未创建过自己的控件。
这是我的意思的图片:单击示例
I have no idea what the correct name for this UI style is. In MS Access the 'relationships' tool shows the db tables as little movable boxes that can be linked with lines. It's the same with Visio and a few audio apps - boxes that are movable, containing lines of text that can be joined together in a meaningful way.
How could I create a similar thing in .NET using Visual Studio 2008 and C#? I've never created my own controls before.
Here's an image of the sort of thing I mean: Click for example
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要两个主要的自定义控件:主视图和表格控件。
表格控件负责绘制自身及其所有列,并确保该项目可以在需要时滚动。 它还负责为指定的行标题提供 x/y 坐标。 这样关系线就可以匹配到正确的行。
主视图负责接受表格对象列表(存储在自定义表格对象中),创建相同数量的表格控件并按指定顺序排列它们。 它还负责绘制表格控件之间的线条。
总而言之,这并不是一件小事。 您需要重写这两个控件的 OnPaint() 方法来完成所有这些自定义绘图。 对 GDI+ 图形例程进行一些研究,找出可以使用哪些方法来绘制它。 您可能最常使用这些对象/方法:
您还需要捕获各种鼠标事件以允许移动控件。 这可以通过重写诸如
OnMouseDown
或OnMouseMove
之类的方法来完成。祝你好运。
You'll need two main custom controls: the main view and the table control.
The table control is responsible for drawing itself with all of its columns and ensuring that the item can scroll if need be. It is also responsible for providing an x/y co-ordinate for a specified row header. This is so that the relationship lines can match up to the correct row.
The main view is responsible for accepting a list of table objects (stored in a custom table object), creating the same number of table controls and arranging them in a specified order. It is also responsible for drawing the lines between the table controls.
All in all, this is not trivial. You'll want to override the OnPaint() method of both these controls to do all this custom drawing. Do some research on the GDI+ graphics routines to find out what methods you can use to draw this. You'll probably be using these objects/methods most often:
You'll also need to trap all kinds of mouse events to enable moving the controls around. This can be done by overriding methods such as
OnMouseDown
orOnMouseMove
.Good luck.
您尝试绘制的图表是 ERD 或数据库设计。 您可能还在寻找类图。
你想要做的事情非常复杂。
以下是一些可能有帮助的链接。 这些都是用于绘制图表的开源类型 UML 工具。
http://imar.spaanjaars.com /501/automatically-generate-class-diagrams-from-a-type-using-reflection
http:// www.codebydesign.com/
http://sourceforge.net/projects/use- case-maker/
http://projects.gnome.org/dia/
http://www.monouml.org/doku.php?id=documentation
The diagram you are trying to draw is an ERD or Database design. What you might also be looking for is a Class Diagram.
What you are trying to do is pretty complex.
Here are some links that might help. These are all open source type UML tools that do diagraming.
http://imar.spaanjaars.com/501/automatically-generating-class-diagrams-from-a-type-using-reflection
http://www.codebydesign.com/
http://sourceforge.net/projects/use-case-maker/
http://projects.gnome.org/dia/
http://www.monouml.org/doku.php?id=documentation