COP4226, Homework 3
Due Monday, October 26
Create an application with a menu strip, tool strip, and status strip. Add
appropriate items to each to make the application more user friendly.
- Use check marks in menus to indicate which options are chosen.
- Add tool strip icons to indicate the current selections. These handlers
should share the corresponding handlers for the associated menu items.
- Update the status bar with appropriate text for selected items.
Add a tab control to the form. In each tab control, implement one of the
parts of this assignment.
Tasks
Pens
- Draw a shape with a pen.
- Create the pen as an instance variable for the main form. Dispose of the
pen properly.
- Show a menu for pens. The menu should have options for Solid, Custom
and Compound.
- Solid - draw the shape with a solid pen.
- Custom - draw the shape with a custom dashing of your creation.
- Compound - draw the shape with a compound pen. This is in addtion to
the other choice of either solid or custom.
- Only show the menu items and tool strip items associated with this tab page
when this page is active.
Brushes
- Fill a shape with a brush.
- Create the brush as an instance variable for the main form. Dispose of the
brush properly.
- Show a menu for brushes. The menu should have options for Solid, Texture,
Hatch, Linear Gradient, Path Gradient
- Solid - fill the shape with a solid brush. Choose a color for the brush
that is partially transparent (create your own color).
- Texture - fill the shape with a texture brush. Add an image to the main
form resources.
- Hatch - fill the shape with a hatch brush. Choose your own hatching and
colors.
- Linear Gradient - fill the shape with a linear gradient brush. Pick an
unusual angle. Choose at least three colors. Specify where each color is at its
full color.
- Path Gradient - fill the shape with a path gradient brush. Create a path
from at least four points. Choose at least three colors. Be sure that the brush
repeats in the event that it is smaller than the region it is filling. Change the
center color.
- Only show the menu items and tool strip items associated with this tab page
when this page is active.
Image Panning
- Add a large image to the resources.
-
Implement the panning example from the book.
- Draw a border around the image rectangle using the pen created in the
pen tab page.
- Do not pan beyond any edge of the image.
- Enable panning by using the mouse.
- While dragging with the mouse, set the cursor appropriately, using the
panning and no move cursors.
- Show a menu for images. The menu should have an option for double buffering.
- Check the menu option on click.
- When enabled, draw the image rectangle using double buffering.
- Double buffering on the main form will not affect the tab page. Create a
user control or do manual double buffering. The user control has the added
complexity of using the pen created in another tab page. Manual double
buffering from the book is the easier method.
- Only show the menu items and tool strip items associated with this tab page
when this page is active.
Shapes and Text
This task introduces the idea of a document.
Create several shape classes. A shape can be created, drawn and moved. A convenience
method will be to know if a point is within the shape. A shape has at least a
location and a size.
- Rectangle. A rectangle has text inside it. Only allow full lines of text to display
in the rectangle. Draw the text in the lower right corner. If more text is available than
will fit in the rectangle, the last line should have an ellipsis. When creating a rectangle, ask the
user for its text. Draw with a solid brush that contrasts with the brushes from the brush tab.
- Ellipse
- Custom. Draw the shape from a graphics path.
- Shape Base Class. Extend the other shape classes from the base class. Use
polymorphism to place common code in the base with implemetnation specific code
in the extended class.
Create a document that contains a list of shapes. The implementation of the
document is unknown to the public. Useful methods will be to find a shape at
a point, draw the document, add a shape.
The main actions for this tab page are:
- Draw all the shapes from the document. Use the pen from the other tab page.
- Fill all the shapes from the document. Use the brush from the other tab page.
- Move any shape to a new location.
- Be able to zoom the tab page to 100%, 200% and 50%. Use a transform.
- Show a menu for shapes. The menu should have an option for adding each shape type
and for zooming. The zooming menu should have a submenu. Moving can happen in the zoomed
state. Add an item for setting the font that is used to display all text withing a
rectangle.
- Only show the menu items and tool strip items associated with this tab page
when this page is active.