COP4226, Homework 2
Due Monday, October 18.
Zip your entire project and upload on the web. Exclude the
Debug and Release directories. Be sure to include the folder that
contains your control library.
Submitting
Homework Online.
Control Library
You will add some classes to the control library from Homework 1. If you did
not create the control library, then you will need to create it now. Add the
project to the Homework 2 solution.
- Add the existing control library to your solution. Be sure to include the
source directory in the ZIP file that you create to submit your homework.
You will need to add a reference to the DLL for the control library.
- Modify the user control for your name so that it is painted with a linear
gradient brush. Make the background of the text transparent, so the brush
can be seen. Use at least three colors in the brush.
- Modify the user control for the course so that it is painted with a path
gradient brush. Make the background of the text transparent, so the brush
can be seen. Change the center color, center point. Add at least two arcs
to the path.
- Add a user control that can be moved using the mouse and using the
keyboard (see relevant example from Chapter 2). Be careful with the default
handling of the arrow keys, it will mess you up.
- Use the mouse events to allow the user to drag the control.
- Use the key events to allow the user to move the control with the
arrow keys.
- This control will be used as a base control for controls that will be
created in the main project.
- Add a form that will be used as a base form for dialogs.
- Dock a panel to the top of the form.
- Add a name control to the panel.
- Add a course control to the panel.
- Dock both controls so that together they cover the entire panel.
- Dock a horizontal splitter under the top panel (do not use a
SplitContainer, use a Splitter)
- Change the width and color of the splitter so that it can be seen
easily.
- The splitter should be able to be moved by the user at run time.
- Dock a panel that fills the lower area of the form.
- Remove the minimize and maximize buttons.
- Change the access modifier for all of these so that derived classes
can access them.
- Be sure that the class and the designer class are declared as public.
- Add a form that will be used as a base form for the main form in the main
project.
- Add a tooltip component; only add one for the entire form.
- Add a menu strip, docked to the top. Add a top level menu item named
Help.
- 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 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.
IOptions Interface
Create an interface, named IOptions, with the following properties.
- pen color
- shape color
- pen width.
Main Project
- Create a user control that extends the movable user control in the
control library.
- Change its shape to a closed Bezier curve. The curve should consist
of at least two, connected Bezier curves.
- Draw the edge of the shape with the current pen color and pen width.
- Fill the shape with a hatched brush. Use the shape color for the
background color and the pen color for the foreground color.
- Create a user control that extends the movable user control in the
control library.
- Change its shape to a compound shape. A compound shape is made of two
or more separate shapes. At least one of the shapes that is added
should not overlap any other shapes.
- Draw the edge of the shape with the current pen color and pen width.
- Fill the shape with a hatched brush. Use the shape color for the
background color and the pen color for the foreground color.
- Create a dialog derived from the base dialog class in the control
library.
- Change the title of the dialog to Oath Dialog.
- Add the user control for the oath to the bottom panel. Anchor (not
dock) it so that it grows and shrinks as the dialog is resized.
- Create a dialog derived from the base dialog class in the control
library.
- Change the title of the dialog to About Dialog.
- Add a text box to the bottom panel.
- Allow more than one line in the text box.
- Do not let the user modify the contents at run time.
- Do not have a border around the text box.
- Set the text of the box to a good description of this assignment.
- Anchor (not dock) it so that it grows and shrinks as the dialog
is resized.
- Create a dialog derived from the base dialog class in the control
library.
- Implement the IOptions interface.
- Change the title of the dialog to Options Dialog.
- The details of this dialog are explained in the section after the
main project section.
- Extend the main form from the base main form in the control library.
- Be sure that the main panel is redrawn when the main form is
resized.
- Add a context menu to the main panel that will open when the user
right-clicks the panel.
- The menu will control how a pen is used to draw a frame around
the main panel.
- Pick a fixed width for each pen.
- The pen should use the current pen color.
- The pen should draw entirely within the panel, along its outer
edge. Be warned that a compound pen cannot use an alignment of
inset.
- Add the following to the menu.
- Implement the IOptions interface.
- Encapsulate corresponding user settings.
- When the message from the options dialog is broadcast, update the
colors and pen width with the properties from the dialog.
- Override the click handler for the oath menu item so
that it opens the oath dialog modally.
- Do not add a new event handler to the click
event; override the handler that already exists in the
base class.
- Override the click handler for the about menu item
so that it opens the about dialog modally.
- Do not add a new event handler to the click
event; override the handler that already exists in the
base class.
- From the main form, insert a new menu item into the base menu. This
cannot be done in the designer, due to issues with visual inheritance
of collection containers.
- Add a context menu to the main form.
- Add an item named Options; when the item is clicked, open an
options dialog modelessly.
- Only allow one options dialog to be open at a time.
- Open the dialog so that it abuts the right edge of the main
form.
- Be sure that the options dialog is always in front of the
main form, even when the main form has focus; be sure the
option dialog is minimized when the main form is minimized. Be
sure that the dialog does not remain as a
topmost window on the desktop.
- Add an item named Save Options; when the item is clicked,
save the user settings.
- Add a tool tip to each menu item, including the top level
item.
- At run time, create a new menu item with a label of Tools.
- Set the DropDown event handler to the context menu.
- Insert the menu item into the base menu from the main form at
runtime.
- From the main form, insert a new menu item into the base menu. This
cannot be done in the designer, due to issues with visual inheritance
of collection containers.
- Add a context menu to the main form.
- Add an item named Bezier.
- Add an item named Compound.
- Add tool tips to the menu items.
- When a menu item is clicked,
- add a corresponding user control to the collection of
controls in the main panel from the base class.
- position all new controls at the upper, left corner of
the main panel.
- change the cursor whenever the mouse is over a shape. Use
a different cursor for bezier and compound shapes.
- At run time, create a new menu item with a label of Shapes.
- Set the DropDown event handler to the context menu just
created.
- Insert the menu item into the base menu from the main form at
runtime.
- Update the status strip as follows. Do not modify the status strip in the
base form in the designer. You must modify the status strip at runtime.
- If a bezier shape is being dragged, show Bezier in the status strip.
- If a compound shape is being dragged, show Compound in the status
strip.
- If nothing is being dragged then do not show a message in the status
strip.
Options Dialog
- Extend the dialog from the base dialog class. Do not modify the base
dialogwhen implementing features for the Options dialog.
- Add a help button so that it is visible in the title bar.
- The dialog will be opened modelessly. Have three
buttons: Close, Apply, Cancel.
- Apply: notify any listeners that the dialog has new data, do not
close the dialog.
- Close: notify any listeners that the dialog has new data and close
the dialog.
- Cancel: do not broadcast a message and close the dialog.
- The dialog may not reference the main form in any way.
- The dialog may not reference the user resources.
- Add a button that will open a color dialog.
- It will select the color of the pen to use when drawing shapes.
- Initialize the color dialog with the current pen color.
- After a color is chosen, change the background color of the button to
that color.
- Add a button that will open a color dialog.
- It will select the background color of the shape controls.
- Initialize the color dialog with the current background color for the
shape controls.
- After a color is chosen, change the background color of the button to
that color.
- Add a numeric up down control that has a range of 1 to 10. This will
control the width of the pen.
- Tile the dialog with an image that is smaller than the dialog. Flip in
the X and Y direction. Use an image that you create in visual studio. Be
sure that the image looks different when it is flipped along the X and Y
axes.
- Add a checkbox that controls if the image is recolored.
- There is an overloaded constructor for TextureBrush that uses an
ImageAttributes class. This is the easiest way to recolor and tile.
Create the ImageAttributes as was explained in class and the text, but
use the TextureBrush constructor and FillRectangle to apply the colors
and tile.
- When the checkbox is in the checked state, do the following:
- Remember the last mouse click, if the X and Y coordinates are
less than the width and height of the image. The initial value of
the mouse click should be set to valid coordinates in your
image.
- When painting, use the ImageAttributes to recolor the image.
Change the color at the pixel in the bitmap that corresponds to the
last saved mouse click. Change the color to the current shape
color.
- Implement the IOptions interface. Encapsulate corresponding values from
the corresponding form controls.
- Add a help provider. Set help information for all the
buttons and up down control.
Main Form, Shape Menu, Oath Dialog, Options Dialog