18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

.NET APPLICATION PROGRAMMING INTERFACE<br />

4. When you compile your project, the .resx file will be compiled into a .resources<br />

module inside your main assembly.<br />

Creating resource files for image resources<br />

The process of adding images, icons, or cursors to a resources file in .NET is more<br />

complex than creating a file containing only string values, because the tools<br />

currently available in the Visual Studio .NET IDE can only be used to add string<br />

resources.<br />

However, a number of sample projects are available with the Visual Studio .NET<br />

Framework SDK that can help you work with resource files. One such sample is<br />

the Resource Editor (ResEditor).<br />

The ResEditor sample can be used to add images, icons, imagelists, and strings to<br />

a resource file. The tool cannot be used to add cursor resources. Files can be<br />

saved as either .resx or .resource files.<br />

Creating resource files programmatically<br />

You can create XML .resx files containing resources programmatically by using<br />

the ResXResourceWriter class (part of the .NET framework). You can create<br />

binary .resources files programmatically by using the ResourceWriter class (also part<br />

of the .NET framework). These classes will allow more flexibility to add the<br />

kind of resources you require.<br />

These classes may be particularly useful if you want to add resources that cannot<br />

be handled by the .NET Framework SDK samples and tools, for example, cursors.<br />

The basic usage of the two classes is similar: first, create a new resource<br />

writer class specifying the filename, then add resources individually by using the<br />

AddResource method.<br />

The code below demonstrates how you could create a new .resx file using the<br />

ResXResourceWriter class and add a bitmap and cursor to the file.<br />

[VB.NET]<br />

Chapter 4 • <strong>Developer</strong> environments • 163

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!