COP4226, Exercise 2
Due Friday, February 29 at 11:59 pm.
Zip your entire project and upload on the web. Exclude the
Debug and Release directories.
Submitting
Homework Online.
Main Form
-
Status Bar: Add a label for displaying information about menu items.
-
Main menu: File, Edit
-
File Submenu: Browse, Exit
-
Edit Submenu: Options, Replace Color
-
Add tooltip text for each menu item, including the main menu options.
-
When the mouse enters a menu item, copy the tooltip to the status bar. Reuse
the same method for each menu item.
-
When the mouse leaves a menu item, write "Ready" in the status bar. Reuse
the same method for each menu item.
-
Create shortcuts for each submenu item: Ctrl-B , Ctrl-X, Ctrl-O, Ctrl-R.
-
Add additional controls as follows:
-
Add a list view control.
-
Add a vertical splitter control.
-
Add a panel for drawing an image. Add an image resource and set the background
image to the resource.
-
The splitter will seperate the list view and the panel. The list view will
fill the entire area to the left of the splitter, the panel will fill the
entire area to the right of the panel. Allow the splitter to be moved by
the user.
-
Menu options:
-
File -> Browse. Open a folder browser dialog. After the user chooses a
directory and clicks OK, then populate the list view (explained below) with
the names of the files in the directory. Use the static method Directory.GetFiles
to obtain a String[] of file names. The next time the dialog is opened, the
previous directory should be displayed in the dialog.
-
File -> Exit. Close the main form.
-
Edit -> Options. Open the an options dialog (explained below).
-
Edit -> Replace Colors. Open a color dialog. If the user chooses a color
and clicks OK, then change the first pixel in the last row of the bitmap
with the chosen color. The current image in the panel should be shown with
the replaced color.
-
List view control:
-
Set the view type as list.
-
Populate the list view control with the files in the directory obtained from
the file browser dialog. Only choose files that have extensions of .jpg,
.bmp. .png and .gif. For each file name, add a ListViewItem to the ListView.Items
collection. Set the text of the item to the filename, without the path. Set
the tag for the item to the full filename, including the path. Do not set
an image index for the item.
-
Clear the list before it is populated again.
-
When a filename is double-clicked, use that image when drawing on the panel.
-
Panel control:
-
Add a resource for an image that will be used as the default image when the
application opens.
-
Displays the default image or the most recent image that was chosen from
the list view control.
-
Use a hatch pattern for the background. The hatch pattern will be visible
if the image is smaller than the panel.
-
Allow the image to be dragged.
-
While dragging, change the mouse pointer to the hand.
-
Do not allow the hatching appear to the left or above the image. In other
words, the upper left corner may be dragged out of the panel to the left
or up, but may not be dragged into the panel.
-
When the image cannot be dragged because of the above restriction, change
the cursor to the universal symbol for no (the circle with a line through
it).
-
Use manual double buffering when dragging the image.
-
When the panel is double clicked, set the icon for the main form to the image
that is currently displayed in the panel.
-
When there is a broadcast message from the options dialog (explained below),
update the hatch style and background color for the hatching in the panel.
Only use your properties to access the information in the dialog.
Options Dialog
-
Add a help provider. Set help information for the buttons, combo boxes, text
box and trackbar.
-
Add a help button so that it is visible in the title bar.
-
Create a border that uses a pen made from a linear gradient brush.
-
Use a custom blend for the gradient. Use at least five positions.
-
Fill the background with a path gradient brush.
-
The brush should be no larger than 200 pixels in either dimension.
-
Set the wrap mode to tile. You may flip along any axis you choose.
-
Use a custom color blend. Use at least three different colors.
-
Open the dialog modelessly. Have three buttons: Close, Apply, Cancel.
-
Apply: broadcast a message that the dialog has new data, do not close the
dialog.
-
Close: broadcast a message that the dialog has new data and close the dialog.
-
Cancel: do not broadcast a message and close the dialog.
-
Create properties for the current hatching and the current background color
for the hatching.
-
The dialog may not reference the main form in any way.
-
Add a panel that will display the current hatching using the current hatching
style and current background color (explained below).
-
Add a combo box control for the hathing style.
-
Set the combo box as a drop down list.
-
Set the items in the control to all the hatching styles.
-
When the dialog opens, the hatching should be selected as the current hatching
in the panel control in the main form.
-
When the hatching style changes, change the hatching style of the hatching
panel in this dialog (not the main form).
-
Add a text box for the brightness.
-
The range should be [0.05, 0.95].
-
Display an error icon if the user enters a non-number or a number outside
the range.
-
Do not let the focus leave the text box, if there is invalid data.
-
Allow the dialog to be closed when there is invalid data.
-
The number chose represents the midpoint for a range of birghtness. If 0.05
is chosen, then the range will be [0, 0.1]; if 0.34 is chosen, then the range
will be [0.29, 0.39].
-
When the dialog opens, it should have the brightness set to the brightness
of the background color of the current hatching in the panel control in the
main form.
-
When the focus leaves the text box, the drop down list of colors (explained
below) should be repopulated with the appropriate colors. The first color
in the list should be selected in the combo box. If there are no colors in
the range, then add the color white to the combo box and select it. Only
update the combo box when the focus leaves the text box; do not update as
the brightness number is being typed.
-
Add a combo box control for possible colors.
-
Set the combo box as a drop down list.
-
Set the items in the list as the know colors that have a brightness in the
range specified by the text box.
-
When the dialog opens, it should have the color set to the background color
of the current hatching in the panel control in the main form.
-
When the color changes, change the background color of the hatching panel
in this dialog (not the main form).
-
Add a trackbar.
-
The trackbar will also set the value of the brightness text box.
-
The range of the trackbar is set in integers, so you will need to do a
transformation between the range of the trackbar and the text box.
-
The range should correspond to [0.05, 0.95].
-
There should be a tick corresponding to every 0.05 on the scale.
-
When the trackbar changes, update the value in the brightness text box.
Screen Shots: Main Form with open menu,
Options Dialog with displayed help.