コード例 #1
0
        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));
        }
コード例 #2
0
        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)));
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
 public static void Tap(this ExternalPortView port) => port.Tapped(port);
コード例 #7
0
 public Source(GateView gate, ExternalPortView port)
 {
     Gate = gate;
     Port = port;
 }