Can I center the diagram

Is there an easy way to center the entire diagram on a page once it has been drawn?

If not then what ar emy alternatives?
Thanks very much
[code] goView1.SheetStyle = GoViewSheetStyle.Sheet;
RectangleF b = goView1.Document.ComputeBounds();
goView1.Document.Bounds = b;
goView1.DocExtentCenter = new PointF(b.X+b.Width/2, b.Y+b.Height/2);[/code]

The code you provided does not seem to work.

I get an error message telling me that Northwoods.Go.GoDocument' does not contain a definition for 'Bounds' and 'Northwoods.Go.GoView' does not contain a definition for 'DocExtentCenter'.

2.6 introduced those two properties.

GoDocument.Bounds is just the combination of GoDocument.TopLeft and GoDocument.Size properties.
GoView.DocExtentCenter is just the center point of the GoView.DocPosition and GoView.DocExtentSize properties.

I am using the 2.6.2 eval version with the new code you gave me and all seems to be going OK.

I have two questions.
1. How can I get the nodes to snap to grid after centering.
2. Why are all my node images and the links between the nodes so thin and "brittle" in version 2.6.2? It almost seems like there is some default setting that is being applied in 2.6.2 that did not exist in 2.5.2 that is improperly scaling the images I am using for the background of my custom Nodes and instead of them all having black borders they have gray shadows.
This may have nothing to do with the different versions of the software. I just realized that I never actually implemented your document recenter code when using the 2.5.2 libraries b/c I didn't know how. This might just be something that happens b/c of the way you wrote the code.
This is what the node looks like before I call the document recentering method:
This is what it looks like afterwards:
Aside from the fact that the lines aren't straight (that I need to adjust on my own) the lines are much thinner than before the recentering code gets called AND the images are not scaling correctly.
You also provided the following code:
view.RescaleWithCenter(newscale, new SizeF);
Would using the above code help the scaling issue? If so, what value should I use for newscale if I want my diagram to always be 100%?

That’s a result of anti-aliasing when lines are drawn. You can try setting different values for the following GoView properties relating to painting quality:

The default values tend to emphasize quality over speed.
The default GoView.DocScale is 1.0f.

Walter, I am sooooooo close!!! I nearly have it! If you could just help me figure out which of the settings you sent me might be causing the images and lines to become all fraile looking then it would be perfect!

Update: Walter, it seems as if now my nodes are being resized which is why they look funny. I am attempting to comment each new step I added per your instructions 1 by 1 in order to figure out what is causing it. I noticed that since I have my child link AvoidNodes property set to true, when I attempt to move one of the parent nodes near the child links not only do the child links move out of the way but there is a significant amount for whitespace between the links and the node I am moving. I don't recall there being that much whitespace between those links and the nodes when I tried to move a node near them before making these new changes to the document positioning.

OK. I figured out that the DocExtentCenter code is the culprit. It causes all of the “iffy” scaling issues.

The question is, how can I fix it? I need it to center my document properly but when I use it all of my links become "super thin" and all of my nodes are not scaled properly.

I’m guessing that you could just make sure that the values of GoView.DocPosition are integral.

However, as soon as the user zooms in or out, you'll have the same problem again.

Could you give an example of what you mean by “integral”?

It's been awhile since I took Calculus. :)

Values that are integers.

I actually looked that one up on Wikipedia. I feel kinda dumb for asking that.

Anyhow, I wrote a "quickie" method that converts all of the values to integers and then uses the modulus operator to check and see if the X/Y and width/height values are odd. If they are odd, I add 1 to their values.
So now I have all even numbers but the problem still remains.
On a side note, how could I set the document to be a fixed size and then automatically show scrollbars when the tree goes beyond the boundaries?
In my application I have a grid control that sits directly below the GoView. In fact, the grid is actually positioned on top of the GoView so it's effectively "hiding" the bottom portion of the GoView. This poses a bit of a problem b/c then scrollbars don't appear when the tree grows and nodes are hidden beneath the grid control until the tree is so long that it actually goes passed the height of the grid.
I currently have the GoView.Dock property set to Fill. What I would like is not necessarily for the GoView to actually fill the whole area, rather to just fill the viewable portion. Then, if the user decides to resize the bottom grid control by dragging it down vertically, the height of the GoView can then increase dynamically depending on how much the user resized the grid control.

Odd, I thought I had answered this before.

That's the default behavior: the document's size is automatically increased as objects are added beyond its current Bounds. When the document's Bounds aren't completely covered by the GoView, scroll bars appear (assuming the appropriate values for GoView.Show...ScrollBar apply).
I don't remember what the default GoDocument.Size is, but you can change that.
I don't recommend hiding part of any Control by occluding it with another Control, when you expect the user to see what's in that obscured Control. You need to layout your Form so things work right for the user. You can read about this on the web, since it's a common topic.

As I’ve mentioned several times, using your code above does technically “center” the document, however it looks all thin and brittle. The weird thing is that if I click the vertical scrollbar (not horizontal -only vertical) the brittleness goes away and everything looks perfect! I don’t even have to scroll! Just clicking the scrollbar does the trick! This has to be a bug of some sort. Why would centering the document cause everything to look weird and then everything looks fine as soon as you click on a vertical scrollbar?

Did you check on whether the X,Y,Width,Height values are integral, and whether GoView.DocPosition has integral values?

Remember that that assumes GoView.DocScale == 1.0f. As soon as the
user zooms in or out, you can get this problem again. So:
Have you tried different values for those GoView properties that control rendering? Are your nodes just Images or are they composed of both a GoShape and a GoImage?

The nodes are just GoImages.

The GoView.DocScale is 1.0f.
I also tried using a custom method (see code below) that would insure my X,Y,Width and Height values were integral as well as the GoView.DocPosition.
private PointF GetDocExtentCenter(RectangleF b) { int ix = Convert.ToInt32(b.X); int iy = Convert.ToInt32(b.Y); if (ix % 2 > 0) { ix += 1; } if (iy % 2 > 0) { iy += 1; } int bw = Convert.ToInt32(b.Width); int bh = Convert.ToInt32(b.Height); if (bw % 2 > 0) { bw += 1; bw = bw / 2; } if (bh % 2 > 0) { bh += 1; bh = bh / 2; } float x = (float)ix + bw; float y = (float)iy + bh; return new PointF(x, y); }
Any thoughts?

For example, did you try setting GoView.PixelOffsetMode to HighSpeed?

I had it set to HighQuality. I will try HighSpeed.

Didn’t make a difference.

I am actually coming back to my own post.
Now that I am back working on that.
I tried the suggestion you gave me Walter and it works but I think I did not explain clearly what I was trying to do.
I don’t want to position the diagram in the center of the document which is what the code you suggested does.
I want the start of the diagram to be on the top of the document but in the center of the line.

For example if My document is 100 wide and 260 high I want the diagram to start at coordinates (50,0) which is at the top of the document but in the middle of the width.
Sorry for not explaining better and the code you suggested works by the way in centering the diagram on the page.
Another thing I want to mention is that many of the properties such as for example
are not really documented and I am not quite sure how to use them.

Thanks again