I have an assignment program that uses an array of images that are created from a supporting resource folder but I wish to incorporate them into the final exe file so how do I make an array from the Resources.resx file please?
Also, one of the images in the resx file is incorrect and should be removed. How can I remove that please? Every time I try anything with the Resources.resx file the Visual Studio 2008 IDE hates me!
Any knowledgeable advice would be greatly appreciated, thanks.
Thanks & Best Regards
[DOSrelic]
¨`•._.®._.•´¨
That is just way messy and old-school.
The ResourceManager already knows all the resources let's just ask it.
Resources are kept on a per-culture basis. This is so you can make your program culture-specific. You can have resources if you deploy in English, a different set for Spanish and so on. We are simply going to get all the resources for English in this case. - System.Resources.ResourceSet temp = Properties.Resources.ResourceManager.GetResourceSet(new CultureInfo("en-US"), false,false);
-
if (temp == null)
-
{
-
// No resources specific to English
-
// Look for other resourses in the language of your application
-
}
-
foreach (System.Collections.DictionaryEntry set in temp)
-
{
-
Console.WriteLine(string.Format("{0}: {1}", set.Key, set.Value));
-
}
Try running this. It will show you the full list of resources and their types. From there you can sort a list, throw out ones that don't start with the word "card" for example etc.
13 4525
Are you using the resource management stuff that VS does or are you trying to directly edit the file?
Hi Plater, The resource management stuff that VS does but there does not seem to be the ability to remove an image. I currently load them from files into an array as I don't know how to use the VS way so the program requires it's own resource sub-folder, thanks.
Hi there I have just started with Csharp and wrote a messy but usable memory card game using a folder with all the images of the cards but I really want to be able to store them in the executable via the project resource file. I can load the resource file but do not know how to retrieve them to assign them to the newly created card class objects.
Instead of the line:
static Bitmap _back = new Bitmap(AmemoryGame .cardBackFileNames[0]);
what should I use please? I sort of figured that I would use ResXResourceReader resxReader = new ResXResourceReader(...)but then realised I didn't even know the name of the file!
Can anyone give me some guidance on how to access my resx resource file images please? Any knowledgeable help would be greatly cheers.
You can reach your resource images by reference. - MyImage = MyProgramNamespace.Properties.Resources.G5_iMac;
@tlhintoq
Thank you tlhintoq, I can now access the resource images individually but is there a way to sort them and put them into an array? I currently have an array of file names so I can assign a unique image to every new card object in a loop: - _cards[index].FrontBm = new Bitmap(AmemoryGameGlobals.cardFrontFileNames[index++]);
I see no reason why you couldn't get a list of the resources, sort it, then assign within a loop.
Neither do I tlhintoq but I'm afraid I wouldn't know how to go about doing that! Can you offer any sage advice on that score please? I mean I have a list of resource names but how do I transfer them to an array automatically? Properties.Resources.ResourceManager.....? Are they not already held in an array of some type and if so can I not set an array to that?
I could think that as a "stack pointer" type of solution. Have a counter variable starting from 0, increasing every time a picture gets in resource file and decreasing every time a picture gets out. In this way you can retrieve any element of the array at any time. Build that in an array structure or class and have all the information about your image inside this class at the specific counter's position (name, user properties...).
If this is not enough (it depends on the application) you can "stick" this counter value at the end of your picture names (kept inside the class): MyPicture00, ThisPicture07, AnyPicture38. So when i.e. an event comes, convert sender's name to char array and keep the last 2 characters (0<=picture_number<100 case). Convert it to int and you will have the counter's value. With this value you know the exact element of the array that triggered the event or you can use this value in a switch-case or do with it whatever you need.
It's a bit low level, but it works.
Hi alexis4, interesting proposal but the resource images arealready preloaded and I just need to sequentially assign them. Does anyone know how to do that please?
That is just way messy and old-school.
The ResourceManager already knows all the resources let's just ask it.
Resources are kept on a per-culture basis. This is so you can make your program culture-specific. You can have resources if you deploy in English, a different set for Spanish and so on. We are simply going to get all the resources for English in this case. - System.Resources.ResourceSet temp = Properties.Resources.ResourceManager.GetResourceSet(new CultureInfo("en-US"), false,false);
-
if (temp == null)
-
{
-
// No resources specific to English
-
// Look for other resourses in the language of your application
-
}
-
foreach (System.Collections.DictionaryEntry set in temp)
-
{
-
Console.WriteLine(string.Format("{0}: {1}", set.Key, set.Value));
-
}
Try running this. It will show you the full list of resources and their types. From there you can sort a list, throw out ones that don't start with the word "card" for example etc.
Thanks again tlhintoq, another great step towards my desired goal but I was wondering if the GetEnumerator property could be used in my loop and if so how would I do that please? Unfortunately I am unaware of how to use it although the IDE advises me that is can iterate through the resource set?
At this point I'm going to recommend experimentation and the MSDN.
Okay tlhintoq, thanks for your help. :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Chris |
last post by:
Visual Studio 2003
Windows XP SP2
Problem: I have lost my original xyz.bmp file.
However it is still available in my app because they get copied into the
..resx file and stores as a base64...
|
by: Jin P via .NET 247 |
last post by:
how you guys embed an audio file (let say wav format) in a resx file? I can embed images but somehow
when I try to embed audios, it said out of memory.
--------------------------------
From: Jin...
|
by: Hiten |
last post by:
Hi
i have created one .resx file for adding 38 Images...............
after creating it when i open it and reads it through
IDictionaryEnumerator or by using DictionaryEntry structure i am not...
|
by: David Krussow |
last post by:
I had an aspx page (mypage.aspx) with a code behind file (mypage.aspx.cs)
that in turn had a resx file (mypage.aspx.resx). I decided to create another
aspx page (myotherpage.aspx) that would reuse...
|
by: Crirus |
last post by:
Hi there
I have an application that I use to add images toa resx file
The strange thing is that when I retrive the image and use in my
application, all pics a re zoomed in and then cropped, so...
|
by: prabhupr |
last post by:
Hi Folks
I'm currently working on a Localization+Globalization project; for this
project, we need to generate ".Resx" files and we use "US English" Resx
file as the base version, to compare the...
|
by: Steave |
last post by:
Hi, using Managed C++ (.Net 2.0), I want to embed some images within an
executable using a .resX file, and upon an event (in this case a combo
box changing), I want the picture box to update with a...
|
by: CKKwan |
last post by:
Dear All,
When creating a new ASPNET project in VS2008, everything looks good.
But when migrating from VS2003 to 2008 (or even VS2005) VS will
create a *.resx file along with each and every...
|
by: raylopez99 |
last post by:
I have the latest version of Visual Studio 2008 Professional, which
allows you to create resource files (this is the .resx file, no?),
unlike the Express version, which does not.
I am trying to...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
| |