アノテーションの削除を検知できるイベントはありますか?
対象製品
LEADTOOLS 17.5J Document Imaging
詳細
AnnAutomationのBeforeObjectChangedイベントもしくは、AfterObjectChangedイベントを使用して削除を検知する方法があります。
以下のサンプルコードは、BeforeObjectChangedイベントを使用してアノテーションを削除する際にメッセージボックスを表示します。
サンプルコード(VB.NET)
サンプルコード(C#)
以下のサンプルコードは、BeforeObjectChangedイベントを使用してアノテーションを削除する際にメッセージボックスを表示します。
サンプルコード(VB.NET)
' プログラムの最初にImportsを追加します。 Imports Leadtools.Annotations Imports Leadtools.Codecs Public Class Form1 ' 自動モードの管理に使用するAutomationManager Private annAutomationManager As AnnAutomationManager Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' RasterCodecsオブジェクトを初期化します。 Dim codecs As RasterCodecs = New RasterCodecs ' メイン画像をビューワにロードします。 RasterImageViewer1.Image = codecs.Load("image1.jpg") If (Not IsNothing(RasterImageViewer1.Image)) Then ' AutomationManagerを作成して設定します。 annAutomationManager = New AnnAutomationManager ' デフォルト(すべて)の自動オブジェクトを作成します。 annAutomationManager.CreateDefaultObjects() ' ツールバーを作成してフォームに追加します。 annAutomationManager.CreateToolBar() Controls.Add(annAutomationManager.ToolBar) ' Automationを設定します(これにより、コンテナも作成されます)。 Dim automation As AnnAutomation = New AnnAutomation(annAutomationManager, RasterImageViewer1) ' アノテーションが変更される直前に呼び出されるイベントを追加します。 AddHandler automation.BeforeObjectChanged, AddressOf automation_BeforeObjectChanged ' このAutomationをアクティブなAutomationに設定します。 automation.Active = True End If End Sub Private Sub automation_BeforeObjectChanged(ByVal sender As Object, ByVal e As AnnBeforeObjectChangedEventArgs) If e.ChangeType = AnnObjectChangedType.Delete Then ' 削除の場合 MessageBox.Show("削除します。") End If End Sub End Class
サンプルコード(C#)
// プログラムの最初にusingを追加します。 using Leadtools.Annotations; using Leadtools.Codecs; ・・・ public partial class Form1 : Form { ・・・ // 自動モードの管理に使用するAutomationManager private AnnAutomationManager annAutomationManager; private void Form1_Load(object sender, EventArgs e) { // RasterCodecsオブジェクトを初期化します。 RasterCodecs codecs = new RasterCodecs(); // メイン画像をビューワにロードします。 rasterImageViewer1.Image = codecs.Load(@"image1.jpg"); if (rasterImageViewer1.Image != null) { // AutomationManagerを作成して設定します。 annAutomationManager = new AnnAutomationManager(); // デフォルト(すべて)の自動オブジェクトを作成します。 annAutomationManager.CreateDefaultObjects(); // ツールバーを作成してフォームに追加します。 annAutomationManager.CreateToolBar(); Controls.Add(annAutomationManager.ToolBar); // Automationを設定します(これにより、コンテナも作成されます)。 AnnAutomation automation = new AnnAutomation(annAutomationManager, rasterImageViewer1); // アノテーションが変更される直前に呼び出されるイベントを追加します。 automation.BeforeObjectChanged += new EventHandler(automation_BeforeObjectChanged); // このAutomationをアクティブなAutomationに設定します。 automation.Active = true; } } private void automation_BeforeObjectChanged(object sender, AnnBeforeObjectChangedEventArgs e) { if (e.ChangeType == AnnObjectChangedType.Delete) { // 削除の場合 MessageBox.Show("削除します。"); } } }
関連情報
- アノテーションオブジェクトのサイズを指定して追加するには?
- アノテーションオブジェクトを別々のコンテナに保存するには?
- 非自動アノテーションオブジェクトを画像に描画するには?
- 選択しているアノテーションオブジェクトのみを画像に描画するには?
キーワード
アノテーション