Question how to translate(move) shapes on the picture box?

thippu

Active member
Joined
Mar 6, 2019
Messages
27
Location
Bangalore
Programming Experience
Beginner
1. I have a shape on the picture box, I know it's position in rectangle object.
2. How to translate the shape according to new (x,y) point given by a user while mouse click?
help me
 
1. shapes are drawn already on the picture box
2. I'm storing in a rectangle like this:
code:
Rectangle rectangle = new Rectangle(Math.Min(m_iX1,m_iX2),Math.Min(m_iY1,m_iY2),Math.Abs(m_iX2-m_iX1),Math.Abs(m_iY2-m_iY1));
 
In that case, the logical course of action seems to be to call the Offset method of that Rectangle. That change will only need to be done once and will be persistent. You could also call the TranslateTransform method of the Graphics object used in the Paint event handler but that's probably less intuitive. I'd only do that if you needed to call RotateTransform as well.
 
Back
Top Bottom