Layout Problem - Stopping

So I have my own “layout” routine that lays out the nodes and elements in my diagram. I just ran into a scenario where the GoView is “laying out” some components of the diagram outside of my custom layout routine.

What is happening is this. I have a bulk programmatic building of the diagram that I have set a property to avoid the “layout” of the diagram as I am doing the addition of each of the elements. This was based on feedback I received on this forum. So the bulk building goes something like this.

MyCustomeDoc.DoLayout = false; (turn off any layout activities)

… bulk programmatic diagram building …

MyCustomDoc.DoLayout = true;

MyCustomView.DoLayout();

Inside the false/true during some of the construction, I am adding two GoComments to the GoDocument directly. For some reason, when I do that it is generating a layout of those two GoComments. I know this because in my custom layout code, I change the background color of the GoComments to a grey vs. the stock lemon color - and I am seeing a flash of the GoComments up in the upper/left corner of the diagram in the lemon background color.

So two questions:

  1. What is triggering this to happen?

  2. How can I actually “turn off” any layouts (or GoView redraw) until I want it to? The apparent mechanism you recommended is not working.

Can you set a breakpoint on the yellow to grey transition and look up the stack?

Unfortunately, I have not found a good place to do that…

Does your DoLayout() method do this:
if (!MyCustomDoc.DoLayout) return;
right at the top? that should turn off all DoLayout activity when you don’t want it to run…
It’s possible that more stuff is happening inside your app than you think, and the layout is being called outside of where you have disable flag set. The fact that you see a flash is interesting… double buffering should make any straight-line code changes to GoObjects not be visible until you return to the idle thread.

Yes it does.

But here is the deal, if any of my custom layout was running the GoComment would be grey. So some other “layout” is being called. At the point this is happening, from what I can tell, the GoComments are the only thing in the document, which is why that is all I am seeing.

Does a GoView (or GoDocument) perform any drawing of the contents based on adding items to the GoDocument?

GoView draws all contents… the OnPaint event is delivered from Windows to fix up invalidated parts of this view.

But, that shouldn't happen if your code is cranking away doing something... the OnPaint won't happen until your code returns control back to the app main loop.
So... I guess you could override Paint in your comment class and set a breakpoint there.
public override void Paint(Graphics g, GoView view) {
base.Paint(g, view);
}
hint: breakpoints at Paint require the debugger and application to not cover each other, or you hit the breakpoint for Paint each time the debug window uncovers the app.