On Oct 13, 3:55 am, "Jeff Jarrell" <jjarrel_NOS...@yahoo.comwrote:
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
"deerchao" <deerc...@gmail.comwrote in message
news:11**********************@v23g2000prn.googlegr oups.com...
On Oct 12, 10:47 pm, "Jeff Jarrell" <jjarrel_NOS...@yahoo.comwrote:
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.
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.Ic ons.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.Mel ee.{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.