COP4226 Assignment 4
Due Thursday, 12/3 Saturday, 12/5
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
Create a Single Instance Multiple-SDI application, like on page 563 of the
text.
The original assignment description did not allow for the use of a rich text box.
You may now use a rich text box; however, you must implement manual drag and
drop, you may not use the built in drag and drop of a rich text box. The changes
to the assignment are displayed in this font.
-
Extend the form from the base form class created in an earlier assignment.
-
Create appropriate help and oath dialogs.
-
Override the click events from the base to display the dialogs.
-
Modify the status bar in the base form.
-
Add separate status labels for the insert, cap lock, num lock and scroll
lock keys.
-
Show appropriate text for each key when each key is toggled. Do not show
text for a key if that key is not toggled.
-
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.
-
If there are multiple command line arguments, then open multiple files.
-
Add a menu to the main form.
-
Insert the menu items into the base menu at runtime.
-
Add all the standard menu items to the menu.
-
Click the tiny arrow to the right of the menu in the designer. Click Insert
Standard Items.
-
Remove the items for printing.
-
Remove the Help menu from this menu (you still have a Help menu in the base).
-
Remove the Options and Customize items under Tools. Do not remove Tools.
-
Add a Seach item to the Tools menu.
-
Add a Close item to the File menu.
-
Add an empty 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.
-
Add short cut keys to all menu items that do not have them.
-
Add a hot key prefix to all menu items that do not have them.
-
Add tool tip info to all menu items that do not have them.
-
Create a context menu.
-
Select all the menu items under the Edit menu from the main menu.
-
Cut them.
-
Insert them into the context menu.
-
At runtime, set the drop down of the Edit menu from the main menu to this
context menu.
-
Add short cut keys to all menu items that do not have them.
-
Add hot key prefix for all menu items that do not have them.
-
Add tool tip info to all menu items that do not have them.
-
Add a toolstrip to the main form.
-
Add all the standard buttons to the tool strip (click the little arrow).
-
Remove the buttons for printing.
-
Add a separator.
-
Add two buttons
-
One button is for redo and the other is for undo.
-
Find small images for each of these buttons.
-
Set the handler for each button to the corresponding menu item handler. Do
not create new handlers for the toolstrip buttons; reuse the ones for the
menu items.
-
Add a rich text box to the main form. It should fill the remaining space not occupied
by the menu, toolstrip and status bar.
-
Rich Text boxes already know how to do redo, undo, cut, copy and paste.
-
Rich Text boxes already have the ability to set selected text.
-
Use existing members of text box to implement the handers for redo, undo,
cut, copy and paste.
-
Set the context menu for the text box to the context menu that you created
above.
-
Enabling menu and toolstrip items.
-
Enable /disable redo, undo, cut, copy and paste only when these operations
can proceed.
-
For menu items, enable/disable when the menu opens.
-
For toostrip buttons, be sure the buttons always show the correct state for
enable/disable. When you disable a button, it will automatically turn gray.
-
Drag and drop
-
Implement manual drag and drop for the rich text box. You may not use the
built in drag and drop of a rich text box.
-
Allow for copy and move.
-
If the operation is move, you must delete the original text after the move
is done.
-
It is allowed that text be moved inside the text box.
-
If the moved text is placed before the original selection, then you will
need to adjust the starting position of the text that needs to be deleted
after the move.
-
It is easier to use Paste to insert the text into the text box than to do
it manually.
-
Paste will not insert dragged text. It will only insert text that is in the
clipboard.
-
Use the Clipboard class and its static members to manipulate the clipboard.
-
Be sure that the clipboard does not retain the dragged text. Reset the clipboard
to the text that was in it before the drag.
-
File Menu
-
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)
and All Files (*.*).
-
The rich text box already knows how to load a file into itself.
-
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.
-
The rich text box already knows how to save itself to a file.
-
Save As - Save the data in a file.
-
In the save file dialog, the file type list should include Text File (*.txt)
and All Files (*.*).
-
The file name of the current file should appear in the file name box of the
dialog.
-
The rich text box already knows how to save itself to a file.
-
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.
-
The rich text box already knows how to keep track of when it is modified by the
user. If you modify the text in code, then you must tell the text box that
it has been modified.
-
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.
-
Do a similar trick as was done for the window menu, so that the the exit
handler is processed in the application base and not in the main form.
-
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.
-
The rich text box already knows how to keep track of when it is modified by the
user. If you modify the text in code, then you must tell the text box that
it has been modified.
-
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
-
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 in the clipboard. Use the Clipboard class and the DataFormats enumeration.
-
Undo - Undo the last edit. Only enable this if there is an edit to undo.
-
Redo - Redo the last edit that was undone. Only enable this if there is an
edit to redo.
-
Search Menu Item
-
Open a modeless dialog containing the following:
-
A list box that will display all the files found.
-
Buttons for starting, stopping and pausing a search. Enabled/disable these
buttons as appropriate.
-
Pause a thread by calling the static method Sleep from the Thread class.
Sleep for short periods of time, checking to see if the thread should resume.
-
A combo box with drop down style of drop down list, containing the different
extensions for text files. Include .txt, .html and .html at the least. You
may add other extensions if you choose.
-
The search should be run in a separate thread.
-
When the search is paused, change the name on the pause button to continue.
If clicked, this button will not continue the search.
-
Search for all files with specific extension on the current computer.
-
Find all files with the extension selected from the drop down list.
-
If the drop down list is changed during the search, then the file extension
that the search is seeking will also change.
-
I have provided a text file with methods
that will search your hard drive for .txt files.
-
You will need to modify the code to work in a thread.
-
You will need to test for cancellation and pause at several places, to guarantee
a fast response to the command.
-
Every time a file is found, add its full path to the list box.
-
Double-clicking the name in the list box should open or activate a window
for that file.
-
Only allow one search dialog to be open at a time.
-
Only allow one search to proceed at any time.
-
If the dialog is closed before the search ends, be sure that the search is
cancelled before the dialog closes.
-
When the search is complete, display a message box stating how many files
were found.
-
I strongly suggest that you use a BackgroundWorker.