COP4226, Shape Assignment
Due Monday, October 30
This application will draw shapes instead of using shape controls. It will use
pens and brushes to draw and fill the shapes. It will
use data binding to exchange data between the main form and the shape dialog.
Create an application that will use a separate class for a document. The document will
contain a list of shape ojects. Define a separate class for the shape information. Be sure
to encapsulate operations in the class they work on.
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.
Control Library
Update the control library from previous assignments. Be sure to include the file in the zip that you upload.
- Create or modify a form that will be used as a base form for the main form in the main
project.
- 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.
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.
- Instead of using an image background, use a path gradient background. Make the brush small enough so that
it must repeat when used to paint the background of the dialog.
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.
- Use a linear gradient pen as a border around the client rectangle of the dialog. Change the
angle of the gradient and use more than two colors.
Enumerations
Create an enumeration for shapes that contains the values Ellipse, Rectangle and Custom.
Create enumerations for pen type and brush type.
Shape Class
Create a class that will hold data for a shape. The shape will have location, size, pen color, pen type, brush color, brush type 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. Use a container class to hold the 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.
- Allow the user to change any of the shape properties.
- Allow three options for pen type: solid, dashed and compound.
- Provide several options for brush type, including linear gradient, solid and hatched.
- The dialog may not access any members from the main form, application settings or user settings.
- Use data binding to exchange data between the main form and the dialog.
- Add buttons to the dialog that allow the user to cycle through the properties for each shape.
- The current shape should be displayed with some theme that indicates that the current properties will change that shape.
Main Form
Extend the main form from the form that was added to the control library for this assignment.
- Allow serialization and deserialization of each document.
- Use a SaveFileDialog for serializing. Add a default extension of your choice.
- Use an OpenFileDialog for deseraializing. Show only files with your extension. Allow for another option to display all files.
- For both open and save, limit the visible files to those with a specific extension for your application.
- If an extension is not included when saving, have the extension added automatcially.
- The entire document should be saved: the collection of shapes and each shape in the collection.
- 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 (refer to the
link on the class page about inherited menus).
- 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 compound can be seen easily.
- When an item is clicked, set the current pen to the selected menu 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 the brush and pen colors.
- When an item is clicked, set the current brush to the selected menu item's brush.
- Add a Color menu item with drop down items for two colors: pen color, brush color.
- 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.
- The upper left and lower right corners of the shape are defined by the original mouse down and the current mouse positions.
- 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.
- Be sure the dialog can still be opened after the shape has been modified.
Submitting the Assignment
Zip your entire project and upload via the Assignment Dropbox on BlackBoard.
Exclude the Debug and Release directories.
Be sure to include your control library in your uploaded file.
Upload your video to me using the upload via the Assignment Dropbox on BlackBoard.