DiagramPanel

StockSharp.Xaml.Diagram.GXDiagram

The DiagramPanel is the central class of a Diagram, holding all of the Layers of Parts, responsible for translation (scrolling) and scaling (zooming) and alignment, keeping track of the diagram's bounds, and having various hit-testing methods used to search the diagram for particular elements.

继承自: Panel

实现: IScrollInfo

构造函数

DiagramPanel()

Construct an empty DiagramPanel.

属性

AdornmentLayer : NodeLayer

Gets the standard layer used to hold Adornments, which is normally in front of all of the other layers.

AutoScrollDelay : int

Gets or sets how long to wait before autoscrolling.

AutoScrollRegion : Thickness

Gets or sets the margin in the panel where a mouse drag will automatically cause the view to scroll.

AutoScrollTime : int

Gets or sets how quickly to change the Position when the mouse is in the AutoScrollRegion.

CanHorizontallyScroll : bool

Gets or sets whether the user can scroll horizontally. (Implements IScrollInfo.)

CanVerticallyScroll : bool

Gets or sets whether the user can scroll vertically. (Implements IScrollInfo.)

Diagram : Diagram

Gets the Diagram that this panel is in.

DiagramBounds : Rect

Gets or sets the model-coordinate bounds of the diagram.

ExtentHeight : double

Get the vertical size of the scrollable part of this diagram, in control (device independent pixel) units. (Implements IScrollInfo.)

ExtentWidth : double

Get the horizontal size of the scrollable part of this diagram, in control (device independent pixel) units. (Implements IScrollInfo.)

FixedBounds : Rect

Gets or sets a fixed bounding rectangle to be returned by ComputeDiagramBounds.

HorizontalContentAlignment : HorizontalAlignment

Gets or sets how the parts are positioned in the panel when the DiagramBounds width is smaller than the ViewportWidth.

HorizontalOffset : double

Gets the horizontal offset of the diagram's parts. (Implements IScrollInfo.)

MaximumScale : double

Gets or sets the largest value that Scale may take.

MinimumScale : double

Gets or sets the smallest value greater than zero that Scale may take.

Padding : Thickness

Gets or sets the amount of extra "empty" space is reserved around the DiagramBounds.

Position : Point

Gets or sets the point, in model coordinates, shown at the top-left corner of this panel.

Scale : double

Gets or sets the scale factor at which everything is rendered.

ScrollHorizontalLineChange : double

Gets or sets the size of a "line" when scrolling horizontally.

ScrollOwner : ScrollViewer

Gets or sets the ScrollViewer that lets the user scroll this panel. (Implements IScrollInfo.)

ScrollVerticalLineChange : double

Gets or sets the size of a "line" when scrolling vertically.

Stretch : StretchPolicy

Gets or sets how the panel's Scale property is set, depending on the size of the DiagramBounds.

VerticalContentAlignment : VerticalAlignment

Gets or sets how the parts are positioned in the panel when the DiagramBounds width is smaller than the ViewportWidth.

VerticalOffset : double

Gets the vertical offset of the diagram's parts. (Implements IScrollInfo.)

ViewportBounds : Rect

Gets the visible part of this panel, in model coordinates.

ViewportHeight : double

Get the vertical size of the visible part of this panel, in control (device independent pixel) units. (Implements IScrollInfo.)

ViewportWidth : double

Get the horizontal size of the visible part of this panel, in control (device independent pixel) units. (Implements IScrollInfo.)

ZoomPoint : Point

Gets or sets the apparent focus point used when zooming in or out.

ZoomTime : int

Gets or sets how quickly to change the Scale and/or Position properties when adapting to DiagramBounds changes or panel size changes causing content re-alignment, or in calls to Rect) or Action).

方法

ArrangeOverride(Size) : Size

Arrange each of the Layers in this panel.

finalSize
CenterPart(Part)

Center a Part's bounds within this viewport.

part
CenterPart(Part, Action)

Center a Part's bounds within this viewport.

part
afterwards
an Action to be performed after the animation is finished; may be null
CenterRect(Rect, Action)

Center a particular area of the diagram within this viewport.

bounds
a Rect in model coordinates
afterwards
an Action to be performed after the animation is finished; may be null
ComputeAutoScrollPosition(Point) : Point

