LEADTOOLS JavaScript (Leadtools.Annotations.Core)
LEAD Technologies, Inc

Lock Method (AnnObject)

Example 

String containing the password used to lock the annotation object.
Locks this AnnObject with the specified password.
Syntax
 function Leadtools.Annotations.Core.AnnObject.lock( 
   password 
)
!MISSING Scrap '_RTJavaScript_Method_SYNTAX'!

Parameters

ParameterTypeDescription
passwordstringString containing the password used to lock the annotation object.
Remarks

Only unlocked objects can be locked. If an object is already locked, it will stay locked with its original password. You must pass the same password to Unlock to unlock this AnnObject.

If this method succeeds, password will be stored inside the object and can be retrieved with the Password property.

An object must be unlocked in order to change that object in automated mode.

For more information, refer to Implementing Annotation Security.

Example
example: function SiteLibrary_DefaultPage$example() {
   var inch = 720.0;

   // Get the container
   var container = this._automation.get_container();

   // Add the lock picture to the container resources

   // Create a new instance of AnnResources if the container does not already have one
   var resources = this._automation.get_container().get_resources();
   if (resources == null) {
      resources = new Leadtools.Annotations.Core.AnnResources();
      this._automation.get_container().set_resources(resources);
   }

   // Get the images collection
   var imagesResources = resources.get_images();

   // Add our picture to it
   imagesResources.add(new Leadtools.Annotations.Core.AnnPicture("Resources/Lock.png"));
   var pictureIndex = imagesResources.length - 1;

   // Add a blue on yellow rectangle from 3in 3in to 4in 4in
   var rectObj = new Leadtools.Annotations.Core.AnnRectangleObject();
   rectObj.set_rect(Leadtools.LeadRectD.create(3 * inch, 3 * inch, 1 * inch, 1 * inch));
   rectObj.set_stroke(Leadtools.Annotations.Core.AnnStroke.create(Leadtools.Annotations.Core.AnnSolidColorBrush.create("blue"), Leadtools.LeadLengthD.create(1)));
   rectObj.set_fill(Leadtools.Annotations.Core.AnnSolidColorBrush.create("yellow"));

   // Set its lock picture
   rectObj.set_lockPicture(pictureIndex);

   // Add it to the container
   container.get_children().add(rectObj);

   // Show the object lock state (default)
   alert("Default lock state");
   this.showLockedState(rectObj);

   // Lock it with a password
   alert("Locking now with a password");
   rectObj.lock("secret");

   // Show the object lock state, it should say locked and the object should be painted with the lock picture
   this.showLockedState(rectObj);

   // Now try to unlock it with a wrong password
   alert("Unlocking with a wrong password");
   rectObj.unlock("wrong password");

   // Check again, it should still be locked
   this.showLockedState(rectObj);

   // Finally unlock it with the correct password
   alert("Unlocking with a correct password");
   rectObj.unlock("secret");

   // Check again, it should still be unlocked
   this.showLockedState(rectObj);
},

showLockedState: function SiteLibrary_DefaultPage$showLockedState(annObj) {
   this._automation.invalidate(Leadtools.LeadRectD.get_empty());

   // Show the object lock state (default)
   alert("Locked: " + annObj.get_isLocked());
},
See Also

Reference

AnnObject Object
AnnObject Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.