Exercises
77
3. (SimpleEdit) Copy the SimpleEdit program you built for Exercise 2 and attach the tool strip
buttons to the corresponding event handlers.
4. (SimpleEdit) Copy the SimpleEdit program you built for Exercise 3 and add code to display
the appropriate image in the Background, Text Color, Offset, and Indent tool strip buttons.
For example, when the user selects Offset Subscript, the
offsetButton button should show
the subscript image.
To make using the foreground and background colors easier, save them in the
foreColorButton and backColorButton buttons’ ForeColor and BackColor properties.
For example, the following code shows what the program does when the user selects the
red foreground color. It displays the red image in the corresponding menu item, context
menu item, and tool strip button. It then saves the color in the
btnFg button’s ForeColor
property and finishes by displaying a placeholder message.
private void foreColorRedToolstripMenuItem_Click(
object sender, EventArgs e)
{
formatTextColorMenuItem.Image = foreColorRedToolstripMenuItem.Image;
textColorContextMenuItem.Image = foreColorRedToolstripMenuItem.Image;
foreColorButton.Image = foreColorRedToolstripMenuItem.Image;
foreColorButton.ForeColor = Color.Red;
MessageBox.Show(“Foreground Red”);
}
5. (SimpleEdit) Copy the SimpleEdit program you built for Exercise 4 and add appropriate
tooltips to the program’s tool strip buttons. For example, set the
alignLeftButton button’s
ToolTipText property to “Align Left.”
6. Build the Scribbler program shown in Figure 6-8. Give
it a
ToolStripContainer and two ToolStrips.
Give the first
ToolStrip buttons representing arrow,
line, rectangle, ellipse, scribble, and star tools. Make
these tools exclusive choices so if the user selects one,
the others deselect. Give the second
ToolStrip two
ToolStripDropDownButtons to represent foreground
and background colors. Make the entries in each drop-
down exclusive choices so if the user selects one, the
others deselect.
You can download the solutions to these exercises from the book’s web page at
www.wrox.com or www.CSharpHelper.com/24hour.html. You can find them in
the Lesson06 folder in the download.
FIGURE 68
596906c06.indd 77 4/7/10 12:32:02 PM
Click here to Play
596906c06.indd 78 4/7/10 12:32:02 PM
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.12.34