This method is called to determine the next position in the document for this view, given a point at which the user is dragging the mouse.

viewPnt
The mouse point, in control coordinates.
ComputeBounds(IEnumerable<Part>) : Rect

Compute the bounding rectangle that surrounds a given collection of parts.

parts

返回值: the union of the Bounds of all of the parts in , or Rect.Empty if there are no parts

ComputeDiagramBounds() : Rect

This is called by UpdateDiagramBounds to determine a new value for DiagramBounds.

返回值: a Rect in model coordinates

CreateBackgroundGridPattern() : GridPattern

Create the GridPattern for the whole diagram, using the GridPatternTemplate data template.

返回值: the unbound Node holding the GridPattern

DoAutoScroll(Point)

Start or continue automatically scrolling the view during a mouse drag.

modelPnt
the current mouse point, in model coordinates
DoMakeVisible(UIElement, Rect) : Rect

This overridable method changes the Position so that the given element becomes visible in the viewport.

elt
a UIElement that is in the visual tree of this panel
rectangle
The region of the element to bring into view; if this is empty, this defaults to the element's parent Part's Bounds.
FindElementAt``1(Point, Func<Visual, T>, Predicate<T>, SearchLayers)

Search all parts that are at a given point that meet a given predicate, and return the first element that matches.

p
a Point in model coordinates
navig
This is a function that is given an element at the given point and returns an element of type to be considered by the predicate . Typically the function will find the ancestor Part or Node.
pred
This is a predicate that is given an element of type ; If the predicate returns true, this method returns that element; if it returns false, the search continues for elements at the given point. If this predicate argument is null, no filtering of elements is done -- the first one found is returned.
layers
The kinds of Layers to search in. For example, if you are looking for a Node, using the value Nodes, this will speed up the search by ignore layers containing Links.

返回值: an element of type , or null if none is found

FindElementsAt``1(Point, Func<Visual, T>, Predicate<T>, SearchLayers)

Search all parts that are at a given point that meet a given predicate, and return a collection of elements that match.

p
a Point in model coordinates
navig
This is a function that is given an element at the given point and returns an element of type to be considered by the predicate . Typically the function will find the ancestor Part or Node.
pred
This is a predicate that is given an element of type ; if the predicate returns true, this method includes that element in its results. If this predicate argument is null, no filtering of elements is done -- all are included.
layers
The kinds of Layers to search in. For example, if you are looking for Nodes, using the value Nodes, this will speed up the search by ignoring layers containing Links.

返回值: a perhaps empty collection of elements of type

FindElementsIn``1(Rect, Func<Visual, T>, Predicate<T>, SearchLayers)

Find elements that are within a rectangle.

rect
a Rect in model coordinates
navig
This is a function that is given an element at the given point and returns an element of type to be considered by the predicate . Typically the function will find the ancestor Part or Node.
pred
This is a predicate that is given an element of type ; if the predicate returns true, this method includes that element in its results.
layers
The kinds of Layers to search in. For example, if you are looking for Nodes, using the value Nodes, this will speed up the search by ignoring layers containing Links.

返回值: a perhaps empty collection of elements of type

FindElementsNear``1(Point, double, Func<Visual, T>, Predicate<T>, SearchLayers)

Find elements that are within a distance of a point.

p
a Point in model coordinates
dist
the distance, in model coordinates
navig
This is a function that is given an element at the given point and returns an element of type to be considered by the predicate . Typically the function will find the ancestor Part or Node.
pred
This is a predicate that is given an element of type ; if the predicate returns true, this method includes that element in its results.
layers
The kinds of Layers to search in. For example, if you are looking for Nodes, using the value Nodes, this will speed up the search by ignoring layers containing Links.

返回值: an element of type , or null if none is found

FindElementsWithin``1(Geometry, Func<Visual, T>, Predicate<T>, SearchLayers)

Search all parts that are at inside a given geometry that meet a given predicate, and return a collection of elements that match.

geo
a Geometry in model coordinates
navig
This is a function that is given an element at the given point and returns an element of type to be considered by the predicate . Typically the function will find the ancestor Part or Node.
pred
This is a predicate that is given an element of type ; if the predicate returns true, this method includes that element in its results.
layers
The kinds of Layers to search in. For example, if you are looking for Nodes, using the value Nodes, this will speed up the search by ignoring layers containing Links.

