473,662 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I access images in the resx file as if they are in an array?

DOSrelic
13 New Member
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]
¨`•._.®._.•´¨
Nov 2 '09 #1
13 4557
Plater
7,872 Recognized Expert Expert
Are you using the resource management stuff that VS does or are you trying to directly edit the file?
Nov 2 '09 #2
DOSrelic
13 New Member
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.
Nov 2 '09 #3
DOSrelic
13 New Member
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(AmemoryG ame .cardBackFileNa mes[0]);
what should I use please? I sort of figured that I would use ResXResourceRea der resxReader = new ResXResourceRea der(...)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.
Dec 27 '09 #4
tlhintoq
3,525 Recognized Expert Specialist
You can reach your resource images by reference.

Expand|Select|Wrap|Line Numbers
  1. MyImage = MyProgramNamespace.Properties.Resources.G5_iMac;
Dec 27 '09 #5
DOSrelic
13 New Member
@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:
Expand|Select|Wrap|Line Numbers
  1. _cards[index].FrontBm = new Bitmap(AmemoryGameGlobals.cardFrontFileNames[index++]);
Dec 27 '09 #6
tlhintoq
3,525 Recognized Expert Specialist
I see no reason why you couldn't get a list of the resources, sort it, then assign within a loop.
Dec 27 '09 #7
DOSrelic
13 New Member
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.Reso urces.ResourceM anager.....? Are they not already held in an array of some type and if so can I not set an array to that?
Dec 28 '09 #8
alexis4
113 New Member
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_num ber<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.
Dec 28 '09 #9
DOSrelic
13 New Member
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?
Dec 28 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2143
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 encoded string, probably encrypted as well as there is a publickeytoken stored in the xml record. My question is has anybody got a bit of code that will take that string or
0
1394
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 P ----------------------- Posted by a user from .NET 247 (http://www.dotnet247.com/) <Id>wH7cq4Ky8EGU49PmVxwSaA==</Id>
1
3272
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 getting images in order i have added in resource it means following resx file is created with A B C D.... images when i read resx file i am not getting in A B C D .... order it is in any order but it has all images
0
499
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 the code-behind from the first page (mypage.aspx.cs). I hooked everything together and both aspx pages work great. In the process I renamed the code-behind file (mypage.aspx.cs). This caused a disconnect in the VS.NET IDE with the resx file. I...
6
1359
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 I have a picture of the same size as the one I inserted, but with right and bottom edges cropped down and zoomed to fit the same rectangle. The image is 80x80 and the cropped area seems to be about 5-10 pixels.. there is any other way to add...
0
1681
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 content with other languages. We have quite a number of Resx file and each Resx file has enough items so there is a high probability that we might miss few nodes/items in RESx files of other language.
0
1642
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 different one. I tried the following code: System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(formDebayer::typeid));
1
1118
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 of your *.aspx page. Can I remove those *.resx file? I have tried to remove a few and don't see any special effect.
8
14935
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 cut and paste code that MSDN recommends for playing a simple wav file from inside an embedded file, like presumeably the 'resources' file .resx is. I want to embed the .wav file in a 'resource file' since I don't want the user storing the file on...
0
8432
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8344
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8857
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8764
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.