Customizing Structured Diagram Content in

advertisement
Learn the benefits of and approaches to
creating, automating, and persisting
custom Structured Diagrams shapes and
relationships.
Customizing
Structured Diagram
Content in Visio
2010
Table of Contents
Custom containers .................................................................................................................................... 2
Custom lists ............................................................................................................................................... 5
Custom callouts......................................................................................................................................... 6
Exposing custom shapes to users ............................................................................................................. 6
Platform Capabilities for Structured Diagrams Shapes............................................................................. 7
ShapeSheet functions for Structured Diagrams relationships .................................................................. 9
Persisting Structured Diagrams relationships ......................................................................................... 10
Using Automation with Structured Diagrams Shapes ............................................................................ 11
Conclusion ............................................................................................................................................... 17
Page 1
Building Custom Structured Diagrams Shapes
While there are many built-in container, list, and callout shapes in Visio 2010, any two-dimensional
shape can be used as a container, list, or callout. This paper describes how shape designers can create,
automate, and persist their own custom Structured Diagrams shapes and relationships.
Custom containers
To designate any shape as a container, list, or callout a shape designer only needs to add one Userdefined cell called User.msvStructureType. For the value enter “Container”, “List”, or “Callout” as
desired. This setting tells Visio that the shape is a Structured Diagrams element and adds many of the
Structured Diagrams behaviors to the shape. In the image below, a rectangle shape is transformed into
a container shape by adding the User.msvStructureType cell and setting it to “Container”.
Any shape with User.msvStructureType = “Container” is treated by Visio as a Container, though Visio
also requires the shape to be 2-D and have an Angle = 0. There are additional settings available to
customize the appearance and behavior as described below. The following ShapeSheet cells define
these container properties, several of which can be configured in the Container Tools contextual tab in
the Ribbon.
Cell Name
Description
User.msvSDContainerMargin
Distance between container boundary and member shapes
User.msvSDContainerResize
Automatic resize behavior for shape (0 = No automatic
resize; 1 = Expand as needed; 2 = Always fit to contents)
Page 2
User.msvSDContainerStyle
1-based index value for the current visual style of the
container
User.msvSDContainerStyleCount
Total number of visual styles supported by the container
User.msvSDHeadingStyle
1-based index value for the current visual style of the
container heading
User.msvSDHeadingStyleCount
Total number of visual styles supported by the container
heading
User.msvSDContainerLocked
Boolean value that prevents membership changes in the
container
User.msvSDContainerRequiredCategories Semi-colon delimited list of category names. Other shapes
must have at least one matching name to be allowed as
container members.
User.msvSDContainerExcludedCategories
Semi-colon delimited list of category names. Other shapes
with at least one matching name are disallowed as
container members.
User.msvSDContainerNoHighlight
Boolean value that suppresses the container highlighting
when member shapes are selected or added to container
User.msvSDContainerNoRibbon
Boolean value that hides the Container Tools contextual
tab in the Ribbon for this container
User.msvSDContainerHeadingEdge
String designating where the interior of the container is
from the perspective of the container heading. Must be
either “Left”, “Right”, “Top”, or “Bottom”.
User.msvSDMembersOnHiddenLayer
Boolean value that determines whether Visio severs
container relationships when the container or member is
placed on a hidden layer. If True, Visio allows relationships
to exist on the hidden layer. If False, Visio severs the
relationships.
Creating a visual style
By default a container shape does not have any Container Style or Heading Style available in the
Container Tools tab. Styles are a way to offer different looks for the container through some
combination of geometry and formatting changes. The container shape can define multiple visual styles
using the User.msvSDContainerStyle, User.msvSDContainerStyleCount, User.msvSDHeadingStyle, and
Page 3
User.msvSDHeadingStyleCount cells (in short, the “Style” cells and the “Count” cells). Use the Count
cells to tell Visio how many styles a shape supports for the overall container or for the heading. Then
determine what ShapeSheet cells should be set for each style. Put formulas in each of these cells that
depend on the value of the Style cells. Visio will check the style count and populate the ribbon galleries
with each style defined by the container shape. When the user chooses a new style from the gallery,
Visio puts that style index back into the Style cells to update the look of the container.
The container shapes in Visio 2010 vary in complexity. The containers in the Insert Container gallery
have many visual styles and lots of formulas to change the appearance of the shapes. There are some
simpler examples in the Wireframe shapes, which define just a few styles each.
Controlling container membership
Visio 2010 introduces the concept of Shape Categories to refine the membership behaviors of
containers. This is the mechanism used by features such as Cross-functional Flowchart and Data Graphic
Legend to ensure that only the right kinds of shapes participate in the list and container behaviors. A
container shape can restrict membership by defining a required or excluded shape category. For this to
work, a prospective member shape must have a User-defined cell User.msvShapeCategories in its
ShapeSheet. The prospective shape lists one or more category names in a semi-colon delimited
string. To only allow a specific category of member shape, a container can set that name in its
User.msvSDContainerRequiredCategories cell. To allow most shapes as members but specifically
exclude a category, a container can set that name in its User.msvSDContainerExcludedCategories
cell. (Prospective shapes with no categories defined will not be allowed in a container with required
categories, and they will always be allowed in a container with excluded categories. Shapes with some
categories that are included and others that are excluded will be excluded from a container.)
Creating a heading sub-shape
The heading of a container is simply the container shape’s text for basic containers. However, it is
possible to achieve more sophisticated visual styles if the heading becomes its own shape. For this
construction the container becomes a group and the heading is added as a sub-shape of the group. The
primary benefit is that Visio can account for the heading sub-shape in sizing and layout operations to
Page 4
avoid putting member shapes on top of the heading. To designate a sub-shape as a heading for the
container, add the cell User.msvStructureType to the sub-shape and give it the value “Heading”. Also
set the User.msvSDContainerHeadingEdge cell in the sub-shape. This cell helps Visio understand how
the heading is positioned relative to the interior of the container. For example, if the heading is near the
left edge of the container then the correct value for the cell is “Right” (regardless of the heading’s
angle). The interior of the container is on the right side of the heading.
Custom lists
Any shape with User.msvStructureType = “List” is treated by Visio as a List. A List orders and arranges it
member shapes automatically. Note that Lists are also considered to be Containers, and they have
similar capabilities such as automatically moving, copying, or deleting member shapes. All of the
previously mentioned Container cells apply to list shapes. The following ShapeSheet cells define
additional list properties.
Cell Name
Description
User.msvSDListAlignment
Determines how list member shapes are aligned in list (0 = Left; 1
= Center; 2 = Right for vertical lists. 0 = Top; 1 = Middle; 2 =
Bottom for horizontal lists.)
User.msvSDListDirection
Direction that list arranges list member shapes (0 = Left to Right; 1
= Right to Left; 2 = Top to Bottom; 3 = Bottom to Top)
User.msvSDListSpacing
Distance between the edges of list members
User.msvSDListItemMaster
Name or UniqueID of master shape to instance on Insert
commands. Value must be placed inside a USE() function.
User.msvSDListNoReorder
Boolean value that prevents reordering of list members. The list
must also be locked via User.msvSDContainerLocked = True for
setting to have any effect.
User.msvSDListRequiredCategories Semi-colon delimited list of category names. Other shapes must
have at least one matching name to be allowed as list members.
User.msvSDListExcludedCategories
Semi-colon delimited list of category names. Other shapes with at
least one matching name are disallowed as list members.
Specifying an insertion shape
There are several ways to add a shape to a list: dragging and dropping the shape, clicking the blue
insertion arrow that appears near the list edge or right-clicking an existing member and inserting a
shape. Clicking the insertion arrow and right-clicking to insert a shape both use the
User.msvSDListItemMaster cell to determine what shape to add to the list. The name of the master is
Page 5
placed in quotes inside a USE() function, such as USE(“List member master”). If no shape is specified in
User.msvSDListItemMaster, Visio will duplicate an adjacent shape in the list when inserting.
It is also possible to automatically populate the list with some member shapes when the list is first
dropped on the page. To do this put the following formula in the EventDrop cell of the list, repeating
the DOCMD(2270) once for each member to be added:
IF(LISTMEMBERCOUNT()=0,DOCMD(2270)+DOCMD(2270)+DOCMD(2270),0)
2270 is the command for inserting before an item in a list (visUiCmds.visCmdListInsertBefore). It is also
possible to use 2271, the command for inserting after an item in a list (visUiCmds.visCmdListInsertAfter).
Controlling list membership
Lists have their own cells to govern list membership. Use the User.msvSDListRequiredCategories and
User.msvSDListExcludedCategories cells to restrict what shapes can become list members. Because lists
are also containers, it is possible for shapes to become container members of the list. The
standard User.msvSDContainerRequiredCategories and User.msvSDContainerExcludedCategories
cells determine this behavior. By default Visio will attempt to add a shape to a list as a list member, but
if that fails it may try to add it as a container member. The difference between a list member and a
container member is that only list members will be arranged by the list and affect its size. Shape
designers should manage both sets of membership cells to ensure the right results.
Custom callouts
Any shape with User.msvStructureType = “Callout” is treated by Visio as a Callout. Callout shapes must
also have a control handle with the Controls row named Controls.Association. Visio manages the
relationship with the callout’s target shape through this row in the ShapeSheet. The following
ShapeSheet cells define additional callout properties.
Cell Name
Description
User.msvSDCalloutNoHighlight Boolean value that suppresses the highlighting on the callout target
shape
User.msvSDTargetIntersection
Location in page coordinates of the intersection between the
geometric boundary of the target shape and a virtual line drawn from
the center of the callout to the center of the target shape. This is a
read-only cell set by Visio.
Exposing custom shapes to users
As with any custom shape, shape designers create Visio masters by dragging them into a stencil. Users
can then open this stencil as part of the document workspace and drag the shapes onto their diagram.
This is still the recommended method for deploying custom Structured Diagrams shapes. Visio 2010
also provides a way to expose custom containers and callouts through the ribbon as described below.
Page 6
Showing custom shapes in the Insert Container gallery
Visio provides several built-in container shapes in the Insert Container gallery located on the Insert tab
of the ribbon. It is possible to override this set of shapes by creating a specially named stencil with
alternate container shapes. Create a stencil named _CONTAIN.vss and place it in the user’s My Shapes
folder.
Showing custom callout shapes in the Insert Callout gallery
Visio provides several built-in callout shapes in the Insert Callout gallery located on the Insert tab of the
ribbon. It is possible to override this set of shapes by creating a specially named stencil with alternate
callout shapes. Create a stencil named _CALLOUT.vss and place it in the user’s My Shapes folder.
Platform Capabilities for Structured Diagrams Shapes
While much of the capabilities of containers, lists, and callouts are defined through custom User-defined
cells, there are some generic shape features that can be utilized to enhance the behaviors of Structured
Diagrams shapes.
DisplayLevel
Typically in Visio the most recently added shape is shown on top of the other shapes on the page. To
change this display order (z-order) users can use commands such as Send Backward or Bring Forward,
which are found in the Arrange group on the Home tab. Because container shapes are intended to sit in
back of other shapes and callout shapes are intended to sit in front of other shapes, a new capability
was added to Visio 2010 to avoid the need for constant display order corrections.
The DisplayLevel cell in the ShapeSheet allows a shape designer to define a z-order band for a shape.
Visio will automatically display a shape behind any shape with a higher DisplayLevel and in front of any
shape with a lower DisplayLevel. The DisplayLevel value can range from -32767 to 32767. By default
shapes have a DisplayLevel of 0. Visio’s built-in containers use a DisplayLevel of -25000. Visio’s built-in
callouts use a DisplayLevel of 25000.
DisplayLevel allows Visio to automatically drop new shapes into the desired display order position on
the diagram. The ordering commands can still be used to move shapes forward and backward.
However, the BringToFront and SendToBack commands behave differently. Invoking one of these
commands once will only move a shape to the top or bottom of their z-order band. The command must
be invoked a second time to move a shape out of their band to the true top or bottom of the z-order.
Page 7
NoQuickDrag
When shapes completely overlap in a diagram, it can be difficult for users to select the shape they
intend. Clicking repeatedly on a stack of shapes will cause Visio to select each one in turn, but this
means that the shape selected when clicking is dependent on the previous selection. In the case of
custom containers, member shapes within the container can be hard to select. Users can accidentally
select the container by clicking on the member or by attempting to clear the selection by clicking just
outside the member shape. Visio also has a behavior where users can click once and initiate a drag
action without first selecting the shape. Thus users may inadvertently click and drag a container when
attempting to lasso select the container’s contents.
Visio 2010 introduces a new ShapeSheet cell that eliminates these problems by designating the filled
geometry of a shape as unselectable. This behavior is controlled by the NoQuickDrag cell. When
NoQuickDrag is True, clicking in the filled region of a shape will not result in selecting or dragging the
shape. Visio treats the region as unfilled for the purpose of selection. Such shapes can still be selected
by clicking directly on the geometry outline, clicking on the shape’s text or using a lasso around the
shape. Visio’s built-in container shapes have NoQuickDrag equal to True for their interior (but not for
their headings).
Custom RMA flyouts
Shapes that have multiple visual styles or parameter-driven appearances often expose their settings as
right-click actions. Visio has long supported custom Actions for shapes, but all actions were exposed as
top level menu items. Visio 2010 adds support for custom actions in flyout menus, which allows shape
designers to better organize their commands.
An Action row is designated as a flyout by setting the FlyoutChild cell to True. Visio will display that row
as a flyout of the closest previous Action row where FlyoutChild is False.
Page 8
ShapeSheet functions for Structured Diagrams relationships
Visio 2010 introduces a number of functions for working with shape relationships.
The following functions return a Sheet reference, or a reference to a shape. This return value can then
be used to call another function. For example, CALLOUTTARGETREF()!HASCATEGORY(“Category”).
Function
Description
CALLOUTTARGETREF()
Returns a Sheet reference to the target shape that this callout
is associated with
CONTAINERSHEETREF(index,
category)
Returns a Sheet reference to the container shape that this
shape is a member of
-- The 1-based Index parameter specifies which parent
container to return, where the topmost container is ordered
first
-- If category is specified, the container must have that
category in order to be returned
LISTSHEETREF()
Returns a Sheet reference to the list container shape that this
shape is a member of
The following functions return the number of related shapes.
Function
Description
CALLOUTCOUNT()
Returns the number of callout shapes associated with the
shape
CONTAINERCOUNT()
Returns the number of containers the shape is a member of
CONTAINERMEMBERCOUNT()
Returns the number of member shapes in the container shape
LISTMEMBERCOUNT()
Returns the number of member shapes in the list container
shape
Page 9
Additional ShapeSheet functions:
Function
Description
HASCATEGORY(string)
Returns TRUE if the specified string is found in the shape's
categories list
LISTORDER()
Returns the 1-based order for the shape within a list
In the example below, the rectangular process shape belongs to a container. It shows the total number
of shapes in the container using a text field with the formula
CONTAINERSHEETREF(1)!CONTAINERMEMBERCOUNT().
The Index parameter for the CONTAINERSHEETREF function directs Visio to return the topmost
container in the case where a shape belongs to multiple containers. If multiple container membership is
common, designers can also provide a Category parameter to ensure that only containers of a specific
type are considered.
Persisting Structured Diagrams relationships
This section is provided for reference only. The relationships among containers, lists, callouts, and
shapes are stored in a ShapeSheet cell named Relationships. This cell uses a series of DEPENDSON
functions, one for each different type of relationship the object has. Note that changes to this cell will
not trigger actual relationship changes; Visio only uses this as a means to store the relationship
information. This cell is not intended to be modified by end users or shape designers.
The types of relationships are listed below.
Value Meaning
1
Shapes that are members of this container
2
Shapes that are members of this list
Page
10
3
Callouts that are associated with this shape
4
Containers that this shape is a member of
5
List that this list item is a member of
6
Shape associated with this callout
7
Container on whose left boundary this shape sits
8
Container on whose right boundary this shape sits
9
Container on whose top boundary this shape sits
10
Container on whose bottom boundary this shape sits
11
List that this list overlaps
A shape named Process that is a member of a container named Container 1 would have a Relationships
cell formula of this form: =SUM(DEPENDSON(4,Container 1!SheetRef())). The container’s Relationship
cell would look like: =SUM(DEPENDSON(1,Process!SheetRef())).
If the Process shape were on the boundary of the left edge of the container, its Relationships cell would
be: =SUM(DEPENDSON(7,Container 1!SheetRef()),DEPENDSON(4,Container 1!SheetRef())). The
container’s cell would remain as listed.
A shape that is a member of two containers would look like:
=SUM(DEPENDSON(7),DEPENDSON(4,Container 1!SheetRef(),Container 2!SheetRef())), and so forth.
Using Automation with Structured Diagrams Shapes
This section describes the programmability features for Containers, Lists, and Callouts in Visio 2010. The
part of the Visio API that manages these Structured Diagrams shapes is known as the Structured
Diagrams API. This API enables developers to identify the logical relationships between shapes, add or
change the relationships between shapes, and detect when the user makes changes to the relationships
between shapes.
Structured Diagrams API Overview
Here are the key objects, properties, and methods in the Structured Diagrams API:
Page
11
There are two new objects in the API. ContainerProperties is an extension of the Shape object. It
encapsulates the special properties and behaviors of containers and lists. RelatedShapePairEvent is an
object used with the Structured Diagrams API events, where Visio can describe a relationship being
formed or broken between two shapes. The remaining parts of the API are additions to existing Visio
objects.
Page
12
Note that lists are just another type of container as far as the API is concerned. Therefore, lists use all
the same objects, properties, and methods as containers; and lists have a few additional properties and
methods as well (those with “List” in their name).
Enabling Structured Diagrams Behaviors in Solutions
Visio 2010 introduces a new feature called Diagram Services that manages what diagramming behaviors
are enabled in the document. There are diagram services that control the behavior of the Auto Size
Page feature and diagram services that control the behaviors of Containers, Lists, and Callouts. These
services are turned on and off at the document level. When a service is off, changes made in the
diagram through automation will not trigger the diagramming behaviors related to that
service. (Changes made through the user interface are not subject to the diagram service state.)
For example, the Auto Size Page feature will normally grow the page size if a shape is placed outside the
page boundary. However, when a shape is placed outside the page via automation, the Auto Size Page
feature will only respond if the Auto Size Page diagram service is enabled. Similarly, dropping a shape
on top of a container will normally make it a member of the container and cause the container to resize
to fit it. However, when the shape is dropped via automation, the Containers feature will only respond
if the Structured Diagrams service is enabled.
The reason Visio 2010 includes this capability is that solutions may not always want these diagramming
behaviors to get triggered while they are manipulating shapes in the diagram. This may especially be
true for existing solutions that have no knowledge of the new Visio 2010 behaviors and have
expectations that shapes respond in ways consistent with Visio 2007. In order for existing solutions to
work as originally designed, all diagram services in Visio 2010 are disabled by default. Solutions must
opt the document in to the new diagramming behaviors. Note that diagram service states apply to
automation properties and methods that existed in Visio 2007. When a new Visio 2010 automation
method is explicitly invoked by a solution - such as any of the examples below – the service state is
ignored. The presumption is that the solution wants the Visio 2010 behavior associated with that
method.
Diagram service states are checked or changed using the Document.DiagramServicesEnabled
property. The value of this property is a mask of all the services currently enabled. Available services
and values are listed in the table below. It is possible for a solution to opt into just one service, all the
services supported in Visio 2010, or even all existing and future services.
VisDiagramServices values:
Enum
Value
Description
visServiceAll
-1
All diagram services
visServiceVersion140
7
Diagram services that exist in Visio 2010
Page
13
visServiceNone
0
No diagram services (default)
visServiceAutoSizePage
1
AutoSize page behaviors
visServiceStructureBasic
2
Behaviors that maintain existing Structured Diagrams
relationships but do not create new relationships
visServiceStructureFull
4
Structured Diagrams behaviors that match the behaviors in
the user interface
There are two services for Structured Diagrams behaviors. The StructureBasic service maintains
relationships but will not form new ones. This might be appropriate for a solution that wants to respect
the user’s usage of Containers, Lists and Callouts but does not want the solution itself to inadvertently
form relationships when shapes are moved around the page. The StructureFull service maintains
relationships and will form new relationships as well. This matches the behaviors that are triggered in
the user interface. If both services are enabled, then Visio uses the StructureFull set of behaviors.
Disabling Structured Diagrams Behaviors in Solutions
As discussed in the previous section, Structured Diagrams behaviors triggered through automation are
disabled by default and must be enabled for solutions using the Diagram Services feature. Structured
Diagrams behaviors triggered through the user interface are enabled by default and not subject to the
Diagram Services state.
It is possible to disable Structured Diagrams behaviors altogether in the UI and API. Solution developers
can add a cell User.msvSDStructureDisabled to the Pagesheet of a page and set the value to TRUE.
Common Tasks with the Structured Diagrams API
Let’s look at some typical Structured Diagrams tasks to explore the API in greater detail. For a complete
list of the special flags that can be passed into the methods, look at the Object Browser within the VBA
editor in Visio.
Add a container to the page
Containers can be added to a page by calling the traditional Page.Drop method, which will add the shape
at the coordinates specified without affecting the membership of existing shapes on the
page. However, there is a new Page method – Page.DropContainer - that will not only drop the
container but will also size it around a set of shapes and make those shapes members of the
container. This is the behavior in the UI when using Insert > Container when a selection
exists. DropContainer needs an object for the container shape. To use one of the shapes in the Insert
Container gallery, use the GetBuiltInStencilFile method to retrieve the hidden stencil where these
containers are stored.
Page
14
Dim vsoDoc1 As Visio.Document
Set vsoDoc1 =
Application.Documents.OpenEx(Application.GetBuiltInStencilFile(visBuiltInStencilConta
iners, visMSUS), visOpenHidden)
Application.ActivePage.DropContainer vsoDoc1.Masters.ItemU("Container 1"),
Application.ActiveWindow.Selection
vsoDoc1.Close
Add a shape to a container
Shapes are added to a container by moving or dropping them onto the container using existing Visio API
properties and methods (if the StructureFull diagram service is enabled). Shapes can be explicitly added
to a container using the AddMember method. This is useful when the shape already overlaps the
container and is not yet a member. It is also helpful if developers want to force the container to expand
to encompass the new member.
vsoContainerShape.ContainerProperties.AddMember vsoShape, visMemberAddExpandContainer
Find the containers on a page
To discover what containers exist in a document, Visio provides a direct way to get the set of containers
in a selection or on a page. The GetContainers method returns an array of Shape IDs for the
containers. Containers nested within other containers can be included or excluded using flags.
For Each containerID In vsoPage.GetContainers(visContainerIncludeNested)
Set vsoContainerShape = vsoPage.Shapes.ItemFromID(containerID)
'...
Next
Get the shapes in a container
Solutions can identify the members of a container using the GetMemberShapes method, which returns
an array of Shape IDs for the member shapes. The flags allow certain kinds of member shapes to be
filtered out of the array returned.
For Each memberID In
vsoContainerShape.ContainerProperties.GetMemberShapes(visContainerFlagsDefault)
Set vsoShape = vsoPage.Shapes.ItemFromID(memberID)
'...
Next
Add a new shape to a list
While shapes can be dropped on the page and then placed into lists, there is a new Page method –
Page.DropIntoList – that will perform both tasks together.
Application.ActivePage.DropIntoList vsoMaster, vsoListShape, 1
Page
15
Reorder a list
Every member of a list is placed in a specific position, and that ordinal value can be retrieved with the
ContainerProperties.GetListMemberPosition method. To reorder a member, developers can call the
ContainerProperties.ReorderListMember method. Both methods use 1 to indicate the first position in
the list.
vsoListShape.ContainerProperties.ReorderListMember vsoShape, 2
Add a callout to the page
Callouts can be added to a page by calling the traditional Page.Drop method, which will add the shape at
the coordinates specified. However, there is a new Page method – Page.DropCallout - that will not only
drop the callout but will associate it with a target shape and position it near the target shape. This is the
behavior in the UI when using Insert > Callout when a selection exists. As with DropContainer,
DropCallout needs an object for the callout shape. To use one of the shapes in the Insert Callout gallery,
use the GetBuiltInStencilFile method to retrieve the hidden stencil where these containers are stored.
Dim vsoDoc1 As Visio.Document
Set vsoDoc1 =
Application.Documents.OpenEx(Application.GetBuiltInStencilFile(visBuiltInStencilCallo
uts, visMSUS), visOpenHidden)
Application.ActivePage.DropCallout vsoDoc1.Masters.ItemU("Text callout"),
vsoTargetShape
vsoDoc1.Close
Get the target shape for a callout
A shape can have multiple callouts, but a callout can have only one target shape at a time. The
Shape.CalloutsAssociated property returns an array of callout shape IDs. Get or set the target shape of
a callout using the Shape.CalloutTarget property.
Set vsoShape = vsoCalloutShape.CalloutTarget
Structured Diagrams Events
In addition to manipulating the containers, lists, and callouts in a document, developers can also
respond to user actions that relate to these shapes. Containers, lists, and callouts work by establishing
relationships with other shapes. Visio fires an event whenever one of these relationships is formed or
broken. For example, adding a shape to a container forms a new relationship between the shape and
the container.
When a relationship event fires, Visio specifies the details in a RelatedShapePairEvent object. The
FromShapeID property of this object indicates the container, list, or callout involved in the
relationship. The ToShapeID property indicates the other shape involved in the relationship. Thus when
adding a shape to a container, the ToShapeID would refer to the new member shape. When associating
a callout with a target shape, the ToShapeID would refer to the target shape.
Page
16
The following events are available for Application, Documents, Pages, and Page event lists (and
Document event lists when using AddAdvise):
ContainerRelationshipAdded
ContainerRelationshipDeleted
CalloutRelationshipAdded
CalloutRelationshipDeleted
Also the ShapeChanged event will now fire when members of a list shape are reordered. The event
passes the list shape as an argument and includes the string “/ListReorder” in the EventInfo argument.
Conclusion
Visio 2010 allows users to organize information quickly and easily through a rich set of Structured
Diagrams capabilities. Structured Diagrams allows users to capture and maintain the logical
relationships in a diagram, and Visio uses this information to provide streamlined behaviors for users.
Visio offers features such as Containers, Lists, and Callouts to manage the logical relationships between
shapes. Shape designers and developers can extend the capabilities of Structured Diagrams through
custom shapes and solutions. In total, Structured Diagrams represents a significant new opportunity for
customers and partners to manage increasing diagram complexity.
Page
17
Download