Article Options
Recently Viewed
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) is a Microsoft Visual Basic MVP who has been working on computer software and design for more than 25 years. His journey has taken him through many different facets of IT. These include training as a Systems Analyst, working in a mainframe software development environment, creating financial management systems and a short time spent on military laptop systems in the days when it took two strong men to carry a 'mobile' system.

Based in an idyllic lochside location in the West of Scotland, he is currently involved in an ever-widening range of VB.NET, WPF and Silverlight development projects. Now working in a consultancy environment, his passion however still remains helping students and professional developers to take advantage of the ever increasing range of sophisticated tools available to them.

Ged is a regular contributor to forums on vbCity and authors articles for DevCity. He is a moderator on VBCity and the MSDN Tech Forums and spends a lot of time answering technical questions there and in several other VB forum sites. Senior Editor for DevCity.NET, vbCity Developer Community Leader and Admin, and DevCity.NET Newsletter Editor. He has written and continues to tutor a number of free online courses for VB.NET developers.

 

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.24590163934428 out of 5
 61 people have rated this page
Article Score44473
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
 
Comment #20  (Posted by IQGUY on 09/08/2008)
Rating
Good article with nice source code.
 
Comment #21  (Posted by an unknown user on 12/01/2008)
Rating
aldomelg
 
Comment #22  (Posted by busrider on 01/04/2009)
Rating
eFront-???????? ??????? ??????? ? ???????????? ??????? www.e-front.com.ua
 
Comment #23  (Posted by an unknown user on 06/01/2009)
Rating
A very well explained starting point for setting out into the world of GDI+. I didn't even know it existed until reading this article and now I will be doing the next 4months of programming I have to do, utilising this tool.
 
Comment #24  (Posted by on 10/11/2009)
Rating

 
Comment #25  (Posted by metabolism. on 11/07/2009)
Rating
does plavix work does plavix work does plavix work . does plavix work does plavix work . does plavix work does plavix work . does plavix work maker of carisoprodol maker of carisoprodol . maker of carisoprodol maker of carisoprodol . maker of carisoprodol maker of carisoprodol . maker of carisoprodol maker of carisoprodol maker of carisoprodol . ambien sales online ambien sales online ambien sales online ambien sales online ambien sales online . ambien sales online ambien sales online ambien sales online ambien sales online ambien sales online .
 
Comment #26  (Posted by a common side effect of most opioids, on 11/24/2009)
Rating
This is one of the best sites I have ever found. Thanks!!! Very nice and informal. I enjoy being here.: URLsWithURL
 
Comment #27  (Posted by Cheap oem software on 09/29/2011)
Rating
2izgYl The text is promising, will place the site to my favorites..!
 
Sponsored Links