Some further experiments were done regarding stacked PulldownButton groups and PushButton members and something very interesting was spotted.
The finding (good or bad but at least good to know) is about the Image and the LargeImage properties, what they are supposed to have, and what if something else are fed to them, of PulldownButton and PushButton members when they are stacked.
Here are some highlights.
People can image that since the stacked PulldownButton can only display small icons we’d better feed something proper like a 16x16 pixel bitmap to the Image property of the group. It is pretty much so. Then what about if a bigger bitmap is provided for the property, or the LargeImage property is provided instead, or both of Image and LargeImage are provided?
The experiments yielded that the answer to the first question is the bigger bitmap will not be automatically adjusted and rather only portion (around left top corner 16x16 pixels, it seems) will be displayed as the icon for the PulldownButton group; the answer to the second is that it will take no effect at all, i.e. nothing will be displayed; the answer to the last is that the LargeImage will be ignored, similar to the second situation.
Things all look natural so far then what is all the fuss about here?
Ok, the interesting part is actually with the Image vs. LargeImage of PushButton members hosted by stacked PulldownButton groups.
Again naturally I imaged that pretty similar behaviour should apply to the Image and LargeImage properties of the PushButton members, that is, only the Image will be used and the LargeImage will be totally ignored, but the truth is out of anybody could imagine.
The Image property will be ignored instead this time! The LargeImage will be used to display either big icons or small ones. How could a stacked PushButton display a small icon with the LargeImage property then?
The magic comes, please provide a proper small image like a 16x16 bitmap to the LargeImage property!!
Here is the test code exhibiting almost every combination of all different cases:
public void AddRibbonItemsToRibbonPanel(RibbonPanel panel)
{
string assemFullName = Assembly.GetExecutingAssembly().Location;
string assemPath = Path.GetDirectoryName(assemFullName);
PulldownButtonData cnt1Stacked_grp1Data = new PulldownButtonData("cnt1Stacked_grp1", @"Pulldown 1");
PulldownButtonData cnt1Stacked_grp2Data = new PulldownButtonData("cnt1Stacked_grp2", @"Pulldown 2");
PulldownButtonData cnt1Stacked_grp3Data = new PulldownButtonData("cnt1Stacked_grp3", @"Pulldown 3");
IList<RibbonItem> cnt1Stacked = panel.AddStackedItems(cnt1Stacked_grp1Data, cnt1Stacked_grp2Data, cnt1Stacked_grp3Data);
PulldownButton cnt1Stacked_grp1 = cnt1Stacked[0] as PulldownButton;
cnt1Stacked_grp1.ToolTip = @"Stacked Pulldown Group 1 (Image Call with a 16x16 BMP)";
cnt1Stacked_grp1.Image = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd16x16.bmp");
//cnt1Stacked_grp1.ToolTip = @"Stacked Pulldown Group 1 (Image Call with a 32x32 BMP)";
//cnt1Stacked_grp1.Image = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd.bmp");
PushButtonData cnt1Stacked_grp1_item1Data = new PushButtonData("cnt1Stacked_grp1_item1", @"PushButton 11", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton cnt1Stacked_grp1_item1 = cnt1Stacked_grp1.AddPushButton(cnt1Stacked_grp1_item1Data) as PushButton;
cnt1Stacked_grp1_item1.ToolTip = @"PushButton 1 (Image Call with a 16x16 BMP) In Pulldown 1";
cnt1Stacked_grp1_item1.Image = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd16x16.bmp");
PushButtonData cnt1Stacked_grp1_item2Data = new PushButtonData("cnt1Stacked_grp1_item2", @"PushButton 12", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton cnt1Stacked_grp1_item2 = cnt1Stacked_grp1.AddPushButton(cnt1Stacked_grp1_item2Data) as PushButton;
cnt1Stacked_grp1_item2.ToolTip = @"PushButton 2 (Image Call with a 32x32 BMP) In Pulldown 1";
cnt1Stacked_grp1_item2.Image = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd.bmp");
PulldownButton cnt1Stacked_grp2 = cnt1Stacked[1] as PulldownButton;
//cnt1Stacked_grp2.ToolTip = @"Pulldown Group 2 (LargeImage Call with a 32x32 BMP)";
//cnt1Stacked_grp2.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd.bmp");
cnt1Stacked_grp2.ToolTip = @"Pulldown Group 2 (LargeImage Call with a 16x16 BMP)";
cnt1Stacked_grp2.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd16x16.bmp");
PushButtonData cnt1Stacked_grp2_item1Data = new PushButtonData("cnt1Stacked_grp2_item1", @"PushButton 21", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton cnt1Stacked_grp2_item1 = cnt1Stacked_grp2.AddPushButton(cnt1Stacked_grp2_item1Data) as PushButton;
cnt1Stacked_grp2_item1.ToolTip = @"PushButton 1 (LargeImage Call with a 32x32 BMP) In Pulldown 2";
cnt1Stacked_grp2_item1.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd.bmp");
PushButtonData cnt1Stacked_grp2_item2Data = new PushButtonData("cnt1Stacked_grp2_item2", @"PushButton 22", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton cnt1Stacked_grp2_item2 = cnt1Stacked_grp2.AddPushButton(cnt1Stacked_grp2_item2Data) as PushButton;
cnt1Stacked_grp2_item2.ToolTip = @"PushButton 2 (LargeImage Call with a 16x16 BMP) In Pulldown 2";
cnt1Stacked_grp2_item2.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd16x16.bmp");
PulldownButton cnt1Stacked_grp3 = cnt1Stacked[2] as PulldownButton;
cnt1Stacked_grp3.ToolTip = @"Pulldown Group 3 (Both Image and LargeImage Call)";
cnt1Stacked_grp3.Image = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd16x16.bmp");
cnt1Stacked_grp3.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.ExtCmd.bmp");
PushButtonData cnt1Stacked_grp3_item1Data = new PushButtonData("cnt1Stacked_grp3_item1", @"PushButton 31", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton cnt1Stacked_grp3_item1 = cnt1Stacked_grp3.AddPushButton(cnt1Stacked_grp3_item1Data) as PushButton;
cnt1Stacked_grp3_item1.ToolTip = @"PushButton 1 (Image Call with a 16x16 BMP and LargeImage Call with a 32x32 BMP) In Pulldown 3";
cnt1Stacked_grp3_item1.Image = BmpImageSource(@"RevitAddinCSProject.Resources.smalla.bmp");
cnt1Stacked_grp3_item1.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigA.bmp");
PushButtonData cnt1Stacked_grp3_item2Data = new PushButtonData("cnt1Stacked_grp3_item2", @"PushButton 32", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton cnt1Stacked_grp3_item2 = cnt1Stacked_grp3.AddPushButton(cnt1Stacked_grp3_item2Data) as PushButton;
cnt1Stacked_grp3_item2.ToolTip = @"PushButton 2 (Both Image and LargeImage Call with 16x16 BMP)In Pulldown 3";
cnt1Stacked_grp3_item2.Image = BmpImageSource(@"RevitAddinCSProject.Resources.smallb.bmp");
cnt1Stacked_grp3_item2.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.smallb.bmp");
PushButtonData cnt1Stacked_grp3_item3Data = new PushButtonData("cnt1Stacked_grp3_item3", @"PushButton 33", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton cnt1Stacked_grp3_item3 = cnt1Stacked_grp3.AddPushButton(cnt1Stacked_grp3_item3Data) as PushButton;
cnt1Stacked_grp3_item3.ToolTip = @"PushButton 3 (Both Image and LargeImage Call with 32x32 BMP)In Pulldown 3";
cnt1Stacked_grp3_item3.Image = BmpImageSource(@"RevitAddinCSProject.Resources.BigC.bmp");
cnt1Stacked_grp3_item3.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.BigC.bmp");
PushButtonData cnt1Stacked_grp3_item4Data = new PushButtonData("cnt1Stacked_grp3_item4", @"PushButton 34", assemFullName, "RevitAddinCSProject.ExtCmd");
PushButton cnt1Stacked_grp3_item4 = cnt1Stacked_grp3.AddPushButton(cnt1Stacked_grp3_item4Data) as PushButton;
cnt1Stacked_grp3_item4.ToolTip = @"PushButton 4 (Image Call with a 32x32 BMP and LargeImage Call with a 16x16 BMP)In Pulldown 3";
cnt1Stacked_grp3_item4.Image = BmpImageSource(@"RevitAddinCSProject.Resources.BigD.bmp");
cnt1Stacked_grp3_item4.LargeImage = BmpImageSource(@"RevitAddinCSProject.Resources.smalld.bmp");
}
public static System.Windows.Media.ImageSource BmpImageSource(string embeddedPath)
{
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(embeddedPath);
var decoder = new System.Windows.Media.Imaging.BmpBitmapDecoder(stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
return decoder.Frames[0];
}
By the way, the embedded ExtCmd.BMP points to a big image resource with 32x32 pixels, the ExtCmd16x16.BMP to a small one, those BigA/B/C/D.BMP resources point to big images and smalla/b/c/d.bmp to small ones as their names imply.
The stacked PulldownButton groups and in-turn PushButton members in them will look like (depending on what those images really are):
Somebody might argue that this explains exactly why I provide two images (one small and one big) to the Image and LargeImage properties respectively always when applicable!
It is not a bad practice, I would say, putting aside considerations for efficiency and effectiveness. The thing is that those stacked PushButton members will always be taller and wider than their parents, and it does not seem so natural.
So, please do not forget to feed small images to the LargeImage properties of PushButton members hosted by stacked PulldownButton groups!
To make things clearer, the following table is created and presented:
All the above are taken care of by RevitAddinWizard.
Links to some related articles:
Ribbon of Revit API - PushButton And TextBox
Use Ribbon Creator of RevitAddCoder to Create PushButton And Separator
Use Ribbon Creator of RevitAddCoder to Create TextBox
Ribbon of Revit API - ComboBox And ComboBoxMember
Use Ribbon Creator of RevitAddCoder to Create ComboBox And ComboBoxMember
Ribbon of Revit API - PulldownButton And SplitButton
Use Ribbon Creator of RevitAddCoder to Create PulldownButton And PushButton
Use Ribbon Creator of RevitAddCoder to Create SplitButton And PushButton
Ribbon of Revit API - RadioButtonGroup And ToggleButton
Use Ribbon Creator of RevitAddCoder to Create RadioButtonGroup And ToggleButton
Ribbon of Revit API - Stacked Group And AddStackedItems
Ribbon of Revit API - Stacked Group And PulldownButton
Use Ribbon Creator of RevitAddCoder to Create Stacked Group And PushButton Items
Use Ribbon Creator of RevitAddCoder to Create Stacked Group And TextBox Items
Use Ribbon Creator of RevitAddCoder to Create Stacked Group And PulldownButton Items
Use Ribbon Creator of RevitAddCoder to Create Stacked Group And ComboBox Items
Use Ribbon Creator of RevitAddCoder to Create Stacked Group And Various Items
Ribbon of Revit API - Slideout
Use Ribbon Creator of RevitAddCoder to Create Slideout And Various Buttons
Ribbon of Revit API - Manipulate Panels Created by Other Addins
Access Ribbons Created by Ribbon Creator From Another Addin
Update Ribbons Created by Ribbon Creator From Another Addin
Use Ribbon Creator of RevitAddCoder to Create a Comprehensive Ribbon Panel
Ribbon of Revit API - Title And Name of Panels
Ribbon of Revit API - Text And Name of RibbonItem
Ribbon of Revit API - LongDescription And TooltipImage of RibbonItem
Recent Comments