Adding Resources to a .NET Micro Framework Project


You will want to add resources to your .NET Micro Framework applications. These can be images, fonts, or data that you want to load into the target device along with your program. For our next examples, we will use the .NET Micro Framework snowflake image to show how bitmaps can be rendered on the display.

In the full .NET Framework, such resources can be embedded in an application assembly and then extracted when the program runs. In the .NET Micro Framework, embedding resources is not done this way; instead, you can use the resource manager to incorporate items. This can be managed from within Visual Studio 2005; you use the Resources tab to manage the different types of data that you want to include in your project when it is deployed to the target device.

Figure 7-7 shows the resource manager in use. The pull-down menu shows the different file types that you can select. The Resources directory in the project, shown in Figure 7-7, contains two font files and a bitmap image. You can add these to the resources for the application by dragging them from the directory in the project into the appropriate resources area, and then you can load the resources as follows:

 Bitmap snowflake = Resources.GetBitmap(Resources.BitmapResources.MFsnowflake); 

image from book
Figure 7-7: The Visual Studio 2005 Resource Manager.

The Name property of a resource is set when you add it (by default, it is taken from the name of the file). When the preceding code runs, a Bitmap instance is created containing the image.

Note 

Although the resource types displayed by Visual Studio include audio files and icons, such resources may not be used in a .NET Micro Framework application because the underlying system does not have a mechanism for dealing with those.




Embedded Programming with the Microsoft .Net Micro Framework
Embedded Programming with the Microsoft .NET Micro Framework
ISBN: 0735623651
EAN: 2147483647
Year: 2007
Pages: 118

Similar book on Amazon
Getting Started with the Internet of Things: Connecting Sensors and Microcontrollers to the Cloud (Make: Projects)
Getting Started with the Internet of Things: Connecting Sensors and Microcontrollers to the Cloud (Make: Projects)
Expert .NET Micro Framework (Expert's Voice in .NET)
Expert .NET Micro Framework (Expert's Voice in .NET)
Netduino Plus
Netduino Plus
Getting Started with Netduino
Getting Started with Netduino

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net