Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C#
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));


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
Posted

1 solution

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
 
Share this answer
 
Comments
Kyle Crewe 2-Sep-11 7:45am    
Wow, that was a quick response.
Thank you so much for your help Bill.

Kindest Regards,

Kyle

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