public PortDrawing(Port port, Point location, Viewport viewport, MainForm mainForm) { this.port = port; this.location = location; this.viewport = viewport; this.hovered = false; this.mainForm = mainForm; this.port.PoweredChanged += new Port.PoweredChangedHandler(PowerChanged); initializePictureBox(); }
public Connection(Port port1, Port port2) { if (port1.isInput == port2.isInput) { throw new Exception(); } if (port1.isInput) { inputPort = port1; outputPort = port2; } else { inputPort = port2; outputPort = port1; } Connect(); }
public ConnectionDrawing getConnectionDrawing(Port port) { foreach (ConnectionDrawing connectionDrawing in connectionDrawings) { if (connectionDrawing.Connection.inputPort == port || connectionDrawing.Connection.outputPort == port) { return connectionDrawing; } } return null; }
public PortDrawing getPortDrawing(Port port) { foreach (ItemDrawing itemDrawing in itemDrawings) { PortDrawing portDrawing = itemDrawing.getPortDrawing(port); if (portDrawing != null) { return portDrawing; } } return null; }
/// <summary> /// Checks if a connection is possible /// </summary> /// <param name="port"></param> /// <returns></returns> public bool connectionPossible(Port port) { if (portDrawingBeingDragged != null && circuitManager.circuit.connectionPossible(portDrawingBeingDragged.port, port)) { return true; } return false; }
public Item(int inputs, int outputs) { Inputs = new Port[inputs]; Outputs = new Port[outputs]; }
/// <summary> /// Delete connections that are associated with a port /// </summary> /// <param name="port">The concerning port</param> public void deleteConnectionsForPort(Port port) { List<Connection> connectionsToDelete = circuit.getAssociatedConnections(port); foreach (Connection connection in connectionsToDelete) { deleteConnection(connection); } }
public Connection(SerializationInfo info, StreamingContext context) { this.inputPort = (Port)info.GetValue("inputPort", typeof(Port)); this.outputPort = (Port)info.GetValue("outputPort", typeof(Port)); this.connected = (bool)info.GetValue("connected", typeof(bool)); }
public List<Connection> getAssociatedConnections(Port port) { List<Connection> associatedConnections = new List<Connection>(); foreach (Connection connection in connections) { if (connection.inputPort == port || connection.outputPort == port) { associatedConnections.Add(connection); } } return associatedConnections; }
/// <summary> /// Checks if a connection is possible between two ports. /// </summary> /// <param name="port1">First port of connection</param> /// <param name="port2">Second port of connection</param> /// <returns>True if a connection is possible, false if not.</returns> public bool connectionPossible(Port port1, Port port2) { if (port1.isInput == port2.isInput) { return false; } if (port1.item == port2.item) { return false; } if (port1.isInput && port1.isUsed || port2.isInput && port2.isUsed) { return false; } return true; }
public PortDrawing getPortDrawing(Port port) { foreach (PortDrawing portDrawing in portDrawings) { if (portDrawing.port == port) { return portDrawing; } } return null; }
public Item(int inputs, int outputs) { Inputs = new Port[inputs]; for (int i = 0; i < inputs; i++) { Inputs[i] = new Port(this, true); Inputs[i].PoweredChanged += ItemInput_PoweredChanged; } Outputs = new Port[outputs]; for (int i = 0; i < outputs; i++) { Outputs[i] = new Port(this, false); } this.output = getOutput(); }