RADactive I-Load 2009.R1
Getting started
See Also
Getting started > Getting started

Glossary Item Box

The best way to use I-Load is along with Microsoft Visual Studio.
The I-Load setup lets you install a series of examples under the form of Microsoft Visual Studio Solutions which allow you to better learn how to use I-Load.

See Examples

 

First time using I-Load: Upload an image of a fixed size and automatically create a thumbnail

This example shows how to use I-Load within a web application to allow a user to upload an image of a fixed size and then automatically generate a thumbnail
of that image.
All of that is in “Design” mode without writing a single line of code.

  1. Inserting the component into the web application
    It is sufficient to drag the I-Load icon from the Microsoft Visual Studio toolbox to the Aspx page.
    The I-Load DLL references will be automatically added to the project.
    See:  Adding RADactive I-Load to an Asp.net WebForm

    When the I-Load setup is executed, the installation program automatically attaches the component to the Microsoft Visual Studio Toolbox.
    If the icon is not present in the Toolbox, see: Adding RADactive I-Load to the Visual Studio toolbox


     
    (Figure 1 - How to insert a new I-Load instance into a project)
  2. Configuring the Web.Config file
    The first time I-Load is inserted into a web application, a dialog window appears to confirm the necessary modifications to the application’s Web.Config file.
    It is important to press the “Yes” button to allow I-Load to modify the Web.Config file
    (Note: A secure copy of the Web.Config file with the name “web.config.RAWC_backup” will be created within the application directory).
     
    (Figure 2 - Confirm dialog for automatic Web.Config changes)
  3. Configuring I-Load
    The easiest way to configure I-Load is through the appropriate configuration window available within Microsoft Visual Studio in “Design” mode.
    To open the configuration window, select I-Load, and in the “Properties” panel, click on the “…” button of the “Configuration” line

    (Figure 3 - How to open the I-Load configuration window)
  4. Setting the size constraints
    To configure I-Load so that it forces the user to upload an image of fixed size, select the “Fixed size” option to insert in the proper text fields the size in pixels (width and height) of the image to be uploaded

    (Figure 4 - How to setup a fixed size constraint)
  5. Creating a new Thumbnail
    To set the Thumbnail, select the “Automatic resizes” tab.
    I-Load can generate an unlimited number of Thumbnails for any images uploaded.
    To create a new Thumbnail, press the “New" button and, in the window that appears, insert “Title” and “InternalCode” for the resize.
    The InternalCode is very important because it allows the thumbnail to be identified at runtime, for example, to know the Path or the URL.
    The InternalCode must be composed only of alphanumeric characters since it is also used in the generation of names for files saved by I-Load (see  The I-Load file naming system)

    (Figure 5 - How to create a new thumbnail)
  6. Setting up a Thumbnail of fixed size with an image that fills it up
    Select the “Fixed resize” option and use the appropriate fields to set the size in pixels (width and height) of the thumbnail to be generated.
    Then select the “Fit to size” option to make the image completely fill the thumbnail.
    You are advised to see Automatic resizes - How to configure custom thumbnails for further information on thumbnails.

    (Figure 6 - How to setup the new thumbnail settings)
  7. Press the “Ok” button inside the I-Load configuration window to confirm and save the changes.

 

All I-Load properties can be configured both in Design-Time within Microsoft Visual Studio and in Run-Time by code.
Newly executed configuration in design time corresponds to this code:

I-Load Configuration / C# Copy Code
private void Page_Load(object sender, System.EventArgs e)
{
 
if (!this.IsPostBack)
 {
   
// Create a new image definition and add it to the I-Load configuration
   
Radactive.WebControls.ILoad.Configuration.WebImageDefinition definition1 = new Radactive.WebControls.ILoad.Configuration.WebImageDefinition("Default", "Default");
   
this.ILoad1.Configuration.WebImageDefinitions.Clear();
   
this.ILoad1.Configuration.WebImageDefinitions.Add(definition1);
   
// Setup the size constraints (Fixed: 350x200)
   
definition1.SizeConstraint.Mode = Radactive.WebControls.ILoad.Configuration.WebImageSizeConstraintMode.FixedSize;
   definition1.SizeConstraint.FixedSizeData.Size =
new System.Drawing.Size(250, 150);

   
// Setup the Thumbnail
   
Radactive.WebControls.ILoad.Configuration.WebImageResizeDefinition resize1 = new Radactive.WebControls.ILoad.Configuration.WebImageResizeDefinition("List Icon", "Thumb1");
   definition1.ResizeDefinitions.Add(resize1);
   resize1.Mode = Radactive.WebControls.ILoad.Core.Drawing.ImageResizeMode.Fixed;
   resize1.Fit = true;
   resize1.FixedSize =
new System.Drawing.Size(92, 92);
  }
}

