COP4226, Homework 1
Due Thursday, September 24 at 5 pm.
Zip your entire project and upload on the web. Exclude the
Debug and Release directories.
Submitting
Homework Online.
Be sure to include your control library in your uploaded file.
Create a forms based application.
Avoid long methods. Each method that you create should be short, to promote
encapsulation. If you have a method that is longer than 25 lines, than it
probably needs to be divided into smaller methods.
Do not create a new data structure if there is one that already exists that
will solve the problem.
Settings
Add to the project settings.
-
Create an integer user setting that will contain the width of a button.
-
Create an integer user setting that will contain the height of a button.
-
Create an integer user setting that will contain the spacing between buttons.
Resources
Add to the project resources.
-
Create an icon that contains your initials.
Button Interface
Create an interface.
-
Add three properties to the interface.
-
ButtonWidth
-
ButtonHeight
-
ButtonSpacing
Preferences Dialog
Create a dialog that will be used to gather information from the user.
-
Set the default, background image of the form to an image that is only
added to this dialog's resources, not to the project resources
-
Create a dialog that has three labels and three text boxes for entering the
width of a button, height of a button and button spacing.
-
Add an OK and Cancel button to the form.
-
Set the OK button as the button that is clicked when the Enter key is pressed
on the form.
-
Set the Cancel button as the button that is clicked when the Esc key is pressed
on the form.
-
Perform validation.
-
Do not let the OK button proceed if there are errors.
-
Display an error icon next to the OK button, if there is an error when it
is clicked.
-
Allow the focus to be moved from a box that has an invalid value.
-
Validate all the text boxes.
-
Validate that the width is between 75 and 200.
-
Validate that the height is between 20 and 35.
-
Validate that the spacing is between 1 and 8.
-
Use an error icon to display an error icon and tooltip next to each invalid
field.
-
Use an icon from SystemIcons, other than the default icon for error providers.
-
Be sure an icon will disappear when the error is fixed.
-
Set the minimum size of the form so that none of the controls ever disappear.
-
Anchor the labels and text boxes so that they are located horizontally in
the center of the form.
-
Anchor the OK and Cancel buttons so that they remain in the lower right area
of the form.
-
Extend the dialog from the button interface. Implement the properties so
that they encapsulate the text property of the corresponding text box.
-
The dialog may not access any members from the main form.
Login Dialog
Display a message box before the application is run.
-
Before the application is run, display a warning message box with the buttons
Yes and No. Make up a creative warning for users that are about to run your
code.
-
If the user selects Yes, then proceed to run the application. If the user
selects No, then do not call Application.Run.
Control Library
Add a control library to the solution. Only add one control library:
it will contain three controls.
Main Form
Modify the main form for the project.
-
Extend the main form from the button interface.
-
The properties should encapsulate access to the settings.
-
The only place that the width, height and spacing settings should be referenced
is from within these properties.
-
Create a context menu with the following options.
-
Open Preferences - open the preferences dialog.
-
Before the dialog is shown, the main form should use the button interface
methods of the dialog to update the properties for the width, height and
spacing.
-
If the user selects OK and closed the dialog, then the main form should retrieve
the width, height and spacing values from the dialog, using the button interface
methods of the dialog. Repopulate the panel (described below).
-
Save Preferences - save the user settings
-
Reload Preferences - reload the user settings. Repopulate the panel (described
below).
-
Reset Preferences - reset the user settings. Repopulate the panel (described
below).
-
Add a menu to the form.
-
Add a top level menu named Help.
-
Add a menu item named Oath to the Help menu. When clicked, display a new
modeless form.
-
Position the window to the right of main window: the right border of
the main window should abut the left border of the new window; the tops of
the windows should be at the same height from the top of the screen.
-
When the main form is moved or resized, maintain the window to the right
of the main window: the right border of the main window should abut the left
border of the new window; the tops of the windows should be at the same height
from the top of the screen.
-
The new form may not access any properties of the main form.
-
Make this an owned form.
-
Center the user control for the name at the top of the form. The name should
remain centered when the form is resized.
-
Center the user control for the course and section below the name. The course
and section should remain centered when the form is resized.
-
Center the user control that contains the oath below the section. The user
control should remain centered when the form is resized.
-
Add a menu item named About to the Help menu. When clicked, display a new
modal form.
-
Position the window below the main window: the bottom border of the
main window should abut the top border of the new window; the left borders
of the windows should be at the same distance from the left edge of the screen.
-
The new form may not access any properties of the main form.
-
Center the user control for the name at the top of the form.
-
Center the user control for the course and section below the name.
-
Add a label that describes this assignment.
-
Add the context menu to the main menu.
-
Add a status bar.
-
Add a status label to the status bar.
-
Make the label expand to fill the status bar, no matter how large the form
is made.
-
Center your name, from the control library, at the top of the form. When
the form is resized, the name should remain centered.
-
Set the minimum size for the form so that the name never disappears.
-
Add a panel that fills the space between the menu and the status bar, no
matter what size the form has.
-
Add buttons to the panel.
-
Each button should have the width and height from the user settings.
-
Lay out the buttons in rows and columns. The space between a row and a column
should be from the user settings.
-
Add enough buttons so that the panel is filled with buttons.
-
Do not overlap buttons.
-
Only add a button if the entire button and its spacing will fit in the panel.
-
The label of the button should contain the location of the button in the
panel coordinates.
-
When the button is clicked, display the number of buttons in the panel and
the row and column where this button is located on the panel.
-
When the form is resized, the panel will also be resized. Repopulate the
panel with buttons whenever the form is resized.
-
You may need to remove buttons from the panel, if they can no longer be displayed
completely.
-
You may need to add buttons to the panel, if there is empty space that can
fit buttons.
-
You may change the location, size and text of a button whenever the buttons
are repopulated.
-
When the mouse moves in the panel, update the status bar with the current
location of the mouse.
-
This should work wherever the mouse is in the panel, including if it is over
a button.
-
You will find the PointToClient and PointToScreen methods very useful here.
-
Add a notify icon.
-
Use your icon with your initials for the icon.
-
Use your context menu for it.
-
When the form is deactivated, make the form partially transparent. When the
form is activated, make the form opaque.
-
When the form closes, ask the user if they really want to close the application.
Only close the application if the user confirms.
Screen Shots
Open Dialogs,
Open Preferences Dialog