-
-
Notifications
You must be signed in to change notification settings - Fork 230
Nodify_NodifyEditor
Namespace: Nodify
Assembly: Nodify
Inheritance: Object → DispatcherObject → DependencyObject → Visual → UIElement → FrameworkElement → Control → ItemsControl → Selector → MultiSelector → NodifyEditor
Implements: IScrollInfo
References: Alignment, BaseConnection, Connection, Connector, EditorState.Cutting, CuttingLine, DecoratorContainer, EditorCommands, EditorGestures, GroupingNode, InputProcessor, ItemContainer, ItemsMovedEventArgs, ItemsMovedEventHandler, Minimap, EditorState.Panning, EditorState.PanningWithMouseWheel, PendingConnection, EditorState.PushingItems, EditorState.Selecting, SelectionType, EditorState.Zooming
Groups ItemContainers and Connections in an area that you can drag, zoom and select.
public class NodifyEditor : MultiSelector, IScrollInfo
Initializes a new instance of the NodifyEditor class.
public NodifyEditor();
The list of supported connection types for cutting. Type must be derived from FrameworkElement.
public static HashSet<Type> CuttingConnectionTypes;
Field Value
protected static DependencyPropertyKey CuttingLineEndPropertyKey;
Field Value
protected static DependencyPropertyKey CuttingLineStartPropertyKey;
Field Value
protected const string ElementConnectionsHost = "PART_ConnectionsHost";
Field Value
protected const string ElementItemsHost = "PART_ItemsHost";
Field Value
protected static DependencyPropertyKey IsCuttingPropertyKey;
Field Value
protected static DependencyPropertyKey IsDraggingPropertyKey;
Field Value
protected static DependencyPropertyKey IsPanningPropertyKey;
Field Value
protected static DependencyPropertyKey IsPushingItemsPropertyKey;
Field Value
protected static DependencyPropertyKey IsSelectingPropertyKey;
Field Value
protected static DependencyPropertyKey PushedAreaOrientationPropertyKey;
Field Value
protected static DependencyPropertyKey PushedAreaPropertyKey;
Field Value
Gets the transform used to zoom on the viewport.
protected readonly ScaleTransform ScaleTransform;
Field Value
protected static DependencyPropertyKey SelectedAreaPropertyKey;
Field Value
Gets the transform used to offset the viewport.
protected readonly TranslateTransform TranslateTransform;
Field Value
protected static DependencyPropertyKey ViewportTransformPropertyKey;
Field Value
Gets or sets whether cancelling a cutting operation is allowed (see Nodify.Interactivity.EditorGestures.NodifyEditorGestures.CancelAction).
public static bool AllowCuttingCancellation { get; set; }
Property Value
Gets or sets whether cancelling a dragging operation is allowed.
public static bool AllowDraggingCancellation { get; set; }
Property Value
Gets or sets whether panning cancellation is allowed (see Nodify.Interactivity.EditorGestures.NodifyEditorGestures.CancelAction).
public static bool AllowPanningCancellation { get; set; }
Property Value
Gets or sets whether push items cancellation is allowed (see Nodify.Interactivity.EditorGestures.NodifyEditorGestures.CancelAction).
public static bool AllowPushItemsCancellation { get; set; }
Property Value
Gets or sets whether cancelling a selection operation is allowed (see Nodify.Interactivity.EditorGestures.SelectionGestures.Cancel).
public static bool AllowSelectionCancellation { get; set; }
Property Value
Gets or sets the maximum distance in pixels from the edge of the editor that will trigger auto-panning.
public double AutoPanEdgeDistance { get; set; }
Property Value
Gets or sets how often the new NodifyEditor.ViewportLocation is calculated in milliseconds when NodifyEditor.DisableAutoPanning is false.
public static double AutoPanningTickRate { get; set; }
Property Value
Gets or sets the speed used when auto-panning scaled by NodifyEditor.AutoPanningTickRate
public double AutoPanSpeed { get; set; }
Property Value
Gets or sets the maximum animation duration in seconds for bringing a location into view.
public double BringIntoViewMaxDuration { get; set; }
Property Value
Gets or sets the animation speed in pixels per second for bringing a location into view.
public double BringIntoViewSpeed { get; set; }
Property Value
Gets or sets whether multiple connections can be selected.
public bool CanSelectMultipleConnections { get; set; }
Property Value
Gets or sets whether multiple ItemContainers can be selected.
public bool CanSelectMultipleItems { get; set; }
Property Value
Invoked when the PendingConnection is completed.
Use PendingConnection.CompletedCommand if you want to control the visibility of the connection from the viewmodel.
Parameter is System.Tuple2 where System.Tuple
2.Item1 is the PendingConnection.Source and System.Tuple`2.Item2 is PendingConnection.Target.
public ICommand ConnectionCompletedCommand { get; set; }
Property Value
Gets or sets the data source that BaseConnections will be generated for.
public IEnumerable Connections { get; set; }
Property Value
Invoked when the PendingConnection is completed. Use PendingConnection.StartedCommand if you want to control the visibility of the connection from the viewmodel. Parameter is PendingConnection.Source.
public ICommand ConnectionStartedCommand { get; set; }
Property Value
Gets or sets the DataTemplate to use when generating a new BaseConnection.
public DataTemplate ConnectionTemplate { get; set; }
Property Value
Invoked when a cutting operation is completed.
public ICommand CuttingCompletedCommand { get; set; }
Property Value
Gets the end point of the CuttingLine while NodifyEditor.IsCutting is true.
public Point CuttingLineEnd { get; set; }
Property Value
Gets the start point of the CuttingLine while NodifyEditor.IsCutting is true.
public Point CuttingLineStart { get; set; }
Property Value
Gets or sets the style to use for the cutting line.
public Style CuttingLineStyle { get; set; }
Property Value
Invoked when a cutting operation is started.
public ICommand CuttingStartedCommand { get; set; }
Property Value
Gets or sets the style to use for the DecoratorContainer.
public Style DecoratorContainerStyle { get; set; }
Property Value
Gets or sets the items that will be rendered in the decorators layer via DecoratorContainers.
public IEnumerable Decorators { get; set; }
Property Value
The area covered by the DecoratorContainers.
public Rect DecoratorsExtent { get; set; }
Property Value
Gets or sets the DataTemplate to use when generating a new DecoratorContainer.
public DataTemplate DecoratorTemplate { get; set; }
Property Value
Gets or sets whether to disable the auto panning when selecting or dragging near the edge of the editor configured by NodifyEditor.AutoPanEdgeDistance.
public bool DisableAutoPanning { get; set; }
Property Value
Gets or sets whether panning should be disabled.
public bool DisablePanning { get; set; }
Property Value
Gets or sets whether zooming should be disabled.
public bool DisableZooming { get; set; }
Property Value
Invoked when the Connector.Disconnect event is raised. Can also be handled at the Connector level using the Connector.DisconnectCommand command. Parameter is the Connector's FrameworkElement.DataContext.
public ICommand DisconnectConnectorCommand { get; set; }
Property Value
Gets or sets whether to display connections on top of ItemContainers or not.
public bool DisplayConnectionsOnTop { get; set; }
Property Value
Gets or sets whether the cutting line should apply the preview style to the interesected elements.
public static bool EnableCuttingLinePreview { get; set; }
Property Value
Gets or sets if the current position of containers that are being dragged should not be committed until the end of the dragging operation.
public static bool EnableDraggingContainersOptimizations { get; set; }
Property Value
Enables selecting and deselecting items while the NodifyEditor.SelectedArea changes. Disable for maximum performance when hundreds of items are generated.
public bool EnableRealtimeSelection { get; set; }
Property Value
Gets or sets if NodifyEditors should enable optimizations based on NodifyEditor.OptimizeRenderingMinimumContainers and NodifyEditor.OptimizeRenderingZoomOutPercent.
public static bool EnableRenderingContainersOptimizations { get; set; }
Property Value
Correct ItemContainer's position after moving if starting position is not snapped to grid.
public static bool EnableSnappingCorrection { get; set; }
Property Value
Gets or sets the margin to add in all directions to the NodifyEditor.ItemsExtent or area parameter when using Nodify.NodifyEditor.FitToScreen(System.Nullable{System.Windows.Rect}).
public static double FitToScreenExtentMargin { get; set; }
Property Value
Gets or sets the value of an invisible grid used to adjust locations (snapping) of ItemContainers.
public uint GridCellSize { get; set; }
Property Value
Gets a value indicating whether the editor has a context menu.
public bool HasContextMenu { get; set; }
Property Value
Gets or sets a value indicating whether the editor uses a custom context menu.
public bool HasCustomContextMenu { get; set; }
Property Value
protected InputProcessor InputProcessor { get; set; }
Property Value
Tells if the NodifyEditor is doing operations on multiple items at once.
public bool IsBulkUpdatingItems { get; protected set; }
Property Value
Gets a value that indicates whether a cutting operation is in progress.
public bool IsCutting { get; set; }
Property Value
Gets a value that indicates whether a dragging operation is in progress.
public bool IsDragging { get; set; }
Property Value
Gets a value that indicates whether a panning operation is in progress.
public bool IsPanning { get; set; }
Property Value
Gets a value that indicates whether a pushing operation is in progress.
public bool IsPushingItems { get; set; }
Property Value
Gets a value that indicates whether a selection operation is in progress.
public bool IsSelecting { get; set; }
Property Value
Invoked when a drag operation is completed for the NodifyEditor.SelectedContainers, or when NodifyEditor.IsPushingItems is set to false.
public ICommand ItemsDragCompletedCommand { get; set; }
Property Value
Invoked when a drag operation starts for the NodifyEditor.SelectedContainers, or when NodifyEditor.IsPushingItems is set to true.
public ICommand ItemsDragStartedCommand { get; set; }
Property Value
The area covered by the ItemContainers.
public Rect ItemsExtent { get; set; }
Property Value
Invoked when a selection operation is completed (see Nodify.NodifyEditor.EndSelecting).
public ICommand ItemsSelectCompletedCommand { get; set; }
Property Value
Invoked when a selection operation is started (see Nodify.NodifyEditor.BeginSelecting(Nodify.SelectionType)).
public ICommand ItemsSelectStartedCommand { get; set; }
Property Value
Gets or sets the maximum zoom factor of the viewport
public double MaxViewportZoom { get; set; }
Property Value
Gets or sets the minimum zoom factor of the viewport
public double MinViewportZoom { get; set; }
Property Value
Gets or sets the maximum distance, in pixels, that the mouse can move before suppressing certain mouse actions. This is useful for suppressing actions like showing a System.Windows.Controls.ContextMenu if the mouse has moved significantly.
public static double MouseActionSuppressionThreshold { get; set; }
Property Value
Gets the current mouse location in graph space coordinates (relative to the NodifyEditor.ItemsHost).
public Point MouseLocation { get; protected set; }
Property Value
Gets or sets the minimum number of ItemContainers needed to trigger optimizations when reaching the NodifyEditor.OptimizeRenderingZoomOutPercent.
public static uint OptimizeRenderingMinimumContainers { get; set; }
Property Value
Gets or sets the minimum zoom out percent needed to start optimizing the rendering for ItemContainers. Value is between 0 and 1.
public static double OptimizeRenderingZoomOutPercent { get; set; }
Property Value
Gets of sets the FrameworkElement.DataContext of the PendingConnection.
public object PendingConnection { get; set; }
Property Value
Gets or sets the DataTemplate to use for the NodifyEditor.PendingConnection.
public DataTemplate PendingConnectionTemplate { get; set; }
Property Value
Gets the currently pushed area while NodifyEditor.IsPushingItems is true.
public Rect PushedArea { get; set; }
Property Value
Gets the orientation of the NodifyEditor.PushedArea.
public Orientation PushedAreaOrientation { get; set; }
Property Value
Gets or sets the style to use for the pushed area.
public Style PushedAreaStyle { get; set; }
Property Value
Invoked when the BaseConnection.Disconnect event is raised. Can also be handled at the BaseConnection level using the BaseConnection.DisconnectCommand command. Parameter is the BaseConnection's FrameworkElement.DataContext.
public ICommand RemoveConnectionCommand { get; set; }
Property Value
The number of units the mouse wheel is rotated to scroll one line.
public static double ScrollIncrement { get; set; }
Property Value
Gets the currently selected area while NodifyEditor.IsSelecting is true.
public Rect SelectedArea { get; set; }
Property Value
Gets or sets the selected connection.
public object SelectedConnection { get; set; }
Property Value
Gets or sets the selected connections in the NodifyEditor.
public IList SelectedConnections { get; set; }
Property Value
Gets the number of selected containers, without allocating (see NodifyEditor.SelectedContainers).
public int SelectedContainersCount { get; set; }
Property Value
Gets or sets the selected items in the NodifyEditor.
public IList SelectedItems { get; set; }
Property Value
Gets or sets the style to use for the selection rectangle.
public Style SelectionRectangleStyle { get; set; }
Property Value
Gets or sets the viewport's top-left coordinates in graph space coordinates.
public Point ViewportLocation { get; set; }
Property Value
Gets the size of the viewport in graph space (scaled by the NodifyEditor.ViewportZoom).
public Size ViewportSize { get; set; }
Property Value
Gets the transform that is applied to all child controls.
public Transform ViewportTransform { get; set; }
Property Value
Gets or sets the zoom factor of the viewport.
public double ViewportZoom { get; set; }
Property Value
Aligns a collection of containers based on the specified alignment.
public void AlignContainers(IEnumerable<ItemContainer> containers, Alignment alignment, ItemContainer relativeTo = null);
Parameters
containers
IEnumerable<ItemContainer>: The collection of item containers to align.
alignment
Alignment: The alignment type to apply to the containers.
relativeTo
ItemContainer: An optional container to use as a reference for alignment. If null, the alignment is based on the containers themselves.
Aligns the selected containers based on the specified alignment.
public void AlignSelection(Alignment alignment, ItemContainer relativeTo = null);
Parameters
alignment
Alignment: The alignment type to apply to the selected containers.
relativeTo
ItemContainer: An optional container to use as a reference for alignment. If null, the alignment is based on the containers themselves.
Starts the cutting operation at the specified location. Call Nodify.NodifyEditor.EndCutting to complete the operation or Nodify.NodifyEditor.CancelCutting to abort it.
public void BeginCutting();
public void BeginCutting(Point location);
Parameters
location
Point
Initiates the dragging operation for the specified ItemContainers. Call Nodify.NodifyEditor.EndDragging to complete the operation or Nodify.NodifyEditor.CancelDragging to abort it.
public void BeginDragging();
public void BeginDragging(IEnumerable<ItemContainer> containers);
Parameters
containers
IEnumerable<ItemContainer>
Starts the panning operation from the specified location. Call Nodify.NodifyEditor.EndPanning to end the panning operation.
public void BeginPanning(Point location);
Parameters
location
Point: The initial location where panning starts, in graph space coordinates.
Starts the panning operation from the current NodifyEditor.ViewportLocation.
public void BeginPanning();
Starts the pushing items operation at the specified location with the specified orientation.
public void BeginPushingItems(Point location, Orientation orientation);
Parameters
location
Point: The starting location for pushing items, in graph space coordinates.
orientation
Orientation: The orientation of the NodifyEditor.PushedArea.
Initiates a selection operation from the specified location.
public void BeginSelecting(SelectionType type = 0);
Parameters
type
SelectionType: The type of selection to perform. Defaults to SelectionType.Replace.
public void BeginSelecting(Point location, SelectionType type = 0);
Parameters
location
Point
type
SelectionType
Moves the viewport center at the specified location.
public void BringIntoView(Point point, bool animated = true, Action onFinish = null);
Parameters
point
Point: The location in graph space coordinates.
animated
Boolean: True to animate the movement.
onFinish
Action: The callback invoked when movement is finished.
Moves the viewport center at the center of the specified area.
public void BringIntoView(Rect area);
Parameters
area
Rect: The location in graph space coordinates.
Cancels the current cutting operation without applying any changes if NodifyEditor.AllowCuttingCancellation is true. Otherwise, it ends the cutting operation by calling Nodify.NodifyEditor.EndCutting.
public void CancelCutting();
Cancels the ongoing dragging operation, reverting any changes made to the positions of the dragged items if NodifyEditor.AllowDraggingCancellation is true. Otherwise, it ends the dragging operation by calling Nodify.NodifyEditor.EndDragging.
public void CancelDragging();
Cancels the current panning operation and reverts the viewport to its initial location if NodifyEditor.AllowPanningCancellation is true. Otherwise, it ends the panning operation by calling Nodify.NodifyEditor.EndPanning.
public void CancelPanning();
Cancels the current pushing operation and reverts the NodifyEditor.PushedArea to its initial state if NodifyEditor.AllowPushItemsCancellation is true. Otherwise, it ends the pushing operation by calling Nodify.NodifyEditor.EndPushingItems.
public void CancelPushingItems();
Cancels the current selection operation and reverts any changes made during the selection process if NodifyEditor.AllowSelectionCancellation is true. Otherwise, it ends the selection operation by calling Nodify.NodifyEditor.EndSelecting.
public void CancelSelecting();
Completes the cutting operation and applies the changes.
public void EndCutting();
Completes the dragging operation, finalizing the position of the dragged items. Raises the NodifyEditor.ItemsMoved event.
public void EndDragging();
Ends the current panning operation, retaining the current NodifyEditor.ViewportLocation.
public void EndPanning();
Ends the current pushing operation and finalizes the pushed area state.
public void EndPushingItems();
Completes the selection operation and applies any pending changes.
public void EndSelecting();
Scales the viewport to fit the specified area or all the ItemContainers if that's possible.
public void FitToScreen(Rect? area = null);
Parameters
area
Rect?
protected override DependencyObject GetContainerForItemOverride();
Returns
Translates the specified location to graph space coordinates (relative to the NodifyEditor.ItemsHost).
public Point GetLocationInsideEditor(Point location, UIElement relativeTo);
Parameters
location
Point: The location coordinates relative to relativeTo
relativeTo
UIElement: The element where the location was calculated from.
Returns
Point: A location inside the graph.
Translates the event location to graph space coordinates (relative to the NodifyEditor.ItemsHost).
public Point GetLocationInsideEditor(DragEventArgs args);
Parameters
args
DragEventArgs: The drag event.
Returns
Point: A location inside the graph
Translates the event location to graph space coordinates (relative to the NodifyEditor.ItemsHost).
public Point GetLocationInsideEditor(MouseEventArgs args);
Parameters
args
MouseEventArgs: The mouse event.
Returns
Point: A location inside the graph
Inverts the ItemContainers selection in the specified area.
public void InvertSelection(Rect area, bool fit = false);
Parameters
area
Rect: The area to look for ItemContainers.
fit
Boolean: True to check if the area contains the ItemContainer. False to check if area intersects the ItemContainer.
protected override bool IsItemItsOwnContainerOverride(object item);
Parameters
item
Object
Returns
Locks the position of the NodifyEditor.SelectedContainers.
public void LockSelection();
public override void OnApplyTemplate();
protected override void OnKeyDown(KeyEventArgs e);
Parameters
protected override void OnKeyUp(KeyEventArgs e);
Parameters
protected override void OnLostMouseCapture(MouseEventArgs e);
Parameters
protected override void OnMouseDown(MouseButtonEventArgs e);
Parameters
protected override void OnMouseMove(MouseEventArgs e);
Parameters
protected override void OnMouseUp(MouseButtonEventArgs e);
Parameters
protected override void OnMouseWheel(MouseWheelEventArgs e);
Parameters
protected void OnRemoveConnection(object dataContext);
Parameters
dataContext
Object
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo);
Parameters
sizeInfo
SizeChangedInfo
protected override void OnSelectionChanged(SelectionChangedEventArgs e);
Parameters
Updates the NodifyEditor.ViewportSize and raises the NodifyEditor.ViewportUpdatedEvent. Called when the UIElement.RenderSize or NodifyEditor.ViewportZoom is changed.
protected void OnViewportUpdated();
Clears the current selection and selects the specified ItemContainer within the same selection transaction.
public void Select(ItemContainer container);
Parameters
container
ItemContainer
Select all NodifyEditor.Connections.
public void SelectAllConnections();
Selects the ItemContainers in the specified area.
public void SelectArea(Rect area, bool append = false, bool fit = false);
Parameters
area
Rect: The area to look for ItemContainers.
append
Boolean: If true, it will add to the existing selection.
fit
Boolean: True to check if the area contains the ItemContainer. False to check if area intersects the ItemContainer.
Snaps the given value down to the nearest multiple of the grid cell size.
public double SnapToGrid(double value);
Parameters
value
Double: The value to be snapped to the grid.
Returns
Double: The largest multiple of the grid cell size less than or equal to the value.
Unlocks the position of the NodifyEditor.SelectedContainers.
public void UnlockSelection();
Unselect all NodifyEditor.Connections.
public void UnselectAllConnections();
Unselect the ItemContainers in the specified area.
public void UnselectArea(Rect area, bool fit = false);
Parameters
area
Rect: The area to look for ItemContainers.
fit
Boolean: True to check if the area contains the ItemContainer. False to check if area intersects the ItemContainer.
Updates the current cutting line position and the style for the intersecting elements if NodifyEditor.EnableCuttingLinePreview is true.
public void UpdateCuttingLine(Vector amount);
Parameters
amount
Vector: The amount to adjust the cutting line's endpoint.
Updates the current cutting line position and the style for the intersecting elements if NodifyEditor.EnableCuttingLinePreview is true.
public void UpdateCuttingLine(Point location);
Parameters
location
Point: The location of the cutting line's endpoint.
Updates the position of the items being dragged by a specified offset.
public void UpdateDragging(Vector amount);
Parameters
amount
Vector: The vector by which to adjust the position of the dragged items.
Pans the viewport by the specified amount.
public void UpdatePanning(Vector amount);
Parameters
amount
Vector: The amount to pan the viewport.
Updates the pushed area based on the specified amount taking the NodifyEditor.PushedAreaOrientation into account.
public void UpdatePushedArea(Vector amount);
Parameters
amount
Vector: The amount to adjust the pushed area by.
Expands or modifies the selection area by the specified amount.
public void UpdateSelection(Vector amount);
Parameters
amount
Vector: Rrepresents the change to apply to the selection area.
Expands or modifies the selection area to the specified location.
public void UpdateSelection(Point location);
Parameters
location
Point: The point, in graph space coordinates, to extend or adjust the selection area to.
Zoom at the specified location in graph space coordinates.
public void ZoomAtPosition(double zoom, Point location);
Parameters
zoom
Double: The zoom factor to apply. A value greater than 1 zooms in, while a value between 0 and 1 zooms out.
location
Point: The point in graph space coordinates where the zoom should be centered.
Zoom in at the viewports center
public void ZoomIn();
Zoom out at the viewports center
public void ZoomOut();
Occurs when items are moved within the editor (see Nodify.NodifyEditor.BeginDragging, Nodify.NodifyEditor.BeginPushingItems(System.Windows.Point,System.Windows.Controls.Orientation)).
public event ItemsMovedEventHandler ItemsMoved;
Event Type
Occurs whenever the viewport updates.
public event RoutedEventHandler ViewportUpdated;
Event Type