Occurs when data is being dragged or dropped from/to this ImageViewer.
public event EventHandler<ImageViewerItemDragDropEventArgs> ItemDragDrop
Public Event ItemDragDrop As EventHandler(Of Leadtools.Controls.ImageViewerItemDragDropEventArgs)
public:
event EventHandler<Leadtools::Controls::ImageViewerItemDragDropEventArgs^>^ ItemDragDrop
For more information refer to Image Viewer Drag and Drop.
For an example on using the image viewer as the source of a drag/drop operation, refer to ImageViewerDragInteractiveMode.
This example will show how to use the ImageViewer as the drop target of a drag/drop operation.
Start with the ImageViewer example, remove all the code inside the example function (search for the "// TODO: add example code here" comment) and insert the following code:
using Leadtools;
using Leadtools.Controls;
using Leadtools.Codecs;
using Leadtools.Drawing;
using LeadtoolsExamples.Common;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
_imageViewer.AllowDrop = true;
_imageViewer.BringToFront();
_imageViewer.ActiveItem = _imageViewer.Items[0];
var dragMode = new ImageViewerDragInteractiveMode();
dragMode.AllowedEffects = DragDropEffects.Copy | DragDropEffects.Move | DragDropEffects.Link;
_imageViewer.InteractiveModes.BeginUpdate();
dragMode = new ImageViewerDragInteractiveMode();
dragMode.AllowedEffects = DragDropEffects.Copy | DragDropEffects.Move | DragDropEffects.Link;
_imageViewer.InteractiveModes.Add(dragMode);
_imageViewer.InteractiveModes.EndUpdate();
EventHandler<ImageViewerItemDragDropEventArgs> handler = (sender, e) =>
{
switch (e.Operation)
{
case ImageViewerItemDragDropOperation.DragEnter:
{
Console.WriteLine(string.Format("DragDrop Operation:{0} {1} {2}", e.Operation, e.Effect, e.Format));
Console.WriteLine(string.Format(" SrcViewer:{0} DstViewer:{1}",
e.SourceImageViewer != null ? e.SourceImageViewer.Name : "null",
e.TargetImageViewer != null ? e.TargetImageViewer.Name : "null"));
Console.WriteLine(string.Format(" SrcItem:{0} DstItem:{1}",
e.SourceItem != null ? e.SourceImageViewer.Items.IndexOf(e.SourceItem).ToString() : "null",
e.TargetItem != null ? e.TargetImageViewer.Items.IndexOf(e.TargetItem).ToString() : "null"));
}
break;
case ImageViewerItemDragDropOperation.DragOver:
{
Console.WriteLine(string.Format("DragDrop Operation:{0} {1} {2}", e.Operation, e.Effect, e.Format));
Console.WriteLine(string.Format(" SrcViewer:{0} DstViewer:{1}",
e.SourceImageViewer != null ? e.SourceImageViewer.Name : "null",
e.TargetImageViewer != null ? e.TargetImageViewer.Name : "null"));
Console.WriteLine(string.Format(" SrcItem:{0} DstItem:{1}",
e.SourceItem != null ? e.SourceImageViewer.Items.IndexOf(e.SourceItem).ToString() : "null",
e.TargetItem != null ? e.TargetImageViewer.Items.IndexOf(e.TargetItem).ToString() : "null"));
}
break;
default:
break;
}
};
_imageViewer.ItemDragDrop += handler;
Imports Leadtools
Imports Leadtools.Controls
Imports Leadtools.Codecs
Imports Leadtools.Drawing
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports LeadtoolsControlsExamples.LeadtoolsExamples.Common
_imageViewer.AllowDrop = True
_imageViewer.BringToFront()
_imageViewer.ActiveItem = _imageViewer.Items(0)
Dim dragMode As New ImageViewerDragInteractiveMode()
dragMode.AllowedEffects = DragDropEffects.Copy Or DragDropEffects.Move Or DragDropEffects.Link
_imageViewer.InteractiveModes.BeginUpdate()
dragMode = New ImageViewerDragInteractiveMode()
dragMode.AllowedEffects = DragDropEffects.Copy Or DragDropEffects.Move Or DragDropEffects.Link
_imageViewer.InteractiveModes.Add(dragMode)
_imageViewer.InteractiveModes.EndUpdate()
Dim handler As EventHandler(Of ImageViewerItemDragDropEventArgs) =
Sub(sender, e)
Select Case e.Operation
Case ImageViewerItemDragDropOperation.DragEnter
Console.WriteLine(String.Format("DragDrop Operation:{0} {1} {2}", e.Operation, e.Effect, e.Format))
If Not e.SourceImageViewer Is Nothing Then
If Not e.TargetImageViewer Is Nothing Then
Console.WriteLine(String.Format(" SrcViewer:{0} DstViewer:{1}", e.SourceImageViewer.Name, e.TargetImageViewer.Name))
Else
Console.WriteLine(String.Format(" SrcViewer:{0} DstViewer:{1}", e.SourceImageViewer.Name, "null"))
End If
Else
If Not e.TargetImageViewer Is Nothing Then
Console.WriteLine(String.Format(" SrcViewer:{0} DstViewer:{1}", "null", e.TargetImageViewer.Name))
Else
Console.WriteLine(String.Format(" SrcViewer:{0} DstViewer:{1}", "null", "null"))
End If
End If
If Not e.SourceItem Is Nothing Then
If Not e.TargetItem Is Nothing Then
Console.WriteLine(String.Format(" SrcItem:{0} DstItem:{1}", e.SourceImageViewer.Items.IndexOf(e.SourceItem).ToString(),
e.TargetImageViewer.Items.IndexOf(e.TargetItem).ToString()))
Else
Console.WriteLine(String.Format(" SrcItem:{0} DstItem:{1}", e.SourceImageViewer.Items.IndexOf(e.SourceItem).ToString(), "null"))
End If
Else
If Not e.TargetItem Is Nothing Then
Console.WriteLine(String.Format(" SrcItem:{0} DstItem:{1}", "null", e.TargetImageViewer.Items.IndexOf(e.TargetItem).ToString()))
Else
Console.WriteLine(String.Format(" SrcItem:{0} DstItem:{1}", "null", "null"))
End If
End If
Case ImageViewerItemDragDropOperation.DragOver
Console.WriteLine(String.Format("DragDrop Operation:{0} {1} {2}", e.Operation, e.Effect, e.Format))
If Not e.SourceImageViewer Is Nothing Then
If Not e.TargetImageViewer Is Nothing Then
Console.WriteLine(String.Format(" SrcViewer:{0} DstViewer:{1}", e.SourceImageViewer.Name, e.TargetImageViewer.Name))
Else
Console.WriteLine(String.Format(" SrcViewer:{0} DstViewer:{1}", e.SourceImageViewer.Name, "null"))
End If
Else
If Not e.TargetImageViewer Is Nothing Then
Console.WriteLine(String.Format(" SrcViewer:{0} DstViewer:{1}", "null", e.TargetImageViewer.Name))
Else
Console.WriteLine(String.Format(" SrcViewer:{0} DstViewer:{1}", "null", "null"))
End If
End If
If Not e.SourceItem Is Nothing Then
If Not e.TargetItem Is Nothing Then
Console.WriteLine(String.Format(" SrcItem:{0} DstItem:{1}", e.SourceImageViewer.Items.IndexOf(e.SourceItem).ToString(),
e.TargetImageViewer.Items.IndexOf(e.TargetItem).ToString()))
Else
Console.WriteLine(String.Format(" SrcItem:{0} DstItem:{1}", e.SourceImageViewer.Items.IndexOf(e.SourceItem).ToString(), "null"))
End If
Else
If Not e.TargetItem Is Nothing Then
Console.WriteLine(String.Format(" SrcItem:{0} DstItem:{1}", "null", e.TargetImageViewer.Items.IndexOf(e.TargetItem).ToString()))
Else
Console.WriteLine(String.Format(" SrcItem:{0} DstItem:{1}", "null", "null"))
End If
End If
Case Else
End Select
End Sub
AddHandler _imageViewer.ItemDragDrop, handler
Parameter | Type | Description |
---|---|---|
sender | object | The source of the event. |
e | ImageViewerItemDragDropEventArgs | The event data. |
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET