Based on an ID I would like to automatically load an Image into my GUI. To do this I would like to be able to get all images out of the Resources.resx file in Visual Studio 2008 (using C#). I know I'm able to get one at a time if I know what they are:
Image myPicture = Properties.Resources.[name of file];
However what I'm looking for is along these lines...
foreach(Bitmap myPicture in Properties.Resources) {Do something...}
Just use Linq (tm)
ResourceManager rm = Properties.Resources.ResourceManager;
ResourceSet rs = rm.GetResourceSet(new CultureInfo("en-US"), true, true);
if (rs != null)
{
var images =
from entry in rs.Cast<DictionaryEntry>()
where entry.Value is Image
select entry.Value;
foreach (Image img in images)
{
// do your stuff
}
}
Ok this seems to be working, however I would welcome other answers.
ResourceManager rm = Properties.Resources.ResourceManager;
ResourceSet rs = rm.GetResourceSet(new CultureInfo("en-US"), true, true);
if (rs != null)
{
IDictionaryEnumerator de = rs.GetEnumerator();
while (de.MoveNext() == true)
{
if (de.Entry.Value is Image)
{
Bitmap bitMap = de.Entry.Value as Bitmap;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With