It is more common to drag files to an application than to drag files from an application to directory in windows. In my wpf application I have a list of files. I will like to enable the user to drag those files (files are custom user control with an image and label) to the desktop for example. Is it possible to do that? Moreover I will like to use the default functionality of windows. That is if I drag the file to a new disk, partition then I will like the file to be copied. If the directory happens to be on the same partition as the file I will like to move that file.
Edit
I found lots of great examples such as this one. and the one that SvenG mentioned in the comments section of this question.
none of those examples work when I need to transfer large files. The mouse cursor and application does not let me interact until the copying or moving of the file is done. I tried ruining that on a separate thread and I have not been able to do so.
Related
Hello wonderful people!
I have created some code for an application which upon startup, simply makes sure the registry has a key for my own file extension (or I guess 'class', as Windows calls it). It allows me to double-click a file with said extension and have it open with my program. Simple.
My query is this; is it possible for me to change the icon for this file class, to be different from the icon of my application? I would prefer to have some different icons for the various file extensions I'm registering, much in the same way that Photoshop for example gives a different icon for .PSD files than the actual application icon.
In simpler terms, I would like to mimic this behaviour but with my own icons and application:
Photoshop (the actual application):
Photoshop Document file:
I am working in C# and WPF. And I should also specify that the solution I'm looking for should be able to work in a scenario where I was to send my application to someone else to install on their computer; they should be able to see all the icons as described. I'd kindly request that in your answers you provide code examples, as I am not particularly familiar with working directly with the registry.
I should also specify that my application does have an icon, and this is currently what the custom filetype displays in Windows Explorer.
I'm implementing a drag and drop capability, that should allow users to drag files from my UWP C# app to an external target.
The problem is that the file is not necessarily available when dragging starts, and needs to be fetched/processed so it's ready for the drag operation.
When the file is not available yet, dragging should only be allowed to Windows explorer with the possibility of getting the target path where the file was dropped to.
The app will likely have the broadfileSystemAccess restricted capability, so a possible solution to allow dragging of unavailable items will be to drag a dummy item, and replace it with the actual file, once it's fetched.
The only relevant events I found for the draggable element flow are: dragStarting and dropCompleted, and it seems that none of them provide the relevant API.
Is there any more API which I might have missed, or any other ideas about how this might be possible?
Thanks
I am coding a C# forms application where I have a ListView with multiple items.
I am wanting to move these items up and down and am wondering if there is a forms control that I can use for this, or should I get my own image, and add this to a simple button for both the up and down action?
Yes you simply create your own button with the desired image.
If you like to use the Microsoft images, you should take a look at the folder %ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Common7\VS2010ImageLibrary. There you'll find (in another sub-folder) a VS2010ImageLibrary.zip file which contains lots of Microsoft images you are allowed to use within your applications. If you can't find your desired resolution you can take a look if you find a corresponding .ico file, cause these normally contains more resolutions then directly available as .png or .bmp file.
I am building a C# Windows Store app and I want to include a few image files with it for the app background. I want to let the user pick one of these images for the app background or pick from their own pictures. The FileOpenPicker.SuggestedStartLocation is only useful for picking from a predefined set of start locations. FilePicker contracts are too complex, include extra UI that appears within the file picker page, and let other apps get to my image files when they really should not have that access.
The only viable alternative so far is to create my own file picker page that looks close to the built-in page, but this is an ugly solution to what should not be this hard.
The best way is to devise your own. Load your included images into a selectable GridView or such and add another button or a specific tile to let the user pick from elsewhere. I wouldn't try to make the basic functionality look like the file picker.
Neither the app's install location or app data folders are intended to be user data, so there isn't an in-box way to pick from them. Advanced users can point the FileOpenPicker at those locations, but there is nothing like SuggestedStartLocations to guide the user there.
It seemed farily straight forward learning how to process files dropped onto a ListView control. But I can't seem to find anything about dragging files FROM the ListView control.
To complicate things, the ListView control is displaying an FTP directory. So I don't want to actually download the files until I confirm they have been dropped on a window that will accept them.
I know that it's possible to provide the actual data for a drag-and-drop operation only after the drop has taken place. But I'm having trouble finding anything about doing this from a ListView control using C# and Webforms.
Any tips?
Thanks!
The best link I've found on this issue yet is at Delay's Blog.
He starts by saying "This code [...] and is specifically targeted at scenarios where an application wants to allow the user to drag an element to a folder and create a file (or files) dynamically on the drop/paste. The standard .NET APIs for drag-and-drop don't support this scenario [...]"
Wow, that's the answer. For all the problems I have with C# and .NET, I run into yet another obstacle. He does have some code to workaround this. I'll be checking that out.