I installed the Visio 2016 SDK but unfortunately the examples haven't been updated much, the Treeview Visual Studio example for vb.net contains marker event handling example code but is for VS 2010/2012 with an old installer project that doesn't work in 2017/2019.
Do you know a more recent example VS 2017/2019 VSTO project on github that allows me to learn from a good example of how to handle marker events coming in from the shapesheet?
A recent C# example is also super of course, it is important to learn from a good example of solidly handling marker events in an add-in.
Thank you very much!
This looks simple. You just add a method to your app class like this:
Public Class ThisAddIn
Private Sub Application_MarkerEvent(app As Application, SequenceNum As Integer, ContextString As String) Handles Application.MarkerEvent
System.Windows.Forms.MessageBox.Show(ContextString)
End Sub
(check if the context string is "yours" and then do whatever you need based on that)
In Visio you just call
(https://i.paste.pics/613b20f0da638a4f63a2669e22cd04b7.png)
Just in case, pushed simplest sample (sample Visio file is included) ;D
https://github.com/nbelyh/QueueMarkerEventSample
BTW, why do you want to call add-in from ShapeSheet (maybe you are facing XY problem?) - this is unusual (for context menu for example, you can use ribbon instead)
Thank you so much Nikolay!
I use the context menu to keep an identical UI between the VBA version and the add-in version, but yes adding a ribbon for the add-in improves the UI, will have to figure out how to only show relevant functionality depending on the shape selected.
If you already do have the menus, then it makes sense, of course. With ribbon, it would be more complicated.
But theoretically you can define context menus there as well, and show/hide and disable/enable them dynamically.
Hope the sample helps.
Yes very helpful thank you Nikolay!
Hi Nikolay,
Thank you the example vs project and code work fine. When I paste the marker event handler line in to the solution you created for Visio add-ins, I get this warning on the
Handles Application.Markerevent:
Severity Code Description Project File Line Suppression State
Warning BC42322 Runtime errors might occur when converting 'Application' to 'Application'. ExtendedVisioAddin1
Do you have an idea for the why of this warning and how I can resolve the issue? Better to understand warnings that may cause issues later, especially if I don't understand why I get them.
Thank you!
Quote from: Nikolay on December 10, 2020, 01:40:37 PM
This looks simple. You just add a method to your app class like this:
Public Class ThisAddIn
Private Sub Application_MarkerEvent(app As Application, SequenceNum As Integer, ContextString As String) Handles Application.MarkerEvent
System.Windows.Forms.MessageBox.Show(ContextString)
End Sub
(check if the context string is "yours" and then do whatever you need based on that)
In Visio you just call
(https://i.paste.pics/613b20f0da638a4f63a2669e22cd04b7.png)
Just in case, pushed simplest sample (sample Visio file is included) ;D
https://github.com/nbelyh/QueueMarkerEventSample
BTW, why do you want to call add-in from ShapeSheet (maybe you are facing XY problem?) - this is unusual (for context menu for example, you can use ribbon instead)
Could you share the project?
I mean, if I build the sample I shared, it seems I don't get this warning: https://github.com/nbelyh/QueueMarkerEventSample
Thank you Nikolay currently travelling will send you the project files when I'm back at my pc Monday.
The queuemarker events work fine this warning notwithstanding but still an odd error.
Nikolay please see your e-mail at support@unmanagedvisio.com for the project files. Hope you have an idea why this warning occurs!
Would doing this in C# be just as simple as adding a method to the ThisAddin Class?
dmbalzer Nikolay found out that because WinForm is used this is also an application and Visual Studio needs Visio.Application not just Application to disambiguate the statement (it might mean the WinForm application after all).