I’m having some difficulty setting up the Print Preview window from an existing Map (Please see both pictures attached –as it is now, and how I’d like it to initially display). The Map comes in fine, but when the window initializes it displays the Map in the upper left corner off the screen. I can drag it and size it to where I want, but I’d like it to start out that way in the first place. I’ve adapted the code from the PrintPreview project and here it is my code as it now exists:
private void AddMapLayer()
{
// Create the MapPrinterLayer and set the position
MapPrinterLayer mapPrinterLayer = new MapPrinterLayer();
mapPrinterLayer.MapUnit = GeographyUnit.DecimalDegree;
mapPrinterLayer.BackgroundMask = new AreaStyle(new GeoPen(GeoColor.StandardColors.Black, 1));
mapPrinterLayer.Open();
// Set the maps position slightly below the pages center and 8 inches wide and 7 inches tall
RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch);
mapPrinterLayer.SetPosition(8, 10, pageBoundingbox.GetCenterPoint().X, pageBoundingbox.GetCenterPoint().Y + 1, PrintingUnit.Inch);
// Setup the intial extent and ensure they snap to the default ZoomLevel
ZoomLevelSet zoomLevelSet = new ZoomLevelSet();
mapPrinterLayer.MapExtent = ExtentHelper.ZoomToScale(zoomLevelSet.ZoomLevel03.Scale, CurrentExtent,
mapPrinterLayer.MapUnit, (float)mapPrinterLayer.GetBoundingBox().Width, (float)mapPrinterLayer.GetBoundingBox().Height);
// Add the World Map Kit layer as the background
WorldMapKitLayer worldMapKitLayer = new WorldMapKitLayer();
worldMapKitLayer.Projection = WorldMapKitProjection.DecimalDegrees;
mapPrinterLayer.Layers.Add(worldMapKitLayer);
//Now Add our Layers
mapPrinterLayer.Layers.Add(DetailLayer);
mapPrinterLayer.MapExtent = CurrentExtent; //The original Extent of the MapControl before the PrintPreview window is called;
PrinterInteractiveOverLay printerInteractiveOverLay = (PrinterInteractiveOverLay)MapControl.InteractiveOverlays["PrintPreviewOverlay"];
printerInteractiveOverLay.PrinterLayers.Add("MapLayer", mapPrinterLayer);
Any Help would be greatly appreciated.
Bob