private NodeSocket GetSocket(Type forType) { var socket = new NodeSocket(); SetValidType(socket, forType); return(socket); }
private Point SnapIfPossible(Point rootRelativePoint) { snappedSocket = null; var nearestNode = root.GetNearestNode(rootRelativePoint); if (null == nearestNode) { return(rootRelativePoint); } var nearestConnector = dragType == DragEndPoint.Input ? nearestNode.GetNearestFreeOutputSocket(rootRelativePoint, null == outputSocket ? null : Node.GetValidType(outputSocket)) : nearestNode.GetNearestFreeInputSocket(rootRelativePoint, null == inputSocket ? null : Node.GetValidType(inputSocket)); if (null == nearestConnector) { return(rootRelativePoint); } var distance = (rootRelativePoint - nearestConnector.Position).Length; if (distance <= SnapDistance) { if (dragType == DragEndPoint.Input && !nearestNode.QueryCanConnectOutput(OutputNode) || dragType == DragEndPoint.Output && !nearestNode.QueryCanConnectInput(InputNode)) { return(rootRelativePoint); } snappedSocket = nearestConnector; return(nearestConnector.Position); } return(rootRelativePoint); }
protected override void OnMouseUp(MouseButtonEventArgs e) { base.OnMouseUp(e); var type = dragType; dragType = DragEndPoint.Unknown; ReleaseMouseCapture(); if (null != snappedSocket) { if (DragEndPoint.Input == type) { ConnectInputEndPoint(snappedSocket); } else { ConnectOutputEndPoint(snappedSocket); } } if (null == inputSocket || null == outputSocket) { Delete(); } snappedSocket = null; e.Handled = true; }
private void Connect(NodeSocket from, IConnectable to) { if (!InputSockets.Contains(from) && !OutputSockets.Contains(from)) { return; } from.Connect(to); }
public SocketType GetSocketType(NodeSocket socket) { if (InputSockets.Contains(socket)) { return(SocketType.Input); } return(OutputSockets.Contains(socket) ? SocketType.Output : SocketType.Unknown); }
public void ConnectOutputEndPoint(NodeSocket to) { outputSocket = to; OutputNode = to.Node; OnConnected(to); UpdateStopPoint(); if (null == inputSocket) { StartPoint = StopPoint; } UpdateCentrePoints(); }
private void AddInputSocket() { if (!CanAutoAddInputs || GetFreeInputSocket() != null) { return; } var socket = new NodeSocket(); if (null != contentNode && contentNode.Inputs != null) { SetValidType(socket, contentNode.Inputs.LastOrDefault()); } SubscribeInputSocket(socket); InputSockets.Add(socket); }
private Point SnapIfPossible(Point rootRelativePoint) { snappedSocket = null; var nearestNode = root.GetNearestNode(rootRelativePoint); if (null == nearestNode) return rootRelativePoint; var nearestConnector = dragType == DragEndPoint.Input ? nearestNode.GetNearestFreeOutputSocket(rootRelativePoint, null == outputSocket ? null : Node.GetValidType(outputSocket)) : nearestNode.GetNearestFreeInputSocket(rootRelativePoint, null == inputSocket ? null : Node.GetValidType(inputSocket)); if (null == nearestConnector) return rootRelativePoint; var distance = (rootRelativePoint - nearestConnector.Position).Length; if (distance <= SnapDistance) { if (dragType == DragEndPoint.Input && !nearestNode.QueryCanConnectOutput(OutputNode) || dragType == DragEndPoint.Output && !nearestNode.QueryCanConnectInput(InputNode)) return rootRelativePoint; snappedSocket = nearestConnector; return nearestConnector.Position; } return rootRelativePoint; }
protected override void OnMouseUp(MouseButtonEventArgs e) { base.OnMouseUp(e); var type = dragType; dragType = DragEndPoint.Unknown; ReleaseMouseCapture(); if (null != snappedSocket) { if (DragEndPoint.Input == type) ConnectInputEndPoint(snappedSocket); else ConnectOutputEndPoint(snappedSocket); } if (null == inputSocket || null == outputSocket) Delete(); snappedSocket = null; e.Handled = true; }
public SocketType GetSocketType(NodeSocket socket) { if (InputSockets.Contains(socket)) return SocketType.Input; return OutputSockets.Contains(socket) ? SocketType.Output : SocketType.Unknown; }
private void AddInputSocket() { if (!CanAutoAddInputs || GetFreeInputSocket() != null) return; var socket = new NodeSocket(); if (null != contentNode && contentNode.Inputs != null) SetValidType(socket, contentNode.Inputs.LastOrDefault()); SubscribeInputSocket(socket); InputSockets.Add(socket); }
public static void SetValidType(NodeSocket element, Type value) { element.SetValue(ValidTypeProperty, value); }
public static Type GetValidType(NodeSocket element) { return((Type)element.GetValue(ValidTypeProperty)); }
private static bool IsCompatible(NodeSocket socket, Type type) { return(null == type || GetValidType(socket) == type); }
private static bool IsSocketFree(NodeSocket socket) { return !socket.IsConnected; }
private static bool IsCompatible(NodeSocket socket, Type type) { return (null == type || GetValidType(socket) == type); }
private static bool IsSocketFree(NodeSocket socket) { return(!socket.IsConnected); }
private NodeSocket GetSocket(Type forType) { var socket = new NodeSocket(); SetValidType(socket, forType); return socket; }
public void ConnectOutputEndPoint(NodeSocket to) { outputSocket = to; OutputNode = to.Node; OnConnected(to); UpdateStopPoint(); if (null == inputSocket) StartPoint = StopPoint; UpdateCentrePoints(); }
public static Type GetValidType(NodeSocket element) { return (Type)element.GetValue(ValidTypeProperty); }
private void Connect(NodeSocket from, IConnectable to) { if (!InputSockets.Contains(from) && !OutputSockets.Contains(from)) return; from.Connect(to); }