[C#] How to Get "Dynamic Connector" from document's Masters

Started by Xenova, July 17, 2015, 07:41:14 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Xenova

Dear all,

       I want to GET the "Dynamic Connector" from the active document's Masters.
       This is the code i used:

Visio.Master DynamicConnectorMaster = visioApp.ActiveDocument.Masters.get_ItemU(@"Dynamic connector");

       I could use the same method to get other masters on in the same Masters collection without problem (e.g. get_ItemU(@"Rectangle") or  get_ItemU(@"Prim Objective") ).
       But when i attempted to get "Dynamic connector", visio will give COMException error. And the tips is just a general "Check the ErrorCode property of the exception to determine the HRESULT returned by the COM object"  :(

       Can anyone enlighten me? Thanks a lot.




Extra Info: The reason i want to get the "Dynamic connector"'s master is i want to rename it. And then rename another master as "Dynamic connector". This whole thing will be executed when users change from one "Page" to another "Page", which meant for different modeling purposes. By rename the another master as "Dynamic connector", this will allow the "autoConnect" function  in Visio to use different "Dynamic connector". (also when users click on the small arrows that appear on a shape when mouse cursor is stopped on that shape more than the designed duration, to connect 2 shapes).

Extra Question: is there other ways to set the "dynamic connector", instead of the way described here (rename the current "Dynamic connector" to something else, and rename a master to "Dynamic Connector")?

     

Nikolay

The "dynamic connector" master is created in the document on demand (when you actually create a connector). So it may happen that it's just not there. The "default connector" is a bit different (but it's read-only): Application.ConnectorToolDataObject

I don't think that tricks like renaming masters will get you somewhere.
To customize connector appearance, try using themes/styles ("Design" tab) - i.e. just apply one style to the first page, and another to the second... that should be it.
Note that "auto-connect" connects are different for page1 and page2:


Xenova

Appreciate that Nikolay. The existing dynamic connector that i'm using is a custom-made master then being renamed to "Dynamic connector". This master connector has two data graphics attached. I also tried to loop through all shapes in the page to remove the data graphic, but this method doesn't seem to work on "dynamic connector" too. Maybe because of the same reason that you said.

shapeInLoop.DataGraphic.Delete();

I will try the "default connector" and see.
Thanks a lot!

Quote from: Nikolay on July 17, 2015, 08:16:12 AM
The "dynamic connector" master is created in the document on demand (when you actually create a connector). So it may happen that it's just not there. The "default connector" is a bit different (but it's read-only): Application.ConnectorToolDataObject

I don't think that tricks like renaming masters will get you somewhere.
To customize connector appearance, try using themes/styles ("Design" tab) - i.e. just apply one style to the first page, and another to the second... that should be it.