Article Options
Premium Sponsor
Premium Sponsor

 »  Home  »  .NET Newbie  »  Chart Success: GDI+ Graphics at work. Part 1  »  Summary
 »  Home  »  Windows Development  »  Graphics  »  Chart Success: GDI+ Graphics at work. Part 1  »  Summary
Chart Success: GDI+ Graphics at work. Part 1
by Ged Mead | Published  03/06/2005 | .NET Newbie Graphics | Rating:
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

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!

How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent
Tell us why you rated this way (optional):

Article Rating
The average rating is: No-one else has rated this article yet.

Article rating:4.84615384615386 out of 5
 26 people have rated this page
Article Score26920
Article Series
Related Articles
Attachments
Comments    Submit Comment

Comment #1  (Posted by an unknown user on 03/13/2005)
Rating
The subject you have picked is one of the most interesting ones in programming. But sure enough, that may just be my opinion. When an interesting subject comes with explanations that are detailed but still very readable, then this means that the author has a great talent for writing and it shows immense responsibility and patience with beginning programmers. And that’s exactly what your article has achieved.
 
Comment #2  (Posted by an unknown user on 03/16/2005)
Rating
Very nice, Ged.

A small suggestion for part II: when would you use GDI+ vs. DirectX?
 
Comment #3  (Posted by Ged Mead on 03/22/2005)
Rating
Thanks for the comments. Part 2 is out now .... but I think it'll be a while before I get round to DirectX!
 
Comment #4  (Posted by an unknown user on 06/12/2005)
Rating
Hi Ged,
Nice and the way u explained is excellent .
The explanation is in steps and easy to understand and for me it the best methord to understand .
Good work i dont have word to appriciate u but excellent job.
From
Mohd Sufian
IT Specialist
Eastern Polymer Group
Thailand
 
Comment #5  (Posted by Dave on 10/03/2005)
Rating
Explained quite well! However I have a persistence problem that you mention in your article. I am drawing inside a picture box. My drawing code is in its own function which I call from the Paint() method. When the form first opens my drawing flashes up quite briefly and then disappears. It reappears and remains whenever I resize the window. How do I get it to come up without telling it to refresh which puts it in an endless loop?
 
Comment #6  (Posted by an unknown user on 04/05/2006)
Rating
Great explanation.I would like to know how to integrate database data with GDI.
 
Comment #7  (Posted by Ronan on 04/13/2006)
Rating
Hi i have read these tutorials and am looking your help.
I am trying to develop a pie chart interface in Visual Studio 2003 for a PDA (Smart Device Application) and tried your code. however it is not compatible as it does not recognise the drawPie and FillPie commands, etc. Do you have an example i could use to help me for this?
Thank you, Ronan
 
Comment #8  (Posted by an unknown user on 08/09/2006)
Rating
Excellent article. I have learnt a lot of GDI+ Stuff from it.
 
Comment #9  (Posted by an unknown user on 10/19/2006)
Rating
Very Useful article. Prakash Bajaj
 
Comment #10  (Posted by an unknown user on 12/22/2006)
Rating
really useful
 
Comment #11  (Posted by an unknown user on 12/29/2006)
Rating
no corners cut, all is clear
 
Comment #12  (Posted by an unknown user on 07/09/2007)
Rating
thank you
Very simple
detailed explanation
 
Comment #13  (Posted by an unknown user on 07/22/2007)
Rating
best for beginner's. language is just perfect
 
Comment #14  (Posted by neelabh on 07/22/2007)
Rating
Language is clear nd decription is best for beginner
 
Comment #15  (Posted by an unknown user on 10/01/2007)
Rating
Easy to follow tutorial. Picked up the main points straight away.
 
Comment #16  (Posted by an unknown user on 12/28/2007)
Rating
I have been searching for a good graphics article to get me started...with this one I found what I was looking for...GREAT JOB. Now I need to found out how to do vertical text.
 
Comment #17  (Posted by an unknown user on 02/05/2008)
Rating
Free, good, patient advice. A rare commodity and precious to beginners.
 
Comment #18  (Posted by an unknown user on 02/06/2008)
Rating
thanks for giving such a good article to start GDI+ from scratch.
 
Comment #19  (Posted by an unknown user on 02/20/2008)
Rating
good one
 
Sponsored Links