C# .NET - how to make a wheel of fortune type wheel in c#

Asked By genica on 06-Jan-11 06:46 AM
i need to make a spinning wheel for my project in my object-oriented programming class
the problem is i don't know how to program a spinning wheel
that would start on stop on button command
after which, wherever the arrow is pointed, it will go into a new form
can anyone help me with this?

I think you would typically use GDI+ - Robbe Morris replied to genica on 06-Jan-11 09:35 AM

for this in a windows forms application.  WPF would be easier but it doesn't sound like you guys are that advanced yet.

You'd use the graphic object of say a PictureBox control and use GDI+ to draw on it.  Getting code drawing a pie charter is probably the easiest place to start:

http://www.eggheadcafe.com/tutorials/aspnet/592d4dc8-74f8-42ea-862a-0cb6488c4fec/draw-pie-chart-for-database-values-in-vbnet.aspx

Here is some additional code for drawing that might be useful.

http://www.eggheadcafe.com/articles/draw_tree_with_gdi_plus.asp

You'd set up a timer that redraws the entire chart with a different color as the starting point every 50 milliseconds or so.  For your pointer, you hard code the boundries of where your selected pie slice should be.  When your timer stops, grab a pixel and see what color it is.

This might also come in handy:

http://www.eggheadcafe.com/articles/20031218.asp



genica replied to Robbe Morris on 07-Jan-11 07:28 AM
thank you for replying... :) i'm going to try,, hopefully i'd be able to do it