C# // Visual Studio // Modal Dialog, User Input Controls, Custom Control, Draw Shapes
Students will create an application that allows for creating shapes from both the main form and a modal dialog. These shapes will then be drawn in random colors on a custom control.
Must use a Custom Control for this assignment and Custom Event Handlers as a means to communicate between forms.
At a minimum you will need a Main form, a second form to act as a modal dialog, and a scrollable custom control.
The Main form will need to have a menuStrip, an instance of your custom control, and an area for user input. In both the Main form and the modal dialog you must accept user input for the values of the X, Y, Width, and Height of shapes that will be created. Additionally the user must be able to select if the shape is a rectangle or an ellipse. There will need to be a button for the user to press when they have finished setting the values of their shape. After adding a shape from the Main form, the form’s controls should default back to 0, while adding from the modal dialog should close the modal dialog.
The Main form’s menuStrip will need a File menu with a New option for clearing the shapes, and a Shape menu with an Add option for bringing up the modal dialog. When the modal dialog is displayed its user input controls should default to whatever values are currently in the Main form’s user input controls.
Your custom control will be used to display all of the shapes that have been added. This means you will need to store each shape that gets created and then draw them in your custom control’s OnPaint method. The custom control that is added to your Main form will need to be able to scroll to a size of 1000 by 1000 pixels. The final requirement is that each shape should be drawn in a random color determined per shape that remains consistent for each individual shape even when a new shape is added. You will likely need to create your own Pen object for this and your own Color object. The Color class has a static FromArgb method to help create a Color.
These are the guidelines used by the grading rubric:
Modal Dialog
The dialog is modal.
Shapes can successfully be added from the dialog.
The dialog’s user input control values are used for shapes added from the dialog.
When the dialog first becomes visible, the user input controls are populated with the values currently in the Main form’s user input controls.
User Input Controls
The user is able to set the four components (X, Y, and Width, Height) for the shapes.
The user can choose between rectangle and ellipse for their shapes.
A button is present for the user to confirm when they want a shape to be added.
Pressing the button to add a shape resets the user input controls to their default values.
Custom Control
Draws shapes with the correct dimensions set by user input.
Shapes are properly drawn as either rectangles or ellipses based on user input.
Shapes remain until the user chooses to clear the shapes using the File->New option.
Color
The shapes are drawn with a random color for each shape and the color remains consistent per individual shape even when a new shape is added. (Partial credit will be awarded if the random color is applied, but the colors change every time OnPaint is called.)
Extra Information
Go back through your code and check for the following:
Your application must compile and must not crash when starting up.
All variables and methods are named appropriately.
Input controls are appropriately labeled.
Any information being output to the user should be clear and concise.
Make sure nothing accesses an object that doesn’t exist.
Add comments to your code to indicate that you know what each line does.