COP4226, Homework 4 (Homework 3 - Part B)
This application will use many features from Homework 3 - Part A. The additions to the assignment
look like this.
Create a Multiple Document Interface application. The app will open child windows that are either ellipses,
rectangles or custom shapes. One dimension (height or width) 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.
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 group's name and the names of all the members.
- Use a new font, size and color for the names.
- Choose a background color for the control. This color should always
be displayed when the control is added to a parent control.
- Dock the names so that they cover 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 the group name.
- Make the font size of the course smaller than the font size of the
group name.
- 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 understand that this is a group project.
It is in my best interest to participate in writing the homework and study all the
code from the homework.
- The oath should fill the entire control, no matter how the control is resized.
- Use the same font and color as was used for the group 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.
- Add an item named preferences with a subitem named Colors. When clicked, the user
can change the background color of the form by choosing a color from a ColorDialog.
- Add an item named File with a subitem named Close. This should close the form.
- 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 the 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 bottom of the dialog.
- Dock the course/semester control at the top 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.
Project Resources
- Add an image to the project resources that will be used as a background image for several dialogs.
Oath Dialog
Create a dialog in the main application that will display the oath of participation.
- 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 modeless 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.
- The user interface should allow the user to enter width of an elliptic child, height of a rectangular child and 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. Choose reasonable validation ranges.
- Allow the form to be resized. No matter what the size is, none of the controls should ever disappear.
- Add the labels and text boxes to a new panel that is just large enough to contain them. 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.
- Display the help icon button in the title bar of the dialog.
- Add tool tips, error providers and help info for each input box and button. Set the help string and tool tip so they 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 an MDI child.
- When the main form is deactivated, make the form partially transparent. When
the main 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.
- Add an appropriate menu item to allow the user see the login screen again.
Elliptic Child
Add a form in the main application that extends the moveable base form.
- Create a constructor that has a float parameter and an integer.
- Remove the frame from the form.
- Define the shape of the form as an ellipse. The integer parameter is the width. The height should be the width multipled by the float parameter.
- Set the menu in the base form so that it will merge with any other menu item with the name Preferences and not appear in the child.
Rectangular Child
Add a form in the main application that extends the moveable base form.
- Create a constructor that has a float parameter and an integer.
- Remove the frame from the form.
- Define the shape of the form as a rectangle. The first parameter is the height. The width should be the height multipled by the float parameter.
- Set the menu in the base form so that it will merge with any other menu item with the name Preferences and not appear in the child.
Custom Child
Add a form in the main application that extends the moveable base form.
- Create a constructor that has a float parameter and an integer.
- Remove the frame from the form.
- Define the shape of the form so to contains at least one ellipse and one rectangle, but it may be as complex as you like. The first parameter is the total width of the shape. The height should be the width multipled by the float parameter.
- Set the menu in the base form so that it will merge with any other menu item with the name Preferences and not appear in the child.
Main Form
Modify the main form for the project.
- 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
for the form.
- If the user selects OK and closes the dialog, then the main form
should retrieve the ellipse width, rectangle height, ellipse ratio and rectangle ratio values from the
dialog. Disable 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
for the form.
- If the user selects OK or Apply, then the main form
should retrieve the ellipse width, rectangle height, ellipse ratio and rectangle ratio values 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.
- Add a status bar. Add a label to the status bar.
- Add a menu to the form.
- Add shortcut keys for all menu items.
- Add a top level menu named File.
- Add an item for opening an elliptic child. Send the value of the elliptic ratio and elliptic width values 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 and rectangle ratio value from
the preferences to the constructor. When focus is on a rectangular child, show the word Rectangle 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 custom child. Send the value of the height value and rectangle ratio value from
the preferences to the constructor. When focus is on a rectangular child, show the word Custom 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 all rectangular children. Only enable the item when the form has at least one open rectangular child.
- Add an item for closing all eliptic children. Only enable the item when the form has at least one open ellipitic child.
- Add an item for closing all open children. The item should not appear if no children are open.
- 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.
- Make this an owned form.
- 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
- Create an icon in the resource editor that contains the initials of one of the members in the group. Set the icon for the form to the intials icon. Delete the color icon templates and modify the black and white 32x32 image and 16x16 image.
- 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.
Create a video
Create a 4-6 minute mp4 video. You may use the free version of
Screencast-o-matic. The video must include:
- A complete walk through of the running program.
- Comment on and show any sections of code that your group is proud of.
- Upload the video to the Video Discussion on Canvas.
Submitting the Assignment
Zip your entire project and upload via the Assignment Submission on Canvas.
Exclude the Debug and Release directories.
Be sure to include your control library in your uploaded file.