Beispiel #1
0
        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);
        }
Beispiel #2
0
 public void AddConnection(Direction direction, CircuitPart part)
 {
     if (!_connections.ContainsKey(direction))
     {
         _connections.Add(direction, part);
     }
 }
Beispiel #3
0
        public Direction GetConnectionDirection(CircuitPart part)
        {
            foreach (var connectionPair in _connections)
            {
                if (connectionPair.Value.Equals(part))
                {
                    return(connectionPair.Key);
                }
            }

            return(Direction.None);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
 public void AddCircuitPart(CircuitPart part)
 {
     CircuitParts.Add(part);
 }