COP4226, Homework 2
Due Friday, November 1 (late 6am 11/2)
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 Single Document Interface 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 will
solve the problem.
Control Library
Use the control library from homework 1. Be sure to include the file in the zip that you upload.
- Add a form that will be used as a base form for the main form in the main
project.
- Add a menu strip, docked to the top.
- Add a top level menu item named Help to the menu strip.
- Add a menu item named Oath
- Add a menu item named About.
- Add handlers for both of these menu options; make them virtual.
The implementation of each should throw a new NotSupportedException
with an appropriate message.
- Add tool tips to the top level menu item and to each submenu
item.
- Add a top level menu item named File to the menu strip.
- Add a menu item named Close. When clicked, close the application.
- Add a status strip, docked to the bottom.
- Add a name control from your user library, dock it to the top, so
that it abuts the bottom of the menu strip.
- Add a main panel that fills the remaining area of the form; if the
form is resized, the panel should still fill the rest of the client
area.
- Change the access modifier for all of these so that derived classes
can access them.
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.
- Extend from the base dialog in the control library.
- Add the oath control. Center it in the remaining space.
- 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.
- Extend from the base dialog in the control library.
- Add a description of the assignment in your own words. Center it in the remaining space.
- The dialog should be a fixed size. Remove the icon, minimize button and maximize button.
Shape Enumeration
Create an enumeration for shapes that contains the values Ellipse, Rectangle and Triangle.
Shape Class
Create a class that will hold data for a shape. The shape will have location, size, rotation, scale, translation and shape type.
Add properties to improve encapsulation. Add more properties and helper methods that contain operations that work on shapes. Encapsulate shape processes in this class.
Document Class
Create a document class that will store shapes. Add properties and helper methods to encapsulate document processes in this class.
Shape Options Dialog
Create a dialog in the main application that will allow the user to modify information for a shape.
- Extend it from the base dialog from the control library.
- Add controls to change all the properties in a shape.
- The interface for the shape should be a ComboBox that is set as a DropDownList. Fill it with the values from the shape enumeration.
- Perform thorough validation. Allow focus change.
- 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.
- The dialog may not access any members from the main form, application settings or user settings.
Main Form
Extend the main form from the form that was added to the control library for this assignment.
- Override the handlers for the Oath and About menu items so they open the Oath and About dialogs modelesslly. Only allow one of each to be open at a time. Open the dialogs so they do not cover the main window. The main form should own the dialogs.
- Add a main menu to the form. Merge it with the menu in the base form.
- Add a Shape menu item with drop down items for each type of shape.
- When an item is clicked, it should be checked.
- Only allow one item to be checked at a time.
- Set one as checked.
- Add a Pen menu item with drop down items for three types of pens: solid, custom dashed, compound.
- When an item is clicked, it should be checked.
- Only allow one item to be checked at a time.
- Set one as checked.
- Create a pen for each item. Each pen should use the pen color. Create a custom dashing for one pen. Create a compound pen for another. Use a big enough width so the dashing and compond can be seen easily.
- When an item is clicked, set the current pen to the selected item's pen.
- Add a Brush menu item with drop down items for three types of brushes: solid, hatch, linear gradient.
- When an item is clicked, it should be checked.
- Only allow one item to be checked at a time.
- Set one as checked.
- Create a brush for each item. The solid brush should use the brush color, the hatch brush should use the brush and pen colors, the linear gradient brush should use more than two colors by alternating the brush and pen colors.
- When an item is clicked, set the current brush to the selected item's brush.
- Add a Color menu item with drop down items for two colors: pen color, brush color.
- When an item is clicked, it should be checked.
- Only allow one item to be checked at a time.
- Set one as checked.
- When an item is clicked, open a color dialog to let the user select each color.
- Add a tool strip. Add items for each of the above menu items. Reuse the handlers for the menu items, do not create new handlers. Create your own images or find useful ones on the web.
User Interface
When the user clicks and drags the mouse, create the currently checked shape from the shape menu.
- Draw the shape on the main panel using the current colors, pen and brush. Draw and fill the shape.
- In the status bar, list the current colors, the type of shape, the type of pen and the type of brush.
- As the mouse is being dragged, show the shape being resized.
- Be sure the shape draws when the mouse is dragged in any direction, not just down and to the right.
-
When a shape is right-clicked, open the options dialog modelessly.
- When the user clicks apply, the main form will retrieve the updated properties and redraw itself.
- The scale, rotation and translation properties will be used to draw the shape using a matrix.
- Be sure the dialog can still be opened after the shape has been transformed.