Visio Shape Icon - How to change.

S

Stumple

I have a shape on a visio page. I am using .NET to control the visio drawing
control which contains the shape. I would like to change the icon that is
displayed on a shape. How might I do this?

I have code to get a picture but I do not know how to set the shapes icon
with it.

int screenWidth = visio.Bounds.Width;
int screenHeight = visio.Bounds.Height;

Bitmap bmpScreenShot = new Bitmap(screenWidth, screenHeight);
Graphics gfx = Graphics.FromImage((Image)bmpScreenShot);
gfx.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth,
screenHeight));
Pic p = new Pic();
p.Image = bmpScreenShot;

Thank you.
 
A

AlEdlund

I'm a little confused. What kind of shape are you trying to apply a bitmap
too. Visio shapes are vector graphics and not bitmaps. Is it a grouped shape
with an embedded bitmap?
al
 
S

Stumple

I see it may be a bit more complicated than I thought.
The shape is probably going to be a basic shape I made by taking a picture
and making a shape out of it. I suppose I need to convert the screen shot I
aquire to a vector graphic?

Basically, all I want to do is take a screen shot of my computer and then
apply that picture as an icon to a shape. What's the easiest and most
simplest way to do this? If the shape needs to be non-grouped I can make or
find one.

When I initially made the shape all I did was take a screen shot and then
make that my shape inside visio. I added that shape to a stencil. Now I want
to be able to change the picture that I used to make the shape. I thought
that was the icon but maybe there is an easier way to do this?

Thank you,

Stumple
 
A

AlEdlund

might not be that hard. When you save a 'shape' to a stencil, one of the
final steps prior to saving it to the stencil is to open the "master
properties". There is a checkbox that allows visio to create the icon based
on the shape when saving.
al
 
S

Stumple

I see that, "Generate Icon automatically from shape data".

What property or method should I be using to set "shape data" so that the
icon is generated properly from a screen shot image I take?

Thank you,

Stumple
 
A

AlEdlund

You're back to the original problem of mixing apples and oranges. The more
advanced a picture is colors, textures, shapes, etc.; the harder it is
render from a structure based on individual pixels to one that is based on
drawing components. You'll end up having the same types of issues going to
something such as WMF. Icons work when the picture is very simple, skinny
down what you are trying to show.
al
 
S

Stumple

I am trying to take a screen shot of visio and display it as the icon,
preferably just a page and what is contained in it. ;)

I don't care about difficulty; I just want to be able to do it. Am I able to
change the icon on a shape though the exposed part of visio? If so I would
like to continue down that path and see what I need to be able to access in
order to change the shapes image.

Thanks,

Stumple
 
A

AlEdlund

sounds like you're looking for the importicon method. It's kinda documented
in the visio automation with some stuff in the v2003/v2007 sdk.
Good luck,
al
 
N

Nikolay Belyh

It is not very clear what do you mean by "Shape's icon". What is it
exactly?
I'm lost... probably other people are lost too... So probably it
would
be helpful if you could describe what you are trying to accomplish...

- Take a screenshot of a visio page in your drawing control
and make an icon out of it?

- Drop a screenshot (bitmap) on a visio diagram programmatically?

- Add some "switchable" icon to a shape on a visio diagram, kinda
"shape status",
and use screenshots as variants for this "status icon"?

- Update visio master's image (i.e. master's "icon" on it's stencil)
pragmatically?

- None of above? :)

Kind regards, Nikolay.
 
S

Stumple

I am not sure how to answer you questions. I am somewhat new to visio
development so I am trying to learn.

Basically, there is a shape I have made and put onto a stencil. I made the
shape by taking a screen shot and then adding it to a visio drawing and then
dropping it onto a stencil.

This shape is taken from my stencil and then dropped onto other drawings.
After the shape that I made is dropped onto other drawings I want to change
the picture that is used as the display for the shape. I thought this was the
shapes icon but maybe I am mistaken. I just want to change this picture no
matter what it takes.

Can this be done? How?

Thanks,

Stumple,
 
P

Paul Herber

I am not sure how to answer you questions. I am somewhat new to visio
development so I am trying to learn.

