Drag and Drop
From DicomObjectsWiki
Using Drag and Drop from DicomViewer COM object, to another application, in .NET enviroment.
In order to enable drag and drop from a DicomViewer COM object, in .NET enviroment, 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(dragdrop);
And implement the dragdrop method.
private void dragdrop(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 expeptions here, usually when you drag something irrelevant to this code to your control.
}
}
That should be it!
Orthocrat ltd.
