LEADTOOLS Annotations for WPF and Silverlight (Leadtools.Windows.Annotations assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.31
Lock Method
See Also 
Leadtools.Windows.Annotations Namespace > AnnAutomation Class : Lock Method



The Lock Method supports WPF/Silverlight.

The Lock Method is available in LEADTOOLS Document and Medical Imaging toolkits.

Locks the object(s) currently being edited (selected). Supported in Silverlight, Windows Phone 7

Syntax

Visual Basic (Declaration) 
Public Overridable Sub Lock() 
Visual Basic (Usage)Copy Code
Dim instance As AnnAutomation
 
instance.Lock()
C# 
public virtual void Lock()
C++/CLI 
public:
virtual void Lock(); 

Example

Visual BasicCopy Code
Private Sub AnnAutomation_Lock(ByVal automation As AnnAutomation)
   ' first add a new object to the automation
   Dim rectObj As AnnRectangleObject = New AnnRectangleObject()
   rectObj.Rect = New Rect(100, 100, 100, 100)
   rectObj.Stroke = Colors.Blue
   rectObj.StrokeThickness = 1.0
   rectObj.Fill = Colors.Yellow
   automation.Container.Children.Add(rectObj)
   ' make sure no objects are selected in the automation
   automation.SelectNone()

   ' see if we can lock or unlock the object (this should show a message informing you that no objects are currently selected (bring edited)
   LockUnlock(automation)

   ' select (edit) the object we have just added
   automation.StartEditing(rectObj, False)

   ' see if we can lock or unlock the object (should show the password dialog to lock the object)
   LockUnlock(automation)

   ' see if we can lock or unlock the object (should show the password dialog to unlock the object)
   LockUnlock(automation)
End Sub

Private Sub LockUnlock(ByVal automation As AnnAutomation)
   ' first, check if we can lock the object
   If automation.CanLock Then
      ' lock this object
      automation.Lock()
   ElseIf automation.CanUnlock Then
      ' unlock this object
      automation.Unlock()
   Else
      MessageBox.Show("Cannot lock or unlock because no object is currently being edited (selected)")
   End If
End Sub
C#Copy Code
private void AnnAutomation_Lock(AnnAutomation automation)
{
   // first add a new object to the automation
   AnnRectangleObject rectObj = new AnnRectangleObject();
   rectObj.Rect = new Rect(100, 100, 100, 100);
   rectObj.Stroke = Colors.Blue;
   rectObj.StrokeThickness = 1.0;
   rectObj.Fill = Colors.Yellow;
   rectObj.StrokeThickness = 1.0;
   automation.Container.Children.Add(rectObj);
   // make sure no objects are selected in the automation
   automation.SelectNone();

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

   // select (edit) the object we have just added
   automation.StartEditing(rectObj, false);

   // see if we can lock or unlock the object (should show the password dialog to lock the object)
   LockUnlock(automation);

   // see if we can lock or unlock the object (should show the password dialog to unlock the object)
   LockUnlock(automation);
}

private void LockUnlock(AnnAutomation automation)
{
   // first, check if we can lock the object
   if(automation.CanLock)
   {
      // lock this object
      automation.Lock();
   }
   else if(automation.CanUnlock)
   {
      // unlock this object
      automation.Unlock();
   }
   else
      MessageBox.Show("Cannot lock or unlock because no object is currently being edited (selected)");
}
SilverlightCSharpCopy Code
private void AnnAutomation_Lock(AnnAutomation automation)
{
   // first add a new object to the automation
   AnnRectangleObject rectObj = new AnnRectangleObject();
   rectObj.Rect = new Rect(100, 100, 100, 100);
   rectObj.Stroke = Colors.Blue;
   rectObj.StrokeThickness = 1.0;
   rectObj.Fill = Colors.Yellow;
   rectObj.StrokeThickness = 1.0;
   automation.Container.Children.Add(rectObj);
   // make sure no objects are selected in the automation
   automation.SelectNone();

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

   // select (edit) the object we have just added
   automation.StartEditing(rectObj, false);

   // see if we can lock or unlock the object (should show the password dialog to lock the object)
   LockUnlock(automation);

   // see if we can lock or unlock the object (should show the password dialog to unlock the object)
   LockUnlock(automation);
}

private void LockUnlock(AnnAutomation automation)
{
   // first, check if we can lock the object
   if(automation.CanLock)
   {
      // lock this object
      automation.Lock();
   }
   else if(automation.CanUnlock)
   {
      // unlock this object
      automation.Unlock();
   }
   else
      MessageBox.Show("Cannot lock or unlock because no object is currently being edited (selected)");
}
SilverlightVBCopy Code
Private Sub AnnAutomation_Lock(ByVal automation As AnnAutomation)
   ' first add a new object to the automation
   Dim rectObj As AnnRectangleObject = New AnnRectangleObject()
   rectObj.Rect = New Rect(100, 100, 100, 100)
   rectObj.Stroke = Colors.Blue
   rectObj.StrokeThickness = 1.0
   rectObj.Fill = Colors.Yellow
   rectObj.StrokeThickness = 1.0
   automation.Container.Children.Add(rectObj)
   ' make sure no objects are selected in the automation
   automation.SelectNone()

   ' see if we can lock or unlock the object (this should show a message informing you that no objects are currently selected (bring edited)
   LockUnlock(automation)

   ' select (edit) the object we have just added
   automation.StartEditing(rectObj, False)

   ' see if we can lock or unlock the object (should show the password dialog to lock the object)
   LockUnlock(automation)

   ' see if we can lock or unlock the object (should show the password dialog to unlock the object)
   LockUnlock(automation)
End Sub

Private Sub LockUnlock(ByVal automation As AnnAutomation)
   ' first, check if we can lock the object
   If automation.CanLock Then
      ' lock this object
      automation.Lock()
   Else If automation.CanUnlock Then
      ' unlock this object
      automation.Unlock()
   Else
      MessageBox.Show("Cannot lock or unlock because no object is currently being edited (selected)")
   End If
End Sub

Remarks

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

This method opens the AnnAutomationManager.PasswordDialogType window and uses the value entered in this dialog as the password to AnnObject.Lock.

If the AnnAutomationManager.PasswordDialogType value is null (Nothing in Visual Basic), this method will not do anything.

For more information, refer to Implementing WPF Annotation Security..

Requirements

Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)

See Also

Lock requires a Document/Medical product license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features and Unlocking Special LEAD Features.