Viewing a fixed size document


#1

I would like to display fixed size GoDocuments.
GoDocument doc = new GoDocument();
doc.Size = new SizeF(1500.0f, 300.0f);
I add a node at 1490,290, near the corner of the document.
I create a standard GoView.
If the user zooms out, the GoView shows an area that is larger than the size I set. The extent of the fixed size document is not visible within the view.
The kind of effect I would like would be something similar to the way I can zoom out in Word, PowerPoint, Visio, or many other products, and see the extent of my document. However far out I zoom, I would still see my node near the corner of the document. Obviously there would have to be some expanding margin around the document. Is there a recommended approach for this kind of thing?
A view options I am considering:
0. Ideally, I would set GoView.ShowAreaBeyondDocSize to false, or something like that.
1. Programatically resize the view, to match the size of the document. Override LimitDocPosition and LimitDocScale to prevent the view covering an area larger than the original doc size. My concern with this approach is that I have to continually resize the view (the GoDiagram control) as users zoom in and out. Also, I can’t dock the GoView.
2. Use GoObjects and layers within the view to represent the 1500 by 300 “working area” and the margins. This seems like a hack, and wouldn’t look nice with a grid overlaying everything.
3. Override Paint for the GoView canvas ?
4. Other options?
What do you recommend?
Pete


(I can’t use print preview, because I want users to interact with the diagram while they can see the extent of the document)


#2
All of those options sound reasonable for you to implement. But note that the document size really shouldn't be "fixed", because the user can easily place objects beyond the sheet of paper you are talking about. (In other words, don't set GoDocument.FixedSize to true.) If you want to prevent users from dragging nodes beyond the edge of the sheet, you can override ComputeMove, just as LimitedNode does in the Demo1 sample. GoRectangle paper = new GoRectangle(); paper.Bounds = new RectangleF(doc.TopLeft, doc.Size); paper.Brush = Brushes.LightGoldenrodYellow; paper.Shadowed = true; GoLayer paperLayer = doc.Layers.CreateNewLayerBefore(null); paperLayer.SetModifiable(false); paperLayer.AllowSelect = false; paperLayer.Add(paper); You can also provide a shadow for the sheet of paper: view.ShadowColor = Color.FromArgb(127, Color.Black); view.ShadowOffset = new SizeF(10, 10); view.BackColor = Color.Gray; If you want a grid on the paper, you'll need to inherit from GoView and override GoView.PaintBackgroundDecoration to do nothing and override GoView.PaintObjects as follows: protected override void PaintObjects(bool doc, bool view, Graphics g, RectangleF clipRect) { foreach (GoLayer layer in this.Layers) { if ((doc && layer.IsInDocument) || (view && layer.IsInView)) { layer.Paint(g, this, clipRect); if (layer == myPaperLayer) { base.PaintBackgroundDecoration(g, clipRect); } } } } If you want to limit the grid to the rectangle, you'll need to intersect the clipRect with the GoRectangle's Bounds.