/// <summary> /// Searches for a node which contains a particular QSetItemBase object. /// </summary> /// <param name="item">QSetItemBase to search for.</param> /// <param name="searchRootNode">Tree node to start search from.</param> /// <returns>The node hosting the item if found, else null.</returns> private QSetItemTreeNode FindNode(QSetItemBase item, QSetItemTreeNode searchRootNode) { QSetItemTreeNode result = null; foreach (TreeNode node in searchRootNode.Nodes) { QSetItemTreeNode checkQSetNode = ((QSetItemTreeNode)node); if (checkQSetNode.QSetItem == item) { result = checkQSetNode; break; } else if (checkQSetNode.QSetItem is QSetFolderItem) { result = FindNode(item, checkQSetNode); if (result != null) { break; } } } return(result); }
/// <summary> /// Handles event fired when a child item is removed from the current item. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ChildItems_BeforeItemRemoved(object sender, BeforeItemRemovedEventArgs e) { QSetItemTreeNode removedNode = (QSetItemTreeNode)base.Nodes[e.RemovedAt]; base.Nodes.RemoveAt(e.RemovedAt); removedNode.Dispose(); }
/// <summary> /// Displays a QSet in the explorer. /// </summary> /// <param name="queueSet">QSet to display.</param> private void DisplayQSet(QSetModel queueSet) { _qsetTreeView.Nodes.Clear(); if (_qset != null) { QSetItemTreeNode queueSetNode = new QSetItemTreeNode(_qset); _qsetTreeView.Nodes.Add((QSetItemTreeNode)queueSetNode); DisplayQSetChildItems(queueSet, queueSetNode); } }
/// <summary> /// Recursively adds child nodes to a node. /// </summary> /// <param name="parentItem">Parent folder item.</param> /// <param name="parentNode">Parent node.</param> public void CreateChildNodes(QSetFolderItem parentFolderItem, TreeNode parentNode) { foreach (QSetItemBase item in parentFolderItem.ChildItems) { QSetItemTreeNode itemNode = new QSetItemTreeNode(item); parentNode.Nodes.Add((TreeNode)itemNode); if (item is QSetFolderItem) { CreateChildNodes((QSetFolderItem)item, itemNode); } } }
/// <summary> /// Handles event fired when a child is added to the current item. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ChildItems_AfterItemAdded(object sender, AfterItemAddedEventArgs e) { QSetItemTreeNode newNode = new QSetItemTreeNode(e.Item); QSetItemTreeNode newNodeRef = newNode; if (e.Item is QSetFolderItem) { CreateChildNodes((QSetFolderItem)e.Item, newNodeRef); } base.Nodes.Insert(e.InsertedAt, newNode); base.Expand(); base.TreeView.SelectedNode = newNode; newNode.EnsureVisible(); }
/// <summary> /// Recursively adds child nodes to a node. /// </summary> /// <param name="parentItem">Parent folder item.</param> /// <param name="parentNode">Parent node.</param> public void CreateChildNodes(QSetFolderItem parentFolderItem, TreeNode parentNode) { foreach (QSetItemBase item in parentFolderItem.ChildItems) { QSetItemTreeNode itemNode = new QSetItemTreeNode(item); parentNode.Nodes.Add((TreeNode)itemNode); if (item is QSetFolderItem) CreateChildNodes((QSetFolderItem)item, itemNode); } }
/// <summary> /// Handles event fired when a child is added to the current item. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ChildItems_AfterItemAdded(object sender, AfterItemAddedEventArgs e) { QSetItemTreeNode newNode = new QSetItemTreeNode(e.Item); QSetItemTreeNode newNodeRef = newNode; if (e.Item is QSetFolderItem) CreateChildNodes((QSetFolderItem)e.Item, newNodeRef); base.Nodes.Insert(e.InsertedAt, newNode); base.Expand(); base.TreeView.SelectedNode = newNode; newNode.EnsureVisible(); }
/// <summary> /// Displays a QSet in the explorer. /// </summary> /// <param name="queueSet">QSet to display.</param> private void DisplayQSet(QSetModel queueSet) { _qsetTreeView.Nodes.Clear(); if (_qset != null) { QSetItemTreeNode queueSetNode = new QSetItemTreeNode(_qset); _qsetTreeView.Nodes.Add((QSetItemTreeNode)queueSetNode); DisplayQSetChildItems(queueSet, queueSetNode); } }
/// <summary> /// Searches for a node which contains a particular QSetItemBase object. /// </summary> /// <param name="item">QSetItemBase to search for.</param> /// <param name="searchRootNode">Tree node to start search from.</param> /// <returns>The node hosting the item if found, else null.</returns> private QSetItemTreeNode FindNode(QSetItemBase item, QSetItemTreeNode searchRootNode) { QSetItemTreeNode result = null; foreach(TreeNode node in searchRootNode.Nodes) { QSetItemTreeNode checkQSetNode = ((QSetItemTreeNode)node); if (checkQSetNode.QSetItem == item) { result = checkQSetNode; break; } else if (checkQSetNode.QSetItem is QSetFolderItem) { result = FindNode(item, checkQSetNode); if (result != null) break; } } return result; }