IResourceBinaries.Value

Syntax

Value(Id: String): IIOStream;

Parameters

Id. Image identifier.

Description

The Value property determines a resource editor image, which identifier is passed by the Id parameter.

Comments

Image identifier is case-sensitive.

Example

Executing the example requires that the repository contains resources with the APP_RESOURCE identifier containing an image with the main_img identifier. These resources contain default language as Russian and translation language as English.

The file system must contain the following files: c:\ru.png and c:\en.png.

Add links to the IO, Metabase system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    Resource: IResourceObject;
    Binares: IResourceBinaries;
    Locales: IResourceLocales;
    Locale: IResourceLocale;
    FileImg: IFileInfo;
    BinR: IBinaryReader;
    Stream: IIOStream;
Begin
    
// Get current repository
    mb := MetabaseClass.Active;
    
// Get resources
    Resource := mb.ItemById("APP_RESOURCE").Edit As IResourceObject;
    
// Get resource languages collection
    Locales := Resource.Locales;
    
// Get default language
    Locale := Locales.DefaultLocale;
    
// Get images for default language
    Binares := Locale.Binaries;
    
// Get file with new image for default language
    FileImg := New FileInfo.Attach("c:\ru.png");
    
If FileImg.Exists Then
        BinR := FileImg.OpenBinaryReader;
        Stream := BinR.Stream;
        
// Replace image for default language
        Binares.Value("main_img") := Stream;
    
End If;
    
// Get the current translation language
    Locale := Locales.CurrentLocale;
    
// Get images for translation language
    Binares := Locale.Binaries;
    
// Get file with new image for translation language
    FileImg := New FileInfo.Attach("c:\en.png");
    
If FileImg.Exists Then
        BinR := FileImg.OpenBinaryReader;
        Stream := BinR.Stream;
        
// Replace image for translation language
        Binares.Value("main_img") := Stream;
    
End If;
    
Dispose FileImg;
    
// Save changes
    (Resource As IMetabaseObject).Save;
End Sub UserProc;

After executing the example default language value and translation language value are set for the main_img image.

See also:

IResourceBinaries