Skip to content
miroiu edited this page Dec 23, 2024 · 1 revision

Connector Class

Namespace: Nodify

Assembly: Nodify

Inheritance: ObjectDispatcherObjectDependencyObjectVisualUIElementFrameworkElementControlConnector

Derived: NodeInput, NodeOutput, StateNode

References: ConnectorState.Connecting, Connection, ConnectorEventArgs, ConnectorEventHandler, ConnectorState.Default, ConnectorState.Disconnect, InputProcessor, ItemContainer, KnotNode, Node, NodifyEditor, PendingConnection, PendingConnectionEventArgs, PendingConnectionEventHandler

Represents a connector control that can start and complete a PendingConnection. Has a Connector.ElementConnector that the Connector.Anchor is calculated from for the PendingConnection. Center of this control is used if missing.

public class Connector : Control  

Constructors

Connector()

public Connector();  

Fields

ElementConnector

protected const string ElementConnector = "PART_Connector";  

Field Value

String

EnableOptimizations

Gets or sets if Connectors should enable optimizations based on Connector.OptimizeSafeZone and Connector.OptimizeMinimumSelectedItems.

public static bool EnableOptimizations;  

Field Value

Boolean

OptimizeMinimumSelectedItems

Gets or sets the minimum selected items needed to trigger optimizations when outside of the Connector.OptimizeSafeZone.

public static uint OptimizeMinimumSelectedItems;  

Field Value

UInt32

OptimizeSafeZone

Gets or sets the safe zone outside the editor's viewport that will not trigger optimizations.

public static double OptimizeSafeZone;  

Field Value

Double

Properties

AllowPendingConnectionCancellation

Gets or sets whether cancelling a pending connection is allowed.

public static bool AllowPendingConnectionCancellation { get; set; }  

Property Value

Boolean

Anchor

Gets the location in graph space coordinates where Connections can be attached to. Bind with System.Windows.Data.BindingMode.OneWayToSource

public Point Anchor { get; set; }  

Property Value

Point

Container

Gets the ItemContainer that contains this Connector.

public ItemContainer Container { get; set; }  

Property Value

ItemContainer

DisconnectCommand

Invoked if the Connector.Disconnect event is not handled. Parameter is the FrameworkElement.DataContext of this control.

public ICommand DisconnectCommand { get; set; }  

Property Value

ICommand

Editor

Gets the NodifyEditor that owns this Connector.Container.

public NodifyEditor Editor { get; set; }  

Property Value

NodifyEditor

HasContextMenu

Gets a value indicating whether the connector has a context menu.

public bool HasContextMenu { get; set; }  

Property Value

Boolean

HasCustomContextMenu

Gets or sets a value indicating whether the connector uses a custom context menu.

public bool HasCustomContextMenu { get; set; }  

Property Value

Boolean

InputProcessor

protected InputProcessor InputProcessor { get; set; }  

Property Value

InputProcessor

IsConnected

If this is set to false, the Connector.Disconnect event will not be invoked and the connector will stop updating its Connector.Anchor when moved, resized etc.

public bool IsConnected { get; set; }  

Property Value

Boolean

IsPendingConnection

Gets a value that indicates whether a PendingConnection is in progress for this Connector.

public bool IsPendingConnection { get; protected set; }  

Property Value

Boolean

Methods

BeginConnecting()

Initiates a new pending connection from this connector with the specified offset (see Connector.IsPendingConnection).

public void BeginConnecting();  

BeginConnecting(Vector)

public void BeginConnecting(Vector offset);  

Parameters

offset Vector

CancelConnecting()

Cancels the current pending connection without completing it if Connector.AllowPendingConnectionCancellation is true. Otherwise, it completes the pending connection by calling Nodify.Connector.EndConnecting.

public void CancelConnecting();  

EndConnecting()

Completes the current pending connection using the specified connector as the target.

public void EndConnecting();  

EndConnecting(Connector)

public void EndConnecting(Connector connector);  

Parameters

connector Connector

FindConnectionTarget(Point)

Searches for a potential Connector or ItemContainer at the specified position within the editor.

public FrameworkElement FindConnectionTarget(Point position);  

Parameters

position Point: The position in the editor to check for a potential connection target.

Returns

FrameworkElement

FindTargetConnector(Point)

Searches for a Connector at the specified position.

public Connector FindTargetConnector(Point position);  

Parameters

position Point: The position in the editor to check for a connector.

Returns

Connector

OnApplyTemplate()

public override void OnApplyTemplate();  

OnKeyDown(KeyEventArgs)

protected override void OnKeyDown(KeyEventArgs e);  

Parameters

e KeyEventArgs

OnKeyUp(KeyEventArgs)

protected override void OnKeyUp(KeyEventArgs e);  

Parameters

e KeyEventArgs

OnLostMouseCapture(MouseEventArgs)

protected override void OnLostMouseCapture(MouseEventArgs e);  

Parameters

e MouseEventArgs

OnMouseDown(MouseButtonEventArgs)

protected override void OnMouseDown(MouseButtonEventArgs e);  

Parameters

e MouseButtonEventArgs

OnMouseMove(MouseEventArgs)

protected override void OnMouseMove(MouseEventArgs e);  

Parameters

e MouseEventArgs

OnMouseUp(MouseButtonEventArgs)

protected override void OnMouseUp(MouseButtonEventArgs e);  

Parameters

e MouseButtonEventArgs

OnMouseWheel(MouseWheelEventArgs)

protected override void OnMouseWheel(MouseWheelEventArgs e);  

Parameters

e MouseWheelEventArgs

OnRenderSizeChanged(SizeChangedInfo)

protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo);  

Parameters

sizeInfo SizeChangedInfo

RemoveConnections()

Removes all connections associated with this connector.

public void RemoveConnections();  

UpdateAnchor(Point)

Updates the Connector.Anchor relative to a location. (usually Connector.Container's location)

protected void UpdateAnchor(Point location);  

Parameters

location Point: The relative location

UpdateAnchor()

Updates the Connector.Anchor based on Connector.Container's location.

public void UpdateAnchor();  

UpdateAnchorOptimized(Point)

Updates the Connector.Anchor and applies optimizations if needed based on Connector.EnableOptimizations flag

protected void UpdateAnchorOptimized(Point location);  

Parameters

location Point

UpdatePendingConnection(Vector)

Updates the endpoint of the pending connection by adjusting its position with the specified offset.

public void UpdatePendingConnection(Vector offset);  

Parameters

offset Vector: The amount to adjust the pending connection's endpoint.

UpdatePendingConnection(Point)

Updates the endpoint of the pending connection to the specified position.

public void UpdatePendingConnection(Point position);  

Parameters

position Point: The new position for the connection's endpoint.

Events

Disconnect

Triggered by the Nodify.Interactivity.EditorGestures.ConnectorGestures.Disconnect gesture.

public event ConnectorEventHandler Disconnect;  

Event Type

ConnectorEventHandler

PendingConnectionCompleted

Triggered by the Nodify.Interactivity.EditorGestures.ConnectorGestures.Connect gesture.

public event PendingConnectionEventHandler PendingConnectionCompleted;  

Event Type

PendingConnectionEventHandler

PendingConnectionDrag

Occurs when the mouse is changing position and the Connector has mouse capture.

public event PendingConnectionEventHandler PendingConnectionDrag;  

Event Type

PendingConnectionEventHandler

PendingConnectionStarted

Triggered by the Nodify.Interactivity.EditorGestures.ConnectorGestures.Connect gesture.

public event PendingConnectionEventHandler PendingConnectionStarted;  

Event Type

PendingConnectionEventHandler

Clone this wiki locally