Creating a Rounded Panel Control

This article talks about how to make your user interfaces a little jazzier with a rounded rectangle Panel control; a fun chunk of code to incorporate into your application.

Introduction



Occasionally, I get tired of plain old rectangular shaped WinForms applications and decide to add some simple rounded-rectangular-ly shaped elements to change it up. The problem is I have to remember how to make them. And, because it's the holiday season, why not keep it fun and light? For your programming pleasure and amusement, in the spirit of the holidays, here is a simple control that rounds the edges of a panel.



Understanding the Coordinate System for Drawing Arcs with GDI+



Generally, in math classes or if you are a pilot or use maps, you think of the coordinate system with North (or 360° or 0°) as being situated at the top, rotation clockwise through 360°. In a Cartesian system this would situate 0° at the top and 180° at the bottom, representing the y-axis and 90° and 270° situated left and right representing the x-axis. GDI+ does not treat the coordinate system that way, at least as far as drawing arcs is concerned. The coordinate system is rotated 90° to the right, as shown in Figure 1.


Figure 1: The Cartesian coordinate system is oriented titled to the right, so 0° is on the right or x-axis.

Knowing the orientation of significant reference points is important if you are going to draw anything manually with GDI+.

Technically, to draw a rounded corner you must know the radius of your circle. The radius will be the offset distance from any of the rectangle's four edges. For example, a rounded upper-right corner would be start at width-d and 0 where d represents the arcs radius, width-d is the x-coordinate and 0 is the y-coordinate. Because the arc starts in the up position, the starting angle would be 270°; to obtain a quarter-circle, the arc would sweep 90°. (Four corners mean 360° divided by 4, yields 90° for each corner arc.) See Figure 2 for an illustration.

Read the Rest of this Article at Developer.com

Regional Articles
- Creating a Rounded Panel Control Alabama
- Creating a Rounded Panel Control Alaska
- Creating a Rounded Panel Control Arizona
- Creating a Rounded Panel Control Arkansas
- Creating a Rounded Panel Control California
- Creating a Rounded Panel Control Colorado
- Creating a Rounded Panel Control Connecticut
- Creating a Rounded Panel Control DC
- Creating a Rounded Panel Control Delaware
- Creating a Rounded Panel Control Florida
- Creating a Rounded Panel Control Georgia
- Creating a Rounded Panel Control Hawaii
- Creating a Rounded Panel Control Idaho
- Creating a Rounded Panel Control Illinois
- Creating a Rounded Panel Control Indiana
- Creating a Rounded Panel Control Iowa
- Creating a Rounded Panel Control Kansas
- Creating a Rounded Panel Control Kentucky
- Creating a Rounded Panel Control Louisiana
- Creating a Rounded Panel Control Maine
- Creating a Rounded Panel Control Maryland
- Creating a Rounded Panel Control Massachusetts
- Creating a Rounded Panel Control Michigan
- Creating a Rounded Panel Control Minnesota
- Creating a Rounded Panel Control Mississippi
- Creating a Rounded Panel Control Missouri
- Creating a Rounded Panel Control Montana
- Creating a Rounded Panel Control Nebraska
- Creating a Rounded Panel Control Nevada
- Creating a Rounded Panel Control New Hampshire
- Creating a Rounded Panel Control New Jersey
- Creating a Rounded Panel Control New Mexico
- Creating a Rounded Panel Control New York
- Creating a Rounded Panel Control North Carolina
- Creating a Rounded Panel Control North Dakota
- Creating a Rounded Panel Control Ohio
- Creating a Rounded Panel Control Oklahoma
- Creating a Rounded Panel Control Oregon
- Creating a Rounded Panel Control Pennsylvania
- Creating a Rounded Panel Control Rhode Island
- Creating a Rounded Panel Control South Carolina
- Creating a Rounded Panel Control South Dakota
- Creating a Rounded Panel Control Tennessee
- Creating a Rounded Panel Control Texas
- Creating a Rounded Panel Control Utah
- Creating a Rounded Panel Control Vermont
- Creating a Rounded Panel Control Virginia
- Creating a Rounded Panel Control Washington
- Creating a Rounded Panel Control West Virginia
- Creating a Rounded Panel Control Wisconsin
- Creating a Rounded Panel Control Wyoming

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML