Any suggestions on how best implement a document with multiple sheets ?
Is there supposed to be any relationship between objects on different “sheets”? I’m asking about seeing multiple sheets in the same Control simultaneously, or expected relative Positions, or links visually connecting objects on different sheets, or being able to rubber-band select objects from different sheets in one operation, or anything else that would require the sheets to be in the same GoDocument?
Here’s code for implementing a PrintController that prints a bunch of sheets, as defined by the locations of a collection of GoSheets.
PrintDocument pd = new PrintDocument();
pd.DocumentName = "Multiple sheet test";
pd.PrintController = new MultiSheetPrintController(goView1.Document, goView1.BackgroundLayer);
pd.Print();
*/
public SheetPrintingView() {}
get { return myPrintSheet; }
set { myPrintSheet = value; }
}
get {
if (this.PrintSheet != null)
return this.PrintSheet.MarginBounds.Location;
else
return base.PrintDocumentTopLeft;
}
}
get {
if (this.PrintSheet != null)
return this.PrintSheet.MarginBounds.Size;
else
return base.PrintDocumentSize;
}
}
get { return 1; }
}
}
public MultiSheetPrintController(GoDocument document, IGoCollection sheets) {
myDocument = document;
mySheets = sheets;
}
private IGoCollection mySheets = null;
private int mySheetIndex = 0;
private ArrayList mySheetArray = null;
private PrintPageEventHandler myPrintPageHandler = null;
SheetPrintingView view = new SheetPrintingView();
view.Document = myDocument;
view.PrintSheet = (GoSheet)mySheetArray[mySheetIndex];
myPrintPageHandler = new PrintPageEventHandler(view.PrintDocumentPage);
document.PrintPage += myPrintPageHandler;
return base.OnStartPage(document, e);
}
mySheetIndex++;
e.HasMorePages = (mySheetIndex < mySheetArray.Count);
base.OnEndPage(document, e);
document.PrintPage -= myPrintPageHandler;
}
mySheetIndex = 0;
mySheetArray = new ArrayList();
foreach (GoObject obj in mySheets) {
GoSheet sheet = obj as GoSheet;
if (sheet != null) {
mySheetArray.Add(sheet);
}
}
if (mySheetArray.Count == 0) {
e.Cancel = true; //??? doesn't work
}
base.OnStartPrint(document, e);
}
}[/code]
Thanks for the reply.
It sounds like you could implement it either way. Will any object extend beyond the extent of a sheet?
No object would be extended over multiple sheets.
OK, you can do either either way. I think using a separate GoDocument for each sheet would probably be easiest for you to implement and to manage. You’ll just need code for dealing with multiple documents when loading/storing and when printing. The code above isn’t right for your purposes, but I hope will give you an idea for how a custom PrintController can be implemented.
There is a similar requirement for me where I need to show multiple sheets in a view linked to one single document.
Could you please tell me how to create multiple sheets and show the same.
Actually I need to implement similar design how an IE7 where we can have multiple tab views and also multisheets view in a single tab.
I have a question related to this post, but deals with objects snapping to grid of multiple sheets.
I’ve created a view with multiple sheets added to the backgroundlayer.
Each sheet has a GoGrid that objects should snap to.
The objects are added to the view’s document, but when dragged around they only snap to the the last added sheet.
Seems like the SnapPoint function traverses backwards on the backgroundlayer to find the closest snappoint.
Anyhow I did a override of the SnapPoint function and it fixed my problem.
I just wanted to confirm if this was the default behavior with multiple sheets. Or if there is a better way to do this.
Thanks,
JW
Each GoSheet has a GoGrid whose GoGrid.SnapOpaque property is true, by default.
So if your sheets are overlapping, objects will only be snapped to the grid of the sheet at which the mouse is.
But if you are creating your own GoGrids, the behavior will depend on their values of GoGrid.SnapOpaque and their extents.
The sheets do no overlap and they are all the same size and SnapOpaque is true.
This is what I did in the override of SnapPoint:
public override PointF SnapPoint(PointF p, GoObject obj)
{
foreach (GoObject gobj in this.BackgroundLayer)
{
GoSheet sheet = gobj as GoSheet;
if (sheet != null && sheet.Bounds.Contains§)
{
return sheet.Grid.FindNearestGridPoint(p, obj);
}
}
return base.SnapPoint(p, obj);
}