简体   繁体   English

实现懒惰拖放

[英]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. 我正在使用IDataObject接口,但我的问题是过早地查询GetData()方法。 For instance a drag over the desktop (without any drop involved) will query the GetData() method a couple of times. 例如,在桌面上拖动(不涉及任何丢弃)将多次查询GetData()方法。 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? 现在,我的问题是:这里有什么问题 - 为什么调用GetData()方法没有任何丢弃? Is there another way to implement lazy drag & drop operations in .net? 还有另一种在.net中实现懒惰拖放操作的方法吗?

Maybe this could work for you... 也许这对你有用......

On every occurrence of the GetData() do this: 每次出现GetData()时都会这样做:

  • 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. 将其设为1秒或从实验中确定其持续时间。
  • on timer event do what has to be done. 在计时器事件上做必须做的事情。

I use similar procedure on many occasions where such workaround is needed. 我需要在需要这种解决方法的许多场合使用类似的程序。

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). 我认为正在调用GetData,以便(潜在的)放置目标可以确定它是否可以接受(潜在的)放置项。 Have you considered using a shell extension? 你考虑过使用shell扩展吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM