Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public void SortChildCircuitParts()
        {
            var query = ChildCircuitParts.Where(c => c.Start.Equals(Start) || c.End.Equals(Start));

            // Return if this the circuitpart is a parallel group
            if (query.Count() > 1)
            {
                return;
            }

            var nextChild     = query.SingleOrDefault();
            var previousChild = nextChild;
            var childIndex    = 0;

            while (childIndex < ChildCircuitParts.Count)
            {
                var reverse = !previousChild.Equals(nextChild) && !previousChild.End.Equals(nextChild.Start);
                if (reverse)
                {
                    nextChild.Drawables.Reverse();

                    var temp = nextChild.Start;
                    nextChild.Start = nextChild.End;
                    nextChild.End   = temp;
                }

                previousChild = nextChild;

                if (reverse)
                {
                    nextChild = ChildCircuitParts.Where(c => !c.Equals(nextChild) && (c.Start.Equals(nextChild.Start) || c.End.Equals(nextChild.Start))).SingleOrDefault();
                }
                else
                {
                    nextChild = ChildCircuitParts.Where(c => !c.Equals(nextChild) && (c.Start.Equals(nextChild.End) || c.End.Equals(nextChild.End))).SingleOrDefault();
                }

                ++childIndex;
            }
        }