![]() And this interface inherits from IEnumerable. This looks promising! Looking a bit further, “ Selection” is an implementation of the interface IVSelection. Looking through the members of this object, we find a property “ Selection”. Luckily, the debugger allows to expand the dynamic view members. Let’s investigate if we can find out something about the selected object(s) in the “ Window” parameter:Īs expected, this is a dynamic object. Now we want to be able to only execute code when a shape is selected. When running this code, each time we select something in Visio, we see our fancy message box. Once you know this “trick”, things become easy. Later, we will do the same for the ShapeAdded event. The SelectionChanged event must be wired in the startup event. MessageBox.Show( " SelectionChanged ActOnShapeSelection") Private void Application_SelectionChanged(Visio.Window Window) Private void ThisAddIn_Startup( object sender, System.EventArgs e)Īpplication.SelectionChanged += Application_SelectionChanged ![]() As a test, we show a message box when starting our add-in, and another one when closing it: This is where we will initialize our events. The result is a project with one C# file ( ThisAddIn.cs). I choose the Visio Add-in project and gave it an appropriate name “ ActOnShapeSelection”. In VS, create a new project (File > New > Project…) like this:Īs you can see, there are new project templates for “Office/SharePoint”. When you launch Visual Studio again, you’ll find a new bunch of project templates. Select Office/SharePoint development and then click “Modify”. In the installer window, select “More > Modify”:Īfter a little while, this takes us to the workloads selection screen. Start Visual Studio Installer (Start -> type “Visual Studio Installer”). Since Visual Studio 2017 the installer allows for modular installation, so we just need to add this to our installation. To do this, we need to install the “Office/SharePoint development” workload. ![]() I decided to use Visual Studio 2017 to create a Visio Add-In. The code for this project can be found here. setting the color of the selected shape.keeping and accessing the state in the Ribbon (for the default color).Sounds simple enough, but there are some caveats, so here is my attempt to tackle this problem. How can I in Visio change the color to a previously selected color just by selecting a shape? A good friend asked me the following question: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |