[英]How to determine which units are being used?
所以我只是想知道你是怎么知道哪些单位被什么使用的? 一切都默认为像素,英寸还是什么?
例如,我想将一个字符串放在 object 的右侧。 所以我认为正在做这样的事情:
string str = "this is a string";
System.Drawing.Font f = new System.Drawing.Font("Verdana",14);
System.Drawing.Size size = System.Windows.Forms.TextRenderer.MeasureText(str, f);
context.DrawText(str, new Point(790-size.Width, 1070));
我假设这将采用 object (790) 的宽度并从中减去字符串的长度,然后字符串会很好并紧贴 object 的右侧......但是当我这样做时,字符串在object中间开始较多,而且字符串和object的正确大小之间有很多空格...
例如,这就是我想要的:
String
这就是我得到的:
string
请注意,在第一个中,“字符串”一词就在右侧,而在第二个中……它不是
那么我怎么知道正在使用哪些单位呢?
谢谢!
System.Windows.Forms.TextRenderer.MeasureText 返回大小(以像素为单位)。
http://msdn.microsoft.com/en-us/library/system.windows.forms.textrenderer.measuretext.aspx
在 WinForms 中,默认单位是像素(例如以点为单位的字体大小除外),包括 MeasureText 的结果。
什么是 context.DrawText? 为什么不调用Graphics.DrawString ?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.