返回值: a perhaps empty collection of elements of type

FindLayer``1(string)

Find a Layer of the given type with exactly the same Id as the given .

name
FindPartAt``1(Point, Predicate<T>, SearchLayers)

Return the front-most Part that is at a given point.

p
a Point in model coordinates
pred
This is a predicate that is given an part of type ; if the predicate returns true, this method returns that part. If this argument is null, this returns the first part it finds at the point.
layers
The kinds of Layers to search in. For example, if you are looking for Nodes, using the value Nodes, this will speed up the search by ignoring layers containing Links.

返回值: null if no such part is found

FindPartsAt``1(Point, SearchLayers)

Return all of the Parts that are at a given point.

p
a Point in model coordinates
layers
The kinds of Layers to search in. For example, if you are looking for Nodes, using the value Nodes, this will speed up the search by ignoring layers containing Links.

返回值: All of the Parts of the given type that are at the Point and that are in the kinds of layers indicated by . This returns an empty list if no qualifying parts are found.

FindPartsIn``1(Rect, SearchFlags, SearchInclusion, SearchLayers)

Find parts that are within a rectangle.

rect
a Rect in model coordinates
srch
Which kinds of parts to include; a typical value might be SelectableParts.
overlap
The required geometric relationship with the part; the typical value is Inside.
layers
The kinds of Layers to search in. For example, if you are looking for Nodes, using the value Nodes, this will speed up the search by ignoring layers containing Links.
FindPartsNear``1(Point, double, SearchFlags, SearchInclusion, SearchLayers)

Find parts that are near a point.

p
a Point in model coordinates
dist
the distance, in model coordinates
srch
Which kinds of parts to include; a typical value might be SelectableParts.
overlap
The required geometric relationship with the part; the typical value is Inside.
layers
The kinds of Layers to search in. For example, if you are looking for Nodes, using the value Nodes, this will speed up the search by ignoring layers containing Links.
FindPartsWithin``1(Geometry, SearchFlags, SearchInclusion, SearchLayers)

Search all parts that are at inside a given geometry that meet certain criteria and return a collection of those that match.

geo
a Geometry in model coordinates
srch
Which kinds of parts to include; a typical value might be SelectableParts.
overlap
The required geometric relationship with the geometry; the typical value is Inside.
layers
The kinds of Layers to search in. For example, if you are looking for Nodes, using the value Nodes, this will speed up the search by ignoring layers containing Links.

返回值: a perhaps empty collection of elements of type

GetLayer``1(string)

Find a Layer of the given type with exactly the same Id as the given , or return a default layer of the given type.

name
InitializeLayers()

If there are no Layers in this panel's collection of Children, create the standard set of layers.

IsDoubleClick(MouseButtonEventArgs) : bool

This predicate is true if the mouse button event represents a double-click.

e
IsUnoccupied(Rect, Predicate<Part>) : bool

Returns true if there are any nodes within or intersecting the given rectangular region.

r
a Rect in model coordinates
skip
a predicate that should return true for nodes to be ignored when checking for collisions, usually the node in the document that you are considering moving; may be null to consider all non-temporary nodes
LineDown()

Increases the VerticalOffset by ScrollVerticalLineChange. (Implements IScrollInfo.)

LineLeft()

Decreases the HorizontalOffset by ScrollHorizontalLineChange. (Implements IScrollInfo.)

LineRight()

Increases the HorizontalOffset by ScrollHorizontalLineChange. (Implements IScrollInfo.)

LineUp()

Decreases the VerticalOffset by ScrollVerticalLineChange. (Implements IScrollInfo.)

MakeBitmap(Size, double, Point, double) : BitmapSource

Return a bitmap showing the parts in a particular area, drawn at a given scale.

bmpsize
the size of the resulting bitmap
dpi
bitmap resolution
viewpos
a Point in model coordinates
scale
a value of 1.0 is normal; the value must be a positive number. Smaller values produce smaller-looking parts.

返回值: a BitmapSource

MakeBitmap() : BitmapSource

Generates a bitmap displaying the parts currently visible in the diagram.

返回值: a BitmapSource

MakeBitmap(Size, double, Point, double, Action<BitmapSource>) : BitmapSource

Return a bitmap showing the parts in a particular area, drawn at a given scale.

