Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi everyone, I want to know if there is a way to put the point (0,0) to the center of the component, because the coordinates origin is on the top left of the component, is there any possible way of do that?, thanks...
Posted
Comments
Sergey Alexandrovich Kryukov 25-Feb-15 11:44am    
Which component? Of which UI library (WPF, Forms, something else?)?
—SA

It is quite possible for certain aspects with certain UI or graphics libraries. You did not specify what you want to use — please see my comment to the question.

With System.Drawing.Graphics:
https://msdn.microsoft.com/en-us/library/system.drawing.graphics.transform%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.matrix%28v=vs.110%29.aspx[^],
https://msdn.microsoft.com/en-us/library/system.drawing.graphics%28v=vs.110%29.aspx[^].

WPF: https://msdn.microsoft.com/en-us/library/ms750596%28v=vs.110%29.aspx[^].

Anything else? You just have to ask, but ask providing sufficient information.

—SA
 
Share this answer
 
v2
The coordinate system assumes (0, 0) is the top left corner of the drawing surface. You can't change that. You'll have to do the math to effect any custom transformation.

Correction: I was wrong. Please see Sergey's solution.

/ravi
 
Share this answer
 
v2
Comments
Cesar Bretana Gonzalez 25-Feb-15 11:01am    
already done that, the equation to that is simple: r = (px + cw/2 ; py + ch/2), beeing cw: Component Weight and ch: Component Height, but now, when I'm add a point, is keeping using the 4th Quadrant, how can I solve this?
Ravi Bhavnani 25-Feb-15 11:09am    
I suspect your math may not be correct.

/ravi
Sergey Alexandrovich Kryukov 25-Feb-15 11:50am    
Sorry, what you said is just not true. Please see Solution 3. You advice still can be used, but it does not answer correctly.
—SA
Ravi Bhavnani 25-Feb-15 12:12pm    
Thanks for the correction, SA. +5d.

/ravi
Sergey Alexandrovich Kryukov 25-Feb-15 12:59pm    
Thank you, Ravi.
—SA
This is the way: (pX + x / 2), (y / 2 - pY)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900