(Leadtools.Annotations.Core)

LoadPicture Event

Show in webframe
Example 





Occurs when a picture object has been finished loading its source image.
Syntax
public event EventHandler<AnnLoadPictureEventArgs> LoadPicture
Public Event LoadPicture As EventHandler(Of AnnLoadPictureEventArgs)
public event EventHandler<AnnLoadPictureEventArgs> LoadPicture
@property (nonatomic,assign) id<LTAnnRenderingEngineDelegate> delegate;
public void addLoadPictureEventListener(AnnLoadPictureEventListener listener)
public void removeLoadPictureEventListener(AnnLoadPictureEventListener listener)
            
add_LoadPicture(function(sender, e))
remove_LoadPicture(function(sender, e))

Event Data

The event handler receives an argument of type AnnLoadPictureEventArgs containing data related to this event. The following AnnLoadPictureEventArgs properties provide information specific to this event.

PropertyDescription
AnnObject Gets the owner annotation object.
Container Gets the owner annotation container.
Error Gets any error information should the picture not load successfully.
Picture Gets the loaded picture object.
Remarks
AnnLoadPictureEventArgs

In the LEADTOOLS Annotation framework, the source image in picture objects is not loaded till render time. For example, when you first render an annotation object that contains a picture, such as the AnnHotspotObject or AnnPointObject, the framework will load the image in AnnPicture.Source in the background. While the image is loading, the framework will use a placeholder rectangle to render the object position and size. When the image is fully loaded, the framework will fire the LoadPicture event and renders the new image instead of the placeholder.

LoadingPictureStroke and LoadingPictureFill are the objects to use for stroking and filling the placeholder rectangle. The default values are a white stroke on a black background.

The LoadPicture event contains data about the picture that finished loading such as the Picture object itself and the owner AnnObject. Also, the event data contains the Error property that will be populated if an error occurred.

Loading an image in the background is an efficient and easy way to start drawing an annotation object without waiting for all the resources to be available in the browser. This is especially true if the object contains a picture with a source URL on a server machine and takes a few seconds to download.

Example
Copy Code  
using Leadtools.Annotations.Automation;
using Leadtools.Annotations.Core;
using Leadtools.Annotations.Rendering;
using Leadtools.Codecs;
using Leadtools.WinForms;

public void AnnRenderingEngine_LoadPicture()
{
   // get the current rendering engine
   AnnRenderingEngine renderingEngine = _automation.AutomationControl.RenderingEngine;
   // Change the default loading object placeholder to be a green border with semi-transparent background
   AnnStroke stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Green"), LeadLengthD.Create(1));
   AnnBrush fill = AnnSolidColorBrush.Create("rgba(0, 0, 0, 0.5)");

   renderingEngine.LoadingPictureStroke = stroke;
   renderingEngine.LoadingPictureFill = fill;

   // Hook to the LoadPicture event
   renderingEngine.LoadPicture += renderingEngine_LoadPicture;

   // Create a new AnnHotspotObject with a picture from a remote server
   double inch = 720;
   AnnHotspotObject hotspot = new AnnHotspotObject();
   // Add the object at location 1,1 inch with size 4,2 inches
   hotspot.Rect = LeadRectD.Create(1 * inch, 1 * inch, 4 * inch, 2 * inch);
   // Set its picture
   AnnPicture picture = new AnnPicture("ms-appx:///Assets/Logo.png");
   hotspot.Picture = picture;

   // Add it to the container
   AnnContainer container = _automation.Container;
   container.Children.Add(hotspot);

   _automation.Invalidate(LeadRectD.Empty);
}

void renderingEngine_LoadPicture(object sender, AnnLoadPictureEventArgs e)
{
   // Check if an error occurred
   if (e.Error != null)
   {
      // Show info about the error
      string str = e.Error.Message;
      str += "\nSource: " + e.Picture.Source;
      str += "\nOwner object: " + e.AnnObject.FriendlyName;
      Debug.WriteLine(str);
   }
}
using Leadtools.Converters;
using Leadtools.Annotations.Automation;
using Leadtools.Controls;
using Leadtools.Annotations.Core;
using Leadtools.Annotations.Rendering;
using Leadtools.Codecs;

[TestMethod]
public void AnnRenderingEngine_LoadPicture()
{
   // get the current rendering engine
   AnnRenderingEngine renderingEngine = _automation.AutomationControl.RenderingEngine;
   // Change the default loading object placeholder to be a green border with semi-transparent background
   AnnStroke stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Green"), LeadLengthDHelper.Create(1));
   AnnBrush fill = AnnSolidColorBrush.Create("rgba(0, 0, 0, 0.5)");

   renderingEngine.LoadingPictureStroke = stroke;
   renderingEngine.LoadingPictureFill = fill;

   // Hook to the LoadPicture event
   renderingEngine.LoadPicture += renderingEngine_LoadPicture;

   // Create a new AnnHotspotObject with a picture from a remote server
   double inch = 720;
   AnnHotspotObject hotspot = new AnnHotspotObject();
   // Add the object at location 1,1 inch with size 4,2 inches
   hotspot.Rect = LeadRectDHelper.Create(1 * inch, 1 * inch, 4 * inch, 2 * inch);
   // Set its picture
   AnnPicture picture = new AnnPicture("ms-appx:///Assets/Logo.png");
   hotspot.Picture = picture;

   // Add it to the container
   AnnContainer container = _automation.Container;
   container.Children.Add(hotspot);

   _automation.Invalidate(LeadRectDHelper.Empty);
}

void renderingEngine_LoadPicture(object sender, AnnLoadPictureEventArgs e)
{
   // Check if an error occurred
   if (e.Error != null)
   {
      // Show info about the error
      string str = e.Error.Message;
      str += "\nSource: " + e.Picture.Source;
      str += "\nOwner object: " + e.AnnObject.FriendlyName;
      Debug.WriteLine(str);
   }
}
Requirements

Target Platforms

See Also

Reference

AnnRenderingEngine Class
AnnRenderingEngine Members

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.