bmpsize
the size of the resulting bitmap, rounded up to the nearest integer
dpi
bitmap resolution
viewpos
a Point in model coordinates for the top-left corner of the area to be rendered
scale
a value of 1.0 is normal; the value must be a positive number. Smaller values produce smaller-looking parts.
act
an Action taking the BitmapSource to be performed later; this may be null

返回值: a BitmapSource

MakeVisible(Visual, Rect) : Rect

Scroll the diagram so that a given element () is in the viewport. (Implements IScrollInfo.)

visual
rectangle
The region of the element to bring into view. This value is normally Rect.Empty, meaning as much of the whole visual element as will fit into the viewport.

返回值: the result of calling Rect)

MeasureOverride(Size) : Size

Measure each of the Layers in this panel.

availableSize
MouseWheelDown()

Increases the VerticalOffset by ScrollVerticalLineChange times the number of lines to scroll for mouse wheel rotation. (Implements IScrollInfo.)

MouseWheelLeft()

Decreases the HorizontalOffset by ScrollHorizontalLineChange times the number of lines to scroll for mouse wheel rotation. (Implements IScrollInfo.)

MouseWheelRight()

Increases the HorizontalOffset by ScrollHorizontalLineChange times the number of lines to scroll for mouse wheel rotation. (Implements IScrollInfo.)

MouseWheelUp()

Decreases the VerticalOffset by ScrollVerticalLineChange times the number of lines to scroll for mouse wheel rotation. (Implements IScrollInfo.)

OnBoundsAlignmentChanged()

This overridable method is called when the DiagramBounds or HorizontalContentAlignment or VerticalContentAlignment or Stretch properties change.

OnDiagramBoundsChanged(RoutedPropertyChangedEventArgs<Rect>)

Raise the DiagramBoundsChanged event.

e
OnDragEnter(DragEventArgs)

Handle a DragEnter event.

e
OnDragLeave(DragEventArgs)

Handle a DragLeave event.

e
OnDragOver(DragEventArgs)

Handle a DragOver event.

e
OnDrop(DragEventArgs)

Handle a Drop event.

e
OnGiveFeedback(GiveFeedbackEventArgs)

Handle a GiveFeedback event.

e
OnInitialLayoutCompleted()

This overridable method is called after the first layout has been performed and the DiagramBounds has been computed.

OnLayoutCompleted()

This overridable method is called after each layout has been performed and the DiagramBounds has been computed.

OnLostMouseCapture(MouseEventArgs)

Handle the event when mouse capture is lost.

e
OnMouseDown(MouseButtonEventArgs)

Handle a mouse down event.

e
OnMouseEnter(MouseEventArgs)

Handle a mouse enter event.

e
OnMouseMove(MouseEventArgs)

Handle a mouse move event.

e
OnMouseUp(MouseButtonEventArgs)

Handle a mouse up event.

e
OnMouseWheel(MouseWheelEventArgs)

Handle a mouse wheel event.

e
OnPositionChanged(Point, Point)

This overridable method is called when the Position changes.

oldpos
a Point in model coordinates
newpos
a Point in model coordinates
OnQueryContinueDrag(QueryContinueDragEventArgs)

Handle a QueryContinueDrag event.

e
OnScaleChanged(double, double)

This overridable method is called when the Scale changes.

oldscale
a double
newscale
a double
OnSizeChanged(Size, Size)

This overridable method is called when the panel's actual size changes.

oldsize
a Size in element coordinates
newsize
a Size in element coordinates
OnViewportBoundsChanged(RoutedPropertyChangedEventArgs<Rect>)

Raise the ViewportBoundsChanged event.

e
OnVisualParentChanged(DependencyObject)

Every DiagramPanel should be in the visual tree of a Diagram.

oldParent
PageDown()

Increases the VerticalOffset by ViewportHeight. (Implements IScrollInfo.)

PageLeft()

Decreases the HorizontalOffset by ViewportWidth. (Implements IScrollInfo.)

PageRight()

Increases the HorizontalOffset by ViewportWidth. (Implements IScrollInfo.)

PageUp()

Decreases the VerticalOffset by ViewportHeight. (Implements IScrollInfo.)

PerformGesture(GestureModifiers, Gesture, Point, Point, Diagram)

Simulate some mouse events.

