COP4226, Exercise 3
Due Sunday, March 23 at 11:59 pm.
Zip your entire project and upload on the web. Exclude the
Debug and Release directories.
Submitting
Homework Online.
This project will open text files and display the data in two formats: column
view and line view. You are only allowed to draw the text to a panel, you
may not use a text box, or a list view, etc. Once the file is open, the font
and color used to display the text can be changed. There will be a data file
for this application. It will save the lines from the text file; it will
store the current font and the current color. When the file is saved, the
lines, font and color will be retrieved from the file. A toolbar will be
used to facilitate access to the menu items. When possible, share the toolbar
handler with the equivalent menu handler.
Data Class
-
Create a data class that contains a generic list of strings, a font, a color,
a default font, a default color and a brush.
-
Create a constructor that is passed a font and color. Set the default font
and color, as well.
-
Create properties for the font and color. Whenever the color is changed,
dispose of the brush and create a new one.
-
Do not expose the list as a property.
-
Create an Add method that is passed the name of a text file. Open the file
and add its lines to the list.
-
Create a reset method that will empty the list and reset the font and color
to the default values.
-
Create several methods for displaying the text in different formats.
-
Line View: display each line in the list as a separate line. Use single line
spacing, left alignement, top line alignment, no wrapping, path ellipsis,
only display full lines.
-
Column View: Split the lines into words. Display the words in columns by
using tab stops. If the words from one line do not fit in one display line,
then use additional display lines to display all the words. The last column
in the display should use character ellipsis if the word will not fit in
the remaining space. If a word is longer than one tab stop, then allow it
to extend into as many columns as it needs (this is the default behavior
for tabs). Set the tab stops at a constant spacing; allow as many tab stops
as will fit in the client window.
-
The class should be serializable.
-
Create a method for serializing this class. Do not serialize the brush.
-
Create a method for deserializing from a file. When the file is deserialized,
create a brush from the stored color.
-
Implement IDisposable. Suppress the finalize method when the class is disposed
of properly.
-
Dispose of the brush when the class is disposed.
-
You may add other helper methods and variables as you see fit. The idea is
to encapsulate all access to the data inside this class.
Main Class
-
Add a panel for drawing the text. When the form opens, display the message
"Please open a file" in the center of the panel. Display this text with a
light gray color.
-
There should be no direct access to the text in the main class: all access
is through the data class.
-
Add a Status Bar: Add a label for displaying what the current view is: column
view or line view.
-
Add a ToolStrip: Add the default items, then remove the ones you don't need.
Add a separator and three buttons to the toolbar. Create simple images for
the new buttons. One is for changing the font, one is for changing the color,
the third is for toggling the view state. Set the view button so it is
self-checking: the appearance of the button will change when clicked.
-
Add a main menu: Add the default items, then remove the ones you don't need.
Under the Tools menu, add items for changing the font and changing the color.
Add two items for setting the view: the item that corresponds to the current
view mode should be checked. When one of the view items is clicked, set the
appropriate check marks and redraw the panel with the corresponding view.
-
File->Open: Reset the data class and open a file. The drop down list of
file choices should be for text files (*.txt) and for files created by this
application (*.ex3). Call the appropriate method in the data class, depending
on the extension.
-
File->New: reset the data class; do not create a new class, reuse the
old one. Display the message "Please open a file" in the center of the panel.
Display this text with a light gray color.
-
File->Save: serialize; only save with the .ex3 extension. The drop down
list of file choices should be for files created by this application (*.ex3).
-
File->Save As: alow the user to choose a file; only save with the .ex3
extension. The drop down list of file choices should be for files created
by this application (*.ex3).
-
File->Exit: close.
-
Tools->Font: change the current font for the data class.
-
Tools->Color: change the current color for the data class.
-
Tools->Line View: display the data in a line view. Update the status bar.
-
Tools->Column View: display the data in a column view. Update the status
bar.
-
Help->About: open an about dialog. Display your name, course and oath
from the control library from assignment 1. Also display a meaningful
description. Add a reference to the DLL file (from the References tab Add
Reference->Browse). To see the controls in the toolbox: open the General
tab; right click; Choose Items; Browse for the DLL.
Screen Shots: Line View,
Column View, File Open.