سؤال

I need to add to my application a place where users can drop files and they appear just like when you drag files to a folder on windows. there is a program in here that has the functuanality that I need but it is written using windows forms and I am using wpf. so that porgram is great because it has the featurs that I need. let me list the features:

1) I can get the same exact icons that I get on my desktop.

2) I can drag folders and files ouside. note how I am draging my libraries folder on the picture

enter image description here

3) when I right click on a file I get the same context menu that I get on windows

enter image description here

4) I am able to drag files and folders in.

enter image description here

note that Example File dialog window was created using windows forms and the source code can be downloaded on the first link that I provided.

I don't want to create a file dialog otherwise I will use the openFileDialog class. I need to embed a border on my wpf application where users can drag and select files. also they can drag files outside and open files from there.

So those are the 4 things that I need to add to my wpf application let me describe the things that I have done in order to try to solve each method.

1)

I have tried looking so many different places to get the code needed to extract the icons from files and they never look identical to the ones on the desktop. I have tried: this and this one also and some others that I cannot remember right now.

note this step will be eassy I am more interested on the other features

2)

this one might be the hardest one. I have not implemented this but I been thinking that in order to achive this functionality I will have to have another window. that window will contain a Image inside. Whenever I drag my mouse on an icon I will instantiate this window passing the image that I am draging as a parameter and it will close on the venent onMouseUP. I don't know how to track on what window I let the mouse go though so I am not sure if I should try to implement this technique

3)

I have no idea how to implement this feature.

4)

that one is eassy. The only hard part is that sometimes you may drag files from a separate disk such as a thumb drive and you will have to have a method in order to copy it. or maybe you drag a link from windows start menu.

Maybe I can use the functionality of the dialog box. I thing I do not have to reinvent the wheel. I do not know that much about windows forms so I have a hard time trying to implement that code on wpf.

هل كانت مفيدة؟

المحلول

What you want is to reuse the controls from Windows, and from .NET these can be accessed via the Windows API Code Pack

Take a look at the Windows Shell section of the code pack, and specifically the Explorer Browser control which should give you all the functionality you need.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top