public static void Connect(this SchemeView scheme, ExternalPortView source, ExternalPortView destination) { source.Tap(); destination.Tap(); var lastWire = scheme.Wires.Last(); Debug.Assert(source.WireStartConnects(lastWire)); Debug.Assert(destination.WireEndConnects(lastWire)); }
public static IEnumerable <WireView> ConnectedWires(SchemeView scheme, ExternalPortView port) { var wires = scheme.Wires; if (port.Type == PortType.Input) { return(wires.Where(w => port.WireStartConnects(w))); } else { return(wires.Where(w => port.WireEndConnects(w))); } }
public static void Connect(this SchemeView scheme, GateView source, ExternalPortView destination, int index = 0) { var sourcePort = source.Outputs.ElementAt(index); sourcePort.Tap(); destination.Tap(); var lastWire = scheme.Wires.Last(); Debug.Assert(source.WireStartConnects(lastWire)); Debug.Assert(destination.WireEndConnects(lastWire)); Debug.Assert(lastWire.Connection.StartPort == index); }
private void MoveExternalOutput(ExternalPortView port, Vector2 newLocation) { // get connected wires to the port var connectedWires = NavigationHelper.ConnectedWires(scheme, port).ToList(); // update location port.MatrixLocation = newLocation; // adjust connected wires location foreach (var w in connectedWires) { var c2 = w.Connection; c2.MatrixEnd = newLocation; c2.EndPoint = port.GetCenterRelativeTo(scheme); w.SetConnection(c2); } }
private void MoveExternalInput(ExternalPortView port, Vector2 newPosition) { var oldLocation = port.MatrixLocation; var newLocation = newPosition; port.MatrixLocation = newLocation; // get connected wires to the port by its old location var connectedWires = scheme.Wires.Where(w => w.Connection.MatrixStart == oldLocation).ToList(); // adjust connected wires location foreach (var w in connectedWires) { var c2 = w.Connection; c2.MatrixStart = newLocation; c2.StartPoint = port.GetCenterRelativeTo(scheme); w.SetConnection(c2); } }
public static void Tap(this ExternalPortView port) => port.Tapped(port);
public Source(GateView gate, ExternalPortView port) { Gate = gate; Port = port; }