public void OnNodeChanged(Object aOldNode, Object aNewNode) { // Enumerate each of the properties that affect FE presentation, test // for difference, and update the FE if necessary. CommandTarget oldTarget = aOldNode as CommandTarget; CommandTarget newTarget = aNewNode as CommandTarget; if (oldTarget == null && newTarget == null) { return; } int itemKey = newTarget.Data.GetHashCode(); if (mNodes.ContainsKey(itemKey)) { ManticoreTreeNode item = mNodes[itemKey] as ManticoreTreeNode; // Check for Label/AccessKey change. if (newTarget.Label != oldTarget.Label) { item.Text = newTarget.Label; } if (newTarget.IsContainer) { item.ImageIndex = mTreeView.GetIconIndex(newTarget); } } }
public void OnNodeAdded(Object aChildNode, Object aParentNode, int aIndex) { // A new Element has been added somewhere. We must find the // parent menu and append it. To interoperate with the Content Builder, // the DataStore must provide |CommandTarget|s to this method. CommandTarget childTarget = aChildNode as CommandTarget; CommandTarget parentTarget = aParentNode as CommandTarget; if (childTarget == null && parentTarget == null) { return; } // Determine based on conditions defined by the |TreeView| // whether or not this node should be built. if (!mTreeView.ShouldBuild(childTarget)) { return; } int childKey = childTarget.Data.GetHashCode(); if (!mNodes.ContainsKey(childKey)) { int parentKey = parentTarget.Data.GetHashCode(); ManticoreTreeNode parentNode; if (mNodes.ContainsKey(parentKey)) { parentNode = mNodes[parentKey] as ManticoreTreeNode; } else { parentNode = mParent as ManticoreTreeNode; } if (parentNode != null) { ManticoreTreeNode childNode = new ManticoreTreeNode(childTarget.Label, childTarget.Data); if (parentNode != null) { int imageIndex = mTreeView.GetIconIndex(childTarget); if (imageIndex > -1) { childNode.ImageIndex = imageIndex; } parentNode.Nodes.Insert(aIndex, childNode); if (childTarget.IsContainer && childTarget.IsOpen) { childNode.Expand(); } mNodes.Add(childKey, childNode); } } } }
public void Recurse(String aRoot, TreeNodeCollection aNodes) { IEnumerator items; mDataStore.GetElements(aRoot, out items); items.Reset(); ManticoreTreeNode node; while (items.MoveNext()) { // |id| is the item's unique identifier within the DataStore. // The handling code can use this to probe for more information // about the selected item. CommandTarget current = items.Current as CommandTarget; if (current != null) { // Determine based on conditions defined by the |TreeView| // whether or not this node should be built. if (!mTreeView.ShouldBuild(current)) { continue; } String id = current.Data as String; int idKey = id.GetHashCode(); if (!mNodes.ContainsKey(idKey)) { node = new ManticoreTreeNode(current.Label, id); int imageIndex = mTreeView.GetIconIndex(current); if (imageIndex > -1) { node.ImageIndex = imageIndex; } aNodes.Insert(mInsertionPoint++, node); if (current.IsContainer && current.IsOpen) { node.Expand(); } mNodes.Add(id.GetHashCode(), node); // If we're a container, recurse if (current.IsContainer) { Recurse(id, node.Nodes); } } } } ResetInsertionPoint(); }
public void OnNodeRemoved(Object aNodeRemoved) { CommandTarget childTarget = aNodeRemoved as CommandTarget; // Remove |MenuItem| representation of |aChildNode|. int childKey = childTarget.Data.GetHashCode(); if (mNodes.ContainsKey(childKey)) { ManticoreTreeNode childNode = mNodes[childKey] as ManticoreTreeNode; ManticoreTreeNode parentNode = childNode.Parent as ManticoreTreeNode; if (parentNode != null) { parentNode.Nodes.Remove(childNode); } else { mTreeView.Nodes.Remove(childNode); } mNodes.Remove(childKey); } }
public void NewFolder() { ManticoreTreeNode root = GetRootItem(); if (root != null) { ManticoreTreeNode temp = new ManticoreTreeNode("New Folder", null); root.Nodes.Add(temp); LabelEdit = true; temp.BeginEdit(); } }
public void Recurse(String aRoot, TreeNodeCollection aNodes) { IEnumerator items; mDataStore.GetElements(aRoot, out items); items.Reset(); ManticoreTreeNode node; while (items.MoveNext()) { // |id| is the item's unique identifier within the DataStore. // The handling code can use this to probe for more information // about the selected item. CommandTarget current = items.Current as CommandTarget; if (current != null) { // Determine based on conditions defined by the |TreeView| // whether or not this node should be built. if (!mTreeView.ShouldBuild(current)) continue; String id = current.Data as String; int idKey = id.GetHashCode(); if (!mNodes.ContainsKey(idKey)) { node = new ManticoreTreeNode(current.Label, id); int imageIndex = mTreeView.GetIconIndex(current); if (imageIndex > -1) node.ImageIndex = imageIndex; aNodes.Insert(mInsertionPoint++, node); if (current.IsContainer && current.IsOpen) node.Expand(); mNodes.Add(id.GetHashCode(), node); // If we're a container, recurse if (current.IsContainer) Recurse(id, node.Nodes); } } } ResetInsertionPoint(); }
public void OnNodeAdded(Object aChildNode, Object aParentNode, int aIndex) { // A new Element has been added somewhere. We must find the // parent menu and append it. To interoperate with the Content Builder, // the DataStore must provide |CommandTarget|s to this method. CommandTarget childTarget = aChildNode as CommandTarget; CommandTarget parentTarget = aParentNode as CommandTarget; if (childTarget == null && parentTarget == null) return; // Determine based on conditions defined by the |TreeView| // whether or not this node should be built. if (!mTreeView.ShouldBuild(childTarget)) return; int childKey = childTarget.Data.GetHashCode(); if (!mNodes.ContainsKey(childKey)) { int parentKey = parentTarget.Data.GetHashCode(); ManticoreTreeNode parentNode; if (mNodes.ContainsKey(parentKey)) parentNode = mNodes[parentKey] as ManticoreTreeNode; else parentNode = mParent as ManticoreTreeNode; if (parentNode != null) { ManticoreTreeNode childNode = new ManticoreTreeNode(childTarget.Label, childTarget.Data); if (parentNode != null) { int imageIndex = mTreeView.GetIconIndex(childTarget); if (imageIndex > -1) childNode.ImageIndex = imageIndex; parentNode.Nodes.Insert(aIndex, childNode); if (childTarget.IsContainer && childTarget.IsOpen) childNode.Expand(); mNodes.Add(childKey, childNode); } } } }