SaveToDoc(Value: String; BgColor: IGxColor): Boolean;
Value. Path to the file where the image is to be stored.
BgColor. Image background color. If Null is sent as background color, the color selection is random.
The SaveToDoc method saves all images from the collection to the file, which path is passed as the Value input parameter. All images are saved as horizontal series and the method returns the attribute that images are stored successfully.
Executing the example requires a form with the button named Button1, the ImageList component named ImageList1 and a set of images from the collection. For details about image loading to the component see the ImageList section. Add links to the Drawing, Forms, Io system assemblies.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
ImgList: IGxImageList;
Str: IIOStream;
Begin
ImgList := New GxImageList.Create;
Str := New MemoryStream.Create;
// Send icons to collection of images via the stream
ImageList1.SaveToStream(Str, GxColor.FromName("White"));
ImgList.LoadFromStream(Str);
// Remove one image from collection and save the rest to file
ImgList.Remove(1);
ImgList.SaveToDoc("C:\temp\1.bmp", GxColor.FromName("White"));
// Display the number of images in collection and sizes of the first image to the console
Debug.WriteLine("Number of images in collection: " + ImgList.Count.ToString);
Debug.WriteLine("Size:");
Debug.WriteLine("Width: " + ImgList.Item(0).Size.Width.ToString);
Debug.WriteLine("Height: " + ImgList.Item(0).Size.Height.ToString);
End Sub Button1OnClick;
Clicking the button removes an image from the collection and all of the rest images are saved as horizontal series to the selected file:
The console window displays the number of images in the file and sizes of the first image.
Executing the example requires a form with the button named Button1 and the ImageListNet component named imageListNet1. The file system should contain the image with the C:\1.bmp icons. Add links to the System.IO .NET assembly and to the Drawing, Forms, Forms.NET system assemblies.
Imports Prognoz.Platform.Forms.Net;
Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Forms;
Imports System.IO;
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
ImgList: IGxImageList;
Str: Stream;
Color: GxColorClassClass = New GxColorClassClass();
il: IImageList;
Begin
ImgList := New GxImageList.Create();
Str := New MemoryStream.Create();
// Add an image with icons from file to the ImageListNet component
il := (imageListNet1.Component As IImageList);
il.LoadFromFile("C:\1.bmp", Color.FromName("White"));
// Send icons to collection of images via the stream
il.SaveToStream(Str, Color.FromName("White"));
ImgList.LoadFromStream(Str, Color.FromName("White"));
// Remove one image from collection and save the rest to file
ImgList.Delete(1);
ImgList.SaveToDoc("C:\temp\1.bmp", Color.FromName("White"));
// Display the number of images in collection and sizes of the first image to the console
System.Diagnostics.Debug.WriteLine("Number of images in collection: " + ImgList.Count.ToString());
System.Diagnostics.Debug.WriteLine("Size:");
System.Diagnostics.Debug.WriteLine("Width: " + ImgList.Item[0].Size.Width.ToString());
System.Diagnostics.Debug.WriteLine("Height: " + ImgList.Item[0].Size.Height.ToString());
End Sub;
The example of Fore.NET example execution matches with that in the Fore example.
See also: