private void AddElementInternal(GraphElement element) { if (element == null) { throw new ArgumentException("Cannot add null element"); } if (containedElements.Contains(element)) { throw new ArgumentException("The specified element is already contained in this scope."); } string reasonWhyNotAccepted = "Cannot add the specified element to this scope."; if (!AcceptsElement(element, ref reasonWhyNotAccepted)) { throw new ArgumentException(reasonWhyNotAccepted); } // Removes the element from its current scope Scope currentScope = element.GetContainingScope(); if (currentScope != null) { currentScope.RemoveElement(element); } m_ContainedElements.Add(element); element.SetContainingScope(this); // To update the scope geometry whenever the added element's geometry changes element.RegisterCallback <GeometryChangedEvent>(OnSubElementGeometryChanged); ScheduleUpdateGeometryFromContent(); }
private void RemoveElementInternal(GraphElement element) { if (element == null) { throw new ArgumentException("Cannot remove null element from this scope"); } if (!m_ContainedElements.Contains(element)) { throw new ArgumentException("This element is not contained in this scope"); } element.UnregisterCallback <GeometryChangedEvent>(OnSubElementGeometryChanged); m_ContainedElements.Remove(element); element.SetContainingScope(null); ScheduleUpdateGeometryFromContent(); }