- StPendl Oct 29, 2011
Now we are ready to start implementing the initial request to enable color selection by clicking the color boxes instead of the radio buttons.
We only have to apply the same naming convention to the graphics boxes used to display the tolerance colors to be able to use a unified mouse event handler.
Streamlining your code
Chapter 5 - Apply mouse selection
-Now we are ready to start implementing the initial request to enable color selection by clicking the color boxes instead of the radio buttons.
We only have to apply the same naming convention to the graphics boxes used to display the tolerance colors to be able to use a unified mouse event handler.
Now we assign the mouse event handlers to all the graphics boxes, which is a piece of cake now, since we use loops to apply changes:
Finally we just need to add the initial display and the mouse event handler.
The complete code now looks like this.
Chapter 1 - Starting the mission
Chapter 2 - Using arrays to reduce redundant code
Chapter 3 - Use variables for duplicate command strings
Chapter 4 - Consolidate event handlers
Chapter 5 - Apply mouse selection
Chapter 6 - Remove radio buttons
Chapter 7 - Use a single graphics box for the resistor display
Chapter 8 - Further reduce the amount of GUI controls
Chapter 9 - Adding some eye-candy
Chapter 10 - Summary