Click here to Skip to main content
15,896,730 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I'm developing a project using Vb.net and sql server.Here basically i got the map of the world and when i click on any particular country [eg- USA/North America] then the complete history of The States will appear.Now the question is that suppose I select any country ie if my mouse cursor is placed on a country then i want the whole country to be outline [like an individual pic] and when i click on it , it should open another tab .I want to avoid hyperlink or a button as far as possible...

Hope you understood the question...If its not clear do tell I'l try to correct it.

Thankyou
Posted

1 solution

You could use the System.Drawing.Region[^] class and its IsVisible()[^] method.

Will need quite some manual work to create the Regions for each country. Or you can get geodesic data you can convert.

When done with that, you can get the clicked country from the mouse pointer's position.

Here is an example:
C#
public static void Example()
{
    System.Drawing.Region someCountryOutline = new Region(
        new System.Drawing.Drawing2D.GraphicsPath(
            new PointF[]{
                new PointF(0F,0F),
                new PointF(200F,0F),
                new PointF(220F, 20F),
                new PointF(220F, 200F),
                new PointF(0F,200F)
            },
            new byte[]{
                (byte)System.Drawing.Drawing2D.PathPointType.Start,
                (byte)System.Drawing.Drawing2D.PathPointType.Line,
                (byte)System.Drawing.Drawing2D.PathPointType.Line,
                (byte)System.Drawing.Drawing2D.PathPointType.Line,
                (byte)(System.Drawing.Drawing2D.PathPointType.Line
                       |System.Drawing.Drawing2D.PathPointType.CloseSubpath)
            }
        )
    );

    if (someCountryOutline.IsVisible(WorldMapControl.MousePosition))
    {
        Console.WriteLine("Mouse within country borders.");
    }
}


You will, however need to change the co-ordinates in some co-ordinate system of your choice. You will end up with one Region per country. The new Region() stuff belongs in some initialization code. The IsVisible() part will be processed in one of the mouse event handlers.
 
Share this answer
 
v2
Comments
Member 8736973 6-Sep-12 9:56am    
Ok thank you . could you tell me how to use them as in how the code would actually go..A small eg would suffice
lukeer 7-Sep-12 2:49am    
I updated my solution.
Member 8736973 7-Sep-12 11:15am    
thanks a lot man...Il try it shortly and get back.....
thanks again

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900