COP4226 Assignment 4

Extra Credit (due 11/30)

If you submit the sections below that have the same style as this paragraph, then you can earn an extra 2.5 points of extra credit towards the course grade.

Due Sunday, 12/2 (late 6am 12/3)

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

This application will be an example of a Multiple - Single Document Interface (Multi-SDI) application. It will run a car race in a separate thread in each main form. One race can be running in each top level window. The thread will run a simulation of a race. Every second will be the equivalent of several laps. The number of laps per second is controlled by a trackbar. Data binding will be used to tie all of the data together. There will be a list of national drivers and local drivers that can be added to a race. There will be data classes to encapsulate all of these concepts.

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 access a variable that is not local to the thread. Pass a custom class between the thread and the thread that called it.

Race Car Driver

Create a class for a race car driver.

Race Data

Create a data class for a race.

Modeless Add Driver

Create a modeless dialog that will be reused by all the top level forms.

New Race Dialog

Create a new race dialog that requires the name of the race and the number of laps in the race.

Multi-SDI

Create a single instance application context that will allow multiple top-level windows to be opend.

Context Interface

The application context will know certain things about the top level form. Here is a starting point for an interface that the top level form will implement. The application context is only allowed to access things about the top level form that are in the interface.

    public interface IContextInfo
    {
        event EventHandler OpenDriverDialog;
        event EventHandler NewRace;
        event EventHandler OpenAbout;
        event EventHandler OpenOath;
        void AddDriver(Object driver);
        ToolStripMenuItem WindowMenu { get; }
    }
   

You may add addtional elements to the interface.

Adding a new top level window should always be handled in the application context. From there, the context can use the interface to access the top level form.

An example of implementing an event in the top level form is

    public event EventHandler OpenAbout
    {
        add { aboutToolStripMenuItem.Click += value; }
        remove { aboutToolStripMenuItem.Click -= value; }
    }

This is similar to a normal property, but add/remove are used instead of get/set.

The context would use the main form and the interface to add a handler for an event.

    ((IcontextInfo)this.MainForm).OpenAbout += new EventHandler(about_Open);
   

This design is different than the one presented in the book for opening the window menu. The top level form does not need to register with the context, since adding a new form is in the context. When a new form is created, the context can listen to the event in the interface.

Top Level Form

Create a top level form that implements the Context Interface. The top level form should never access the application context. The application context will create all new top level forms and will access what it needs from the top level form through the interface.

Screen Shots: Image Folder

Video: HW4 Demo