Being a geek, I have a lot of geek friends. Being friends, we tend to eat lunch together. The only problem is sometimes we have a hard time deciding where to go to eat lunch. This invariably leads to the “Where do you wanna eat?”, “I dunno, where do you wanna eat go?”, “It doesn’t matter to me, you decide.” Well here is a simple solution to this daily dilemma:
Lunch-O-Matic
Our UI has just enough class to be exciting and interesting, yet simple enough not to cause us too much grief. Seek balance in all things. The concept: restaurant logos flash across the screen, eventually stopping on the chosen food establishment. The application is visual, which is appealing. The application is clear. The user can easily tell which restaurant is chosen by following the ginormous arrow. A light blue background give the app a little warm and the arrow adds character.
We have a folder called LunchLogos. Any png file found is the folder is added to an generic image list at the start of the program. When the user clicks Spin, the logos are randomly displayed on the screen for a random number of times before stopping on a chosen eatery.
If you don’t like a restaurant all you have to do is remove the logo from the folder. If you have a restaurant you like that isn’t in the list all you have to do is add the logo to the same folder, simple, simple.
Again for this application we used the RNGCryptoServiceProvider class to generate a statistically sound random number.
1: private int GetRandomNumber(int minValue, int maxValue)
2: {
3: // Use a 4-byte array to fill it with random bytes and convert it then
4: // to an integer value.
5: byte[] randomBytes = new byte[4];
6:
7: // Generate 4 random bytes.
8: RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
9: rng.GetBytes(randomBytes);
10:
11: // Convert 4 bytes into a 32-bit integer value.
12: int seed = (randomBytes[0] & 0x7f) << 24 |
13: randomBytes[1] << 16 |
14: randomBytes[2] << 8 |
15: randomBytes[3];
16:
17: // Now, this is real randomization.
18: Random random = new Random(seed);
19:
20: return random.Next(minValue, maxValue);
21: }
And we have created a simple randomize list function to mix things up a bit.
1: public void RandomizeList(List<string> arrayList)
3:
4: if (arrayList == null) { return; }
5: int count = arrayList.Count;
6: for (int i = 0; i < count; i++)
7: {
8: string tmp = arrayList[i];
9: arrayList.RemoveAt(i);
10: arrayList.Insert(GetRandomNumber(0, count), tmp);
11: }
12: }
Last but not least, we use the Mod function to make sure we can loop around the list when picking images.
1: private void Spin()
3: int index1 = GetRandomNumber(0, logos.Count);
4: int index2 = (index1 + 1) % logos.Count;
5: int index3 = (index2 + 1) % logos.Count;
7: pictureBoxTop.Image = logos[index1];
8: pictureBox.Image = logos[index2];
9: pictureBoxBottom.Image = logos[index3];
10: }
Possibilities:
Well, I think it would be cool if there was a background sound to go along with the spin. I also think a UI for adding and deleting logos would be great. It would be nice to be able to assign weights to each restaurant, and to favor new choices over previously selected places.
Download executable: lunchomatic.cab
Download Source Code: lunchomatic.zip
Feedback:
How could we make this application even better? Share your ideas with the community.
Theme design by Jelle Druyts
Pick a theme: BlogXP BlogXP business calmBlue Candid Blue dasBlog dasblogger DirectionalRedux Discreet Blog Blue Elegante essence Just Html MadsSimple Mobile Mono Movable Radio Blue Movable Radio Heat nautica022 orangeCream Portal Project84 Project84Grass Slate Sound Waves The Right Stuff 2.0 Tricoleur useit.com Voidclass2 BlogXP BlogXP business calmBlue Candid Blue dasBlog dasblogger DirectionalRedux Discreet Blog Blue Elegante essence Just Html MadsSimple Mobile Mono Movable Radio Blue Movable Radio Heat nautica022 orangeCream Portal Project84 Project84Grass Slate Sound Waves The Right Stuff 2.0 Tricoleur useit.com Voidclass2
Powered by: newtelligence dasBlog 2.0.7226.0
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2009, Chris Craft
E-mail