Solved

Stoplight Project - Graphics and GDI+

Posted on 2006-07-10
7
268 Views
Last Modified: 2008-03-04
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?
0
Comment
Question by:Bezak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 400 total points
ID: 17073269
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
 

Author Comment

by:Bezak
ID: 17074383
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
 

Author Comment

by:Bezak
ID: 17074769
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Bezak
ID: 17076153
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 17077082
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 17077084
I've never worked with "svg" images before.  My only suggestion there is to move to a more common format...
0
 

Author Comment

by:Bezak
ID: 17078660
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question