public void Remove(string l2) { // Remove it from the serialized form if (newObjectsData.ContainsKey(l2)) { newObjectsData.Remove(l2); SerializeObjects(); } // Remove all instances of it foreach (Board board in multiBoard.Boards) { for (int i = 0; i < board.BoardItems.TileObjs.Count; i++) { LayeredItem li = board.BoardItems.TileObjs[i]; if (li is ObjectInstance) { ObjectInfo oi = (ObjectInfo)li.BaseInfo; if (oi.oS == oS && oi.l0 == l0 && oi.l1 == l1 && oi.l2 == l2) { li.RemoveItem(null); i--; } } } } // Search it in newObjects foreach (ObjectInfo oi in newObjects) { if (oi.l2 == l2) { newObjects.Remove(oi); oi.ParentObject.Remove(); return; } } // Search it in wz objects foreach (WzImageProperty prop in l1prop.WzProperties) { if (prop.Name == l2) { prop.Remove(); // We removed a property that existed in the file already, so we must set it as updated SetOsUpdated(); return; } } throw new Exception("Could not find " + l2 + " in userObjs"); }