It is possible to drag and drop an Image between multiple DicomViewer controls even between different version of DicomObjects.

Simple sample code below shows how it can be done.

Drag and Drop in .NET version of DicomObjects

private void Viewer1_MouseDown(object sender, MouseEventArgs e)
{
	if (e.Button == System.Windows.Forms.MouseButtons.Left)
	{
		DicomImage img = Viewer1.Images[0];             
		Viewer1.DoDragDrop(img, System.Windows.Forms.DragDropEffects.Copy);
	}
}

private void Viewer2_DragDrop(object sender, DragEventArgs e)
{
	System.Windows.Forms.IDataObject io = ((System.Windows.Forms.IDataObject)(e.Data));
	Viewer2.Images.Add(io.GetData(typeof(DicomImage)) as DicomImage);
}

private void Form1_Load(object sender, EventArgs e)
{
	Viewer1.Images.Read("DICOMImage_1");
}

private void Viewer2_DragEnter(object sender, DragEventArgs e)
{
	if (e.Data.GetFormats().Contains("DicomObjects.DicomImage"))
		e.Effect = DragDropEffects.Copy;
}


\

Drag and Drop from DicomViewer COM object, to another application in .NET environment.

In order to enable drag and drop from a DicomViewer COM object, in .NET environment, Follow the following steps:

  • In the definition part of the dicom viewer (in the form “InitializeComponent” section), add the following line:
  this.axDicomViewer1.MouseDownEvent += new AxDicomObjects.IDicomViewerEvents_MouseDownEventHandler(this.axDicomViewer1_MouseDown);
  • Then implement axDicomViewer1 MouseDown:
private void axDicomViewer1_MouseDown(object sender, IDicomViewerEvents_MouseDownEvent e)
{
   if (((e.button& 1) != 0)) //left button clicked
   {
      Array arr = (Array)image.WriteArray(true,null,"100");  //convert the image to an array
      byte [] ba = new byte[arr.LongLength];
      arr.CopyTo(ba,0);
      axDicomViewer1.DoDragDrop(ba, DragDropEffects.Copy);   //send the array as the drag/drop object
   }
}
  • Then, in the target application, in your drop target control, do:
this.TARGET_CONTROL.DragDrop += new System.Windows.Forms.DragEventHandler(drag drop);
  • And implement the drag drop method:
private void drag drop(Object sender, DragEventArgs e)
{
   try
   {
       DicomImage di;
       IDataObject io = ((IDataObject)(e.Data));
       DicomImages images = new DicomImages();
       byte [] ba = (byte[]) io.GetData("System.Byte[]");
       di = (DicomImage) images.ReadArray(ba);
       if (di!=null)
       {
         //your DicomImage is now imported. you can now use it.
       }
   }
   catch
   {
      //Handle exceptions here, usually when you drag something irrelevant to this code to your control.
   }
}