Visio Add-in, Add GraphicItem to the Visio Shape programatically

I

Ironleg

Hello
I am developing a process flow Visio Add-in application in using C# and
VSTO2005 SE, I have been able to create shapes and connect them together with
dynamic connectors, but I can't figure out how to embed an icon into the
shape or use existing Visio GraphicItems when the data property of the shape
like "Duration" is equal to some value. But I can do all this manualy on the
diagram after it's been generated with my code.

Does anyone know how to add a Visio.GraphicItem to the Shape programatically
in C# or VB?

Thank you,

Oleg
 
A

Al Edlund

I believe there are examples in the v2007 sdk on how to do that. If all else
fails David Parkers book does a lot with Visio Graphics.
al
 
D

dilettante101

Hello
I am developing a process flow Visio Add-in application in using C# and
VSTO2005 SE, I have been able to create shapes and connect them together with
dynamic connectors, but I can't figure out how to embed an icon into the
shape or use existing Visio GraphicItems when the data property of the shape
like "Duration" is equal to some value. But I can do all this manualy on the
diagram after it's been generated with my code.

Does anyone know how to add a Visio.GraphicItem to the Shape programatically
in C# or VB?

Thank you,

Oleg

Oleg,

You need to use the DateGraphic object. It is very easy to assign a
DG to and object based on the value of a data field. Here's a piece
of code that removes the DataGraphic from selected Shapes:

Public Sub NoDataGraphics()
Dim grpShape
Dim vShape As Shape

Set grpShape = ActivePage.Shapes("GrpBoard")
For Each vShape In grpShape.Shapes
vShape.DataGraphic = Nothing
Next

End Sub

Where GrpBoard is a Group of Shapes.

And here is some code that assigns a DataGraphic (DG_IsBasic) based on
a value in a Custom cell.

So in the end, all you need do is create your DG's in Visio, name them
and then access by name to make it easy.

Incidentally, some of the gurus that watch over this group have
published examples of creating your own custom DG's.

Good Luck,

Steve
 
I

Ironleg

Thank you Steve for reply,
but I was more looking for answer in case the shape has no
DataGraphic.GraphicItems like Process shape from "Basic Flowchart Stencil", I
went the way of programmatically dropping and modifying Process shapes (like
setting the gradient color, round corners and etc.), so I was looking for
solution to add DataGraphic Icon to the Process Shape thru code.
At this stage I can create a Master of type
VisMasterTypes.visTypeDataGraphic but I can’t figure out how add Icon set
“Status Icons†to the DataGraphic master.

May be it would be better for me to create my own Stencil with shapes and
assing GraphicItems to it manually, and then use those shapes to drop on the
page.

Regards,
Oleg
 
D

dilettante101

Thank you Steve for reply,
but I was more looking for answer in case the shape has no
DataGraphic.GraphicItems like Process shape from "Basic Flowchart Stencil", I
went the way of programmatically dropping and modifying Process shapes (like
setting the gradient color, round corners and etc.), so I was looking for
solution to add DataGraphic Icon to the Process Shape thru code.
At this stage I can create a Master of type
VisMasterTypes.visTypeDataGraphic but I can’t figure out how add Icon set
“Status Icons” to the DataGraphic master.

May be it would be better for me to create my own Stencil with shapes and
assing GraphicItems to it manually, and then use those shapes to drop on the
page.

Regards,
Oleg

Oleg,

I apologize for being dense, but I am not quite sure what you are
looking for. So just let me give you some of the references I have
for manipulating data graphics. Hopefully one of them targets what
you are looking to do.

This one is a Microsoft tutorial on how to build custom DataGraphics:

http://msdn2.microsoft.com/en-us/library/aa468596.aspx

And here's one from Bill Morein's weblog. The key take away from this
one is to make a copy of an existing data graphic and manipulate that
using the Edit Master function.

http://blogs.msdn.com/wmorein/archive/2006/06/15/632742.aspx

And this one is a clever piece of graphical manipulation by the Visio
Guy a.k.a. Chris Roth:

http://www.visguy.com/2007/08/16/forefront-icons-and-data-graphic-shapes/

I hope these references are helpful. If not, just iterate back and
hopefully me or somebody else can help you converge on a solution.

SteveM
 

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