473,421 Members | 1,668 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,421 software developers and data experts.

Loading Image Resources

Building a large app where we want to be able to ship updated icons like
patches/assign different "skins", etc.

So, I'm looking at storing sets of related icons in assemblies that will be
loaded dynamically.

Some questions:

What's the "best practices" way to load an assembly where its only purpose
is to provide resources?

In my simplistic view, I would just do something like this:
{
Assembly theAssembly = Assembly.LoadFile(theFileName);
Image theImage =
Image.FromStream(theAssembly.GetManifestResourceSt ream(resourceID));
}

Now, I'm not looking for the "quick fix" here, this needs to be durable and
enterprise-grade. Is there somewhere else that I should be looking?

I thought about the resource manager, but it seems to be all about
internationalization, and that's not really what I'm trying to solve here.
Nov 17 '05 #1
4 1758
J.Marsch <jm*****@newsgroup.nospam> wrote:
Building a large app where we want to be able to ship updated icons like
patches/assign different "skins", etc.

So, I'm looking at storing sets of related icons in assemblies that will be
loaded dynamically.

Some questions:

What's the "best practices" way to load an assembly where its only purpose
is to provide resources?

In my simplistic view, I would just do something like this:
{
Assembly theAssembly = Assembly.LoadFile(theFileName);
Image theImage =
Image.FromStream(theAssembly.GetManifestResourceSt ream(resourceID));
}

Now, I'm not looking for the "quick fix" here, this needs to be durable and
enterprise-grade. Is there somewhere else that I should be looking?

I thought about the resource manager, but it seems to be all about
internationalization, and that's not really what I'm trying to solve here.


One way to make things simpler might be to include a single type in the
resource assembly - that way you can make sure the assembly is loaded
(and get a reference to the Assembly object) just by using
typeof(TypeInResourceAssembly) (etc).

Now, if you've already got a type within the assembly, you could make
that some kind of ImageManager type which is able to load the resources
requested and return images directly.

Does that help at all?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
Actually, yes that does help. I still think that I am going to have to load
the assembly dynamically, but it might be handy to have a manager sitting in
there to help with pulling out the resources -- I'll have to noodle on that
a bit.

Oh, and here's why I _think_ I need to do dynamic loads (I'm not dead-set on
that idea yet):

These icons might change as a result of a user preference. For example:
today maybe the set of icons in the assembly supports the "blue" XP look.
Maybe next week, we ship a download that supports the "silver" XP theme, and
maybe next year we toss one out that is more appropriate to Longhorn.

Even that is a simplification. There is a specific type of partition (think
of it as a business entity) in this system, and the user can associate
different color schemes with different entities. As they move from entity
to entity, the application will change in obvious ways (different large
icons and headings), and subtly (different accent colors and tree icons,
etc).

So these resource assemblies are sort of like extensions, or plug-ins but
they do not offer code, just alternate resources. In some ways, that is
kind of like internationalization; it's just that the selection of the
resource set is not tied to culture.
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
J.Marsch <jm*****@newsgroup.nospam> wrote:
Building a large app where we want to be able to ship updated icons like
patches/assign different "skins", etc.

So, I'm looking at storing sets of related icons in assemblies that will
be
loaded dynamically.

Some questions:

What's the "best practices" way to load an assembly where its only
purpose
is to provide resources?

In my simplistic view, I would just do something like this:
{
Assembly theAssembly = Assembly.LoadFile(theFileName);
Image theImage =
Image.FromStream(theAssembly.GetManifestResourceSt ream(resourceID));
}

Now, I'm not looking for the "quick fix" here, this needs to be durable
and
enterprise-grade. Is there somewhere else that I should be looking?

I thought about the resource manager, but it seems to be all about
internationalization, and that's not really what I'm trying to solve
here.


One way to make things simpler might be to include a single type in the
resource assembly - that way you can make sure the assembly is loaded
(and get a reference to the Assembly object) just by using
typeof(TypeInResourceAssembly) (etc).

Now, if you've already got a type within the assembly, you could make
that some kind of ImageManager type which is able to load the resources
requested and return images directly.

Does that help at all?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #3
J.Marsch <jm*****@newsgroup.nospam> wrote:
Actually, yes that does help. I still think that I am going to have to load
the assembly dynamically, but it might be handy to have a manager sitting in
there to help with pulling out the resources -- I'll have to noodle on that
a bit.

Oh, and here's why I _think_ I need to do dynamic loads (I'm not dead-set on
that idea yet):