Basically, there is a shape I have made and put onto a stencil. I made the
shape by taking a screen shot and then adding it to a visio drawing and then
dropping it onto a stencil.

This shape is taken from my stencil and then dropped onto other drawings.
After the shape that I made is dropped onto other drawings I want to change
the picture that is used as the display for the shape. I thought this was the
shapes icon but maybe I am mistaken. I just want to change this picture no
matter what it takes.

I think you just want to change the shape itself don't you.
You seem to be confusing terminology somewhat, the shape within the
stencil has an icon representing the shape, that icon may or may not
be an accurate representation of the actual shape. When that shape is
dragged onto the drawing page then what you see is the real shape.
Now it might be that what you are using for a shape is in fact an
image (your screenshot I think).
You just want to change this for another image. Correct?
 
N

Nikolay Belyh

This shape is taken from my stencil and then dropped onto other drawings.
After the shape that I made is dropped onto other drawings I want to change
the picture that is used as the display for the shape. I thought this was the
shapes icon but maybe I am mistaken. I just want to change this picture no
matter what it takes.

Can this be done? How?

Probably the "picture used as the display for the shape" you want to
change
is "master icon" in "visio terms". In this case, just use context
menu command "Edit Master" -> "Edit Icon Image".

Take a look here:

HOWTO: Edit a master icon
http://office.microsoft.com/en-us/visio/HP850506751033.aspx

Kind regards, Nikolay.
 
P

Paul Herber

Probably the "picture used as the display for the shape" you want to
change
is "master icon" in "visio terms". In this case, just use context
menu command "Edit Master" -> "Edit Icon Image".

But Stumple wants to change the image *after* it's been dropped on the
drawing page. I suspect that the Visio drawing page is being seen as
equivalent to the Windows desktop where the image shown is an icon and
the OP wants an equivalent of the change icon.
 
A

AlEdlund

that's pretty much what I got out of my discussion with stumple. The
secondary issue is that the source is a bitmap of a screen capture and he is
dissatisfied with the resultant quality of the icon created.
al
 
S

Stumple

Paul,

That is absolutely correct. I apologize for not using the correct
terminology but I am trying to learn as I go.

Stumple
 
S

Stumple

I have not an issue with the quality of the picture for the shape created. I
never said anything of that nature. The picture is fine. I only want to
change it as my program changes. The picture is used to give the user a
visual representation of what is happening elsewhere and I would like to
update the picture as the program progresses.

Bascially, the icon on the visio page is going to be a graphical
representation of what the user sees somewhere else. A screen shot would give
me a way to capture what the user sees else where. What I would like to do is
replace the picture of the shape on the drawing control. This may be done
immediately after thew user drops the shape on the control or sometime in the
future. I only need a way to change the picture.


AlEdlund said:
that's pretty much what I got out of my discussion with stumple. The
secondary issue is that the source is a bitmap of a screen capture and he is
dissatisfied with the resultant quality of the icon created.
al
 
A

AlEdlund

I apologize for misunderstanding what you wanted to do.
al

Stumple said:
I have not an issue with the quality of the picture for the shape created.
I
never said anything of that nature. The picture is fine. I only want to
change it as my program changes. The picture is used to give the user a
visual representation of what is happening elsewhere and I would like to
update the picture as the program progresses.

Bascially, the icon on the visio page is going to be a graphical
representation of what the user sees somewhere else. A screen shot would
give
me a way to capture what the user sees else where. What I would like to do
is
replace the picture of the shape on the drawing control. This may be done
immediately after thew user drops the shape on the control or sometime in
the
future. I only need a way to change the picture.
 
S

Stumple

It's all good. I just didn't want people to think I disliked the product. I
am quite pleased with it thus far. There are lots of options.

Stumple
 
S

Stumple

I figured out how to change the picture by changing the ForeignData section
of a shape within the <Masters> in the visio XML document. I suppose I could
write my current document out and then change the XML and then read it back
in.

Is there an easier way to do this programatically?

Thanks,

Stumple
 
S

Stumple

I found another way to get a shape into a page from a file.

shape.ContainingShape.Import(@"c:\test.bmp");

Is there anyway to make this the picture of the shape? Right now it is just
importing it into the visio and putting it on top of everything else.

Thanks,

Stumple
 

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