|
GoDiagram Concepts
The GoDiagram library, Northwoods.Go, is a set of controls and classes
built on the .NET platform. GoDiagram makes it easy to deliver editors that
allow
users to see and manipulate diagrams of two-dimensional graphical objects
arranged in a scrollable window.
GoDiagram provides a variety of basic graphical objects such as rectangles,
ellipses, polygons, text, images, and lines. You can group objects together
to form more complex objects. You can customize their appearances and
behaviors by setting properties and overriding methods.
GoDiagram View
A GoDiagram view is a control that displays a GoDiagram document. It supports
mouse-based object manipulation, including selecting, resizing, moving
and copying using drag-and-drop. GoDiagram organizes input behaviors into
tools that you can modify, override, or add or remove from a view. The
view also supports in-place editing, printing, and grids.
GoDiagram Document
A GoDiagram document implements a model that supports manipulation of objects.
Adding an object to the document makes it visible in the document's views.
You can organize objects in layers. GoDiagram provides support for composing
and manipulating graphs (node & arc diagrams), where nodes have ports
that are connected by links.
Flexibility and Extensibility
The GoDiagram library is flexible and extensible. Predefined node classes
make it easy to build many kinds of graphs. You can easily customize most
objects for application-specific purposes by setting properties or by
subclassing. You can add completely new graphical objects to the existing
framework.
AutoLayout
To provide greater customizability and ease of use, Northwoods offers,
as a separate option, another library, Northwoods.Go.Layout. This option
extends GoDiagram by providing sophisticated automatic layout algorithms
for nodes in graphs. The AutoLayout component is sold and documented separately.
A True .NET component
GoDiagram is written entirely in C#. It only depends on the standard .NET
Framework classes and does not explicitly call any external functions.
Why GoDiagram is better than an ActiveX control
Using an ActiveX control rather than a .NET control results in broad,
systemic differences in the architecture, interfaces, extensibility, and
usability in the .NET environment, both at design time as well as at run
time.
- ActiveX controls are less safe (implemented in unmanaged code)
- ActiveX controls are slower (requires frequent transitions to unmanaged
code)
- Typical ActiveX controls are not as extensible as GoDiagram (not organized
as classes you can inherit from and call in a type-safe manner)
- ActiveX controls require other large DLLs to run (large downloads
for browser apps)
- ActiveX controls do not offer a model-view-controller architecture
- Can't have multiple views displaying one document in different ways,
such as with different scales or greeking
- Can't define new kinds of
behaviors and swap and share them among views
Sample Program
Here
is the full VB.NET source code to MinimalApp. The screenshot shows
how the MinimalApp appears after selecting the two
initial nodes, drag-copying them, moving them, creating links between
some of them, and then renaming a blue one to blue and
a magenta one to magenta.
Visual Basic:
|
|
|
Public Class MinimalApp |
| |
|
|
Inherits Form
' constructor
Public Sub New() |
| |
|
|
|
MyBase.New()
Me.Text = "Minimal GoDiagram app"
' create a Go view (a Control) and add to the form
Dim myView As GoView = New GoView()
myView.Dock = DockStyle.Fill
Me.Controls.Add(myView)
' create two nodes for fun...
Dim node1 As GoBasicNode = New GoBasicNode()
' specify position, label and color
node1.Location = New PointF(100, 100)
node1.Text = "first"
node1.Editable = True ' first node is editable with F2 only
node1.Brush = Brushes.Blue
' add to the document, not to the view
myView.Document.Add(node1)
Dim node2 As GoBasicNode = New GoBasicNode()
node2.Location = New PointF(200, 100)
node2.Text = "second"
node2.Label.Editable = True ' editable by clicking only
node2.Brush = Brushes.Magenta
myView.Document.Add(node2)
|
| |
|
|
End Sub
Shared Sub Main() |
| |
|
|
|
Application.Run(New MinimalApp()) |
| |
|
|
End Sub
|
| |
|
End Class |
| |
|
|
|
|
|
|