LEADTOOLS JavaScript (Leadtools.Annotations.Automation)

Lock Method

Show in webframe
Example 
Locks the object(s) currently being edited (selected).
Syntax
 function Leadtools.Annotations.Automation.AnnAutomation.lock()
Remarks

Use the CanLock property to determine whether you can currently call this method.

For more information, refer to Implementing Annotation Security.

Example

This example will show how to lock and unlock an object, prompting the user for a password.

example: function SiteLibrary_DefaultPage$example() {
   var _this = this;

   // first add a new object to the automation
   var rectObj = new lt.Annotations.Core.AnnRectangleObject();
   rectObj.set_rect(lt.LeadRectD.create(100, 100, 800, 800));
   rectObj.set_stroke(lt.Annotations.Core.AnnStroke.create(
      lt.Annotations.Core.AnnSolidColorBrush.create("blue"),
      lt.LeadLengthD.create(1)));
   rectObj.set_fill(lt.Annotations.Core.AnnSolidColorBrush.create("yellow"));
   this._automation.get_container().get_children().add(rectObj);
   this._automation.invalidate(lt.LeadRectD.get_empty());

   // make sure no objects are selected in the automation
   this._automation.selectObject(null);

   var myPassword = "secret";

   // Hook to the lock and unlock events
   var lockObject = function(sender, e) {
      // e is of type AnnLockObjectEventArgs
      alert("Lock it, sending password = " + myPassword);
      e.set_password(myPassword);
   };

   var unlockObject = function(sender, e) {
      // e is of type AnnLockObjectEventArgs
      alert("Unlock it, sending password = " + myPassword);
      e.set_password(myPassword);
   };

   this._automation.add_lockObject(lockObject);
   this._automation.add_unlockObject(unlockObject);

   // see if we can lock or unlock the object (this should show a message informing you that no objects are currently selected (bring edited)
   this.lockUnlock(this._automation);

   // select (edit) the object we have just added
   this._automation.selectObject(rectObj);

   // see if we can lock or unlock the object (should show the password dialog to lock the object)
   this.lockUnlock(this._automation);

   // see if we can lock or unlock the object (should show the password dialog to unlock the object)
   this.lockUnlock(this._automation);

   this._automation.remove_lockObject(lockObject);
   this._automation.remove_unlockObject(unlockObject);
},

lockUnlock: function SiteLibrary_DefaultPage$lockUnlock(automation) {
   // first, check if we can lock the object
   if(automation.get_canLock()) {
      // lock this object
      automation.lock();
   }
   else if(automation.get_canUnlock()) {
      // unlock this object
      automation.unlock();
   }
   else {
      alert("Cannot lock or unlock because no object is currently being edited (selected)");
   }
},
See Also

Reference

AnnAutomation Object
AnnAutomation Members

 

 


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