Example #1
0
 public void AddChild(UIElement child)
 {
     if (child.Parent != null)
     {
         throw new Exception("Tried to add a child that already has a parent!");
     }
     if (!Children.Contains(child))
     {
         if (!ToAdd.Add(child))
         {
             throw new Exception("Tried to add a child twice!");
         }
     }
     else
     {
         throw new Exception("Tried to add a child that already belongs to this element!");
     }
 }
Example #2
0
 public void RemoveChild(UIElement child)
 {
     if (Children.Contains(child))
     {
         if (!ToRemove.Add(child))
         {
             throw new Exception("Tried to remove a child twice!");
         }
     }
     else
     {
         throw new Exception("Tried to remove a child that does not belong to this element!");
     }
 }
Example #3
0
 public bool HasChild(UIElement element)
 {
     return Children.Contains(element) && !ToRemove.Contains(element);
 }