←Select platform

Url Property

Summary

URL of image data associated with this item.

Syntax

C#
VB
C++
public Uri Url { get; set; } 
Public Property Url() As System.Uri 
   Get 
   Set 
public:  
   property System::Uri^ Url 
   { 
      System::Uri^ get() 
      void set(System::Uri^ value) 
   } 

Property Value

The URL of the image associated with this item. Default value is null.

Remarks

The action taken when setting this value depends on whether the item is already a member of a viewer (it has been added to Items). If the item is not part of a viewer, then the value of Url will be set with the new value and the actions described below will not occur till the item is added to a viewer.

When setting the value of this property (or adding an item to the viewer's Items), the viewer will do the following:

If the new value is null, then any previous image data is deleted. This done by setting the value of Image and SvgDocument to null. The value of Resolution is not changed. This will create an empty item.

If the new value is not null, then the following happens:

  1. The RasterCodecs object stored in RasterCodecsInstance is used to load the URL as follows:

  2. If the value of LoadUrlAsSvg is false (the default), then RasterCodecs.LoadAsync is used.

  3. If the value of LoadUrlAsSvg is true then RasterCodecs.LoadSvgAsync is used.

In either case, the load is performed asynchronously and control is returned back to the user right away. The value of Url is not changed and will still hold the old value.

  1. When the loading finishes (LoadAsyncCompleted or LoadSvgAsyncCompleted occur), The Url property will be updated with the original value passed. Previous data in Image or SvgDocument will be deleted and replaced with the image object (either a RasterImage or SvgDocument depending on LoadUrlAsSvg). The value of Resolution will also be updated with the DPI of the image. When this is done, ItemChanged will occur with information on the item and Reason set to ImageViewerItemChangedReason.Url. If an error occurs during load, ItemError will fire with information about the error. Url, Image, SvgDocument and Resolution will not be updated and will still hold the original data.

in essence, setting the value of Url to null will clear the image data right away.

Setting the value of Url to another value will return control immediately without changing the item, when loading is finished, the values are updated (including Url itself) and ItemChanged will occur.

If an error occur, the item is not changed and ItemError will occur.

ImageUrl property of ImageViewer will update this member if this is the active item when the viewer is used in single item mode.

For more information, refer to Image Viewer Items.

Example

C#
VB
using Leadtools; 
using Leadtools.Controls; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
using LeadtoolsExamples.Common; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
 
string[] urls = 
{ 
   @"http://localhost/myimages/layouttest/200by100_1.png", 
   @"http://localhost/myimages/layouttest/200by100_2.png", 
   @"http://localhost/myimages/layouttest/200by100_3.png", 
   @"http://localhost/myimages/layouttest/100by200_1.png", 
   @"http://localhost/myimages/layouttest/100by200_2.png", 
   @"http://localhost/myimages/layouttest/100by200_3.png" 
}; 
 
int itemIndex = 0; 
_imageViewer.BeginTransform(); 
for (int urlIndex = 0; urlIndex < urls.Length; urlIndex++) 
{ 
   ImageViewerItem item = new ImageViewerItem(); 
   item.Url = new Uri(urls[urlIndex]); 
   item.Text = "Item" + itemIndex; 
   this._imageViewer.Items.Add(item); 
   itemIndex++; 
} 
_imageViewer.EndTransform(); 
Imports Leadtools 
Imports Leadtools.Controls 
Imports Leadtools.Codecs 
Imports Leadtools.Drawing 
Imports Leadtools.ImageProcessing 
Imports Leadtools.ImageProcessing.Color 
Imports LeadtoolsControlsExamples.LeadtoolsExamples.Common 
 
Dim urls As String() = {"http://localhost/myimages/layouttest/200by100_1.png", 
                        "http://localhost/myimages/layouttest/200by100_2.png", 
                        "http://localhost/myimages/layouttest/200by100_3.png", 
                        "http://localhost/myimages/layouttest/100by200_1.png", 
                        "http://localhost/myimages/layouttest/100by200_2.png", 
                        "http://localhost/myimages/layouttest/100by200_3.png"} 
 
Dim itemIndex As Integer = 0 
_imageViewer.BeginTransform() 
Dim urlIndex As Integer = 0 
Do While urlIndex < urls.Length 
   Dim item As ImageViewerItem = New ImageViewerItem() 
   item.Url = New Uri(urls(urlIndex)) 
   item.Text = "Item" & itemIndex 
   Me._imageViewer.Items.Add(item) 
   itemIndex += 1 
   urlIndex += 1 
Loop 
_imageViewer.EndTransform() 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Controls.WinForms Assembly