Locks the object(s) currently being edited (selected).
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 Basic | Copy Code |
---|
Public Sub AnnAutomation_Lock(ByVal automation As AnnAutomation)
Dim rectObj As AnnRectangleObject = New AnnRectangleObject()
rectObj.Bounds = New AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel)
rectObj.Pen = New AnnPen(Color.Blue, New AnnLength(1, AnnUnit.Pixel))
rectObj.Brush = New AnnSolidBrush(Color.Yellow)
automation.Container.Objects.Add(rectObj)
automation.Viewer.Invalidate(rectObj.InvalidRectangle)
automation.SelectNone()
LockUnlock(automation)
automation.StartEditing(rectObj, False)
LockUnlock(automation)
LockUnlock(automation)
End Sub
Private Sub LockUnlock(ByVal automation As AnnAutomation)
If automation.CanLock Then
automation.Lock()
ElseIf automation.CanUnlock Then
automation.Unlock()
Else
MessageBox.Show("Cannot lock or unlock because no object is currently being edited (selected)")
End If
End Sub |
C# | Copy Code |
---|
public void AnnAutomation_Lock(AnnAutomation automation) { // first add a new object to the automation AnnRectangleObject rectObj = new AnnRectangleObject(); rectObj.Bounds = new AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel); rectObj.Pen = new AnnPen(Color.Blue, new AnnLength(1, AnnUnit.Pixel)); rectObj.Brush = new AnnSolidBrush(Color.Yellow); automation.Container.Objects.Add(rectObj); automation.Viewer.Invalidate(rectObj.InvalidRectangle); // 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)"); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also