private void HandleAtlasCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { ////////////////////////////// Early out://////////////////////////// if (ViewModel.SuppressChangedEvents) { return; } ////////////////////////////// End early out//////////////////////////// var shouldSave = false; if (e.Action == NotifyCollectionChangedAction.Add) { var whatWasAdded = e.NewItems[0] as AtlasViewModel; string folderToAdd = whatWasAdded.Folder; loadedFile.AddAtlas(folderToAdd); shouldSave = true; } else if (e.Action == NotifyCollectionChangedAction.Remove) { // Someone: Check this when deletion is supported: var whatWasRemoved = e.OldItems[0] as AtlasViewModel; string folderToRemove = whatWasRemoved.Folder; loadedFile.RemoveAtlas(folderToRemove); shouldSave = true; } else if (e.Action == NotifyCollectionChangedAction.Reset) { loadedFile.ClearAtlases(); shouldSave = true; } else { throw new NotImplementedException(); } if (shouldSave) { var fileName = GlueCommands.Self.GetAbsoluteFileName(referencedFileSave); loadedFile.Save(fileName); } }