void measureChevronMenuItem( object sender, MeasureItemEventArgs e ) {
if ( !(sender is MenuItem) ) return;
MenuItem menu = (MenuItem)sender;
if ( menu.Tag == null ) return;
if ( !(menu.Tag is ToolBarButton) ) return;
ToolBarButton button = (ToolBarButton)menu.Tag;
SizeF text_size = e.Graphics.MeasureString( menu.Text, SystemInformation.MenuFont );
int width = (int)text_size.Width;
int height = (int)text_size.Height;
height = Math.Max( height, button.Parent.Height );
if ( button.Parent != null && button.Parent.ImageList != null ) {
if ( 0 <= button.ImageIndex && button.ImageIndex < button.Parent.ImageList.Images.Count ) {
Image img = button.Parent.ImageList.Images[button.ImageIndex];
if ( img != null ) {
width += img.Width;
height = Math.Max( height, img.Height );
}
}
}
e.ItemHeight = height;
e.ItemWidth = width;
}