Miner.Windows Assembly > Miner.Windows Namespace : ResourceData Class |
'Declaration Public Class ResourceData
'Usage Dim instance As ResourceData
public class ResourceData
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.
System.Object
Miner.Windows.ResourceData
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.