Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.4.3
|
Leadtools.Controls Assembly > Leadtools.Controls Namespace > ImageViewer Class : ItemDragDrop Event |
public event EventHandler<ImageViewerItemDragDropEventArgs> ItemDragDrop
'Declaration
Public Event ItemDragDrop As EventHandler(Of ImageViewerItemDragDropEventArgs)
The event handler receives an argument of type ImageViewerItemDragDropEventArgs containing data related to this event. The following ImageViewerItemDragDropEventArgs properties provide information specific to this event.
Property | Description |
---|---|
Abort | Gets or a sets a value that indicate whether drag/drop operation is to be aborted. |
Effect | Current drop effect. |
Format | Format of the drop object. |
Location | Location of the drag item. |
NativeEvent | Native event that initiated this drag/drop operation |
Operation | Current drag operation. |
SourceImageViewer | Image Viewer that initiated the drag event. |
SourceItem | The item that originated this drag/drop operation. |
TargetImageViewer | Current target image viewer for this drop operation. |
TargetItem | The target item for this drop operation. |
For more information refer to Image Viewer Drag and Drop.
ImageViewerItemDragDropEventArgsFor 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:
Imports Leadtools Imports Leadtools.Controls Imports Leadtools.Codecs Imports Leadtools.Drawing Imports Leadtools.ImageProcessing Imports Leadtools.ImageProcessing.Color _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
using Leadtools; using Leadtools.Controls; using Leadtools.Codecs; using Leadtools.Drawing; 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;