DiagramTool
This abstract tool class is the standard base class for all of the predefined tools.
Inherits: FrameworkElement
Implements: IDiagramTool
Properties
public bool Active { get; set; }
value = diagramTool.Active
diagramTool.Active = value
Gets or sets whether this tool is started and is actively doing something.
public Diagram Diagram { get; set; }
value = diagramTool.Diagram
diagramTool.Diagram = value
Gets the Diagram that owns this tool and for which this tool is handling input events.
public bool MouseEnabled { get; set; }
value = diagramTool.MouseEnabled
diagramTool.MouseEnabled = value
Gets or sets whether this tool can be started by a mouse event.
protected string TransactionResult { get; set; }
value = diagramTool.TransactionResult
diagramTool.TransactionResult = value
Gets or sets the name of the transaction to be committed; if null, the transaction will be rolled back.
public WheelBehavior WheelBehavior { get; set; }
value = diagramTool.WheelBehavior
diagramTool.WheelBehavior = value
Gets or sets the behavior of StandardMouseWheel.
Methods
public virtual bool CanStart()
result = diagramTool.CanStart()
This predicate is used by the diagram to decide if this tool can be started.
Returns: true if MouseEnabled is true and if the ToolManager can make this tool the current one and then call the DoStart method
protected virtual void CaptureMouse()
diagramTool.CaptureMouse()
This calls UIElement.CaptureMouse on the Diagram's Panel.
public virtual void DoActivate()
diagramTool.DoActivate()
This method is called by the diagram after setting CurrentTool, to make the new tool active.
public virtual void DoCancel()
diagramTool.DoCancel()
The diagram will call this method when the user wishes to cancel the current tool's operation.
public virtual void DoDeactivate()
diagramTool.DoDeactivate()
This method is called by the diagram on the old tool when CurrentTool is set to a new tool.
public virtual void DoKeyDown(KeyEventArgs e)
diagramTool.DoKeyDown(e)
The diagram will call this method upon a key down event.
public virtual void DoKeyUp(KeyEventArgs e)
diagramTool.DoKeyUp(e)
The diagram will call this method upon a key up event.
public virtual void DoMouseDown()
diagramTool.DoMouseDown()
The diagram will call this method upon a mouse down event.
public virtual void DoMouseMove()
diagramTool.DoMouseMove()
The diagram will call this method upon a mouse move event.
public virtual void DoMouseUp()
diagramTool.DoMouseUp()
The diagram will call this method upon a mouse up event.
public virtual void DoMouseWheel()
diagramTool.DoMouseWheel()
The diagram will call this method as the mouse wheel is rotated.
public virtual void DoStart()
diagramTool.DoStart()
This method is called by the diagram when this tool becomes the current tool.
public virtual void DoStop()
diagramTool.DoStop()
This method is called by the diagram when this tool stops being the current tool.
protected FrameworkElement FindAdornedElement(FrameworkElement handle)
result = diagramTool.FindAdornedElement(handle)
Given a handle element in an adornment, return its adornment's AdornedElement.
- handle
- a FrameworkElement
Returns: a FrameworkElement inside the adorned part, not inside this adornment
protected Part FindAdornedPart(FrameworkElement handle)
result = diagramTool.FindAdornedPart(handle)
Given a handle element in an adornment, return its adornment's AdornedPart.
- handle
- a FrameworkElement
Returns: a Part that is not an adornment
protected Adornment FindAdornment(FrameworkElement handle)
result = diagramTool.FindAdornment(handle)
Given a handle element, return its containing Adornment.
- handle
- a FrameworkElement
Returns: the containing Adornment (which might be several visual levels up) or null if the element does not belong to an Adornment
protected virtual FrameworkElement FindElementUpFrom(FrameworkElement elt, Func<FrameworkElement, bool?> pred, Predicate<FrameworkElement> valid)
result = diagramTool.FindElementUpFrom(elt, pred, valid)
Search up the chain of visual parent elements starting with the given element to find one that has true and true.
- elt
- a FrameworkElement
- pred
- When this predicate and are both true, return that element, When this predicate is false, return null. Otherwise continue up the parent chain. Stop going up the visual parent chain when reaching the Part.
- valid
- a predicate that must be true for an element for it to be returned by this method
protected virtual FrameworkElement FindElementUpFrom(FrameworkElement elt, Predicate<FrameworkElement> pred)
result = diagramTool.FindElementUpFrom(elt, pred)
Search up the chain of parent visual elements starting with the given element to find one for which is true
- elt
- a FrameworkElement
- pred
- When this predicate is true for an element, return that element. When this predicate is false for an element, continue up the visual parent chain. Stop going up the visual parent chain when reaching the Part.
Returns: null if no such element is found
protected virtual Part FindPartAt(Point p, bool selectable)
result = diagramTool.FindPartAt(p, selectable)
Find a Part at the given point, perhaps requiring it to be Selectable.
- p
- a Point in model coordinates
- selectable
- if true, the Part found must be selectable; otherwise any Part will do
Returns: the first (frontmost) Part at the location ; the part could be a Node or a Link, including temporary ones such as Adornments.
protected virtual FrameworkElement FindToolHandleAt(Point p, string category)
result = diagramTool.FindToolHandleAt(p, category)
Find an element at the given point that is a tool handle.
- p
- a Point in model coordinates
- category
- the handle's Adornment's Category
protected virtual int GetWheelDelta()
result = diagramTool.GetWheelDelta()
Return how much the wheel has turned.
Returns: If the last mouse event was the mouse wheel turning forward, this returns a positive integer. If the last mouse event was the mouse wheel turning backward, this returns a negative integer. Otherwise this returns zero.
protected virtual bool IsAltKeyDown()
result = diagramTool.IsAltKeyDown()
Return true when the alt key modifier is pressed.
protected virtual bool IsBeyondDragSize()
result = diagramTool.IsBeyondDragSize()
Return true when the last mouse point is far enough away from the first mouse down point to constitute a drag operation instead of just a potential click.
Returns: true if the first and last mouse points are more than two pixels apart in either axis
protected virtual bool IsControlKeyDown()
result = diagramTool.IsControlKeyDown()
Return true when the control key modifier is pressed.
protected virtual bool IsDoubleClick()
result = diagramTool.IsDoubleClick()
Return true when the last mouse down event occurred very close to and very soon after the previous mouse down event.
protected virtual bool IsLeftButtonDown()
result = diagramTool.IsLeftButtonDown()
Return true when the left mouse button is pressed during a mouse button event.
protected virtual bool IsRightButtonDown()
result = diagramTool.IsRightButtonDown()
Return true when the right mouse button is pressed during a mouse button event.
protected virtual bool IsShiftKeyDown()
result = diagramTool.IsShiftKeyDown()
Return true when the shift key modifier is pressed.
protected bool RaiseEvent(RoutedEvent evt, DiagramEventArgs args)
result = diagramTool.RaiseEvent(evt, args)
Raise a RoutedEvent on the Diagram.
- evt
- a RoutedEvent
- args
- a DiagramEventArgs
Returns: true if the event was raised and it was Handled
protected virtual void ReleaseMouse()
diagramTool.ReleaseMouse()
This calls UIElement.ReleaseMouseCapture on the Diagram's Panel.
protected virtual void StandardMouseSelect()
diagramTool.StandardMouseSelect()
Implement the standard behavior for selecting parts with the mouse, depending on the control and shift modifier keys.
protected virtual void StandardMouseWheel()
diagramTool.StandardMouseWheel()
Implement the standard behavior for mouse wheel events.
protected virtual bool StartTransaction(string tname)
result = diagramTool.StartTransaction(tname)
Call String) with the given transaction name.
- tname
public void StopTool()
diagramTool.StopTool()
If the CurrentTool is this tool, stop this tool and start the DefaultTool by making it be the new current tool.
protected virtual bool StopTransaction()
result = diagramTool.StopTransaction()
If TransactionResult is null, call RollbackTransaction, otherwise call String).
Returns: the result of the call to rollback or commit the transaction
public virtual void UpdateAdornments(Part part)
diagramTool.UpdateAdornments(part)
The diagram asks each tool to update any adornments the tool might use for a given part.
- part
Fields
public static readonly DependencyProperty MouseEnabledProperty
value = DiagramTool.MouseEnabledProperty
Identifies the MouseEnabled dependency property.
public static readonly DependencyProperty WheelBehaviorProperty
value = DiagramTool.WheelBehaviorProperty
Identifies the WheelBehavior property.