Coordinates node drag-and-drop operations and their feedback for a TreeView element.
Definition
Namespace:Telerik.WinControls.UI
Assembly:Telerik.WinControls.UI.dll
Syntax:
public class TreeViewDragDropService : RadDragDropService, IDisposable, INotifyPropertyChanged, ICustomTypeDescriptor, IMessageListener
Inheritance: objectDisposableObjectRadObjectRadServiceRadDragDropServiceTreeViewDragDropService...
Derived Classes:
Implements:
Inherited Members
Constructors
Creates a drag-and-drop service for the specified TreeView element.
public TreeViewDragDropService(RadTreeViewElement owner)
The element whose nodes are handled by this service.
Properties
Gets or sets the solid color used to draw the drop-position line.
public Color DropHintColor { get; set; }
When this value is Empty, the target tree's ItemDropHint supplies the image when available. For a cross-tree drop using this fallback, the source tree's ItemDropHint is also read for positioning and must be non-null.
Gets whether the built-in node-transfer paths should copy rather than move nodes because the Alt key is held.
protected virtual bool IsCopyingNodes { get; }
Gets the TreeView element whose nodes this service handles.
protected RadTreeViewElement Owner { get; }
Gets or sets a value indicating whether drag hint should be shown.
public bool ShowDragHint { get; set; }
true if [show drag hint]; otherwise, false.
Gets or sets a value indicating whether show drop hint should be shown.
public bool ShowDropHint { get; set; }
true if [show drop hint]; otherwise, false.
Methods
Determines whether the drop event has already been handled and should not be processed by this service.
protected virtual bool CancelPreviewDragDrop(RadDropEventArgs e)
The pending drop event.
Returns:Rejects invalid node placements and otherwise prepares target expansion or auto-scroll feedback as needed.
protected virtual bool CanDragOver(DropPosition dropPosition, TreeNodeElement targetNodeElement)
The proposed placement relative to the target node.
targetNodeElementTreeNodeElementThe row being considered as a drop target.
Returns:true when the selected nodes can be dropped at the proposed position.
Determines whether the pointer is over the before-node or after-node area where a line hint is shown.
Creates a new tree node in the target RadTreeView using the information from the source tree.
protected virtual RadTreeNode CreateTreeNode(RadTreeNode sourceTreeNode)
The source tree node.
Returns:A new instance of RadTreeNode if successfull.
Disposes the current layered drop-hint window, if one has been created.
protected virtual void DisposeHint()
Clears cached drag state and releases the drop-hint window.
protected override void DisposeManagedResources()
Overrides:
Gets the selected nodes eligible to move, excluding descendants of another selected node.
protected virtual List<RadTreeNode> GetDraggedNodes(RadTreeNode draggedNode)
The node that initiated the drag.
Returns:List<RadTreeNode>
The selected root nodes to transfer, or the initiating node when no selected node is eligible.
Maps a pointer location within a target row to a before, after, or child drop position.
protected DropPosition GetDropPosition(Point dropLocation, TreeNodeElement targetNodeElement)
The pointer location in the target row's coordinate system.
targetNodeElementTreeNodeElementThe row under the pointer.
Returns:The drop position determined by the row's vertical thirds.
Copies the source tree's current selection before the drop changes it.
protected virtual List<RadTreeNode> GetSelectedNodes(RadTreeNode draggedNode)
The node that initiated the drag.
Returns:List<RadTreeNode>
A list containing the nodes selected in the source tree.
Raises item-drag notifications and creates, positions, or disposes the node drop-hint window as the pointer moves.
protected override void HandleMouseMove(Point mousePosition)
The current pointer position in screen coordinates.
Overrides:
Hides the active drag hint window.
public void HideHintWindow()
Rejects the node being dragged as its own drop target before applying the base target validation.
protected override bool IsDropTargetValid(ISupportDrop dropTarget)
The proposed drop target.
Returns:false for the dragged node itself; otherwise, the base service's validation result.
Overrides:
Processes a drop by notifying handlers, transferring accepted nodes, and updating the affected trees' selection.
protected override void OnPreviewDragDrop(RadDropEventArgs e)
The drop target, location, and handled state for this drag operation.
Overrides:
A handled drop is skipped by CancelPreviewDragDrop(RadDropEventArgs). Each node can also be rejected by the cancelable DragEnding event.
Applies the drag-hint visibility setting and forwards generic preview data as TreeView-specific event data.
protected override void OnPreviewDragHint(PreviewDragHintEventArgs e)
The generic preview data; when drag hints are disabled, its default hint is suppressed before forwarding.
Overrides:
The forwarded TreeViewPreviewDragHintEventArgs has a None position because this overload has no target-specific position.
Raises the preview-hint notification with the candidate position when the pointer is over a TreeView node.
protected virtual void OnPreviewDragHintWithDropPosition(TreeViewPreviewDragHintEventArgs e)
The target-specific drag-hint data, including the computed drop position.
Override this method to customize feedback by drop position. Call the base implementation to preserve the inherited preview notification.
Determines drop feedback for a tree or node target and raises DragOverNode for node targets.
protected override void OnPreviewDragOver(RadDragOverEventArgs e)
The drag-over event containing the hit target and current drop location.
Overrides:
Caches the source item's drag image after the base service starts.
protected override void OnStarted()
Overrides:
Releases the cached source-item image before the base service stops.
protected override void OnStopped()
Overrides:
Clears the TreeView's stored dragged node when the service is stopping without committing the operation.
protected override void OnStopping(RadServiceStoppingEventArgs e)
The service-stopping event data indicating whether the operation will be committed.
Overrides:
Applies the drop to a target row, filtering nodes through the cancelable ending event before moving or copying them.
protected virtual void PerformDragDrop(Point dropLocation, TreeNodeElement targetNodeElement, List<RadTreeNode> draggedNodes)
The pointer location in the target row's coordinate system.
targetNodeElementTreeNodeElementThe row receiving the drop.
draggedNodesList<RadTreeNode>The dragged nodes; nodes rejected by the ending event are removed from this list.
Dropping as a child uses the binding provider when available; before- and after-node placements are handled by PerformDragDropCore(DropPosition, RadTreeNode, List<RadTreeNode>).
Inserts or delegates the accepted dragged nodes before or after a target node.
protected virtual void PerformDragDropCore(DropPosition position, RadTreeNode targetNode, List<RadTreeNode> draggedNodes)
The before-node or after-node placement.
targetNodeRadTreeNodeThe node that determines the insertion location.
draggedNodesList<RadTreeNode>The dragged nodes; nodes rejected by the ending event are removed from this list.
A bound tree can handle the transfer through its binding provider; otherwise nodes are cloned for copy operations or removed and inserted for move operations.
Captures the source node from the drag context after the base service initializes it.
protected override void PerformStart()
Overrides:
Releases drop-hint resources and clears the active drag state after the base service stops.
protected override void PerformStop()
Overrides:
Raises the cancelable starting event before preparing the drag context, then raises the started event for a TreeView node.
Creates a layered drop-hint image from the configured color or, when no color is set, the target tree's item-drop shape.
protected virtual void PrepareDragHint(TreeNodeElement nodeElement)
The target row whose tree supplies the drop-hint shape and available width.
If no color or target-tree item-drop shape is available, no hint window is created.
Positions the drag hint and, over a node, displays feedback for the computed drop position.
protected override void SetHintWindowPosition(Point mousePt)
The pointer position in screen coordinates.
Overrides:
The default TreeView hint combines the position marker with the cached source-item image; preview handlers can supply custom feedback.
Shows the active drag hint window.
public void ShowHintWindow()
Positions the drop-hint window at the target row's before-node or after-node edge.
protected virtual void UpdateHintPosition(Point mousePosition)
The pointer position in screen coordinates.