Click here to Skip to main content
15,439,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

I'm relatively new to C# and very new to C# graphics and am trying to produce a graphical output for some optimisation routines I'm experimenting with (I'm a bit more experienced in mathematics). Trying to work this out with Google has been frustrating - have had little success and am not even sure it's doable (but surely it is).

My problem is around automatically rendering objects designed in one dimension onto an object with a set scale and transformation.

Essentially I want to do the following:

- I will be working and making calculations purely in 2D on a (0,0) to (a,b) space and wish to keep the origin (0,0) at the bottom left for argument's sake. When I output anything, it has to be scaled and transformed onto the graphics object (say a panel) on my Windows form (which as far as I can see has (0,0) at the top left and arbitrary dimensions related to its actual size).

- generate and display some random shapes (ellipses and rectangles). I can do this (not too hard) but can't get my head around generating them in my working dimensions and displaying them on my graphics surface automatically without having to scale/transform them before rendering.

As an example:

- say I'm working/calculating on a x/y space from (0,0) to (100,100) with (0,0) at the bottom left.

- the object for display (say a panel) on my windows form has dimensions (0,0) top left down to (200,300) bottom right.

- I create a circle in my working space to have centre at (50,50) and radius 10 (right in the middle of my working space).

- Now I want to display this in the middle of the panel as if it had my working space dimensions, with C# automatically doing the transformations such that it will appear to scale and with the origin at the bottom.

I hope this makes sense. Any help will be very gratefully received.

Many regards,
David (Sydney)
Updated 21-Jan-15 17:26pm

1 solution

I think you can get some good information here:
Professional C# - Graphics with GDI+[^]

And maybe here:[^]
Share this answer
Member 11393012 22-Jan-15 0:53am    
Hello George - many thanks for responding so quickly. I'm slowly getting through your links and fingers crossed will unravel these mysteries before I get old. :-)
George Jonsson 23-Jan-15 3:11am     CRLF
It takes some time to get into GDI+. Glad you found the links useful.

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