Custom a node


#1

Hi,
Is there any sample code about how to develop a new type of node (like dispaly a user contol as a node)?
Thanks.


#2

In general it’s easiest to inherit from one of the existing node classes. Practically all of the sample classes do this. But some do inherit from the base GoNode class rather than from some more specific node class such as GoTextNode or GoGeneralNode. Here’s the results of a quick search:
Classier\ClassNode.cs(19): public class ClassNode : GoTextNode {
Demo1\AutoLinkNode.cs(24): public class AutoLinkNode : GoGeneralNode {
Demo1\AutoLinkNode.cs(96): public class AutoLinkNodePort : GoGeneralNodePort {
Demo1\ColoredNode.cs(26): public class ColoredNode : GoGeneralNode {
Demo1\ColoredNode.cs(295): public class ColoredNodePort : GoGeneralNodePort {
Demo1\GraphNode.cs(46): public class GraphNode : GoSimpleNode {
Demo1\LimitedNode.cs(23): public class LimitedNode : GoGeneralNode {
Demo1\LimitedNode.cs(272): public class LimitedNodePort : GoGeneralNodePort {
Demo1\LimitedNode.cs(425): public class LimitedWidthIcon : GoNodeIcon {
Demo1\PinNode.cs(17): public class PinNode : GoNode {
Demo1\MultiPortNode.cs(20): public class MultiPortNode : GoIconicNode {
Demo1\MultiTextNodeWithBack.cs(17): public class MultiTextNodeWithBack : GoMultiTextNode {
Demo1\RecordNode.cs(19): public class RecordNode : GoMultiTextNode {
Demo1\SequencedNode.cs(23): public class SequencedNode : GoGeneralNode {
FamilyTree\PersonNode.cs(18): public class PersonNode : GoTextNode {
FlowCharter\GraphNode.cs(42): public class GraphNode : GoTextNode {
LayoutDemo\BasicLayoutNode.cs(18): public class BasicLayoutNode : GoNode {
ObjectBrowser\ObjectNode.cs(17): public class ObjectNode : GoMultiTextNode {
OrgCharter\GraphNode.cs(35): public class GraphNode : GoTextNode {
Processor\ActivityNode.cs(35): public class ActivityNode : GoIconicNode {
Processor\RemoteConnectorNode.cs(20): public class RemoteConnectorNode : GoBasicNode {
ProtoApp\CS\GraphNode.cs(46): public class GraphNode : GoSimpleNode {
TreeApp\TreeAppNode.cs(20): public class TreeAppNode : GoBasicNode {
WebWalker\WebNode.cs(22): public class WebNode : GoBasicNode {
As far as displaying Controls as nodes, it depends on the Control. Basically you want to use the GoControl class, which inherits from GoObject. The simplest use is just to create a GoControl object and set its ControlType property to the Control class that you want it to create. But you’ll probably want to use a subclass of your control class so that you can deal with initialization and focus.
For a slightly more complicated example, look at the RectangleWithCheckBoxEditor class, in the download described by: http://www.nwoods.com/forum/forum_posts.asp?TID=111 This example emphasizes defining an in-place editor (where the Control is only present in a modal fashion as part of a GoView) rather than having the Control be visible all the time because it is part of a GoDocument. But the basic ideas are the same.
The most thorough example is the RichText class, in Demo1. It deals with things that you usually need to deal with, such as focus issues, and with things that you usually do not need to deal with, such as printing and caching images to avoid having a real Control present except when doing in-place editing.


#3

Thanks a lot. Walter.