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 Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
public void ImageViewerItemDragDrop_Example()
{
_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
Public Sub ImageViewerItemDragDrop_Example()
_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
End Sub
Parameter | Type | Description |
---|---|---|
sender | object | The source of the event. |
e | ImageViewerItemDragDropEventArgs | The event data. |
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.