modifiers
a GestureModifiers value, some combination of Control, Shift, and Alt
action
a Gesture value, typically MouseLeftButton; a value of None does nothing
down
the Point in model coordinates for the mouse down event; this value must be within the ViewportBounds
up
the Point in model coordinates for the mouse up event; this value must be within the ViewportBounds
other
The Diagram where the mouse up occurs. If this is different from this panel's Diagram, a simulated drag-and-drop will occur. (This does not use real Windows drag-and-drop in WPF.) This may be null to use this panel's diagram, thus keeping the whole gesture within this one diagram.
SetHorizontalOffset(double)

Change the value of HorizontalOffset by changing the value of Position. (Implements IScrollInfo.)

offset
SetScaleAndPosition(double, Point, int, Action)

Set the Scale and Position properties with animation.

newscale
the new positive double value for Scale
newpos
the new Point value for Position
animationtime
a time in milliseconds; if a very short time, no animation occurs and the properties are simply set
act
an Action to perform after the animation is finished; null to do nothing afterwards
SetVerticalOffset(double)

Change the value of VerticalOffset by changing the value of Position. (Implements IScrollInfo.)

offset
StopAutoScroll()

Stop any ongoing auto-scroll action.

TransformModelToView(Point) : Point

Convert a Point in model coordinates to element coordinates.

p
TransformViewToModel(Point) : Point

Convert a Point in element coordinates to model coordinates.

p
UpdateDiagramBounds()

Request that the DiagramBounds value be updated, with a call to ComputeDiagramBounds.

ZoomToFit()

Change the Scale so that everything within the DiagramBounds fits within the viewport.

ZoomToFit(StretchPolicy, Action)

Change the Scale so that everything within the DiagramBounds fits within the viewport.

policy
normally a value of Uniform, but may be UniformToFill
afterwards
an Action to be performed after the animation is finished; may be null

事件

DiagramBoundsChanged : RoutedPropertyChangedEventHandler<Rect>

This event occurs when the diagram's bounds or alignment changes.

ViewportBoundsChanged : RoutedPropertyChangedEventHandler<Rect>

This event occurs when the viewport changes.

字段

AutoScrollDelayProperty : DependencyProperty

Identifies the AutoScrollDelay dependency property.

AutoScrollRegionProperty : DependencyProperty

Identifies the AutoScrollRegion dependency property.

AutoScrollTimeProperty : DependencyProperty

Identifies the AutoScrollTime dependency property.

CanHorizontallyScrollProperty : DependencyProperty

Identifies the CanHorizontallyScroll dependency property.

CanVerticallyScrollProperty : DependencyProperty

Identifies the CanVerticallyScroll dependency property.

DiagramBoundsChangedEvent : RoutedEvent

Identifies the DiagramBoundsChanged routed event.

DiagramBoundsProperty : DependencyProperty

Identifies the DiagramBounds dependency property.

FixedBoundsProperty : DependencyProperty

Identifies the FixedBounds dependency property.

HorizontalContentAlignmentProperty : DependencyProperty

Identifies the HorizontalContentAlignment dependency property.

MaximumScaleProperty : DependencyProperty

Identifies the MaximumScale dependency property.

MinimumScaleProperty : DependencyProperty

Identifies the MinimumScale dependency property.

PaddingProperty : DependencyProperty

Identifies the Padding dependency property.

PositionProperty : DependencyProperty

Identifies the Position dependency property.

ScaleProperty : DependencyProperty

Identifies the Scale dependency property.

ScrollHorizontalLineChangeProperty : DependencyProperty

Identifies the ScrollHorizontalLineChange dependency property.

ScrollOwnerProperty : DependencyProperty

Identifies the ScrollOwner dependency property.

ScrollVerticalLineChangeProperty : DependencyProperty

Identifies the ScrollVerticalLineChange dependency property.

StretchProperty : DependencyProperty

Identifies the Stretch dependency property.

VerticalContentAlignmentProperty : DependencyProperty

Identifies the VerticalContentAlignment dependency property.

ViewportBoundsChangedEvent : RoutedEvent

Identifies the ViewportBoundsChanged routed event.

ZoomPointProperty : DependencyProperty

Identifies the ZoomPoint dependency property.

ZoomTimeProperty : DependencyProperty

Identifies the ZoomTime dependency property.