private void RememberExpansion() { m_expandedCollections.Clear(); foreach (string category in TreeAdapter.GetChildren(TreeAdapter)) { if (TreeControlAdapter.IsExpanded(category)) { m_expandedCollections.Add(category); } } }
/// <summary> /// Clears all items from the palette</summary> public void RemoveAllItems() { m_searchInput.ClearSearch(); TreeAdapter.RemoveAllItems(); m_objectClients.Clear(); TreeControl.Root.Clear(); TreeAdapter.RefreshControl(); }
/// <summary> /// Adds an item to the palette in the given category</summary> /// <param name="item">Palette item</param> /// <param name="categoryName">Category name</param> /// <param name="client">Client that instantiates item during drag-drop operations</param> public void AddItem(object item, string categoryName, IPaletteClient client) { if (m_objectClients.ContainsKey(item)) { throw new InvalidOperationException("duplicate item"); } if (categoryName != null) { m_objectClients.Add(item, client); TreeAdapter.AddItem(item, categoryName); } }
//Stack of open elements public OpenElementStack(Node document, Func <Element, string> getNamespaceUri, Func <Element, string> getTagName, Func <TemplateElement, DocumentFragment> getTemplateContent) { this.StackTop = -1; this.items = new List <Element>(); this.Current = document; this.CurrentTagName = null; this.CurrentTmplContent = null; this.TmplCount = 0; this.treeAdapter = new TreeAdapter(getNamespaceUri, getTagName, getTemplateContent); }
private void searchInput_Updated(object sender, EventArgs e) { if (TreeControl.Root == null) { return; } if (m_searchInput.IsNullOrEmpty()) { if (m_searching) { // get the tree control to force-reload the tree data TreeAdapter.RefreshControl(); RestoreExpansion(); } m_searching = false; return; } else { if (!m_searching) { RememberExpansion(); } m_searching = true; } TreeAdapter.RefreshControl(); // expand categories that have matched children foreach (object category in TreeAdapter.GetChildren(TreeAdapter)) { foreach (object typeName in TreeAdapter.GetChildren(category)) { ItemInfo info = new WinFormsItemInfo(); TreeAdapter.GetInfo(typeName, info); if (m_searchInput.Matches(info.Label)) { TreeControlAdapter.Expand(category); break; } } } RestoreExpansion(); }
private static TreeAdapter Find(int nextIndex, int index, int[] sequense) { var newIndex = index + nextIndex; if (newIndex < sequense.Length && sequense[newIndex] - sequense[index] <= 3) { if (!keyValuePairs.TryGetValue(newIndex, out var adapter)) { adapter = new TreeAdapter(newIndex, sequense); keyValuePairs.Add(newIndex, adapter); } return(adapter); } return(null); }
/// <summary> /// Removes an item from the palette</summary> /// <param name="item">Item to remove</param> public void RemoveItem(object item) { TreeAdapter.RemoveItem(item); m_objectClients.Remove(item); }