In our application we have multiple views of the same document. For every view we want to highlight different nodes (e.g. by using a different background color). In other words, we want some nodes to be painted differently in different views. How can this best be achieved? Can this be done without making temporary modifications to the document before every view is painted? I guess it would be possible to override GoObject.Paint for the nodes and there decide how to draw the node depending on which view we are in, but is that the recommended way to do it?
You have the right idea – you cannot modify the document object when its Paint method is called, so you have to behave differently depending on which GoView the Paint method is being called for.
You might want to define your own GoView-inheriting class that adds a property (or several) that your GoObject.Paint method will want to use to decide what to draw. That way you can easily customize different views with different special-node-background-colors.
A predefined example of this is how shadows are drawn. Each Paint method, if it supports painting with a shadow, checks the GoObject.Shadowed property, and if true calls the GoObject.GetShadow... methods to determine what and how to draw. For example, GoObject.GetShadowOffset(GoView) just returns the GoView.ShadowOffset property of the argument GoView.
I don't know what kind of "highlighting" effect you want. You could consider doing something like what the LitIconicNode example class does in Demo1. But instead of having HighlightColor be a property implemented as a field on the node, you could implement it by getting the value from the custom GoView class.