COP4226, Homework 4
Due Friday, 12/5 (late 6am 12/6)
Zip your entire project and upload on the web. Exclude the
Debug and Release directories.
Submitting
Homework Online.
Be sure to include your control library in your uploaded file.
Avoid long methods. Each method that you create should be short, to promote
encapsulation. If you have a method that is longer than 25 lines, then it
probably needs to be divided into smaller methods.
Multi-SDI Application
This application will be an example of a Multiple - Single Document Interface (Multi-SDI)
application. It will create a better notepad that can open multiple windows. The improved
notepad will also look for prime numbers. Perhaps the name for the application should be
NotePrime.
Be sure that I cannot crash your
program. This means that you will need to implement validation appropriately.
Do not swallow exceptions! If something goes wrong, be sure that the
appropriate exception is thrown.
Be sure that dialogs open in appropriate
places. Use docking, anchoring, splitting, minimum and maximum sizes to control
the appearance of your application. Use your base classes and user controls
from previous homeworks to improve the appearance of your application.
Under no circumstances should any child form access any part of a parent.
Use interfaces appropriately.
Implement encapsulation. Separate the view from the document.
Under no circumstances may a thread change a variable that is not local to
the thread. The thread may not change parameters.
Application Context
Use the Visual Basic application context.
- Create a multiple document - single instance application. This is not an MDI application, each new document will
have its own top level form.
- Maintain the window menu for all open documents.
- Hint: start with the book example from Chapter 14. Fix the window menu
as I indicated in class.
Prime Thread
Allow an additional thread in the application that calculates prime numbers.
- Allow only one thread to be running at a time.
- Use a custom delegate to pass a custom class between the thread and the thread that called it.
- A prime number is a number that is not divisible by any prime number less than its square root.
- The thread will continually test numbers sequentially. Each time it finds a new prime, notify the main thread.
User Interface
Create a user interface for a text editor.
- Add a menu bar for all the options in the application.
- Add a toolbar for file new, file open, file save, file exit, print, print preview, print preview all, edit copy, edit paste, edit cut. It should appear directly below the main menu for the application. You
may need to change the docking order in order to make it appear correctly.
- Add a rich text box that fills the remaining area. A rich text box has many methods that make life easy. You may use any method in rich text box.
- Add Oath and About dialogs to the application.
- Use your control library as in other assignments.
- Make your application as user friendly as possible, using menus, toolstrips, tooltips, error providers, etc.
Main Application
The main application will handle editing of the document. Just handle plain text. Do not do anything special for rich text.
- Allow drag and drop of text.
- Allow copy and paste of text in the clipboard.
- Allow serialization and deserialization of each document. You may save the file as a simple text file, if you do not want to do serialization and deserialization.
- Use a SaveFileDialog for serializing. Add a default extension of your choice.
- Use an OpenFileDialog for deseraializing. Show only files with your extension. Allow for another option to display all files.
Allow printing and print preview of the document.
- Use an overloaded
MeasureString
method to paginate the document. Fill each page with the maximum number of lines that will fit within the actual margin bounds. Maintain the source formatting. By source formatting, I mean the line breaks and form feeds. You may use one font to display the text in the printed page
- Print a header on each page that contains the course aligned
to the top left and the name of the assignment aligned to the
top right. The header should be outside the actual margin bounds and within the actual page bounds.
- Print a footer on each page that contains your name centered
and the page number aligned to the left. The header should be outside the actual margin bounds and within the actual page bounds.
- Use different fonts for the header, footer and content of the
page. Use a serif font, a sans serif font and a monospace font.
For one of them, use a generic font family. Make the
header font bold; make the footer font italic.
- When printing is chosen, open a print dialog. Allow the user to print selections and ranges. You will need to know the total number of pages in order to do this. Hint: look in the book!
Each open document should be able to start, stop, pause the thread. You may place these controls in the modeless dialog for the thread. The form only has to be able to open the modeless dialog. It does not need individual buttons for the thread.
- Enable and disable the buttons as appropriate.
- Stop the thread before closing the application.
Each open document should be able to open a modeless dialog that shows all the primes that have been found.
- Only allow one dialog to be open at a time for the entire application.
- New primes should populate the dialog as they are found.
The thread may only change a variable that it created. The thread may not change parameters.
Allow serialization and deserialization of all found primes.
- When the application closes, save all the found primes to a fixed file that is located in your application. Do not request a file name.
- When the application opens, read the saved primes from a fixed file that is location in your application. Do not request a file name.
- Upon restart, the thread should determine the last prime and start searching at the next number.