←Select platform

Lock Method

Summary
Locks the object(s) currently being edited (selected).
Syntax
C#
VB
Objective-C
C++
Java
publicvirtualvoidLock()
PublicOverridableSubLock()
-(void) lock;
publicvoidlock()
public:virtualvoidLock()
Remarks

Use theCanLockproperty to determine whether you can currently call this method.

For more information, refer to我mplementing Annotation Security.

Example

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

C#
usingLeadtools.Annotations.Automation;usingLeadtools.Annotations.Engine;usingLeadtools.Codecs;usingLeadtools.Controls;usingLeadtools.Annotations.Rendering;usingLeadtools.Annotations.WinForms;publicvoidAnnAutomation_Lock(){// first add a new object to the automationAnnRectangleObject rectObj =newAnnRectangleObject();rectObj.Rect = LeadRectD.Create(100, 100, 800, 800);rectObj.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), LeadLengthD.Create(1));rectObj.Fill = AnnSolidColorBrush.Create("Yellow");_automation.Container.Children.Add(rectObj);_automation.Invalidate(LeadRectD.Empty);// make sure no objects are selected in the automation_automation.SelectObject(null);// Hook to the lock and unlock events_automation.LockObject += _automation_LockObject;_automation.UnlockObject += _automation_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)LockUnlock(_automation);// select (edit) the object we have just added_automation.SelectObject(rectObj);// see if we can lock or unlock the object (should show the password dialog to lock the object)LockUnlock(_automation);_automation.LockObject -= _automation_LockObject;_automation.UnlockObject -= _automation_UnlockObject;}privatevoidLockUnlock(AnnAutomation automation){// first, check if we can lock the objectif(automation.CanLock){// lock this objectautomation.Lock();}elseif(automation.CanUnlock){// unlock this objectautomation.Unlock();}else{Debug.WriteLine("Cannot lock or unlock because no object is currently being edited (selected)");}}void_automation_LockObject(objectsender, AnnLockObjectEventArgs e){Debug.WriteLine(string.Format("Lock it, sending password = {0}","secret"));e.Password ="secret";}void_automation_UnlockObject(objectsender, AnnLockObjectEventArgs e){Debug.WriteLine(string.Format("Unlock it, sending password = {0}","secret"));e.Password ="secret";}
Requirements

Target Platforms

Leadtools.Annotations.Automation Assembly
188金宝搏的网址客服|Support|Contact Us|我ntellectual Property Notices
© 1991-2021LEAD Technologies, Inc.All Rights Reserved.