Deliverable 7: Object Persistence


Objectives: Complete the reference program.  

Description: Finalize the reference program by saving the references to a binary file, and then open the file, format the references, and write them to a doc file for future use.


In the last deliverable you saved your references to an ArrayList as each one was entered.  However, when you closed your program you lost the reference objects so you can never choose an alternate format in which to display them.

In this program you will achieve object persistence through the use of Object I/O.

As with previous programs the user will have the option of entering references, with the difference being the new capability of saving the objects to a file. As in the previous program, the user will also have the option of saving the formatted reference list to a rtf file. This program also introduces menus

A menu item should be provided to allow a user to open the reference input form and add new references.  When all references have been entered, the entire ArrayList can be written to a binary file with a .dat extension.  Note that you are writing the unformatted data to a file, not the formatted output.

Keep in mind that the user may enter his references one day, but not use them again for several days or weeks.  Therefore, the form should include a menu option that will allow the user to open, via an OpenFileDialog, the dat file of references that was created and saved in the previous step and store them in an ArrayList. The user can then add to that list of references.  

You should provide a menu option to preview the formatted output in a RichTextBox control.  The user will also want to specify the reference format that is desired.  Thus, the form should also have submenus to allow the user to select the format desired (MLA, APA, Chicago).  Then the array should be sorted by first author's last name, each element in the sorted array should have the proper formatting method (formatMLA, formatAPA, formatChicago) called, and the resulting string should be written to a RichTextBox.

You should provide a menu option to save the formatted output to an rtf file.  The user should be allowed to specify the reference format that is desired via submenus providing choices of MLA, APA, Chicago.  Then the formatted reference list will be written to a RichTextBox as in the preview option, the user will be allowed to select or specify an rtf file in which to save the formatted data via a SaveFileDialog, and the contents of the RichTextBox will be written to an rtf file for later use in a paper.

========

Summary:

  1. Create source file
    1. enter reference details <from previous deliverable>
    2. store references in an ArrayList  <from previous deliverable>
    3. save UNFORMATTED references to a binary file (.dat file)
  2. Open binary file of references
    1. Specify source file
      1. open file (.dat file)
      2. read file into ArrayList
      3. close file (.dat file)
      4. sort array <from previous deliverable>
  3. Save references
    1. Select format
      1. loop through array, applying the selected format, and writing to RichTextbox.  <from previous deliverable>
    2. Specify destination file (.rtf file) <from previous deliverable>
    3. Save formatted references: save the contents of the RichTextBox in the rtf file <from previous deliverable>
  4. Preview references
    1.  Select format
      1. loop through array, applying the selected format, and writing to RichTextbox.  <from previous deliverable>


Interface Design

In the screens below the buttons perform the following functions:

Menu Item Purpose
File Opens the File submenu.
   Open File Open existing file of previously entered references, i.e., the binary file that contains the unformatted references.  It then reads the file contents into an ArrayList and then sorts the ArrayList.  [Additional references can be added by the Edit - Add References item.]
   Save File Select MLA, APA, or Chicago reference style and the references are written to the RichTextBox control.  The application allows you to specify the destination rtf file in which you want the sorted reference list to be stored. It then saves the contents of the RichTextBox to the file.
        MLA Selects MLA reference style for the saved reference list. Loops through the ArrayList and applies the MLA format to every reference and writes the result to the RichTextBox.
        APA Selects APA reference style for the saved reference list. Loops through the ArrayList and applies the MLA format to every reference and writes the result to the RichTextBox.
        Chicago Selects Chicago reference style for the saved reference list. Loops through the ArrayList and applies the MLA format to every reference and writes the result to the RichTextbox.
   Preview View your reference list in various reference styles in a RichTextBox by selecting MLA, APA, or Chicago.
        MLA Selects MLA reference style for the preview.
        APA Selects APA reference style for the preview.
        Chicago Selects Chicago reference style for the preview.
   Exit Exits the application.
Edit Opens the Edit submenu.
   Add References Opens the reference entry form so new references can be added.
Help Opens a Help screen.

Click here for sample screens.


Demo



C# Specifics:


You will need to provide a user-friendly interface for this final deliverable similar to the demo program.  Be sure to use menus and tab controls.


To open one form from another use code like the following:

frmReferences myForm2 = new frmReferences();
myForm2.Show();


If your program has variables that must be accessible to multiple forms, simply add a static class to your program and declare the variables within it.  Here is an example:

static class clsGlobals
{
    private static ArrayList m_referenceList = new ArrayList();

    public static ArrayList referenceList
    {
        get { return m_referenceList; }
        set { m_referenceList = value; }
    }
}