public void Add(SnippetInMemory snippet) { if (!snippets.Contains(snippet)) snippets.Add(snippet); Dirty = true; }
public void Remove(SnippetInMemory snippet) { // This assert is NOT always valid, because sometimes the UI wipes out // a parent and then wipes out children and all kinds of weird shit. // It's all ok. // Debug.Assert(snippets.Contains(snippet),"Removing non-existent snippet " + snippet + "."); snippets.Remove(snippet); Dirty = true; }
void RemoveChildSnippet(SnippetInMemory child) { children.Remove(child); ((SnippetInMemory)child).parents.Remove(this); model.Dirty = true; if (child.Parents.Count == 0) { child.RemoveAllChildSnippets(); model.Remove((SnippetInMemory)child); } UI.Hide(child); }
void MoveUpChild(SnippetInMemory child) { Debug.Assert(children.Contains(child)); int i = children.IndexOf(child); if (i > 0) { children.Remove(child); children.Insert(i-1, child); model.Dirty = true; UI.OnAfterReorder(); } }
void AddChildSnippet(SnippetInMemory child) { OnBeforeAdd(child); // this should only happen using the old serializers, not using the UI Debug.Assert(!children.Contains(child), "Parent " + this + ", Child " + child + "." + "Trying to add child that already exists. This should ONLY happen from the old serializer."); children.Add((SnippetInMemory)child); ((SnippetInMemory)child).parents.Add(this); model.Dirty = true; UI.Show(child); }
public override Kbase.Model.Snippet AddChildSnippet() { // make a new one SnippetInMemory retVal = new SnippetInMemory(this.model); if (UI.ShowingChildren) retVal.UI.ShowChildren(); else retVal.UI.HideChildren(); // add it as a child AddChildSnippet(retVal); // and add it to the model model.Add((SnippetInMemory)retVal); return retVal; }
public static SnippetInMemory MakeLastXSnippet(SnippetDictionary model) { SnippetInMemory retVal = new SnippetInMemory(model); retVal.title = LAST_X_TEXT; model.TopLevelSnippet.AddChildSnippet(retVal); return retVal; }