dynamic connetor

F

Florin Capra

Hello,

I am using Dynamic connector shape to connect my custom shapes. In the
business process I need to catch the selected shape (at mouse click)
using SpatialSearch method. Everything works well with my custom shapes
the problem I encounter is related with Dynamic connector. Always obtain
null when click the connector.

Could you please help me in this case ?

Regards,
 
J

JuneTheSecond

Would you tell us what is correct, when you click connector.
If you wish to get connected shape, I recommend to use connect object.
 
F

Florin Capra

First of all thanks for your quick answer.

No, I want to obtain the connector shape itself.

Regards!
 
F

Florin Capra

JuneTheSecond said:
I thought I asked what did you wish to obtain?

Please take a look at what I develop. I am working on a telecom
application where I want to represent the network in a Visio. Suppose I
have 2 equipments that are linked by an circuit. All shapes have custom
properties and options for save/delete, etc. For equipments I have
custom shapes and for circuit I am using a Dynamic connector. Now, when
I click one shape (equipments or circuits) I need to obtain the shape
object (Shape class) where I clicked. For this I have the following code


Selection foundShapes = currentPage.get_SpatialSearch(clickLocationX,

clickLocationY,
(short)VisSpatialRelationCodes.visSpatialContainedIn,
tolerance,

(short)VisSpatialRelationFlags.visSpatialFrontToBack);


if (foundShapes.Count > 0)
{
foundShape = foundShapes[1];
}
else {return null}

This code work well if I have selected my custom shapes (Equipments) but
when I select a circuit (Dynamic connector) the foundShapes.Count = 0
always.

How could obtain the clicked shape Dynamic connector inside the code ?

Thanks a lot !

Regards,
 
D

David Parker

If you have selected shapes, then why are you not using the Window.Selection
collection of shapes?

--
David Parker
Microsoft MVP (Visio)
http://bvisual.spaces.live.com
http://www.visualizinginformation.com
Florin Capra said:
JuneTheSecond said:
I thought I asked what did you wish to obtain?

Please take a look at what I develop. I am working on a telecom
application where I want to represent the network in a Visio. Suppose I
have 2 equipments that are linked by an circuit. All shapes have custom
properties and options for save/delete, etc. For equipments I have custom
shapes and for circuit I am using a Dynamic connector. Now, when I click
one shape (equipments or circuits) I need to obtain the shape object
(Shape class) where I clicked. For this I have the following code


Selection foundShapes = currentPage.get_SpatialSearch(clickLocationX,
clickLocationY, (short)VisSpatialRelationCodes.visSpatialContainedIn,
tolerance,
(short)VisSpatialRelationFlags.visSpatialFrontToBack);


if (foundShapes.Count > 0)
{
foundShape = foundShapes[1];
}
else {return null}
This code work well if I have selected my custom shapes (Equipments) but
when I select a circuit (Dynamic connector) the foundShapes.Count = 0
always.

How could obtain the clicked shape Dynamic connector inside the code ?

Thanks a lot !

Regards,
 
F

Florin Capra

David said:
If you have selected shapes, then why are you not using the
Window.Selection collection of shapes?

Hi David,

I don't know how could I use "Window.Selection collection of shapes" to
collect the selected shape at mouse click event.

Could you please help me ?

Thanks a lot !

Regards,
 
D

David Parker

Visio.Application.ActiveWindow.Selection are all your selected shapes.
The first shape is specifically identied as
Visio.Application.ActiveWindow.Selection.PrimaryItem
but you can also enumertae the collection :

Dim shp as Visio.Shape

For Each shp in Visio.Application.ActiveWindow.Selection
'Do whatever you want
If Not shp.Master is Nothing Then
If shp.Master.NameU = "Dynamic connector" Then
'Rejoice, etc
End If
End If
Next shp
 
F

Florin Capra

David said:
Visio.Application.ActiveWindow.Selection are all your selected shapes.
The first shape is specifically identied as
Visio.Application.ActiveWindow.Selection.PrimaryItem
but you can also enumertae the collection :

Dim shp as Visio.Shape

For Each shp in Visio.Application.ActiveWindow.Selection
'Do whatever you want
If Not shp.Master is Nothing Then
If shp.Master.NameU = "Dynamic connector" Then
'Rejoice, etc
End If
End If
Next shp

Hi David,

Thank you very much for your help. Works good, my mistake was I have
accessed the ActiveWindow.Selection collection in the MouseUp click
event, where it doesn't work. Now I traverse this collection before my
specific action (when I press a button in a tool bar) and works well.

Once again many thanks !

Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top