COP4226 Assignment 3
Due Wednesday, 11/22 at 11:59 pm.
Make sure your application is object oriented!
If you have written a helper method that has many references to the members
of a class, then perhaps there should be a method for this operation in your
class. I will be looking for object oriented design when I grade the assignment.
Create a Single Document Interface Application
-
Create a new project. Copy my
SdiBase.dll
and
SdiBase.pdb
into the application directory and add a reference
to it. The application directory is the location of your main form.
ZIP of SdiBaseSimple. If you have already
downloaded this file, then please download an updated copy.
-
Create two views that extend
SdiBase.SdiView
. One view will
display text drawn in rectangles (drawing view), the other view will
show the corresonding data in a DataGridView
(list view).
-
Create a document that extends
SdiBase.SdiDoc
.
-
Extend the main form class from
SdiBase.SdiMainForm
.
-
Do not change my files. All changes should be in your extended classes.
MainForm
-
Add a status bar.
-
Be sure that the status bar is never covered by another control.
-
Add a label that will contain the name of the view that is currently displayed
in the main form.
-
Add a label that will contain the current zoom factor.
-
Add a main menu.
-
File
-
New: Clear the document.
-
Close: Close the current top level form.
-
Close All: Close all the top level forms.
-
View
-
Draw: Switch to the drawing view.
-
List: Switch to the list view.
-
New Top Level: Open a new top level main form. Only close the application
when there is one top level form and it is closed.
-
The Draw item should be checked and disabled when the current view is a draw
view; the List item should be checked and disabled when the current view
is a list view.
-
Zoom. Resize everything in the view, including the text and the size of the
view.
-
50%: Half the size.
-
100%: No zooming.
-
200%: Twice the size.
-
The current zoom should be disabled and checked.
-
Add a toolbar.
-
Add images to the resources for each menu option.
-
For toolbar images that correspond to options that can be disabled, be sure
that there are two different images: one for enabled, one for disabled. Set
the image in the toolbar accordingly. Use a simple theme for distinguishing
between disabled and enabled images: for instance, white background for all
enabled images, gray background for all diabled images.
-
Dock a scrollable panel to the client area.
-
Add a drawing view to this panel.
Add a data class to your project
-
Make the class serializable.
-
Implement INotifyPropertyChanged.
-
Add variables to the class to store text's location (Point), value (String),
font family (String), font style (FontStyle), font size (float) and color
(Color).
-
Create a copy constructor.
-
Add properties to access these variables.
-
Add a method that can be called with a graphics object to draw the text.
-
Use the location as the starting point for drawing the text.
-
Create a font with font family, font style and font size.
-
Draw the text using the color.
-
Draw a rectangle that fits snugly around the text. The border of the rectangle
should use the color.
-
Add any other variables that you need.
-
Add any other methods that you need.
In the docmuent class
-
Extend your document class from
SdiBase.SdiDoc
.
-
Create a generic
System.ComponentModel.BindingList<T>
for instances of
your new data class.
-
Add a member of your data class type to store the current default values.
When new text is added in a drawing view, these values will be used to define
how the text will look.
-
Add other members as needed. Any variable that needs to be saved must be
in the document.
-
Add helper methods as needed, including accessors and mutators for accessing
data in the document.
-
Override the DeleteContents method. The method in the base class already
calls
UpdateAllViews
.
In the Drawing View
-
Set the total size of the view to 700 pixels by 600 pixels.
-
When the left mouse button is clicked, add a data object to the document.
-
Use the current mouse location for the location of the text.
-
Use default values for the other members in the data class.
-
When the control-left mouse button is pressed test if the mouse point is
in a data object.
-
If the point is in a data object, do not add a new data object.
-
If the point is in a data object, as long as the mouse is down, drag the
object to a new location.
-
Only move one object at a time, even if the point is in more than one data
object.
-
When the right mouse button is clicked in the rectangle that bounds the text,
open a dialog that allows you to change all the values for the data object.
-
Use a font dialog to select the font and color.
-
The font dialog should be opened so that the color of the font can be selected.
-
The font dialog should be opened so that the effects are visible.
-
The font dialog should open with the current font and color preselected.
-
Use text boxes to specify the value of the text and the location.
-
If you use a data source to define the controls in the dialog, be sure to
disable the controls for the color. All other controls should be enabed and
should be able to change the property in the underlying object.
-
In the paint method, draw all the current data objects.
-
When zooming, be sure that the mouse point under the current mouse pointer
is used for all hit testing and data object location. Do not use the zoomed
transformation of the mouse point. In other words, when the left mouse is
clicked, be sure that the new data object location is under the mouse pointer;
when the right mouse is clicked, be sure it is testing if the point under
the mouse pointer is in the data object; when the control-left is clicked,
be sure that the starting location of the drag is the point under the mouse
pointer.
In the List View
-
Set the total size of the view to 600 pixels by 350 pixels.
-
When a list view is active, diable the zoom menu options and toolbar images.
-
Add a DataGridView.
-
Set the data source as the list that is in the document.
-
Whenever a row is edited, update all the views so they know the document
has changed.
-
You should be able to edit the data in the grid view, add rows and delete
rows. These changes should be reflected in all open views.