ResizingTool
The ResizingTool is used to interactively change the size of an element.
Inherits: DiagramTool
Properties
protected FrameworkElement AdornedElement { get; set; }
value = resizingTool.AdornedElement
resizingTool.AdornedElement = value
Gets or sets the current FrameworkElement that is being resized.
protected Node AdornedNode { get; }
value = resizingTool.AdornedNode
Gets the current Node that the AdornedElement is in.
public Size CellSize { get; set; }
value = resizingTool.CellSize
resizingTool.CellSize = value
Gets or sets the cell size of the selected element, so that resizing is limited to multiples of the cell size.
protected FrameworkElement Handle { get; set; }
value = resizingTool.Handle
resizingTool.Handle = value
Gets or sets the current resize handle that is being dragged.
public Size MaxSize { get; set; }
value = resizingTool.MaxSize
resizingTool.MaxSize = value
Gets or sets the maximum size of the selected element.
public Size MinSize { get; set; }
value = resizingTool.MinSize
resizingTool.MinSize = value
Gets or sets the minimum size of the selected element.
protected Rect OriginalBounds { get; set; }
value = resizingTool.OriginalBounds
resizingTool.OriginalBounds = value
Gets or sets the bounds, in model coordinates, of the AdornedElement when the user started resizing.
protected Point OriginalLocation { get; set; }
value = resizingTool.OriginalLocation
resizingTool.OriginalLocation = value
Gets or sets the location, in model coordinates, of the AdornedNode when the user started resizing.
Methods
public override bool CanStart()
result = resizingTool.CanStart()
The ResizingTool may run when there is a mouse-down event on a resize handle.
protected virtual Size ComputeCellSize()
result = resizingTool.ComputeCellSize()
The size should be a multiple of the value returned by this method.
Returns: The CellSize, unless one or both of its width and height are Double.NaN or zero. If that is the case, it uses the width and/or height from the node's ResizeCellSize. But if one or both of the width and height are still Double.NaN or zero, it searches for a grid snapping node behind the AdornedNode, one that is DragOverSnapEnabled, and uses its DragOverSnapCellSize. If it cannot find such a grid snapping node, or one or both of the width and height are NaN, it uses the diagram's GridSnapCellSize if the diagram is GridSnapEnabled. Finally, it defaults to 1x1.
protected virtual Size ComputeMaxSize()
result = resizingTool.ComputeMaxSize()
The effective maximum resizing size is the minimum of MaxSize and the FrameworkElement's MaxWidth and MaxHeight.
Returns: the desired maximum Size during resizing
protected virtual Size ComputeMinSize()
result = resizingTool.ComputeMinSize()
The effective minimum resizing size is the maximum of MinSize and the FrameworkElement's MinWidth and MinHeight.
Returns: the desired minimum Size during resizing
protected virtual Rect ComputeResize(Point newPoint, Spot spot, Size min, Size max, bool reshape)
result = resizingTool.ComputeResize(newPoint, spot, min, max, reshape)
Given a Spot in the OriginalBounds and a new Point, compute the new Rect.
- newPoint
- a Point in model coordinates
- spot
- The Spot in the rectangular bounds for which the Handle is being dragged
- min
- the computed rectangle must be at least as large as these dimensions
- max
- the computed rectangle must be no larger than these dimensions
- reshape
- whether the aspect ratio of the rectangle may change
public override void DoCancel()
resizingTool.DoCancel()
Restore the OriginalBounds of the AdornedElement and stop this tool.
public override void DoDeactivate()
resizingTool.DoDeactivate()
This stops the current edit (StopTransaction).
public override void DoMouseMove()
resizingTool.DoMouseMove()
Call Rect) with a new bounds determined by the mouse point.
public override void DoMouseUp()
resizingTool.DoMouseUp()
Call Rect) with a rectangle based on the most recent mouse point, and raise an "object resized" event before stopping the tool.
protected virtual void DoResize(Rect newr)
resizingTool.DoResize(newr)
Change the AdornedElement's Width and/or Height, and perhaps the AdornedNode's Location, given a new rectangular bounds for the adorned element.
- newr
public override void DoStart()
resizingTool.DoStart()
Capture the mouse when starting this tool.
public override void DoStop()
resizingTool.DoStop()
Release the mouse capture when stopping this tool.
public override void UpdateAdornments(Part part)
resizingTool.UpdateAdornments(part)
Show an Adornment with resize handles at points along the edge of bounds of the AdornedElement, if the node is selected and visible and if CanResize is true.
- part
Fields
public static readonly DependencyProperty CellSizeProperty
value = ResizingTool.CellSizeProperty
Identifies the CellSize dependency property.
public static readonly DependencyProperty MaxSizeProperty
value = ResizingTool.MaxSizeProperty
Identifies the MaxSize dependency property.
public static readonly DependencyProperty MinSizeProperty
value = ResizingTool.MinSizeProperty
Identifies the MinSize dependency property.