public ConnectionDrawing(Connection connection, Viewport viewport, MainForm mainForm) { this.connection = connection; this.viewport = viewport; this.mainForm = mainForm; }
private ConnectionDrawing getConnectionDrawing(Connection connection) { foreach (ConnectionDrawing connectionDrawing in connectionDrawings) { if (connectionDrawing.Connection == connection) { return connectionDrawing; } } return null; }
public void portUp(PortDrawing port) { if(connectionPossible(port.port)) { Connection connection = new Connection(portDrawingBeingDragged.port, port.port); circuitManager.addConnection(connection); refresh(); unsavedChangesMade = true; } }
/// <summary> /// Deletes a connection and add a step to the stack /// </summary> /// <param name="connection">The connection that will be deleted</param> /// <returns>True if succesful, false if not</returns> public bool deleteConnection(Connection connection) { Step step = new Step(); Action action = new Action(circuit, Action.ActionType.delete, connection); step.addAction(action); if (step.execute()) { addStep(step); return true; } else { return false; } }
/// <summary> /// /// </summary> /// <param name="port1"></param> /// <param name="port2"></param> /// <returns>True if successful, false if not.</returns> public virtual bool addConnection(Connection connection) { throw new System.NotImplementedException(); }
/// <summary> /// Add a connection to the circuit /// </summary> /// <param name="port1">First port of the connection</param> /// <param name="port2">Second port of the connection</param> public void addConnection(Connection connection) { if (!connection.connected) { connection.Connect(); } connections.Add(connection); }
/// <summary> /// Deletes a connection from the circuit /// </summary> /// <param name="connection">The connection that should be deleted</param> /// <returns>True if successful, false if not.</returns> public bool deleteConnection(Connection connection) { connections.Remove(connection); connection.Disconnect(); return true; }