ThinkGeo.com    |     Documentation    |     Premium Support

PrintDocument property

Hi,


In MapSuite 2.0, there is a PrintDocument property in the Map class, I can't find the same property in MapSuite 3.0 WinformsMap class.


Where can I find it?


Thanks


Rose


 



Rose,


I am afraid we don’t have this API in DesktopEdition RC1, I have added this to our tracking system and we will consider add it in the next release.

Here’s a piece of code to print the current map for now.




Bitmap bitmap;
private void button1_Click(object sender, EventArgs e)
{
    // Create a geoCanvas and draw the current map on the bitmap.
    bitmap = new Bitmap(winformsMap1.Width, winformsMap1.Height);
    GeoCanvas canvas = new GdiPlusGeoCanvas();
    canvas.BeginDrawing(bitmap, winformsMap1.CurrentExtent, winformsMap1.MapUnit);

    // Draw each overlay 
    winformsMap1.BackgroundOverlay.Draw(canvas);
    foreach (Overlay overlay in winformsMap1.Overlays)
    {
        overlay.Draw(canvas);
    }
    foreach (InteractiveOverlay overlay in winformsMap1.InteractiveOverlays)
    {
        overlay.Draw(canvas);
    }
    winformsMap1.AdornmentOverlay.Draw(canvas);

    canvas.EndDrawing();

    // Print the image
    PrintDocument printDoc = new PrintDocument();
    printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
    printDoc.Print();
}

private void printDoc_PrintPage(object sender, PrintPageEventArgs e)
{
    e.Graphics.DrawImage(bitmap, new Point(0, 0));
}

Thank,

ThinkGeo Support

 



Lee:


Has this feature been implemented?


Also, I want to design a button, when the user clicks on this button, the program will copy the map area to the Clipboard, then the user can paste it to other document, such as Word.


Any information or code snippet is greatly appreciated!


Thanks


Rose



Rose,


1. About Print the current map, please take a reference to the following post, hope it will give your answer you needed.
 
gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/21/aft/5878/afv/topic/afpgj/1/Default.aspx#9144
 
gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/21/aft/5912/afv/topic/afpgj/1/Default.aspx#5912
 
2.
Following code you can take reference to copy the bitmap in the MapControl to the Clipboard and then be used in other documents such as word.

Bitmap bitmap = new Bitmap(winformsMap1.Width,winformsMap1.Height);
winformsMap1.DrawToBitmap(bitmap,new Rectangle(0,0,bitmap.Width,bitmap.Height));
Clipboard.SetData(DataFormats.Bitmap, bitmap);

Let me know if you have any more questions.


Thanks.


 
Yale