|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionTool strips are a fantastic asset because they provide a tidy and user-friendly interface for the user. It is possible to add images to many of the different tool strip items. It is even possible to force such items to appear larger by adjusting the property Usually it is desirable to make our applications as accessible as possible. Larger tool strip items are fantastic for those with poorer sight, or even those who just simply enjoy the quality of larger icons. Unfortunately, the standard So I decided that it would be a nice idea to add multi-image support to the DesignWhen An
When no For my extension I decided that four discreet sizes would ease the implemention of custom image providers. The available sizes are: Small (16 x 16), Medium (24 x 24), Large (32 x 32), and ExtraLarge (48 x 48). When the requested image size is not available, a default icon can be automatically substituted if the Images are selected as follows:
Using the CodeIt is always a good idea to backup your project before trying something new! To use the attached code simply:
If you want to convert an existing
To make items automatically resizable add a handler for your form's (or control's) private void Form1_Load(object sender, EventArgs e)
{
// Begin updating tool strip images. This is important because it prevents
// the tool strip from refreshing after each image assignment.
this.iconToolStrip.BeginUpdateImages();
// Here it is possible to provide an 'IImageProvider' instance.
this.iconToolStrip.AssignImage(toolStripBack, new IconImageProvider(
Resources.arrow_left));
// Or just provide icons themselves.
this.iconToolStrip.AssignImage(toolStripForward, Resources.arrow_right);
this.iconToolStrip.AssignImage(toolStripHome, Resources.home);
this.iconToolStrip.AssignImage(toolStripStop, Resources.stop);
// Finalize updating.
this.iconToolStrip.EndUpdateImages();
// Then to select an initial icon size.
this.iconToolStrip.ImageSize = ImageSize.Medium;
}
When a tool strip item is permenantly removed, the associated If you always want to remove an associated private void iconToolStrip_ItemRemoved(object sender, ToolStripItemEventArgs e)
{
// Automatically remove associated image provider.
this.iconToolStrip.RemoveImage(e.Item);
}
Alternatively the associated provider can be removed along with the item: public void RemoveToolStripItem(ToolStripItem item)
{
// Remove item itself.
this.iconToolStrip.Items.Remove(item);
// Remove any associated provider.
this.iconToolStrip.RemoveImage(item);
}
Points of InterestThe fantastic icons used in the demo application were kindly provided by glyFX from their free 'Vista Common' icon set. The required icons were combined together using the free IcoFX tool. HistoryOriginal version posted.
|
|||||||||||||||||||||||||||||||||||