COP4226 Assignment 4
Due Sunday, 4/6 at 11:59 pm.
Zip your entire project and upload on the web. Exclude the
Debug and Release directories.
Submitting
Homework Online. Be sure to include any additional projects that you
use, when you submit the homework
I have created a base application for you to modify.
Download base class. These are the modifications
you need to make.
-
Make it a Single Instance Multiple-SDI application, like on page 563 of the
text.
-
Close the application when all the top level windows have been closed.
-
Each command line argument should be treated as the path to a file. Open
each file in its own top level window.
-
File Menu - The handlers for these options have already been mapped.
-
New - Open a new, top level window.
-
Open - Open a file in a new top level window. The open file dialog is already
opened in the handler and it will open the file selected.
-
In the open file dialog, the file type list should include Text File (*.txt),
Rich Text Files (*.rtf) and All Files (*.*).
-
If the file is opened as Rich Text, then be sure that formatting of the file
appears as it should with fonts and colors.
-
If the file is opened as Text, then be sure that the data appears as plain
text. There should be no additional formatting of colors and fonts. If the
file contains Rich Text formatting codes, then they should appear as text.
-
Save - Save the data in a file..
-
If the data has already been saved, then save it using the current file name.
-
If the data was opened from a file, then save it using the current file name.
-
If the data has not been saved before or did not come from a file, then call
the Save As handler.
-
There is a helper method that will save text to a file. Pass the filename
and the text to save as parameters.
-
Save As - Save the data in a file. The save file dialog is already opened
in the handler and calls a helper method that will .
-
In the save file dialog, the file type list should include Text File (*.txt),
Rich Text Files (*.rtf) and All Files (*.*).
-
If the file is saved as Rich Text, then be sure that formatting of the file
is saved.
-
If the file is saved as Text, then do not save the Rich Text formatting codes.
Only save the plain text.
-
The file name of the current file should appear in the file name box of the
dialog.
-
There is a helper method that will save text to a file. Pass the filename
and the text to save as parameters.
-
Close - Close the current, top level window.
-
Before the window is closed, warn the user if data is to be lost. Inlcude
the file name in the message box title. Give the user three options.
-
Save the data.
-
Do not save the data.
-
Return to the application, without erasing the contents.
-
If this is the last open window, then the application should close.
-
Exit - Close all the open forms. Do not call Application.Exit. Close each
form individually, so that if the close operation for one form is cancelled,
it will not cancel the closing of other forms.
-
Warn the user if data will be lost in each form before it is closed. Inlcude
the file name in the message box title. Give the user three options.
-
Save the data.
-
Do not save the data.
-
Return to the application, without erasing the contents.
-
Iterating through the open forms and closing them can cause exceptions. I
suggest that you use the array notation to access the open forms and close
them in reverse order.
-
Edit Menu - The handler for these options have already been mapped. Update
the state of the menu items and tool strip items in the Application Idle
event handler.
-
Cut - Cut the selected text. Only enable this option if there is selected
text.
-
Copy - Copy text from the clipboard. Only enable this option if there is
selected text.
-
Paste - Paste text from the clipboard. Only enable this option if there is
Text or RTF data in the clipboard. Use the Clipboard class and the DataFormats
enumeration.
-
Font - A font dialog is opened already.
-
Initialize the font dialog with the current font for the selection.
-
If the user selects OK, then set the font as the font for the current selection.
-
If the current selection has a length of zero, then the font will modify
new text added at the current location.
-
Color - A color dialog is opened already.
-
Initialize the color dialog with the current color for the selection.
-
If the user selects OK, then set the color as the color for the current
selection.
-
If the current selection has a length of zero, then the color will
modify new text added at the current location.
-
View Menu - This controls which view is active.
-
Text View - This is the default view with the rich text box.
-
Rectangle View - This is a view that allows a rectangle and an ellipse to
be dragged.
-
Click anywhere in the rectangle to drag it.
-
Click anywhere in the ellipse to drag it. Notice that the ellipse can only
be dragged when the mouse clicks within the ellipse.
-
When the rectangle is dragged, only the smallest area is invalidated.
-
When the ellipse is dragged, only the smallest are is invalidated.
-
As it is implemented, the hatching in the rectangle does not drag with the
rectangle. Make the hatching drag with the rectangle.
-
Zoom - This has submenus for zooming at 50%, 100% and 200%.
-
Use a transform to change the zoom factor, so that the diagrams are zoomed.
-
There is one handler for all three submenus. Modify this handler so that
the panel is zoomed.
-
After zooming, the rectangle and ellipse should still be able to be dragged
by clicking within them. Only the smallest area should be invalidated to
drag each.
-
Modify the menu so that the menu item that corresponds to the current zoom
factor is checked.
-
Window Menu - This will contain a list of the open, top level forms. The
item for the current form should have a check next to it.
-
Help Menu
-
About - Open an about dialog, similar to the one for HW3.
-
Oath - Open an oath dialog, simlar to the one for HW3.
-
The rich text box has a property named Modified. Use this property
to remember if the text has changed since the text was cleared, opened or
saved.
-
When the form closes, make sure that there is not unsaved data. There are
already statements that dispose of resources, only call these when the form
actually closes. Warn the user if data will be lost in each form before it
is closed. Inlcude the file name in the message box title. Give the user
three options.
-
Save the data.
-
Do not save the data.
-
Return to the application, without erasing the contents.