-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support drag and drop with icon and text label #5884
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Drag images can be created today via the Note that the drag source supplies the image, but the drop destination supplies the text and icon. You cannot provide label text from a drag source. |
I can see this API from microsoft website. IDragSourceHelper2::SetFlags with flag DSH_ALLOWDROPDESCRIPTIONTEXT https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-idragsourcehelper2-setflags It will display the drag image and text at the same time. |
Would you like to do a formal API proposal so we can take it to the next level? If you have a POC - it would greatly aid in discussions. |
@wjk Can you help me to fill the formal API proposal? My English is not very good. Thank you very much. |
Good idea. |
Yes, that's a perfect effect. In this way, more data and hints can be displayed to users. |
@roland5572 - you have really good ideas. |
Thank you. I also have some ideas about WPF, if you are interested, you can check it out. |
I will check those out. For this issue, has any progress been made on a proposal? |
Okay then if nobody minds, I will take a closer look. I need to learn quite a bit more about drag and drop before I would be comfortable suggesting anything but I think with a little focus it is doable. Drag image and text. |
π
|
Drag image with drop description proof of concept. DragImageDropDescription.mp4 |
This is awesome stuff! Have you thought about whether we should support for dragging something with a drag source outside of the application? Like picking up a file from Windows to copy into your app. |
Thanks, its been really fun. I think adding support for drag images and drop descriptions for drag sources outside of the application would be really helpful. It would allow the application to display more details to the user regarding the drag-and-drop operation. |
Drag images and drop descriptions from Explorer. DragCatFromExplorer.mp4 |
Awesome! |
This will be a stretch for me but I'll start putting it together. I believe there are some other subtler features I haven't looked at yet such as the mouse cursor offset in relation to the drag image and how that allows for some cool things like insertion points with previews. |
namespace System.Windows.Forms;
public enum DropImageType
{
Invalid = -1,
None = 0,
Copy = DragDropEffects.Copy,
Move = DragDropEffects.Move,
Link = DragDropEffects.Link,
Label = 6,
Warning = 7,
NoImage = 8
}
public class DragEventArgs : EventArgs
{
// Existing:
// public DragEventArgs(IDataObject? data, int keyState, int x, int y, DragDropEffects allowedEffect, DragDropEffects effect);
public DragEventArgs(IDataObject? data, int keyState, int x, int y, DragDropEffects allowedEffect, DragDropEffects effect, DropImageType dropIcon, string message, string insert);
// Existing:
// public IDataObject? Data { get; }
// public int KeyState { get; }
// public int X { get; }
// public int Y { get; }
// public DragDropEffects AllowedEffect { get; }
// public DragDropEffects Effect { get; set; }
public DropImageType DropImageType { get; set; }
public string? Message { get; set; }
public string? MessageReplacementToken { get; set; }
}
public class GiveFeedbackEventArgs : EventArgs
{
// Existing:
// public GiveFeedbackEventArgs(DragDropEffects effect, bool useDefaultCursors);
public GiveFeedbackEventArgs(DragDropEffects effect, bool useDefaultCursors, Bitmap? dragImage, Point cursorOffset, bool useDefaultDragImage);
// Existing:
// public DragDropEffects Effect { get; }
// public bool UseDefaultCursors { get; set; }
public Bitmap? DragImage { get; set; }
public Point CursorOffset { get; set; }
public bool UseDefaultDragImage { get; set; }
}
public partial class Control
{
// Existing:
// public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects);
public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects, Bitmap dragImage, Point cursorOffset, bool useDefaultDragImage);
}
public partial class ToolStripItem
{
// Existing:
// public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects);
public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects, Bitmap dragImage, Point cursorOffset, bool useDefaultDragImage);
} |
That is awesome. I agree with the suggested changes and will start working on updating the proposal and draft PR. Thank you everyone for taking a look at this. I understand that time is short and I greatly appreciate everyone's effort on this issue. |
@willibrandon Is this work completed? Since we saw the related PR is merged and tested it in the latest .Net 7.0 build. |
Yes, @Olina-Zhang, this has been resolved by #6576. |
Verified on .NET 7.0 test pass build: .NET 7.0.100-preview.7.22370.3, issue was fixed: it supports dragging and dropping pictures and RTF files now. |
@roland5572 - I'm not sure how we're going to top this one. Good idea. |
Haha, we have plenty of issue in the back log π I'm sure you can find something to your taste there, e.g.:
api-approved
Thanks again for your contributions. |
π₯ π₯ β¬οΈβ¬οΈ Scroll to the API proposal β¬οΈβ¬οΈπ₯ π₯
About Winform drag and drop:
https://docs.microsoft.com/en-us/dotnet/desktop/winforms/input-mouse/drag-and-drop
Winforms supports drag and drop, but it displays the Windows 2000/XP old school style.
Unlike win10, win10 can provide richer display effects. If you drag and drop a file on Win10, Win10 will display an icon and a text label. Then you can know your specific operation through the text label.
Picture 1: Drag a file:
Picture 2: When you hold down the Control or Alt key, the icon and text will also be changed.
Picture 3: Drag a file to application shortcut, it will display:
So if the drag and drop can provide an Icon and Text properties, the application can display a more detailed operating instruction to users, and the application will be more modern.
The text was updated successfully, but these errors were encountered: