RoundRect
-
Does anyone know what the equivalent would be in C#? System.Drawing.Graphics does not seem to have a means of doing what I want, which is a recangle with rounded corners.
-
Does anyone know what the equivalent would be in C#? System.Drawing.Graphics does not seem to have a means of doing what I want, which is a recangle with rounded corners.
Charles Petzold's Programming Microsoft Windows with C# has an example demonstrating how to create one. Unfortunately the code from the book isn't available on his website, nor MSPress' website so I can't give you his exact code. But I don't think there would be any harm in giving you the algorithm since it is common sense when you think about it :) First break up your rounded rectangle up into its distinct sections. You have the four sides, and 4 rounded parts. The rounded parts if you put them together form an ellipse. So all you have to do to create your own rounded rect function is to use the DrawArc and DrawLine methods of the Graphics object to position each part where it needs to be. HTH, James Sonork: Hasaki "I left there in the morning with their God tucked underneath my arm their half-assed smiles and the book of rules. So I asked this God a question and by way of firm reply, He said - I'm not the kind you have to wind up on Sundays." "Wind Up" from Aqualung, Jethro Tull 1971
-
Does anyone know what the equivalent would be in C#? System.Drawing.Graphics does not seem to have a means of doing what I want, which is a recangle with rounded corners.
I have written an article showing how it's done, but as the other poster said, it's pretty obvious. I provide a function that allows you to set % rounded, just like GDI did. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?! - Jon Hulatt, 22/3/2002
-
I have written an article showing how it's done, but as the other poster said, it's pretty obvious. I provide a function that allows you to set % rounded, just like GDI did. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. "I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?! - Jon Hulatt, 22/3/2002
Thanks both of you. I was hoping I was missing something and would not have to do it manually. I don't understand why they would not have brought RoundRect forward into C#/.NET, it seems like something that would be useful (at least to me).