ArcFM Desktop Developer Guide
ResourceData Class
Members 


Version: 10.2.1b and 10.2.1b SP1

Resource Center Home

Product Availability
ArcFM Desktop and ArcFM Engine
Required Licenses
ArcFM, Designer, ArcFM Viewer, ArcFM Engine, ArcFM Engine Editor, or ArcFM Viewer for ArcGIS Engine
.NET Assembly
Miner.Windows.dll
Provides access to assembly resources (text, bitmaps, icons, cursors) and manages localization of application text.
Object Model
ResourceData Class
Syntax
'Declaration
 
Public Class ResourceData 
'Usage
 
Dim instance As ResourceData
public class ResourceData 
Remarks
This class provides a standard mechanism for supplying text and image resources for an application. Typically the project for an application will be organized such that it has a 'Resources' folder that contains all of the bitmaps, etc. that will be embedded into the application. Also, the 'Resources' folder contains an resx file that defines a set of name-value pairs that is used to provide the default internationalized text for the application. The name of this file is typically 'Text.resx' and is also located in the 'Resources' folder with the other application resources. Thus, when the project is compiled, the images and text resources will be accessible via the default namespace name for the project plus the name of the resource folder, for example 'FrameworkProgram.Resourses' where 'FrameworkProgram' is the default namespace of the main application holding the resources and 'Resources' is the folder where the resources are located. This location is known as the resourceBaseName and is the first parameter to the constructor for this class.

The second parameter to the constructor for this class is the name of the resx file that contains the default internationalized text (typically the 'Text.resx' file but a different name can be used if desired). This same file name will be used in the other language versions of the text so the automatic localization by .NET can be used. (These are the language version DLLs which will be placed in the subfolders below the executable file where the subfolder name is the name of the language version. When the .NET current culture is set to one of these language names, then .NET will automatically use that language DLL rather than the default embedded resource providing the naming properly corresponds.)

Finally, the third parameter to the constructor for this class specifies the .NET assembly which contains the resources. If an application is composed of a number of DLLs, each DLL can have its own set of embedded resources and will create its own instance of this ResourceData class to access its resources. The framework provides the MainApp.Resources property to automatically provide access to the resources of the 'main assembly' of the application without that assembly having to provide any creation code. The assembly attribute 'AssemblyResourceInfo' tells the framework the necessary information to setup access to the main assembly's embedded resources, for example, in the AssemblyInfo.cs file might look like:

[assembly: AssemblyResourceInfo("FrameworkProgram.Resources", "Text")]

The program code to utilize this class to access internationalized text is very simple. As an example, assume that the main assembly contains a form that has a label which needs to be internationalized text. The following code would provide the text: label1.Caption = MainApp.Resources[name1]; where 'name1' is a string that specifies the name of the name-value pair located in the 'Text.resx' file which provides the text. Sometimes it is desirable to pass additional information to this class that is to be part of the displayed text. For example, suppose that the text to be displayed is Processing item xx of yy items. name-value: name2-value2 = "Processing item {0} of {1} items." label1.caption = MainApp.Resources[name2, count, total]; where count = current item number and total = number of items. Remember that the order of the parameters will always be the same regardless of which language is being used. But, thankfully, the data references ({n}) in the format string do not have to be in parameter order so that the data can appear in a different order for a different language.

In addition to text, this class also provides access to bitmaps, bitmap strips, icons, and cursors stored as embedded resources in the assembly. (It is assumed that these items are language independent.) Simply call the appropriate method and pass the name of the resource to be returned; for example, suppose the bitmap for a toolbar button is desired. The following would obtain the Bitmap object for an embedded bitmap with the name "bitmapName": Bitmap buttonBitmap = MainApp.Resources.GetBitmap("bitmapName"); Notice that the method supplies the extension for the resource name and it is not necessary to pass it as part of the parameter.

Inheritance Hierarchy

System.Object
   Miner.Windows.ResourceData

Requirements

Target Platforms: Windows XP SP3 (32-bit and 64-bit), Windows 7 (32-bit and 64-bit)

Not all Operating Systems are supported on all products. Visit the ArcFM Solution Supported Versions page for full details.

See Also

Reference

ResourceData Members
Miner.Windows Namespace

 

 


Send Comment