COP4226, Homework 1
Due Friday, October 18 (not late until 6am 10/19)
Create a Multiple Document Interface application. The app will open child windows that are either ellipses
or rectangles. The height of each will be determined by a ratio that is set by the user. The child windows can have different colors and can be moved by the mouse.
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.
Use properties to encapsulate implementation details.
Use meaningful names for all variables. Any variable that ends with a number will lose points.
Do not create a new data structure, event, property if one that already exists will
solve the problem.
Settings
Add to the project settings. In the program, use
properties to encapsulate the settings.
- Create a float user setting that will contain the ratio of the width to the height for an elliptic child.
- Create a float user setting that will contain the ratio of the width to the height for a rectangular child.
- Create a float application setting that will contain the minimum value for the range of values for a ratio.
- Create a float application setting that will contain the maximum value for the range of values for a ratio.
Resources
Add to the project resources.
- Use the resource editor to create an icon.
- The icon will be used as the icon for the main form.
- The icon in the control box is the 16x16, 8 bit icon.
- Create the icon so that it looks like your initials. Use the transparent
color to hide portions of the icon that are not your initials.
- Add an image of your choice to the resources. Choose a small image.
Control Library
Add a project for a control library to the solution. Only add one control library:
it will contain three controls and two forms.
- Add a user control that contains your full name.
- Use a new font, size and color for your name.
- Choose a background color for the control. This color should always
be displayed when the control is added to a parent control.
- Dock the name so that it covers the entire user control. You will have to disable the auto-size property for the label.
- Add a user control that contains the course name and semester of the course. Use a separate label for each.
- Use the same font and color as was used for your name.
- Make the font size of the course smaller than the font size of the
name label.
- Make the font size of the semester smaller than the font size of the
course.
- This control should use the background color and background image of
the parent control that it is added to.
- Dock these so that one is above the other and they cover the entire
control, no matter how the control is resized.
- Center each label in its control.
- Add a control that contains the following.
I attest that the homework I am uploading was done by me.
I understand that if it is determined that I shared my
assignment with another person or copied my assignment
from another person's work, then I and the other person
will suffer the consequences that are defined in the syllabus.
Student: your-name
- The oath should fill the entire control, no matter how the control is resized.
- Use the same font and color as was used for your name.
- Make the font size smaller than the font size of the
semester.
- This control should use the background color and background image of
the parent control that it is added to.
- Add a Windows form that will be used as a base form.
- Allow the form to be moved by clicking and dragging with the mouse in the client area.
- Add a context menu to the form. The menu will have one item named Color. When clicked, the user can change the background color of the form by choosing a color from a ColorDialog.
- Add a menu to the form.
- Add an item named Preferences with a subitem named Colors. This option should perform the same action as the context menu Color item.
- Add an item named File with a subitem named Close Child. This should close the form.
- Allow these items to be merged into items with the same name in a MDI parent.
- This menu should not appear in the child. All its items should be merged with the parent at runtime.
- Add a form that will be used as a base for dialogs.
- Dock the name control at the top of the dialog.
- Dock the course/semester control at the bottom of the dialog.
- Dock a panel in the middle that fills all the remaining space. The panel should show the background color and image of its parent.
Interfaces
Use interfaces to encapsulate implementation details. Design code so that the implementation details of data could be changed in the future without having to rewrite all the code that accesses that data.
Oath Dialog
Create a dialog in the main application that will display the pledge of honesty.
- Use the image resource as the background image.
- Extend from the base dialog in the control library.
- Add the oath control. Center it in the panel in the base dialog.
- The dialog should be a fixed size. Remove the icon, minimize button and maximize button.
About Dialog
Create a dialog in the main application that will display a description of the assignment.
- Use the image resource as the background image.
- Extend from the base dialog in the control library.
- Add a description of the assignment. Center it in the panel in the base dialog.
- The dialog should be a fixed size. Remove the icon, minimize button and maximize button.
Preferences Dialog
Create a dialog in the main application that will be used to gather information from the user.
- Extend it from the base dialog in the control library.
- 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. Choose a small image.
- Display the help icon button in the title bar of the dialog.
- The user interface should allow the user to enter the ratio of the width to the height for
elliptic and rectangular children. Add OK, Cancel and Apply buttons. Set the default buttons for the
dialog.
- Perform thorough validation. Allow focus change. The minimum and maximum values for the valid range should be passed to the dialog in the constructor.
- Allow the form to be resized. No matter what the size is, none of the controls should never disappear.
- Add the labels and text boxes to a new panel that is just large enough to contain them. Add padding to the panel to improve appearance. The panel should be centered horizontally in the form. It should remain centered when the form is
resized. The panel should have a different color from the rest of the dialog.
- Add tool tips, error providers and help info for each input box and button. For the ellipse ratio and rectangle ratio text boxes, set the help string and tool top at run time, so they can include the range of valid numbers.
- Anchor the OK, Apply and Cancel buttons so that they remain in the lower right
area of the form when the form is resized.
- When using an interface, it is better to encapsulate actual properties in the dialog or components than to create additional variables.
- Only allow one preferences dialog to be open at a time.
- This is a normal dialog, not a MDI child.
- Create a constructor that accepts the minimum and maximum values for the valid range of numbers for the ratios.
- When the form is deactivated, make the form partially transparent. When
the form is activated, make the form opaque.
- The dialog may not access any members from the main form, application settings or user settings.
Login Dialog
Display a dialog before the application is run.
- Before the application is run, display a warning dialog 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.
- Add a checkbox that allows the user to skip this screen in the future.
- Save the preference in a user setting.
- When the app is started, skip the login dialog if the preference is set.
Elliptic Child
Add a form in the main application that extends the moveable base form.
- Create a constructor that has a float parameter.
- Remove the frame from the form.
- Define the shape of the form as an ellipse. The height should be multipled by the elliptic ratio.
- Set the menu in the base form so that it will merge with any other menu item with the name Preferences.
Rectangular Child
Add a form in the main application that extends the moveable base form.
- Create a constructor that has a float parameter.
- Remove the frame from the form.
- Define the shape of the form as an ellipse. The height should be multiplied by the rectangular ratio.
- Set the menu in the base form so that it will merge with any other menu item with the name Preferences.
Main Form
Modify the main form for the project.
- Create properties tied to the user and application settings.
- Create a context menu with the following options for the preferences dialog.
- 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 update the properties for the
ellipse ratio and rectangle ratio.
- If the user selects OK and closes the dialog, then the main form
should retrieve the ellipse ratio and rectangle ratio values from the
dialog. Hide the Apply buton when opened modally.
- 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 update the properties for the
ellipse ratio and rectangle ratio.
- If the user selects OK or Apply, then the main form should
retrieve the ellipse ratio and rectangle ratio from the dialog. 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.
- The dialog should never show behind the main form. Do not make it a top level form.
- 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 label to the status bar.
- Add a menu to the form.
- Add a top level menu named File.
- Add an item for opening an elliptic child. Send the value of the elliptic ratio value from the preferences to the constructor. When focus is on an elliptic child, show the word Ellipse in the status bar along with the current background color of the child. Update the status bar when the color changes, too. Remember that the child may know nothing about the parent.
- Add an item for opening a rectangular child. Send the value of the height value from the preferences to the constructor. When focus is on a rectangular child, show the word TALL in the status bar along with the current background color of the child. Update the status bar when the color changes, too. Remember that the child may know nothing about the parent.
- Add an item for closing the application.
- Add a top level menu named Help.
- Add a menu Oath to the Help menu.
- This is not a child form, it is a normal dialog.
- When clicked, display a new modal form.
- Position the 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.
- Make this an owned form.
- Add a menu item named About to the Help menu.
- This is not a child form, it is a normal dialog.
- When clicked, display a new modeless form.
- Only allow one About dialog to be open at one time.
- 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.
- Add an item to the main menu, named Preferences, whose drop down is the context menu created above. Do not duplicate the items in the context menu, make the drop down of the new item the same as the context menu. Refer to the additional lecture notes on the class page for Inherited Menus
- Set the icon for the form to your intials icon.
- Set the context menu to the context menu for the preferences.
- When the form closes, ask the user if they really want to close the
application. Only close the application if the user confirms.
Upload Assignment
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.