Learning how to make context-sensitive ribbon icons in add-in

Started by Visisthebest, February 25, 2021, 12:08:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Visisthebest

Slowly but surely I am learning how to develop a Visio add-in with Visio and VB.NET, still getting used to the differences between VBA and Visual Studio and Office VSTO for sure.

I am now getting to the adding Ribbons and ribbon icons (I think of them as buttons) to the add-in, and wondering what is the best way to go about creating context-sensitivity.

In terms of what I want to accomplish, when a user clicks a certain shape depending on the shape type I want to show different icons (so irrelevant functionality is not shown, because those icons/buttons will be 'dead' in this context, have to give the user a warning that he's selected the wrong shape for this functionality, not a good UI experience). What is the best, most solid way to do this in a Visio add-in?

Thank you for your help!


Visio 2021 Professional

Visisthebest

Ok, so for me the easiest way to deal with this is to add a RibbonTab for my add-in, and then group the context-sensitive ribbon buttons in groups.

Depending on which shape is selected, I set Visible = true/false on the RibbonGroups depending on the shape selected.

Are there good code uptodate code examples for capturing selection events (I understand advice is to use AddAdvise because it is less 'chatty'), then I can quickly assess what shape type is selected and set the RibbonGroup visibility accordingly.

Event handling in an add-in is not an easy thing no doubt, so advice on how to set it up well is appreciated thank you!
Visio 2021 Professional

Visisthebest

So I need to capture SelectionChanged, need to adapt this VBA code:
https://docs.microsoft.com/en-us/office/vba/api/visio.eventlist.addadvise

to a .NET add-in, should be able to figure this out.
Visio 2021 Professional