Large app, many icons how to manage

  • Thread starter Thread starter Jeff Jarrell
  • Start date Start date
J

Jeff Jarrell

We are migrating a large app to .net. There are many forms and there will
be many, many icons.

What are some suggested techniques for more or less sharing imagelists (easy
enough), BUT without giving up the design time experience.

jeff
 
We are migrating a large app to .net. There are many forms and there will
be many, many icons.

What are some suggested techniques for more or less sharing imagelists (easy
enough), BUT without giving up the design time experience.

jeff

I don't know how large is your app, and I don't know how many icons
you are using. But with my current project, I compile more than 1400
jpeg icons at size 32*32 into a dll as resources, and splite them into
two ImageList (identify each by its file name), and the result is
nearly perfect, although it's a little slower (1-3 seconds than not
using icons) at creating the ImageList instance for the first time.
So I guess maybe this works for you.
 
Sounds interesting. This seems like a fair comparison in terms of size.

Let me get clear on the workflow. Add a resource file the project, then add
images to the resource file. Then how does it get assembled into the
imagelist? And do you still have design time support? You have an article
you could point me to for the technique.

Thanks,

jeff
 
Sounds interesting. This seems like a fair comparison in terms of size.

Let me get clear on the workflow. Add a resource file the project, then add
images to the resource file. Then how does it get assembled into the
imagelist? And do you still have design time support? You have an article
you could point me to for the technique.

Thanks,

jeff

I don't use resource files, it's a little harder to get along with. I
just create a new library project, and add these 1400+ files into it,
then set their "Build Action" to "Embedded Resource". And I created a
class IconsManager in this project too. Here is some code from this
class:

private static ImageList meleeImageList;
static ImageList MeleeImageList
{
get
{
if (meleeImageList == null)
{
meleeImageList = new ImageList();
Assembly asmb =
Assembly.GetAssembly(typeof(IconsManager));
string[] resources =
asmb.GetManifestResourceNames();
foreach (string resource in resources)
{
if
(resource.StartsWith("Deerchao.War3Share.Client.Icons.Melee."))
{
using (Stream stream =
asmb.GetManifestResourceStream(resource))
{
Bitmap bmp = Bitmap.FromStream(stream)
as Bitmap;
meleeImageList.Images.Add(resource,
bmp);
}
}
}
}
return meleeImageList;
}
}

public static ImageList GetImageList()
{
return MeleeImageList;
}

public static string GetImageKey(string itemName)
{
return
string.Format("Deerchao.War3Share.Client.Icons.Melee.{0}.jpg",
itemName);
}

As for design time support, sorry, there isn't any. To asign an icon
to a control, I have to use code, so I can see these icons only at run
time. This is what I do:

protected override OnLoad(...)
{
listView1.SmallImageList=IconsManager.GetImageList();
}

ListViewItem item=...;
item.ImageKey=IconsManager.GetImageKey("xxxx");

Hope this helps.
 

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

Back
Top