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 />

Me.TextBox1.Text = "My String"<br />

[C#]<br />

this.textBox1.Text = "My String";<br />

Image files (BMPs, JPEGs, PNGs, and so forth) can be embedded in your assembly<br />

as follows:<br />

1. Right-click the project in the Solution Explorer, click Add, then click Add<br />

Existing Item.<br />

2. In the Add Existing Item dialog box, browse to your image file and click<br />

Open.<br />

3. In the Solution Explorer, select the image file you just added, then press F4 to<br />

display its properties.<br />

4. Set the Build Action property to Embedded Resource.<br />

Now you can reference the image in your code. For example, the following<br />

code creates a bitmap object from the first embedded resource in the assembly:<br />

[VB.NET]<br />

Dim res() As String = GetType(Form1).Assembly.GetManifestResourceNames()<br />

If (res.GetLength(0) > 0)<br />

Dim bmp As System.Drawing.Bitmap = New System.Drawing.Bitmap( _<br />

GetType(Form1).Assembly.GetManifestResourceStream(res(0)))<br />

...<br />

[C#]<br />

string[] res = GetType().Assembly.GetManifestResourceNames();<br />

if (res.GetLength(0) > 0)<br />

{<br />

System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(<br />

GetType().Assembly.GetManifestResourceStream(res[0]));<br />

...<br />

Creating resource files<br />

Before attempting to provide localized resources, you should ensure you are<br />

familiar with the process of creating resource files for your .NET projects. Even<br />

if you do not intend to localize your resources, you can still use resource files<br />

instead of using images and strings directly as described above.<br />

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

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

Saved successfully!

Ooh no, something went wrong!