Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL .NET Server
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 5-Sep-12 23:57pm

1 solution

Rate this: bad
good
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[]{
                (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.
  Permalink  
v2
Comments
Member 8736973 at 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 at 7-Sep-12 2:49am
   
I updated my solution.
Member 8736973 at 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
0 OriginalGriff 320
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 Sergey Alexandrovich Kryukov 184
0 OriginalGriff 5,415
1 DamithSL 4,422
2 Maciej Los 3,820
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,911


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 7 Sep 2012
Copyright © CodeProject, 1999-2014
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