COP4226, Homework 1
Due Wednesday, October 10 (not late until 8am 10/11)
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 dialog 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, then it
probably needs to be divided into smaller methods.
Do not create a new data structure if one that already exists that
will solve the problem.
Settings
Add to the project settings. These settings will be used to control the
appearance of the main panel in your application. In the program, you will use
properties to encapsulate the settings.
- Create an integer user setting that will contain the width of a label.
- Create an integer user setting that will contain the height of a label.
- Create an integer user setting that will contain the spacing between
labels.
Resources
Add to the project resources.
- Use the resource editor to create an icon.
- The icon will be used in a notify icon, described later.
- The icon in the system tray is the 32x32 icon.
- Create an icon that contains your initials.
Label Interface
Create an interface. Interfaces will be used for all dialogs in this course.
The only way that the main form should access the data from a dialog is through
the interface of its public properties.
- Add three properties to the interface.
- LabelWidth
- LabelHeight
- LabelSpacing
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 label, height of a label and label spacing.
- Add an OK and Cancel button to the form. There should also be an Apply
buuton that only appears when the form is opened modelessly.
- 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 the 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. They should remain centered when the form is
resized.
- Anchor the OK and Cancel buttons so that they remain in the lower right
area of the form when the form is resized.
- Extend the dialog from the label 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 or system
properties.
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 label interface.
- The properties should encapsulate access to the user settings.
- The only place that the width, height and spacing user settings
should be referenced is from within these properties.
- Create a context menu with the following options.
- Open Preferences Modally - open the preferences dialog as a
modal dialog. Be sure that its resources are released when you
are done with it.
- Before the dialog is shown, the main form should use the label
interface methods of the dialog to update the properties for the
width, height and spacing.
- If the user selects OK and closes the dialog, then the main form
should retrieve the width, height and spacing values from the
dialog, using the label interface methods of the dialog. Repopulate
the panel (described below).
- Open Preferences Modelessly - open the preferences dialog as a
modeless dialog. Be sure that its resources are released when
you are done with it.
- Before the dialog is shown, the main form should use the label
interface methods of the dialog to update the properties for the
width, height and spacing.
- If the user selects OK or Apply, then the main form should
retrieve the width, height and spacing values from the dialog,
using the label interface methods of the dialog. Repopulate the
panel (described below). On OK, close the dialog. Do not close the
dialog on Apply.
- If the user selects Cancel, ESC, Alt-F4, X button, revert to the
orignal values when the dialog was opened.
- 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 status bar.
- Add a menu to the form.
- Add a top level menu named Help.
- Add a menu Oath to the Help menu.
- Add a menu item named New Dialog to the Oath menu.
- When clicked, display a new modeless form.
- Allow multiple Oath dialogs to be opened.
- Position the first Oath dialog 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.
- Cascade additional Oath dialogs on top of the previous
Oath dialogs.
- When the main form is moved or resized, maintain the Oath
dialogs to the right of the main window: the right border
of the main window should abut the left border of the first
Oath dialog; the tops of the windows should be at the same
height from the top of the screen. Additional open Oath
dialogs should cascade on top of the previous Oath dialogs.
- 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 Close All to the Oath menu. When
clicked, close all of the open Oath dialogs.
- Add a menu item named About to the Help menu.
- When clicked, display a new modeless 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.
- Only allow one of these windows to be open at a time.
- Make this an owned form.
- When the main form is moved or resized, maintain the position
of this dialog below the main window.
- 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.
- 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 labels to the panel.
- Each label should have the width and height from the label
interface properties.
- Lay out the labels in rows and columns. The space between a row
and a column should be from the label interface properties.
- Each label should have a three-dimesional border.
- Add enough labels so that the panel is filled with labels.
- Do not overlap labels.
- Only add a label if the entire label and its spacing will fit in
the panel.
- The text of the label should contain the location of the label in
the panel coordinates. Center the text in the label.
- When the mouse is moved over the label, update the title of the
main form with the number of labels in the panel and the row and
column where this label is located.
- Do not use a FlowLayout.
- When the form is resized, the panel should be resized. Repopulate the
panel with labels whenever the form is resized.
- You may need to remove labels from the panel, if they can no
longer be displayed completely.
- You may need to add labels to the panel, if there is empty space
that can fit labels.
- You may change the location, size and text of a label whenever
the labels are repopulated.
- Be efficient. Reuse labels that have already been created,
when possible.
- 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 label.
- 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
Login Screen, Open Dialogs, Open Preferences Dialog, Notify Icon