Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add two images for xml ribbon button for large and normal sizes

Tags:

c#

xml

vsto

ribbon

I have a button on Ribbon XML with a custom image like this

<group id="MyGroup">
<button id="buttonTest" size="large" getImage="GetCustomImage" label="Test"/>
</group>
public Bitmap GetCustomImage(Office.IRibbonControl control)
{
    return Resources.test; // test.png
}

But when user adds this button on the Quick Access Toolbar, button become normal size. Office resize icon and it can look ugly after this. How can I add two images for button for large (32x32) and normal (16x16) sizes?

like image 990
anzood Avatar asked Nov 03 '22 02:11

anzood


1 Answers

Does the GetCustomImage method get called when the button is on the Quick Access Toolbar? If so, then it shouldn't be too hard to do what you're asking. You just need to know if the button is in the Ribbon or the Q.A.T.

BUT

If that does not work, I don't think it's possible to do what you are asking. Each button can only have 1 image and 1 size associated with it.

What you could possibly do is have 2 buttons and toggle which one is visible. And the user could make sure to add the buttonNormal to the Quick Access Toolbar. I mean, this is ugly and I don't know if I would do this. But if the ugly icon is really bothering you, then go ahead.

<group id="MyGroup">
    <button id="buttonLarge" size="large" image="largeImage" label="Test" getVisible="GetIsLargeButtonVisible"/>
    <button id="buttonNormal" size="normal" image="normalImage" label="Test" getVisible="GetIsNormalButtonVisible"/>
</group>

And then in the GetIsNormalButtonVisible and GetIsLargeButtonVisible methods, you could hide and show whichever one you want.

like image 186
Chris Leyva Avatar answered Nov 11 '22 09:11

Chris Leyva