ThinkGeo.com    |     Documentation    |     Premium Support

Cloning the WinformsMap control

I am trying to set up printing in my application.  I have a WinformsMap control on my main form.  I want to open up a print preview form and I need a WinformsMap control on it to display the map data.  I don't want to have to remember all of the data I have open but I need a duplicate of the dataset in the control on the print preview form.  I also don't want changes to the extent, or size of the print preview control to effect the main display control. 


Is there a way of duplicating everything in one WinformsMap control in another?


Is there a better way of duplicating the capabilities I need to send a data set to a printer? 


Charles



Charles,


Thanks for your post and question.
 
The winformsMaps inherts from Control which do not support Serialization. So, I think you might need to write your own copy logic. Following is a simple code snippet, hope it can give you some inspirations.

private WinformsMap GetCopiedWinformsMap(WinformsMap sourceWinforms)
        {
            WinformsMap targetMap = new WinformsMap();
            targetMap.Width = sourceWinforms.Width;
            targetMap.Height = sourceWinforms.Height;
 
            foreach (Overlay overlay in sourceWinforms.Overlays)
            {
                targetMap.Overlays.Add(overlay);
            }
 
            targetMap.CurrentExtent = sourceWinforms.CurrentExtent;
 
            return targetMap;
        }


 
 
Sorry for the inconvinience for now.
 
Thanks.
 
Yale

Morning, 
 how can i use winformsMap printing (preview, listing network prints) class in vb application? 
 Emma

 Hello Emmanuella,


 
You can refer: wiki.thinkgeo.com/wiki/Map_S...nt_Preview
 
Sorry we only have the c# sample for this function, but it's easy to convert to VB, there are a lot of tools can do it.
 
Regards,
 
Gary