Windows窗体组件中的坐标 [英] Coordinates in a Windows Form Component

查看:90
本文介绍了Windows窗体组件中的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我想知道是否有办法将点(0,0)放到组件的中心,因为坐标原点位于组件的左上角,是否有任何可能的方法那样做了吗?谢谢......

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...

推荐答案

对于某些UI或图形库,某些方面很有可能。您没有指定要使用的内容 - 请参阅我对该问题的评论。



使用 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- ü s / library / system.drawing.graphics%28v = vs.110%29.aspx [ ^ ]。



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



还有别的吗?你只需要问,但要求提供足够的信息。



-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


坐标系统假定(0,0)是绘图表面的左上角。 你不能改变它。你必须做数学来实现任何自定义转换。



更正:我错了。请参阅Sergey的解决方案。



/ ravi
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


这是方式:(pX + x / 2),(y / 2 - pY)
This is the way: (pX + x / 2), (y / 2 - pY)


这篇关于Windows窗体组件中的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