0

I have items that are added to a dropdown menu, upon selecting one of the items, the main button changes to that items image. However once changed, the images vary in size, when they should be holding a size of 24, 24. Is there a way to set the button properties so that even if the image is set to a larger image, it will hold the size to 24, 24 ?

foreach (IEffectModuleDescriptor effectDesriptor in ApplicationServices.GetModuleDescriptors<IEffectModuleInstance>().Cast<IEffectModuleDescriptor>())
{
    ToolStripMenuItem menuItem = new ToolStripMenuItem(effectDesriptor.EffectName);
    menuItem.Tag = effectDesriptor.TypeId;
    menuItem.Text = effectDesriptor.EffectName;
    menuItem.Image = effectDesriptor.GetRepresentativeImage(24, 24);
    menuItem.Click += (mySender, myE) => 
    {
        toolStripDropDownDrawMode.Image = menuItem.Image;
    };
    toolStripDropDownDrawMode.DropDown.Items.Add(menuItem);

}

I Solved this by creating a new bitmap of my image as follows, for others who may encounter this issue.

menuItem.Image = new Bitmap(effectDesriptor.GetRepresentativeImage(24, 24), new Size(24,24));
John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • What is the definition of `GetRepresentativeImage`? – Dai Aug 15 '14 at 00:01
  • Looking at the definition revealed the true problem, it returns one of three possible sizes 16x 48x or 64x, the ability to pass the size is very misleading, and the source of my issue. – James Bolding Aug 15 '14 at 00:36
  • @JamesBolding: you should add that as the answer. You can then get upvotes for it (and even accept it) – John Saunders Aug 15 '14 at 03:14

0 Answers0