public CircuitPart Clone() { var clone = new CircuitPart(Start); foreach (var node in Drawables) { clone.AddDrawableBase(node); } foreach (var resistance in ResistancesList) { clone.AddResistance(resistance); } clone.EndPoints = new EndPointsClass() { End = End, Start = Start, }; clone.End = End; clone.Start = Start; clone.DebugColor = DebugColor; clone.IsLooseEnd = IsLooseEnd; clone.LinkedToBattery = LinkedToBattery; return(clone); }
public void AddConnection(Direction direction, CircuitPart part) { if (!_connections.ContainsKey(direction)) { _connections.Add(direction, part); } }
public Direction GetConnectionDirection(CircuitPart part) { foreach (var connectionPair in _connections) { if (connectionPair.Value.Equals(part)) { return(connectionPair.Key); } } return(Direction.None); }
public CircuitPart GetEquivalentCircuitPart() { var equivalentCircuitPart = new CircuitPart(Start) { End = End }; CircuitParts.ForEach(c => { var nodes = c.Drawables; foreach (var node in nodes) { equivalentCircuitPart.AddDrawableBase(node); } equivalentCircuitPart.ChildCircuitParts.Add(c); }); equivalentCircuitPart.AddResistance(EquivalentResistance); return(equivalentCircuitPart); }
public bool ContainsChildCircuitPart(CircuitPart part) { var returnValue = ChildCircuitParts.Contains(part); if (returnValue == false && ChildCircuitParts.Count > 0) { foreach (var childpart in ChildCircuitParts) { if (childpart.ContainsChildCircuitPart(part)) { returnValue = true; } } } else if (returnValue == false && ChildCircuitParts.Count == 0) { returnValue = part.Equals(this); } return(returnValue); }
public Direction GetConnectionDirectionOfParallelGroupPart(CircuitPart part) { foreach (var connectionPair in _connections) { var connectionPairValue = connectionPair.Value; if (part.ChildCircuitParts.Count > 0) { if (part.ContainsChildCircuitPart(connectionPairValue)) { return(connectionPair.Key); } } else { if (connectionPair.Value.Equals(part)) { return(connectionPair.Key); } } } return(Direction.None); }
public void AddCircuitPart(CircuitPart part) { CircuitParts.Add(part); }