Project #2 - Twinkly - 15%
due by midnight, Sun. Jan. 22

Please read the class programming standards and the GUI testlist.
 
Deduction for lateness is 10% per day for 5 days, then no credit.  Start early!

Version 1.0, last updated 08/07/2006

GRADING CRITERION:

  1. 75% correct execution
  2. 25% coding practices (maintainability etc.)

Using Microsoft Visual C#, write a screen joke that scatters buttons which change color and flash on and off randomly all over the screen, something like this:

RULES:

  1. Your Twinkly program should behave, look and feel as much like my Twinkly prototype as possible (with one exception--see rule 7, below).  Menus should use the exact text shown in my prototype. Download the prototype and run it--stop it by right-clicking over its icon in the system tray. 
  2. Twinkly must be a stand-alone executable, requiring no external files to run, and creating no files when it runs.
  3. The program must be controllable from an icon in the system tray.
  4. Twinkly's buttons should stay on top of any other running programs, but Twinkly should still allow you to run other programs.
  5. The right-click menu in the system tray must offer the option of bringing up an "About..." window which tells who wrote the program, etc.
  6. Twinkly must use have the following architecture:
  7. Buttons must seem randomly to appear and disappear.  Also (and my prototype does not do this), when it reappears, the button should have changed location randomly.
  8. While visible, buttons must rotate periodically (and randomly) among at least 15 different colors.
  9. Buttons must not all change colors at the same time, and must not change to the same color (that is, colors must not be chosen in a predictable order).  The thing to strive for is a "twinkling" effect; the changing of color, appearance and disappearance of buttons, should attempt to be random-seeming.
  10. Buttons must not seem to all disappear at the same time.
  11. The previous requirements imply that each button has information inside it about its current state, and when its Click() method is called by MainForm's timer, it looks at its state fields to determine whether this button should change color, move-and-appear, or disappear, or do nothing during this click (that is, wait for a future click).
  12. Buttons must be square and should be 7 pixels wide/tall, unless the screen is wider than 1024 pixels, in which case buttons should be 9 pixels wide/tall.
  13. There should be at least 125 buttons, unless the screen is wider than 1024 pixels, in which case there should be at least 155 buttons.
  14. Buttons should be placed over the entire screen randomly.  The MainForm's edges and background must not show.
  15. Twinkly must not appear in the task bar when running.
  16. The timer interval should probably be between 300 and 700 milliseconds.  I used 400 ms, you may need it to be slower or faster depending on your processor.
EXTRA CREDIT OPPORTUNITY: My prototype is a processor hog, using 25-50% of CPU time on a 2.1 GHz Dell.  If you can figure out a way to do all the above while being less hoggy, the grader may consider extra credit up to 10% of this project (that's worth 1.5 points on your course average--if you can get it).  This extra credit will be at the discretion of the grader, who gets to determine whether any performance advantage over my prototype is significant.  A good way to determine processor usage is to use the free utility Process Explorer--sort it's output by CPU usage.  Good luck!

GOALS:

  1. To become familiar with using the Timer control.
  2. To practice keeping state in a program (Twinkly buttons are either on or off at a given moment).
  3. To practice using a random number generator.
  4. To practice creating and using a custom control (Twinklers are custom buttons).
  5. To practice using delegates to make a form and custom control able to call each other's methods.

TIPS and TECHNIQUES:

  1. Here's how to use the system tray.
  2. Here's a sample timer program (I dragged a timer from the ToolBox onto the main form and added a little code to the MainForm_Load and timer1_Tick methods).   There are two timer controls in the Toolbox view of VS.NET, one in "Windows Forms" tab and another in "Components" tab.  Please use the one in the "Windows Forms" tab.
  3. Here's sample code that uses delegates to send methods from a form to another class.
  4. Here's a program that uses random number generator.
  5. Here's some tutorials on extending controls such as buttons

IMPORTANT: Programming Standards

GETTING HELP:
If you need help, try (in preferred order):

  • posting to the Discussion Group in Blackboard
  • call or find me or a TA
  • send email (last resort)

TURN-IN:
The turn-in procedure for programming assignments is as follows:

  1. Create a folder with your emailID as its name.  The folder I would create would be pgpalmer; yours will be different.
  2. Copy your Visual Studio solution and project, and all related files, into this folder.
  3. Test your copied program thoroughly to make sure it works.
  4. When fully tested, zip up the entire folder, including all files underneath the folder.  NOTE: Please do not use the "save full path info" option.
  5. Test unarchiving the zip file to make sure it produces all your files and directories, but in whatever folder the person unzipping chooses (such as, on the Desktop).
  6. If correct, log into Blackboard and turn in the zip file (via file upload in your web browser).

Visitors:  Hit Counter