Share image resources between projects

B

bbrewder

I am interested in hearing how other people have handled sharing
resources in multiple projects (for example, a save icon).

We have a product that has many forms within many projects. Many of
these forms have a save button with an icon (along with other common
buttons and icons). At this point, we've added the icon to each
project.

Unfortunately, if we want to change the icon, we now have to go to
every project and change it. It would be nice if all the buttons used
an icon from a shared resource assembly but I can't figure out how to
enable something like that in the designer.

Any ideas would be appreciated.
 
K

Kevin Spencer

You can embed the image as a resource into a DLL assembly.

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP
 
C

CassioT

I have the same problem. I could embed the images into a dll assembly
but I don't know how access them while designing the screen. Can
anyone tell me how?

Thank you,

Cassio Tavares
 
B

bbrewder

I ended up creating a resource assembly, using the resource generator
from Code Project (http://www.codeproject.com/dotnet/
ResXFileCodeGeneratorEx.asp - creates a strongly typed class for
resources that is public), adding a new property to the button control
for the image type (I need this for icons on buttons so the image
types would be open, create new, save, close, delete, etc.). When the
user sets the image type, I get the image set (both the small and
large icon) from the resource file.

I used a UITypeEditor to display a list of the available image types
which I got from the resource class (I could have used a
TypeConverter, but I already had a convenient base UITypeEditor
available). If the image type property is set, I do not serialize the
image properties (if the image properties are serialized, the images
will be added to the project).

This is certainly not a simple process (it took me a couple of hours
and I am fairly experienced with many of these designer issues) and it
forced me to do some odd things to make it work. I hope VS 2008 allows
external resource assemblies to be used in the WinForms designer.

Brian Brewder
 

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