Cannot drag and drop on unconnected ImageViewerControl

Hello,

I’m using the MIP SDK 2020 R3.

I already know about https://developer.milestonesys.com/s/article/Drag-and-drop-enabled-MIP-plugin

I can’t find a way to enable drag and drop on a ImageViewerControl that is not yet connected:

private void Init()
        { 
            _imageViewerControl.ClickEvent += this.OnClick;
            _imageViewerControl.DoubleClickEvent += this.OnDoubleClick;
 
            _imageViewerControl.DragDrop += this.OnDragDrop;
            _imageViewerControl.DragEnter += this.OnDragEnter;
 
            _imageViewerControl.Anchor = AnchorStyles.Top | AnchorStyles.Left;
            _imageViewerControl.AllowDrop = true;
            _imageViewerControl.EnableMouseControlledPtz = true;
            _imageViewerControl.EnableMousePtzEmbeddedHandler = true;
            _imageViewerControl.EnableDigitalZoom = true;
            _imageViewerControl.EnableScrollWheel = true;
            _imageViewerControl.EnableMiddleButtonClick = true;
            _imageViewerControl.EnableVisibleCameraName = true;
            _imageViewerControl.EnableVisibleHeader = true;
            //_imageViewerControl.Initialize();
            //_imageViewerControl.Connect();
            //_imageViewerControl.ShowImageViewer = true;
        }
 
        private void OnDragEnter(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Copy;
        }
 
        private void OnDragDrop(object sender, DragEventArgs e)
        {
            var cameraGuidList = e.Data.GetData("VideoOS.RemoteClient.Application.DragDrop.DraggedDeviceIdList") as List<Guid>;
            if (cameraGuidList != null && cameraGuidList.Any())
            {
                // do stuffs
            }
            else
            {
                MessageBox.Show("DragDrop: the only supported dragged content for this plugin is a camera");
            }
        }

As soon as I connect a camera (with Connect() and Initialize() by using a FQID etc), then I can drop on the ImageViewerControl and my code works.

I found a workaround by uncommenting the 3 lines (with Initialize() and Connect() and ShowImageViewer set to true) but that feels wrong

  1. What should I do to allow drag and drop on a unconnected ImageViewerControl? My goal is to mimick the behavior of a default view item as much as possible. I only wrote my own class so I could add overlays/widgets outside of the camera part (but still inside the view)
  2. I can enable things like “EnableMouseControlledPtz” or “EnableDigitalZoom”, but while it somewhat works there’s no display like for the default view where you have the arrows and the little home to reset the view. Should I draw these myself?

Internal event handlers are not initialized until Initialize() is called, so you need to call that for the drag-drop events to trigger. But you don’t have to do the connect.

Thanks. It’s not really working tho:

If I do:

_imageViewerControl.Initialize();
_imageViewerControl.ShowImageViewer = true;

Then the black viewer is shown and I can drop on it but nothing happens. If I Connect() then I can drop and it and something happens.

If I do

_imageViewerControl.ShowImageViewer = true;
_imageViewerControl.Initialize();

Then the viewer is not shown (gray background) and I cannot drop on it.

If I have ShowIMageViewer to false then dropping on it never works. I know I drop on the correct one because I set a BackColor to blue.

We have been investigating this, but unfortunately the way the ImageViewerControl is implemented this cannot easily be supported.

I will recommend replacing it with ImageViewerWpfControl instead as this already has the support for this.

Thanks, I’ll give it a try and report.