Drawing Primitives

Any examples how one would allow the user to draw primitives such as Rectangle, Line, Arc, Circle, etc directly on the Diagram?

Do you mean something like the StrokeDrawingTool and/or PolygonDrawingTool that are in the Demo1 sample?
Or do you mean using the ink interfaces with the TabletPC?

Ah yes…I see them in the demo…great…
Unless you have quick example of other primitives…

I’m not sure it would make sense for someone to try to draw a rectangle by specifying the four corner points. The same goes for most other shapes, which is why the StrokeDrawingTool and PolygonDrawingTool are really the only ones like it.
Perhaps you want to use GoToolCreating? I guess I still don’t understand what you want users to be able to do.

I want to create a tool to allow the users to create custom shapes…
Basically something to draw a line, arc, rect, circle, elipse, text, ports, etc.
And then I will use the info to create GoGroup…
I did not understand the GoToolCreating…what does it do?

Here is what I ended up with…

<Serializable()> Public Class RectDrawingTool
Inherits GoTool
Private startpoint As System.Drawing.PointF
Private myRect As GoRectangle = Nothing
Public Sub New(ByVal view As GoView)
MyBase.new(view)
End Sub
Public Overrides Sub Start()
MainForm.App.SetStatusMessage(“Drawing mode – click and drag to draw reactangle”)
Me.View.Cursor = Cursors.Cross
End Sub
Public Overrides Sub Stop
If Not (myRect Is Nothing) Then
myRect.Remove()
myRect = Nothing
End If
Me.View.Cursor = Me.View.DefaultCursor
MainForm.App.SetStatusMessage(“Stopped drawing mode”)
End Sub
Public Overrides Sub DoMouseDown()
If (myRect Is Nothing) Then
myRect = New GoRectangle()
startpoint = Me.FirstInput.DocPoint
setbounds()
Me.View.Layers.Default.Add(myRect)
End If
End Sub
Public Overrides Sub DoMouseMove()
If Not (myRect Is Nothing) Then
setbounds()
End If
End Sub
Public Overrides Sub DoMouseUp()
If Not (myRect Is Nothing) Then
setbounds()
myRect.Remove()
Me.View.Document.Add(myRect)
myRect = Nothing
'StopTool()
End If
End Sub

Private Sub setbounds()
Dim startx As Integer
Dim starty As Integer
Dim width As Integer
Dim height As Integer
If startpoint.X < Me.LastInput.DocPoint.X Then
startx = startpoint.X
width = Me.LastInput.DocPoint.X - startx
Else
startx = Me.LastInput.DocPoint.X
width = startpoint.X - startx
End If
If startpoint.Y < Me.LastInput.DocPoint.Y Then
starty = startpoint.Y
height = Me.LastInput.DocPoint.Y - starty
Else
starty = Me.LastInput.DocPoint.Y
height = startpoint.Y - starty
End If
myRect.Bounds = New System.Drawing.Rectangle(startx, starty, width, height)
End Sub
End Class

You give a GoToolCreating tool instance a prototype object, and when the user drags in the background (or anywhere if the tool is modal) the tool will add a copy of the object to the document with bounds from the mouse down to the mouse up point.
Hmmm, I suppose we ought to add a mode in Demo1 that uses that tool, for demonstration purposes.