Click here to Skip to main content
13,095,135 members (81,052 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I'm developing a project using 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.

Posted 5-Sep-12 22:57pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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:
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[]{
    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.
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 7 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100