Stoplight Project - Graphics and GDI+

Hello All,
 I have an idea for a project I want to do so I can become familiar with GDI+.  My program is a simple collection of images (let’s say JPEGs for now) that I want to construct into a stoplight.  I want to have the light change colors from red, to green, to yellow and repeat over again.

The images I have are:
 -- The stoplight: an orange box with three black circles
 -- The red light: one red circle
 -- The yellow light: one yellow circle
 -- The green light: one green circle

I am looking to use all these images and have an almost layered effect.  In thirty second intervals, I would like the top black circle to change red (using the red light image) then they yellow and then the green.

Could anyone help me get the basics down for this idea?
BezakAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Set the Image property of the PictureBox to your Stoplight.

Then in the paint() event of your PictureBox you can use Graphics.DrawImage() to paint one of the colored lights on top:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDrawingGraphicsClassDrawImageTopic.asp
Use one of the overloads above to draw the image at a specific point in your PB.

Use a Timer control with the Interval set to 30,000 (thirty seconds) to change the light.
0
 
BezakAuthor Commented:
let's say the images are svg instead of jpegs.  How would you handle that because GDI only uses JPG, TIFF, GIF, and Bitmaps.
0
 
BezakAuthor Commented:
Idle_Mind
 How can I click on one of the three lights and make it pop up a box that says the color red, yellow or green?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
BezakAuthor Commented:
Idle_Mind,
  Working on this with your suggestion and ran into a question...how do I find the specific point on the PB?  I am not clear on how to find the exact coordinate.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
When you click down on the PB, the MouseDown event will fire.  The "e" parameter will give you the coordinates as in "e.x" and "e.y".
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
I've never worked with "svg" images before.  My only suggestion there is to move to a more common format...
0
 
BezakAuthor Commented:
Yea, I am going to stick with jpeg...it was just a suggestion from a person I know.  I didn't find any helpful information in converting those images from SVG anyway.

Thanks for the tips on finding the coordinate. I will look into further and hopefully get this thing working. It seems like a great beginner project.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.