These icons might change as a result of a user preference. For example:
today maybe the set of icons in the assembly supports the "blue" XP look.
Maybe next week, we ship a download that supports the "silver" XP theme, and
maybe next year we toss one out that is more appropriate to Longhorn.

Even that is a simplification. There is a specific type of partition (think
of it as a business entity) in this system, and the user can associate
different color schemes with different entities. As they move from entity
to entity, the application will change in obvious ways (different large
icons and headings), and subtly (different accent colors and tree icons,
etc).

So these resource assemblies are sort of like extensions, or plug-ins but
they do not offer code, just alternate resources. In some ways, that is
kind of like internationalization; it's just that the selection of the
resource set is not tied to culture.


Right. That seems pretty reasonable, yes. You may want to think about
organising your resources in the same way as for cultures, with a
hierarchy (which in your case may be arbitrarily deep). So, for
instance, you might have:

MyResources
MyResources-Windows
MyResources-Windows-XP
MyResources-Windows-XP-Silver
MyResources-Windows-XP-Blue
MyResources-Windows-Longhorn
MyResources-Linux
MyResources-Linux-Gnome
MyResources-Linux-KDE

with each deferring requests for any unfound resources to its "parent".

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4
Yes, that makes sense. Thank you for the commentary, Jon.

-- Jeremy

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
J.Marsch <jm*****@newsgroup.nospam> wrote:
Actually, yes that does help. I still think that I am going to have to
load
the assembly dynamically, but it might be handy to have a manager sitting
in
there to help with pulling out the resources -- I'll have to noodle on
that
a bit.

Oh, and here's why I _think_ I need to do dynamic loads (I'm not dead-set
on
that idea yet):

These icons might change as a result of a user preference. For example:
today maybe the set of icons in the assembly supports the "blue" XP look.
Maybe next week, we ship a download that supports the "silver" XP theme,
and
maybe next year we toss one out that is more appropriate to Longhorn.

Even that is a simplification. There is a specific type of partition
(think
of it as a business entity) in this system, and the user can associate
different color schemes with different entities. As they move from
entity
to entity, the application will change in obvious ways (different large
icons and headings), and subtly (different accent colors and tree icons,
etc).

So these resource assemblies are sort of like extensions, or plug-ins but
they do not offer code, just alternate resources. In some ways, that is
kind of like internationalization; it's just that the selection of the
resource set is not tied to culture.


Right. That seems pretty reasonable, yes. You may want to think about
organising your resources in the same way as for cultures, with a
hierarchy (which in your case may be arbitrarily deep). So, for
instance, you might have:

MyResources
MyResources-Windows
MyResources-Windows-XP
MyResources-Windows-XP-Silver
MyResources-Windows-XP-Blue
MyResources-Windows-Longhorn
MyResources-Linux
MyResources-Linux-Gnome
MyResources-Linux-KDE

with each deferring requests for any unfound resources to its "parent".

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Adrian MacNair | last post by:
Hi, I created an image gallery which displays 63 images in a slideshow. The problem is that the show was slow because each image loaded one at a time during the show. No problem right? I just...
1
by: D. Yates | last post by:
Hi, I am looking for an example of how to extract bitmap images from an embedded resource file (a file with *.res extension, which can be viewed inside of the ide and can hold bitmaps, icons,...
1
by: Novice | last post by:
I'm afraid I will incur the wraith of Mr. Powell on this one - but I did read his #1 FAQ and some others and I still can't figure this out. I created this little c# app. and I have a PictureBox...
17
by: Joshua Kendall | last post by:
I have a splash screen that is set to a timer. When the timer reaches it's Interval of 1000, I want it to load the next form in my project. My brother knows VB6 from school but can't figure out...
3
by: Joshua Kendall | last post by:
I need to know the code to load another form. In vb6 it's simply "load" what is it in dotnet? Anyway here's my code: Public Class Splash Inherits System.Windows.Forms.Form #Region "...
2
by: Ivan Sammut | last post by:
Hi, Anyone can give me an example on how to load a bitmap from resource. Thanks Ivan
27
by: Chris Tomlinson | last post by:
Hi, is there any way to specify the sequence in which images load on a web page? More specifically, here is what we need to achieve: Image1 starts loading first and the browser does not...
14
by: MsNews | last post by:
Hi, I'm creating a free Icon library in C# with source code include, it already support .ico/.dll../exe and I'd like to support .ICL format too, I need to load a file .ICL (Icon Library) that...
0
by: speedcoder | last post by:
hi all, i'm stumped. my applet used to load images over the network. (it was actually designed by someone else.) yes, the applet used to load each image file independently over the network and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.