Drags images and floaters from an image viewer using mouse or touch, often to achieve Drag and Drop effects.
public class ImageViewerDragInteractiveMode : ImageViewerInteractiveMode
Public Class ImageViewerDragInteractiveMode
public ref class ImageViewerDragInteractiveMode : ImageViewerInteractiveMode
This mode allows you to use an ImageViewer as the source for a drag operation. The viewer will then handle initializing and updating the UI notifications when the user clicks and drags on an image or floater of an item in the viewer.
The mode works on any item in the viewer. The mode uses AutoSet to automatically detect the source item for the drag operation when the user clicks on the viewer. This is done by listening to DragStarted events.
When this event occurs, the mode first checks whether the user clicked an item (ImageViewerInteractiveMode.Item is not null). If not, it will not start a drag. Then it checks ItemPart to determine which part of the item to drag. Currently, if the value is ImageViewerItemPart.Floater, then Floater will be dragged; otherwise, ImageViewerItem.Image. If this condition is not met (The item does not have an image or a floater when ImageViewerItemPart.Floater is specified), then the operation will not start.
In the Windows Forms platform, the drag is performed using System.Windows.Forms.Control.DoDragDrop(System.Object,System.Windows.Forms.DragDropEffects). This methods requires two parameters. The first is the drag object and the second is the allowed effects.
The drag object is obtained from the item (either the image or the floater) and then the value of Format is checked as follows:
If Format is RasterImage.RasterImageDataFormat, then the same source RasterImage reference is used. The object is not serialized and will be used as is. This is supported only if the drag target is in the same application.
No other format is supported at this time. Setting Format to any other value will throw an exception.
The AllowedEffects property determines which effects are allowed for the target (Copy, Move or Link). If the value of AllowedEffects is System.Windows.Forms.DragDropEffects, then the drag operation is not started. Note that if a floater image is used, the Link effect is not supported and the drag operation will be aborted. The floater must be copied or moved. System.Windows.Forms.Control.DoDragDrop(System.Object,System.Windows.Forms.DragDropEffects) is called on the current image viewer control using the data object and effects obtained in the previous step. When this method returns and the Move effect was used, then the mode will delete the image or floater from the source item. AutoDisposeImages is used to make sure the data is not freed twice. If Link was specified, then the same RasterImage reference is placed in the target item or ImageViewer. This should go into consideration when the items are disposed by the application. For target items in the same image viewer, this is typically automatically handled by AutoDisposeImages. For target items in a different image viewer, the user is responsible for resolving the conflict on which instance will free the now shared image. TargetImageViewerMode is used to determine which image viewer is supported as the target of this drag operations. The image viewer can drag an image from one item to another in the same viewer or to a different viewer in the same application when Format is RasterImage.RasterImageDataFormat is used. If System.Windows.Forms.DataFormats.Bitmap is used, the target destination can be any other control that accepts this format (and the effect) as the drop data. As System.Windows.Forms.Control.DoDragDrop(System.Object,System.Windows.Forms.DragDropEffects) is working and the user is dragging the source image, ImageViewer will fire ItemDragDrop events that allows the user to modify the drop operation or cancel the operation. The event data contains the following members:
|SourceImageViewer||The image viewer that initiated the drag event. This is the same ImageViewer currently attached to ImageViewerDragInteractiveMode|
|TargetImageViewer||The current target image viewer for this drop operation. This changes as the user drags on the application if more than one image viewer exists. It can be null if the object is not currently over an image viewer object and the same value as SourceImageViewer if the item is being dragged over the same viewer (if supported)|
|Operation||Current drag operation such as Enter, Over, Leave or Drop|
|Location||Current location of the drag item in relation to TargetImageViewer|
|SourceItem||The item in SourceImageViewer that originated the operation|
|TargetItem||The item in TargetImageViewer that will currently be the target for the drop operation. It can be null if the image viewer does not have any items or if the object is not on top of any item boundary|
|Effect||Current effect, change this to update the cursor|
|Format||The format of the data object|
|Abort||Allows the user to cancel the operation|
Medical Web Viewer .NET