Rewrite Hello World, with the following enhancements:
Separate the control area from the ink area with a splitters, so that you can
change the relative sizes of control and ink areas.
Convert the ink collector to an ink overlay to allow editting and selection, with buttons
to switch between ink, select, and erase modes.
Have the color button change the color of the selected text. (I had some trouble on this
one until I realized it was necessary to invalidate the ink panel after changing colors)
Add a track bar to control width of all of the lines. Each time the trackbar changes,
update all the line widths.
Hints
There is quite a bit to this assignment, below are the step I went through. You will get the
most out of this assignment if you only refer to these as necessary.
Panels with a splitter: Place a panel in the form - call it controlPanel. Set docking to
top. Now add a splitter to the form - set its docking to top (this will flip it from vertical
to horizontal). Now add another panel (call it inkPanel).Set its docking to fill. Done!
Add an ink overlay to the form - setting its handle to the inkPanel. Add color buttons to
the control area. Add on-click methods to the buttons.
Add three mode buttons to the panel. Add on-click methods to set appropriate modes (e.g.,
inkOverlay.EditingMode = InkOverlayEditingMode.Select. The inkOverlay allows the strokes to be
selected, moved and erased.
Now add code so that the color buttons change the colors of the selected strokes. This
requires iterating through all the strokes in the selected strokes from the ink overlay. The
behavior was strange until I added inkOverlay.Invalidate();
Add a track bar to control line width. Set value to 1 (but keep min 0, max 10). Add an on
-value-changed method to update line width. This is done by iterating over the strokes in
inkOverlay.Ink.Strokes and set DrawingAttributes.Color to the right value. (I chose 53*
trackBar.Value - 53 was the initial width). The new pen size is set by setting inkOverlay.Ink.
DefaultDrawingAttributes.Width. The final detail is to an an invalidate call for the ink Panel.
Screen shots
Department of Computer Science & Engineering
University of Washington
Box 352350
Seattle, WA 98195-2350
(206) 543-1695 voice, (206) 543-2969 FAX
[comments to anderson]