Ged Mead

Ged Mead (XTab) has been around computers since the 1980's when the first affordable home computers came on the market. His journey from that very first Dragon 32 to the present has taken him through many different facets of the IT Industry. These include formal training as a Systems Analyst, employment in a mainframe software development environment, and a short time spent demonstrating rugged military IT systems in the days when it took two strong men to carry a 'mobile' system.
His most rewarding challenge was the creation of a financial management system for a large organisation.
Now based in an idyllic lochside location in the West of Scotland, he is currently involved in a range of development projects, whenever he can drag his gaze away from the stunning surrounding views, that is!
Ged is a Microsoft MVP, Senior Editor for DevCity.NET, vbCity Developer Community Leader and Admin, Helper of the Month competition winner and DevCity.NET newsletter Editor.
View all articles by Ged Mead...
Summary
In this first article, we have been introduced to the Graphics Object and the Rectangle. We used the DrawPie and FillPie Methods, and looked at how those methods use the Rectangle, StartAngle and SweepAngle settings to create the finished drawing we required.
We employed Brush objects to fill the coloured segments and also to draw the text; a Pen object was used to draw the enclosing lines round the pie segments and bullets.
We saw that the Font is also an object and how we can use its Constructor to create New instances based on our preferences of Font name, size and style.
The DrawString method was used to display text in the font and the various colors of our choosing. We used the FillEllipse and DrawEllipse methods to create circular Colored bullets in the Key.
We have seen that if we put our drawing code in the OnPaint event it will be redrawn whenever the form’s surface has been covered, hidden or otherwise visually affected. We learned that good housekeeping includes disposing of disposable objects when finished with.
So, although the amount of code used in this project is relatively short, it has included several key graphics techniques, including:-
• Brush objects
• DrawEllipse method
• FillEllipse
• Dispose
• DrawLine
• DrawPie
• DrawString
• FillPie
• Font object
• Persistence Using OnPaint
• Rectangle object
• SolidBrush
• StartAngle
• SweepAngle
• Using OnPaint event to Persist the drawing
What we’ve done here of course touches only the very tip of the .Net Graphics iceberg. The power, scope and potential of the graphics tools that are available to you will enable you to bring parts of your application to life in a way that would be difficult - if not impossible - in any other way.
In future articles we will continue to put some of this power to use. Along the way, I hope I will help demystify some of the difficult terms and arcane syntax that makes many developers see Graphics and GDI+ as something of a Black Art. There is so much potential in there, it would be shame not to use at least some it, and - who knows? - in time you may well succeed in graduating from Graphics Apprentice to fully qualified Wizard!