I’m overriding GoTextNode. I’m trying to supply an alternate rendering of the text by overriding the Paint() and ComputeBounds() methods. However, this seems to break the selection tool.
This is the code for a node which overrides GoTextNode. There’s a
custom Paint() function, and a custom ComputeBounds() function. Paint
happily paints the big red square created in the ctor. ComputeBounds
happily gives it enough space to be drawn. But the selection tool does
not allow you to select the red square; it seems to use the underlying
mybase.ComputeBounds function, or something close…
Public Class GoBadSelectionNode
Dim _picture As Image
’ Set some node text
Me.Text = “short”
’ create a big red square
_picture = New Bitmap(100, 100)
Dim g As Graphics = Graphics.FromImage(_picture)
’ invalidate the bounds to force a recalc
Me.InvalidBounds = True
Public Overrides Sub Paint(ByVal g As System.Drawing.Graphics, ByVal view As Northwoods.Go.GoView)
g.DrawImage(_pic ture, Me.Bounds.Left, Me.Bounds.Top, Me.Bounds.Width,
Protected Overrides Function ComputeBounds() As System.Drawing.RectangleF
Dim baseRect As RectangleF = MyBase.ComputeBounds()
If _picture Is Nothing Then
&nbs p; '
this is necessary because ComputeBounds is called on mybase.New(),
before _picture has been set.
Return New RectangleF(baseRect.X, baseRect.Y, _picture.Width,
I’m adding one such node to a GoView with the call
Have I missed something? Is there something I have to do to get the selection tool to select within it’s new bounds?
Thanks for any light you might be able to shed on it…