DraggingTool
The DraggingTool is used to move or copy selected parts with the mouse.
Inherits: DiagramTool
Properties
public Dictionary<Part, Info> CopiedParts { get; set; }
value = draggingTool.CopiedParts
draggingTool.CopiedParts = value
Gets or sets the collection of parts that this tool has copied.
public bool CopiesEffectiveCollection { get; set; }
value = draggingTool.CopiesEffectiveCollection
draggingTool.CopiesEffectiveCollection = value
Gets or sets whether for a copying operation the extended selection is copied or only selected parts.
protected Part CurrentPart { get; set; }
value = draggingTool.CurrentPart
draggingTool.CurrentPart = value
Gets or sets the Part found at the mouse point by StandardMouseSelect.
public bool DraggableLinks { get; set; }
value = draggingTool.DraggableLinks
draggingTool.DraggableLinks = value
Gets or sets whether the user can drag a single Link, disconnecting it from its connected nodes and possibly connecting it to valid ports when the link is dropped.
protected Link DraggedLink { get; set; }
value = draggingTool.DraggedLink
draggingTool.DraggedLink = value
Gets or sets the Link that may be dragged and reconnected when DraggableLinks is true.
public Dictionary<Part, Info> DraggedParts { get; set; }
value = draggingTool.DraggedParts
draggingTool.DraggedParts = value
Gets or sets the collection of Parts being dragged.
protected bool DragOutStarted { get; set; }
value = draggingTool.DragOutStarted
draggingTool.DragOutStarted = value
Gets or sets whether a potentially external drag-and-drop has been started by this tool.
protected Part DragOverPart { get; set; }
value = draggingTool.DragOverPart
draggingTool.DragOverPart = value
Gets or sets a Part, not being dragged, that the mouse is over, and sets its IsDropOntoAccepted property appropriately.
public DragOverSnapArea DragOverSnapArea { get; set; }
value = draggingTool.DragOverSnapArea
draggingTool.DragOverSnapArea = value
Gets or sets whether dragging any parts over the diagram or over any parts causes their position to be snapped to grid points.
public bool DropOntoEnabled { get; set; }
value = draggingTool.DropOntoEnabled
draggingTool.DropOntoEnabled = value
Gets or sets whether stationary parts get their IsDropOntoAccepted property temporarily set to true during a drag.
internal bool Dropped { get; set; }
value = draggingTool.Dropped
draggingTool.Dropped = value
Gets or sets whether a drop has occurred after a drag-out had started.
public string FromPortId { get; set; }
value = draggingTool.FromPortId
draggingTool.FromPortId = value
Gets or sets the port identifier used when Point) creates a new link due to DropOntoBehavior is AddsLinkFromNode, AddsLinkToNode, or SplicesIntoLink.
public EffectiveCollectionInclusions Inclusions { get; set; }
value = draggingTool.Inclusions
draggingTool.Inclusions = value
Gets or sets whether moving or copying a node also includes all of the node's children and their descendants, along with the links to those additional nodes.
public bool IsRealtime { get; set; }
value = draggingTool.IsRealtime
draggingTool.IsRealtime = value
Gets or sets whether parts move continuously during a drag or if a simple object is dragged instead, with the parts actually moving only upon a mouse up.
public static DraggingTool Source { get; internal set; }
value = DraggingTool.Source
DraggingTool.Source = value
This is an experimental property that gets the DraggingTool that is the source of a simulated drag-and-drop.
protected Point StartPoint { get; set; }
value = draggingTool.StartPoint
draggingTool.StartPoint = value
Gets or sets the mouse point from which parts start to move.
public string ToPortId { get; set; }
value = draggingTool.ToPortId
draggingTool.ToPortId = value
Gets or sets the port identifier used when Point) creates a new link due to DropOntoBehavior is AddsLinkFromNode, AddsLinkToNode, or SplicesIntoLink.
Methods
public virtual IDataCollection AcceptData(IDataObject dataobj)
result = draggingTool.AcceptData(dataobj)
Convert an IDataObject into an IDataCollection.
- dataobj
- An IDataObject, typically the value of DragEventArgs.Data
Returns: An IDataCollection that the diagram's model can copy
public override bool CanStart()
result = draggingTool.CanStart()
This tool can run if this diagram allows selection and moves/copies/dragging-out, if the mouse has moved far enough away to be a drag and not a click, and if FindDraggablePart has found a selectable part at the mouse-down point.
public virtual Dictionary<Part, Info> ComputeEffectiveCollection(IEnumerable<Part> parts)
result = draggingTool.ComputeEffectiveCollection(parts)
Find the actual collection of nodes and links to be moved or copied, given an initial collection.
- parts
Returns: a Dictionary of Parts, mapped to Infos holding their original Locations
protected virtual Point ComputeFocusPoint(IEnumerable<Part> parts)
result = draggingTool.ComputeFocusPoint(parts)
Determine the focus point or hot-spot point for an external drag.
- parts
- the copied Nodes and Links being dragged
Returns: a Point in model coordinates
protected virtual Point ComputeMove(Node n, Point newloc, Dictionary<Part, Info> draggedparts)
result = draggingTool.ComputeMove(n, newloc, draggedparts)
This method computes the new location for a node, given a new desired location and a dictionary of dragged parts.
- n
- the Node being moved
- newloc
- the proposed new Location for the node , in model coordinates
- draggedparts
- a Dictionary of Parts being dragged
Returns: a new location for the node, in model coordinates
protected virtual bool ConsiderDragOver(Point pt, Part p)
result = draggingTool.ConsiderDragOver(pt, p)
Determine if the currently dragged selection (DraggedParts or CopiedParts) would be valid to be dropped onto the target part , depending on its DropOntoBehavior.
- pt
- normally the current mouse point, in model coordinates
- p
- the Part under the mouse point that the selection might be dropped onto
protected virtual bool ConsiderSnapTo(Node moving, Point pt, Node snapper, Dictionary<Part, Info> draggedparts)
result = draggingTool.ConsiderSnapTo(moving, pt, snapper, draggedparts)
This predicate is true if the given node can control the movement of the given node.
- moving
- the Node being dragged
- pt
- a Point in model coordinates, typically the current mouse point
- snapper
- the Node that might control the node's movement
- draggedparts
- a Dictionary of Parts being dragged
Returns: true if the is not in the and is DragOverSnapEnabled
public override void DoActivate()
draggingTool.DoActivate()
Start the dragging operation.
protected virtual DragDropEffects DoDragDrop(IDataCollection data, DragDropEffects eff)
result = draggingTool.DoDragDrop(data, eff)
Call DragDrop.DoDragDrop.
- data
- this represents the data to be dragged
- eff
- this is passed as the third argument to DragDrop.DoDragDrop
Returns: the result of calling DragDrop.DoDragDrop
public virtual void DoDragEnter(DragEventArgs e)
draggingTool.DoDragEnter(e)
Update the DragEventArgs.Effects.
- e
public virtual void DoDragLeave(DragEventArgs e)
draggingTool.DoDragLeave(e)
If no drop is allowed, remove any temporary copied parts.
- e
protected virtual void DoDragOut()
draggingTool.DoDragOut()
Start a drag-and-drop operation.
public virtual void DoDragOver(DragEventArgs e)
draggingTool.DoDragOver(e)
For copies or external moves, create and move copied parts for the drag-and-drop data.
- e
public virtual void DoDrop(DragEventArgs e)
draggingTool.DoDrop(e)
Perform the drop of a drag-and-drop.
- e
public virtual void DoGiveFeedback(GiveFeedbackEventArgs e)
draggingTool.DoGiveFeedback(e)
By default this does nothing.
- e
public override void DoKeyDown(KeyEventArgs e)
draggingTool.DoKeyDown(e)
Handle switching between copying and moving modes as the Control key is pressed or released.
- e
public override void DoKeyUp(KeyEventArgs e)
draggingTool.DoKeyUp(e)
Handle switching between copying and moving modes as the Control key is pressed or released.
- e
public override void DoMouseMove()
draggingTool.DoMouseMove()
As the user moves the mouse, move the collection of CopiedParts or DraggedParts, depending on whether MayCopy or MayMove is true.
public override void DoMouseUp()
draggingTool.DoMouseUp()
On a mouse-up finish moving or copying the effective selection.
public virtual void DoQueryContinueDrag(QueryContinueDragEventArgs e)
draggingTool.DoQueryContinueDrag(e)
If the user hits the ESCAPE key, call DoCancel to abort this tool.
- e
public override void DoStop()
draggingTool.DoStop()
Finish and clean-up after a dragging operation.
protected virtual void DragOver(Point pt, bool moving, bool copying)
draggingTool.DragOver(pt, moving, copying)
Affect some stationary unselected objects that are under a given point, and consider auto-scrolling.
- pt
- normally the current mouse point, in model coordinates
- moving
- copying
protected virtual void DropOnto(Point pt)
draggingTool.DropOnto(pt)
Perform any additional side-effects after a drop.
- pt
protected virtual Part FindDraggablePart()
result = draggingTool.FindDraggablePart()
Return the selectable and movable/copyable Part at the mouse-down point.
Returns: null if there is no selectable Part at the point, or if CanMove and CanCopy are both false.
public virtual bool IsValidLink(Node fromnode, Node tonode, Link relink)
result = draggingTool.IsValidLink(fromnode, tonode, relink)
This predicate is called to determine whether a Node may be reconnected by Point).
- fromnode
- tonode
- relink
- the Link to relink to connect the and the
Returns: the result of calling Object) if is null, or if is supplied, the result of calling Object), Object), or Object).
public virtual bool IsValidMember(Group group, Node node)
result = draggingTool.IsValidMember(group, node)
This predicate is called to determine whether a Node may be added as a member of the Group by Point).
- group
- this may be null if the node is being added as a top-level node
- node
- a Node, possibly another Group
Returns: the result of calling Object)
protected virtual FrameworkElement MakeDragImage(Rect bounds)
result = draggingTool.MakeDragImage(bounds)
Create a representation of the Parts that are being dragged when IsRealtime is false.
- bounds
- The bounds occupied by the DraggedParts, in model coordinates
Returns: FrameworkElement
public virtual bool MayAcceptData(IDataObject dataobj)
result = draggingTool.MayAcceptData(dataobj)
Decide whether an IDataObject is suitable for copying into this diagram's model.
- dataobj
- An IDataObject, typically the value of DragEventArgs.Data
Returns: By default, this checks whether the dataobject has data in the model's DataFormat or in the model's GetNodeType.
protected virtual bool MayCopy()
result = draggingTool.MayCopy()
This predicate is true when the view allows objects to be copied and inserted, and some object in the diagram's selection is copyable, and the user is holding down the Control key.
protected virtual bool MayCopyExternal(DragEventArgs e)
result = draggingTool.MayCopyExternal(e)
This predicate is true if the user may copy the selection on an external drag-and-drop.
- e
Returns: False if the AllowedEffects does not allow copy. False if Shift key modifier applies (trying to require a move). False if the diagram IsReadOnly or does not AllowInsert. False if the drag-and-drop started in this control. False if the model is not Modifiable. False if there is no drag-and-drop data of the model's DataFormat. Otherwise true.
protected virtual bool MayCopyInternal(DragEventArgs e)
result = draggingTool.MayCopyInternal(e)
This predicate is true if the user may copy the selection on an internal drag-and-drop.
- e
Returns: False if the AllowedEffects does not allow copy. False if Shift key modifier applies (trying to require a move). False if the diagram IsReadOnly or does not AllowInsert. False if the drag-and-drop came from another control. False if the model is not Modifiable. Otherwise true.
protected virtual bool MayMove()
result = draggingTool.MayMove()
This predicate is true when the view allows objects to be moved, and some object in the Selection is movable.
protected virtual bool MayMoveExternal(DragEventArgs e)
result = draggingTool.MayMoveExternal(e)
This predicate is true if the user may move the selection on an external drag-and-drop.
- e
Returns: False if the AllowedEffects does not allow move. False if Control key modifier applies (trying to require a copy). False if the diagram IsReadOnly or does not AllowInsert. False if the drag-and-drop started in this control. False if the model is not Modifiable. False if there is no drag-and-drop data of the model's DataFormat. Otherwise true.
protected virtual bool MayMoveInternal(DragEventArgs e)
result = draggingTool.MayMoveInternal(e)
This predicate is true if the user may move the selection on an internal drag-and-drop.
- e
Returns: False if the AllowedEffects does not allow move. False if Control key modifier applies (trying to require a copy). False if the diagram IsReadOnly or does not AllowMove. False if the drag-and-drop came from another control. Otherwise true.
public virtual void MoveParts(Dictionary<Part, Info> parts, Point offset)
draggingTool.MoveParts(parts, offset)
Move a collection of Parts by a given offset.
- parts
- a Dictionary of parts, mapped to Info values that include the nodes' original locations
- offset
- a Point value in model coordinates
protected virtual Point SnapTo(Node moving, Point pt, Node snapper, Dictionary<Part, Info> draggedparts)
result = draggingTool.SnapTo(moving, pt, snapper, draggedparts)
Compute the new location for a node, given another node that is controlling its movement.
- moving
- the Node being dragged
- pt
- the Point in model coordinates to which the node is being dragged
- snapper
- the Node, typically a grid, which is controlling the drag snapping
- draggedparts
- a Dictionary of Parts being dragged
Returns: a new node location, in model coordinates
protected override void StandardMouseSelect()
draggingTool.StandardMouseSelect()
Don't have the Control modifier unselect an already selected part.
Fields
public static readonly DependencyProperty CopiesEffectiveCollectionProperty
value = DraggingTool.CopiesEffectiveCollectionProperty
Identifies the CopiesEffectiveCollection dependency property.
public static readonly DependencyProperty DraggableLinksProperty
value = DraggingTool.DraggableLinksProperty
Identifies the DraggableLinks dependency property.
public static readonly DependencyProperty DragOverSnapAreaProperty
value = DraggingTool.DragOverSnapAreaProperty
Identifies the DragOverSnapArea dependency property.
public static readonly DependencyProperty DropOntoEnabledProperty
value = DraggingTool.DropOntoEnabledProperty
Identifies the DropOntoEnabled dependency property.
public static readonly DependencyProperty FromPortIdProperty
value = DraggingTool.FromPortIdProperty
Identifies the FromPortId dependency property.
public static readonly DependencyProperty InclusionsProperty
value = DraggingTool.InclusionsProperty
Identifies the Inclusions dependency property.
public static readonly DependencyProperty IsRealtimeProperty
value = DraggingTool.IsRealtimeProperty
Identifies the IsRealtime dependency property.
public static readonly DependencyProperty ToPortIdProperty
value = DraggingTool.ToPortIdProperty
Identifies the ToPortId dependency property.