Images in RESX file

So now I am going through some of the sample applications. The one that is the closest to what we want is probably the ProtoApp sample. But I have a question concerning how this sample works.
I notice that there is an Images.resx file that holds a complete list of all the images used in the Treeview and the Palette. I want to be able to add my own images in this resx file but how do I determine the type and mimetype for my own pictures? It generates an error if these are not specified correctly. And how does the resx file know which directory the images are located under?
Joy

If all of your images are bitmaps/icons of the same size, and you are using Windows Forms, you could just use an ImageList, which you can define and edit in Visual Studio .NET.
If you have JPEGs or PNGs or whatever, or if you are using ASP.NET Web Forms, you’ll need to put them into resource files. Alas, Visual Studio .NET doesn’t help you there. I don’t know why they don’t support it. You’ll need to use other tools or write your own tool to do this (it’s just a few lines of code). Read about using the ResXResourceWriter class.

Ok, but clearly GoDiagram already has ways to handle at least the reading of an resx file. The ProtoApp sample application calls the GoImage.DefaultResourceManager and passes the resx file as a parameter. I don’t see any code using the ResXResourceReader to read the images in the *.resx file. Therefore it appears to me that the “DefaultResourceManager” handles the reading of the resx file. So I guess my question is, what functionality does GoDiagram come with concerning resx files. Does it only have the ability to read resx files or is there also code in there somewhere to write the resx files as well??
Joy

The resource files are self-contained; they contain (copies of) the data that each image holds. The compiled resource files are linked into your assembly, so the “file” being read is actually the assembly itself. That’s why neither GoDiagram nor .NET Windows Forms nor you need to use ResXResourceReader–no XML files are involved at run-time.
GoImage.LoadImage is the method that is responsible for getting an Image for GoImage.Paint to display. If there is a GoImage.Name string, it looks for an Image by that name.
First it checks the value of the GoImage.ResourceManager property. If that’s non-null, it calls ResourceManager.GetObject(name, CultureInfo.CurrentCulture).
Second, if GoImage.ResourceManager is null, it checks the value of the static/shared property GoImage.DefaultResourceManager. If it’s non-null, it also calls GetObject.
Third, if the static DefaultResourceManager is null, it calls Image.FromFile(name), assuming the name is a file pathname.

What is the main difference between using resx files with GoDiagram and using Image Lists?
Joy

If all of your images are bitmaps/icons of the same size, and you are using Windows Forms, you could just use an ImageList, which you can define and edit in Visual Studio .NET.
If you have JPEGs or PNGs or whatever, or if you are using ASP.NET Web Forms, you’ll need to put them into resource files.

ok - maybe this is a silly question but - is it possible to remove the code used to create an resx file when it has been run once? And does the code used to create the resx file have to be run inside the .net project it needs to be associated with - so that it gets linked to the right assembly?
Joy

Oh, no, it would be a separate tool–nothing to do with your application or with GoDiagram. Look in the .NET Framework Developer’s Guide: Resources in .Resx File Format.
Actually, you might just want to use the ResEditor sample that comes with the SDK. Search for “ResEditor”. You need to build it yourself. I haven’t used it, so I can’t vouch for it’s usefulness, but it appears to have the functionality you need.

Well the reason I asked is because I found this code at http://msdn.microsoft.com/library/default.asp?url=/library/e n-us/cpguide/html/cpconResourcesInResxFileFormat.asp which allows you to create an resx file programmatically and add images to it. But I didn’t know if I should run this code in my project or in a separate one.
Imports System
Imports System.Drawing
Imports System.Resources

Public Class SampleClass

Public Sub Main()
Dim img As Image
Dim rsxw As ResXResourceWriter
img = Image.FromFile(“en-AU.jpg”)
rsxw = new ResXResourceWriter(“en-AU.resx”)
rsxw.AddResource(“en-AU.jpg”,img)
rsxw.Close()
End Sub
End Class

Ok - I figured it out - I was able to make an resx file with that code I just posted and it works.
Sorry I am so high maintenance :)
Joy

Hi,
I am still having problems with changing the images in the ProtoApp sample. I am wondering is this is because I am using the Go Express Kit. I get an error : IO.FileNotFound.
Perhaps I could try using the ImageList. Are there any samples on how to set the GoImage.ImageList Property?
Rainbirdit

[QUOTE=walter]
If all of your images are bitmaps/icons of the same size, and you are using Windows Forms, you could just use an ImageList, which you can define and edit in Visual Studio .NET.
If you have JPEGs or PNGs or whatever, or if you are using ASP.NET Web Forms, you’ll need to put them into resource files. Alas, Visual Studio .NET doesn’t help you there. I don’t know why they don’t support it. You’ll need to use other tools or write your own tool to do this (it’s just a few lines of code). Read about using the ResXResourceWriter class.[/quote]

The ResourceManager is a .NET feature, and thus has nothing to do with GoDiagram.
You can edit ImageLists in VS.NET. Just drop one on your Form, select it, bring up the Properties window, and click on the “…” button for specifying the contents of the Images collection.