COP4226 Assignment 3
Due Thursday, 11/19 at 11:59 pm.
Data Class
Create a data class that contains a string, a point, a font, a color and
a brush for that color.
-
Create a constructor that is passed a string, a font and a color. Initialize
the string, font, color with these parameters.
-
Create public properties for the brush, point, string, font and color. Whenever
the color is changed, dispose of the current brush and create a new one.
-
The class should be serializable.
-
The brush cannot be serialized.
-
On deserialization, the brush will need to be recreated.
-
Implement ISerializable, not IDeserializationCallback.
-
Implement IDisposable and dispose of all remaining resources when the class
is disposed. Optimize garbage collection.
-
Implement INotifyPropertyChanged and send a message when any of the properties
change.
-
Add a Paint method that is passed a Graphics object. Call this method when
a data object needs to be painted.
-
Add a Contains method that is passes a Graphics object and a point. The method
will return a boolean value indicating if the point is within the bounding
rectangle of the text.
-
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.
View State
Create a class that will encapsulate the state of the view.
-
Create a binding list of the data class.
-
Add a property for a zoom factor.
-
Add a property for a translation. A translation will have an X and a Y component
that can be different.
-
Add a property for a rotation.
-
The class should be serializable. Implement IDeserializationCallback, not
ISerializable.
-
Implement IDisposable and dispose of all remaining resources when the class
is disposed. Optimize garbage collection.
-
Add a Find method that is passed a Graphics object and a point. The method
will attempt to return the first data object it can find whose bounding rectangle
contains the point. This method must work properly when the view is transformed,
too.
-
You may add other helper methods and variables as you see fit. The idea is
to encapsulate all access to the view state inside this class.
MainForm
-
Extend the main form from the form base class in the HW2 control library.
Add typical oath and about dialogs; extend them from the base dialog from
the HW2 control library.
-
Add methods to serialize and deserialize the view state.
-
Create three user controls that will contain different views of the data.
-
Draw View: Create a user control that will draw the data.
-
Pass a view state object to the contstructor. You will have to add the view
to the main form in code, as the designer will always call the default
constructor.
-
Add a public property to change the view state.
-
Add a binding source to the view. Bind it to the list of data in the view
state.
-
Draw the text of each data element at its location.
-
Use the font and brush to draw the text.
-
Open a modal dialog when the user right-clicks the mouse on a string.
-
The dialow is described below under the Options menu.
-
When the dialog closes, the data object should be updated with the new values.
-
If a change is made in the draw view, then the change should be apparent
immediately in the draw view and will appear in the grid view the next time
it is shown.
-
Do not paint if the draw view is being displayed in the designer. (This is
a precaution to prevent null pointer exceptions when designing the form.)
-
Draw lines along the coordinate axes, so that it is easy to see where the
origin is. Draw each axis in a different color.
-
Grid View: Create a user control that will show the contents of the fields
of the data.
-
Pass a view state object to the contstructor. You will have to add the view
to the main form in code, as the designer will always call the default
constructor.
-
Use a data grid view. Set the data source to the binding list in the view
state.
-
Allow insertion and deletion.
-
If a change is made in the grid view, then the change should be apparent
immediately in the grid view and will appear in the draw view the next time
it is shown.
-
Split View: Create a user control that has top and bottom panels with a splitter
in between.
-
Show a Draw View in the top panel. Pass the view state to the draw view.
-
Show a Grid View in the bottom panel. Pass the view state to the grid view.
-
If a change is made in either view, then the change should be apparent
immediately in the other view.
-
Add a file menu.
-
File New. Reset the view state to its original state.
-
Do not create a new list in the view state; remove all the current elements
from the list.
-
Provide suitable default values for the properties.
-
File Open. Open a file that was saved previously by this application.
-
By default, only display files with the .hw4 extension.
-
In addition to all hw4 files, allow the user to change the visible files
to all files.
-
After recreating the view state, you will need to update the view state in
all the views.
-
File Save. If the current data has already been saved, then use the current
name to save the file; otherwise, treat this option as Save As.
-
File Save As. Always ask the user for the name of the file to save to.
-
By default, only display files with the .hw4 extension.
-
In addition to all hw4 files, allow the user to change the visible files
to all files.
-
Save the file with the extension hw4.
-
Save all the data in the view state.
-
Exit.
-
Add a menu that will change the view to one of three possibilities.
-
Display the Draw View in the main form.
-
Display the Grid View in the main form.
-
Display a splitter panel with the Draw View in the top panel and the Grid
View in the bottom panel.
-
When the menu opens, place a check next to the option that is currently in
effect.
-
Add an Options menu.
-
Add a Transform menu.
-
Open a dialog that allows the user to change the Zoom, Translation and Rotation.
-
Validate that all input contains valid numbers.
-
Use an error provider to show which fields are invalid.
-
Add a binding source. Bind the view state to the dialog.
-
Add a property for setting the data source.
-
Add text.
-
Use a binding source.
-
Add a property for setting the data source.
-
Open a dialog that will allow the user to enter a location (as two integers),
a string, a font (as font name, font size and check boxes for bold, italic,
underline and striekout) and a color (as 4 numeric up down controls for A,
R, G, B).
-
The dialog should have an OK button.
-
Validate that the location and font size contain valid numbers.
-
Use numeric up down controls for the A, R, G, B values of the color.
-
Use check boxes for the possible font styles bold, underline, strikeout,
italic.
-
If the dialog is opened from the menu, then when it closes, add the new data
element to the view state list and redraw the view. If the dialog is opened
from a right mouse click, then update the current data object with the new
values.
-
All changes should appear in all views.
Screen Shots: Main Form, Main Form Transformed, Main Form Edit Text.