Use custom dragging tool in drag/drop from palette

I have a custom dragging tool deriving from DraggingTool that provides indicators to the user while dragging. I would like this tool to be used while dragging from the palette into the main diagram. How can I achieve this? Thanks.

It depends on when and how you want that customized behavior to happen.

Have you tried replacing the Diagram.DraggingTool in both the Palette as well as the target Diagram?

That unfortunately doesn’t have the desired effect. I have overridden DoStart, DoStop, and DragOver to provide visual alignment guidelines and node proximity indicators (using DraggingTool.Diagram.Panel.FindPartsIn) while dragging. This depends on using the DraggingTool.CurrentPart in relation to the other DraggingTool.Diagram.Nodes, which functions correctly after a node has already been dropped from the palette. Ideally, I would be able to provide these indicators while dragging from the palette to the target diagram. Is there any way I can detect a node being dragged from the palette to the target diagram before it is dropped?

In the source Palette, that would be the Palette.DraggingTool; in the target Diagram, that would be the Diagram.DraggingTool.

You could override DraggingTool.DragOver and DraggingTool.DropOnto in the target Diagram. It isn’t clear to me from your description whether this is the case or not.

Additionally in the target diagram there will be calls to DraggingTool.DoDragEnter and DraggingTool.DoDragLeave.

It appears that DraggingTool.DoDragEnter executes at the time I am looking for. How can I get a reference to the node that is being dragged from the palette to the target Diagram? Is this node not part of the target Diagram until it is dropped? Thanks.

By default that method just sets DragEventArgs.Effects, so no temporary Parts exist yet.

You’ll need to override DraggingTool.DoDragOver and call the base method first and look at DraggingTool.CopiedParts. Or override DraggingTool.DragOver.

Thank you! DraggingTool.CopiedParts is what I was looking for.