DrawString调整大小并重新放置C#/GDI + [英] DrawString Resize and Relocate C# / GDI+
问题描述
大家好,
我正在使用GDI +在C#中创建Clock应用.
我在下面发布的代码向我展示了如何使用图形表面并相应地将我的钟面编号排列成一个圆圈.
Hi Guys,
I am creating a Clock app in C# using GDI+.
The code I have posted below shows me using a graphics surface and arranging my clock face numbers accordingly in a circle.
g.DrawString("1", new Font("Arial", 14.0f), new SolidBrush(Color.Black), new PointF(240.0f, 50.0f));
g.DrawString("2", new Font("Arial", 14.0f), new SolidBrush(Color.Black), new PointF(290.0f, 95.0f));
g.DrawString("3", new Font("Arial", 14.0f), new SolidBrush(Color.Black), new PointF(310.0f, 160.0f));
g.DrawString("4", new Font("Arial", 14.0f), new SolidBrush(Color.Black), new PointF(290.0f, 228.0f));
g.DrawString("5", new Font("Arial", 14.0f), new SolidBrush(Color.Black), new PointF(240.0f, 275.0f));
g.DrawString("6", new Font("Arial", 14.0f), new SolidBrush(Color.Black), new PointF(175.0f, 295.0f));
g.DrawString("7", new Font("Arial", 14.0f), new SolidBrush(Color.Black), new PointF(110.0f, 277.0f));
g.DrawString("8", new Font("Arial", 14.0f), new SolidBrush(Color.Black), new PointF(60.0f, 230.0f));
g.DrawString("9", new Font("Arial", 14.0f), new SolidBrush(Color.Black), new PointF(40.0f, 165.0f));
g.DrawString("10", new Font("Arial", 14.0f), new SolidBrush(Color.Black), new PointF(50.0f, 100.0f));
g.DrawString("11", new Font("Arial", 14.0f), new SolidBrush(Color.Black), new PointF(95.0f, 50.0f));
g.DrawString("12", new Font("Arial", 14.0f), new SolidBrush(Color.Black), new PointF(165.0f, 30.0f));
我对大家的问题是:
使用resize事件调整窗口大小时,如何根据Windows窗体将这些数字按相同的顺序以相等的间距保持不变?
该代码当前在我覆盖的OnPaint中,但不知道如何调整数字的大小.
希望这是有道理的,并预先感谢,
Kyle
My question to you all is:
How do I keep these numbers in the same order with equal spacing according to the Windows Form when I resize the window using my resize event?
This code Is currently in my overridden OnPaint but haven''t a clue how to resize the numbers.
Hope this makes sense and thanks in advance,
Kyle
推荐答案
在CP上有大量资源[
我相信您可以研究他的代码,并调整他的几何计算,以便在需要放大和重新定位时钟数字时使用.
最好,比尔
There''s a great resource here on CP[^], "CircleControl - A Circular Motion Control" by Graham Wilson that shows how to create ''circular'' controls.
I am sure you can study his code and adapt his geometric calculations to use when you need to scale up and reposition your clock-numbers.
best, Bill
这篇关于DrawString调整大小并重新放置C#/GDI +的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!