IGxImageList.LoadFromFile

Syntax

LoadFromFile(Value: String; [Transparent: IGxColor = Null]);

Parameters

Value. Parameter that determines the line specifying the path to the file, which will be loaded to the collection.

Transparent. Parameter that determines the color that is used as a transparent one.

Description

The LoadFromFile method loads images to the collection from the file, which path and name are passed by the Value parameter.

Fore Example

Executing the example requires that the file system contains two icons: C:\Icon_small.bmp and C:\Icon_large.bmp. Add links to the Metabase, Drawing, Fore, Io (Fore.IO for the Fore.NET example) system assemblies in the unit.

Sub UserProc;
Var
    Mb: IMetabase;
    Object: IMetabaseObject;
    CustomClassExtender: IMetabaseCustomExtender;
    CustClasses: IMetabaseCustomClasses;
    CustomClass: IMetabaseCustomClass;
    Description: IMetabaseObjectDescriptor;
    ImgList: IGxImageList;
    ImgList32: IGxImageList;
Begin
    Mb := MetabaseClass.Active;
    // Determine container of custom classes
    Description := Mb.SpecialObject(MetabaseSpecialObject.CustomExtender);
    Object := Description.Edit;
    CustomClassExtender := Object As IMetabaseCustomExtender;
    // Create a collection of images
    ImgList := New GxImageList.Create;
    ImgList.Height := 16;
    ImgList.LoadFromFile("C:\Icon_small.bmp", GxColor.FromKnownColor(GxKnownColor.White));
    CustomClassExtender.SmallImages := ImgList;
    ImgList32 := New GxImageList.Create;
    ImgList32.Height := 32;
    ImgList32.LoadFromFile("C:\Icon_large.bmp", GxColor.FromKnownColor(GxKnownColor.White));
    CustomClassExtender.LargeImages := ImgList32;
    CustomClassExtender.IsShared := True;
    // Add a custom class to the container
    CustClasses := CustomClassExtender.Classes;
    CustomClass := CustClasses.Add;
    CustomClass.Name := "My class";
    CustomClass.Description := "Custom class";
    CustomClass.ImageIndex := 0;
    Object.Save;
End Sub UserProc;

After executing the example the custom classes container including a class named My Class will be created. The source for a big icon will be the file C:\Icon_large.bmp, for a little icon - C:\Icon_small.bmp.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Fore;
Imports Prognoz.Platform.Interop.ForeIO;

Public Shared Sub Main(Params: StartParams);
Var
    Mb: IMetabase;
    Object: IMetabaseObject;
    CustomClassExtender: IMetabaseCustomExtender;
    CustClasses: IMetabaseCustomClasses;
    CustomClass: IMetabaseCustomClass;
    Description: IMetabaseObjectDescriptor;
    ImgList: GxImageList;
    ImgList32: GxImageList;
    Color: GxColorClass = New GxColorClassClass();
Begin
    Mb := Params.Metabase;
    // Determine container of custom classes
    Description := Mb.SpecialObject[MetabaseSpecialObject.msoCustomExtender];
    Object := Description.Edit();
    CustomClassExtender := Object As IMetabaseCustomExtender;
    // Create a collection of images
    ImgList := New GxImageList.Create();
    ImgList.Height := 16;
    ImgList.LoadFromFile("C:\Icon_small.bmp", Color.FromKnownColor(GxKnownColor.clWhite));
    CustomClassExtender.SmallImages := ImgList;
    ImgList32 := New GxImageList.Create();
    ImgList32.Height := 32;
    ImgList32.LoadFromFile("C:\Icon_large.bmp", Color.FromKnownColor(GxKnownColor.clWhite));
    CustomClassExtender.LargeImages := ImgList32;
    CustomClassExtender.IsShared := True;
    // Add a custom class to the container
    CustClasses := CustomClassExtender.Classes;
    CustomClass := CustClasses.Add();
    CustomClass.Name := "My class";
    CustomClass.Description := "Custom class";
    CustomClass.ImageIndex := 0;
    Object.Save();
End Sub;

See also:

IGxImageList