I have big Image - map and I laid it in PictureBox with scroling and zoom.
I need lay some small pictures on this map.
I use :
Graphics g = Graphics.FromImage( imgMap);
g.DrawImage( imgSmall);
Rectangle rectImgSmall = new Rectangle((int)X, (int)Y, imgSmall.Width, imgSmall.Height);
Region regImgSmall = new Region( rectImgSmall);
But when I work with event MouseClick of pictureBox (there my Region regImgSmall):
private void pictureBox_MouseClick(object sender, MouseEventArgs e)
{
if(this.regImgSmall.IsVisible(new Point(e.X, e.Y))) { // Here alway false !
...
}
}
How can I recieve coordinates for my region from coordinates of MouseEventArgs ( e.X, e.Y) ?
Help me please. I'm sorry for my english.
Richard BlythePosted Mar 30, 2007, 11:38 AM
The mouse coordinates are stored in Screen coordinates (0,0 is the upper-left of the screen)
Anything stored inside a Form (your picturebox) has Client coordinates. In other words, if your picturebox has a location value of 10,50 it means that the picturebox is 10,50 pixels from the upper-left corner of the "Form". What you need to do is convert the mouse "Screen" coords to Client Coords. Try this function: Note: e.X and e.Y is refering to the mouse coords.
Point pnt = PointToClient(new Point(e.X, e.Y));
Look at the pnt coords in relation to your picturebox and see what you find.
Good Luck!
Richard