Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implement lazy drag & drop

I am trying to implement a lazy drag and drop operation. I want to show a listview with files to my user, when the user drags a file and drops it into a folder the content should be downloaded and delivered.

I am using the IDataObject interface, but my problem is that the GetData() method is queried way too early. For instance a drag over the desktop (without any drop involved) will query the GetData() method a couple of times. And each of these calls starts the download of the file :/

Now, my question is: What's wrong here - why is the GetData() method called without any drop? Is there another way to implement lazy drag & drop operations in .net?

like image 600
tanascius Avatar asked Sep 14 '10 12:09

tanascius


2 Answers

Maybe this could work for you...

On every occurrence of the GetData() do this:

  • you'll need some kind of a timer here.
  • if your timer is already active, kill it.
  • create and start a new timer. Make it 1sec or determine its duration from the experiment.
  • on timer event do what has to be done.

I use similar procedure on many occasions where such workaround is needed.

like image 183
Daniel Mošmondor Avatar answered Sep 27 '22 23:09

Daniel Mošmondor


I think GetData is being called so that the (potential) drop target can determine whether or not it can accept the (potential) drop item(s). Have you considered using a shell extension?

like image 27
gkrogers Avatar answered Sep 27 '22 22:09

gkrogers