Reputation: 179
I have a rectangle, when I click on this, this will display to another view
I'm using Rectangle.Contains(e.Location) (e is MouseEventArgs) This is ok when SizeMode is normal: https://i.sstatic.net/ydQCn.png
But when I set the display SizeMode to fit, the Rectangle has to go to another location, but I must click on old location same as SizeMode normal https://i.sstatic.net/PUPsC.png
I think I need scale rectangle when go to fit mode, but I don't know the ratio. Please help me
Upvotes: 2
Views: 128
Reputation: 17027
To calulate the ratio of rectangle, you could calculate ratio = Width / Height
So width and height are always linked by this formula, if you want to keep the same ratio
if you know the new width, new height = new width / ratio
or
if you know the new height, new width = ratio * new height
Upvotes: 0
Reputation: 1202
You might need to map the screen co-ordinates to control co-ordinates. Take a look at the helper PointToClient.
Upvotes: 1