(Leadtools.Annotations.Automation)

フレームを表示

Lockメソッド






現時点では編集されている(選択した)オブジェクトをロックします。
構文
public virtual void Lock()
'Declaration
 
Public Overridable Sub Lock() 
public virtual void Lock()
-(void) lock;
public void lock()
 function Leadtools.Annotations.Automation.AnnAutomation.Lock()
解説

現在、このメソッドを呼び出すことができるかどうかを判断するには、CanLockプロパティを使います。

詳細については、「アノテーションセキュリティ の実装」を参照してください。

サンプル

このサンプルはオブジェクトをロックして、ロック解除する方法を示します。そして、パスワードのためにユーザーを促します。

Copy Code  
using Leadtools.Annotations.Automation;
using Leadtools.Annotations.Core;
using Leadtools.Codecs;
using Leadtools.Controls;
using Leadtools.Annotations.Rendering;
using Leadtools.Annotations.WinForms;

[TestMethod]
public void AnnAutomation_Lock()
{
   // first add a new object to the automation
   AnnRectangleObject rectObj = new AnnRectangleObject();
   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;
}

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
   {
      Debug.WriteLine("Cannot lock or unlock because no object is currently being edited (selected)");
   }
}

void _automation_LockObject(object sender, AnnLockObjectEventArgs e)
{
   Debug.WriteLine(string.Format("Lock it, sending password = {0}", "secret"));
   e.Password = "secret";
}

void _automation_UnlockObject(object sender, AnnLockObjectEventArgs e)
{
   Debug.WriteLine(string.Format("Unlock it, sending password = {0}", "secret"));
   e.Password = "secret";
}
using Leadtools.Annotations.Automation;
using Leadtools.Controls;
using Leadtools.Converters;
using Leadtools.Annotations.Core;
using Leadtools.Codecs;

[TestMethod]
public void AnnAutomation_Lock()
{
   // first add a new object to the automation
   AnnRectangleObject rectObj = new AnnRectangleObject();
   rectObj.Rect = LeadRectDHelper.Create(100, 100, 800, 800);
   rectObj.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), LeadLengthDHelper.Create(1));
   rectObj.Fill = AnnSolidColorBrush.Create("Yellow");
   _automation.Container.Children.Add(rectObj);
   _automation.Invalidate(LeadRectDHelper.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;
}

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
   {
      Debug.WriteLine("Cannot lock or unlock because no object is currently being edited (selected)");
   }
}

void _automation_LockObject(object sender, AnnLockObjectEventArgs e)
{
   Debug.WriteLine(string.Format("Lock it, sending password = {0}", "secret"));
   e.Password = "secret";
}

void _automation_UnlockObject(object sender, AnnLockObjectEventArgs e)
{
   Debug.WriteLine(string.Format("Unlock it, sending password = {0}", "secret"));
   e.Password = "secret";
}
必要条件

ターゲットプラットホーム

参照

参照

AnnAutomationクラス
AnnAutomationメンバ

  Leadtools.Annotations.Automationは、DocumentまたはMedicalツールキットのライセンスと、解除キーが必要です。詳細は、以下を参照してください。LEADTOOLSツールキット機能