Krzysztof Mossakowski
Windows Programming
2009 - Tasks
Windows Forms: controls
Demonstration
Functionality:
Run the specified number of balls in the blue area
Let the user to 'draw' a rectangle in the blue area (a collision between any ball and the rectangle stop 'drawing')
Inform the user about the result and add it to the list of all results
Allow the user to change the number of balls
Define user interface elements and their behaviour as in the demonstration application.
Be sure to allow to resize the window and automatically adjust the controls positions and/or sizes as in the demonstration application.
Technical requirements:
Drawing is forbiden
. Only objects (esp. controls) and their properties and events can be used.
Speed and direction of each ball should be random. Be sure to bounce balls against the blue area's edges.
Hints:
ListView
FullRowSelect, HideSelection, MultiSelect
View - Details
Sorting
Columns
NumericUpDown
Value, Minimum, Maximum
Timer
Control, Controls
MouseDown, MouseMove, MouseUp
MessageBox
.Show(
string
.Format(
"Result: {0:F2} [{1} ball(s), {2:P}]"
, result, numberBalls, perc));
Approximate points:
controls and their layout (including the window's resizing): 3.0
the ListView control (including adding items with values in 4 columns): 2.0
'balls', their number and movement: 1.5
'drawing' a rectangle: 2.5
logic of the game: 1.0
Links for uploading:
Solutions
Corrections