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.