I-Load Configuration / VB.NET Copy Code
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  If (Not Me.IsPostBack) Then
    ' Create a new image definition and add it to the I-Load configuration
    Dim definition1 As Radactive.WebControls.ILoad.Configuration.WebImageDefinition = New Radactive.WebControls.ILoad.Configuration.WebImageDefinition("Default", "Default")
    Me.ILoad1.Configuration.WebImageDefinitions.Clear()
    Me.ILoad1.Configuration.WebImageDefinitions.Add(definition1)
    ' Setup the size constraints (Fixed: 350x200)
    definition1.SizeConstraint.Mode = Radactive.WebControls.ILoad.Configuration.WebImageSizeConstraintMode.FixedSize
    definition1.SizeConstraint.FixedSizeData.Size = New System.Drawing.Size(250, 150)

    ' Setup the Thumbnail
    Dim resize1 As Radactive.WebControls.ILoad.Configuration.WebImageResizeDefinition = New Radactive.WebControls.ILoad.Configuration.WebImageResizeDefinition("List Icon", "Thumb1")
    definition1.ResizeDefinitions.Add(resize1)
    resize1.Mode = Radactive.WebControls.ILoad.Core.Drawing.ImageResizeMode.Fixed
    resize1.Fit = True
    resize1.FixedSize = New System.Drawing.Size(92, 92)
  End If
End Sub

 

Archiving uploaded images with I-Load

When an image is uploaded or edited with I-Load, the files generated by the component are saved in a temporary directory.
Further information on I-Load temporary files and on the read-write permissions necessary for I-Load is available on this page: I-Load temporary files.

It is the application’s job to permanently save the temporary files (in a directory or within a database).
If the temporary files are not saved, by default they are automatically deleted (normally at the end of the Asp.Net session).

The easiest way to store images uploaded with I-Load is within a directory in the file system.

To store files, you can use the MoveToFileSystemFolderAndChangeId method from the WebImage class.

For example:

Save images into file system / C# Copy Code
if (ILoad1.Value != null)
{
 
// An image has been selected...

 
// Setup the repository folder path
 
string myRepositoryFolderPath = Server.MapPath("~/Repository/MyFolder");
 
// Setup the image id
 
string myID = "123";
 
// Save the image into file system
 
ILoad1.Value.MoveToFileSystemFolderAndChangeId(true, myRepositoryFolderPath, myID);
}

Save images into file system / VB.NET Copy Code
if (Not (ILoad1.Value is Nothing)) Then
  ' An image has been selected...

  ' Setup the repository folder path
  Dim myRepositoryFolderPath As String = Server.MapPath("~/Repository/MyFolder")
  ' Setup the image id
  dim myID As string = "123"
  ' Save the image into file system
  ILoad1.Value.MoveToFileSystemFolderAndChangeId(True, myRepositoryFolderPath, myID)
End If

For further information on how to store images uploaded with I-Load, see Which method to choose ?

 

Loading and displaying a stored image

To load an I-Load image previously stored in the file system you can use the Load method from the class WebImage.
The Load method restores an object of the WebImage type.
The WebImage class is used by I-Load to store all information relative to an uploaded image.
The information contained in the WebImage class is stored by I-Load under the format of file XML (index).
The properties and methods of this class allow you to learn the FileUrl and the FilePath of any thumbnail, both of the image selected by the user (SelectedImage) and of the original image uploaded (SourceImage).

Other useful information includes the original name of the uploaded file (SourceImageClientFileName), the size in bytes of the file (FileSize), and the size in pixels of the image (ImageSize).

The following code shows how to load an image and find the path of the photo selected by the user and of the "Thumb1" thumbnail:

Load an archived image / C# Copy Code
// Setup the repository folder path
string myRepositoryFolderPath = Server.MapPath("~/Repository/MyFolder");
// Setup the image id
string myID = "123";

if (Radactive.WebControls.ILoad.WebImage.ExistsInFileSystem(myRepositoryFolderPath, myID))
{
 
// WebImage found...

 
// Load the WebImage
 
Radactive.WebControls.ILoad.WebImage image = Radactive.WebControls.ILoad.WebImage.LoadFromFileSystem(myRepositoryFolderPath, myID);

 
// Get the "Selected" image file path
 
string selectedImageFilePath = image.SelectedImage.FilePath;

 
// Get the "Thumb1" Thumbnail file path
 
string thumb1ImageFilePath = image.Resizes["Thumb1"].FilePath;
 
 
// Display the image inside the I-Load web control
 
ILoad1.Value = image;
}

Load an archived image / VB.NET Copy Code
' Setup the repository folder path
Dim myRepositoryFolderPath As string = Server.MapPath("~/Repository/MyFolder")
' Setup the image id
Dim myID as String = "123"

If (Radactive.WebControls.ILoad.WebImage.ExistsInFileSystem(myRepositoryFolderPath, myID)) Then
  ' WebImage found...

  ' Load the WebImage
  Dim image As Radactive.WebControls.ILoad.WebImage = Radactive.WebControls.ILoad.WebImage.LoadFromFileSystem(myRepositoryFolderPath, myID)

  ' Get the "Selected" image file path
  Dim selectedImageFilePath As String = image.SelectedImage.FilePath

  ' Get the "Thumb1" Thumbnail file path
  Dim thumb1ImageFilePath As String = image.Resizes("Thumb1").FilePath

  ' Display the image inside the I-Load web control
  ILoad1.Value = image
End If

 

See Also

Copyright © RADactive srl 2010 - All Rights Reserved.