←Select platform

ItemDragDrop Event

Summary

Occurs when data is being dragged or dropped from/to this ImageViewer.

Syntax
C#
C++
public event EventHandler<ImageViewerItemDragDropEventArgs> ItemDragDrop 
vb[VB Syntax] 
Public Event ItemDragDrop As EventHandler(Of Leadtools.Controls.ImageViewerItemDragDropEventArgs) 
public:  
   event EventHandler<Leadtools::Controls::ImageViewerItemDragDropEventArgs^>^ ItemDragDrop 
Remarks

For more information refer to Image Viewer Drag and Drop.

Example

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:

C#
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; 
 
} 
Event Data
ParameterTypeDescription
senderobjectThe source of the event.
eImageViewerItemDragDropEventArgsThe event data.
Requirements

Target Platforms

Help Version 22.0.2022.4.4
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2022 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Controls Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2022 LEAD Technologies, Inc. All Rights Reserved.