Beispiel #1
0
        internal bool HasChildNode(IExplorerObject exObject)
        {
            if (exObject == null)
            {
                return(true);
            }
            TreeNode node = treeView.SelectedNode;

            if (node == null)
            {
                return(true);
            }
            node.Expand();

            foreach (TreeNode n in node.Nodes)
            {
                if (!(n is ExplorerObjectNode))
                {
                    continue;
                }
                IExplorerObject ex = ((ExplorerObjectNode)n).ExplorerObject;
                if (ex == null)
                {
                    continue;
                }

                if (ExObjectComparer.Equals(ex, exObject))
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #2
0
 public void DeleteItem(IExplorerObject exObject)
 {
     foreach (ExplorerObjectListViewItem item in listView.Items)
     {
         if (ExObjectComparer.Equals(exObject, item.ExplorerObject))
         {
             listView.Items.Remove(item);
         }
     }
 }
Beispiel #3
0
        async internal Task <IExplorerObject> AddChildNode(IExplorerObject exObject)
        {
            if (!(treeView.SelectedNode is ExplorerObjectNode) || exObject == null)
            {
                return(exObject);
            }

            ExplorerObjectNode node = treeView.SelectedNode as ExplorerObjectNode;

            if (node.ExplorerObject is IExplorerParentObject)
            {
                await((IExplorerParentObject)node.ExplorerObject).Refresh();
                foreach (IExplorerObject child in await((IExplorerParentObject)node.ExplorerObject).ChildObjects())
                {
                    if (ExObjectComparer.Equals(child, exObject))
                    {
                        exObject = child;
                        break;
                    }
                }
            }

            if (exObject is IExplorerObjectDeletable)
            {
                ((IExplorerObjectDeletable)exObject).ExplorerObjectDeleted += new ExplorerObjectDeletedEvent(CatalogTreeControl_ExplorerObjectDeleted);
            }

            if (exObject is IExplorerObjectRenamable)
            {
                ((IExplorerObjectRenamable)exObject).ExplorerObjectRenamed += new ExplorerObjectRenamedEvent(CatalogTreeControl_ExplorerObjectRenamed);
            }

            if (!node.IsExpanded)
            {
                return(exObject);
            }

            int imageIndex = gView.Explorer.UI.Framework.UI.ExplorerIcons.ImageIndex(exObject);

            node.Nodes.Add(new ExplorerObjectNode(exObject, imageIndex));

            return(exObject);
        }
Beispiel #4
0
        internal ExplorerObjectNode FindNode(TreeNode parent, IExplorerObject exObject)
        {
            if (parent == null)
            {
                return(null);
            }

            if (parent is ExplorerObjectNode &&
                ExObjectComparer.Equals(((ExplorerObjectNode)parent).ExplorerObject, exObject))
            {
                return(parent as ExplorerObjectNode);
            }

            foreach (TreeNode node in parent.Nodes)
            {
                ExplorerObjectNode n = FindNode(node, exObject);
                if (n != null)
                {
                    return(n);
                }
            }
            return(null);
        }
Beispiel #5
0
        internal void RemoveChildNode(IExplorerObject exObject)
        {
            if (exObject == null)
            {
                return;
            }

            TreeNode node = treeView.SelectedNode;

            if (node == null)
            {
                return;
            }

            bool removed = false;

            if (node.IsExpanded)
            {
                int index = -1;
                foreach (TreeNode n in node.Nodes)
                {
                    if (!(n is ExplorerObjectNode))
                    {
                        continue;
                    }

                    IExplorerObject ex = ((ExplorerObjectNode)n).ExplorerObject;
                    if (ex == null)
                    {
                        continue;
                    }

                    if (ExObjectComparer.Equals(ex, exObject))
                    {
                        index = node.Nodes.IndexOf(n);
                        break;
                    }
                }
                if (index != -1)
                {
                    node.Nodes.RemoveAt(index);
                    removed = true;
                }
            }
            if (removed)
            {
                if (node.Nodes.Count == 0)
                {
                    node.Nodes.Add(new DummyNode());
                    node.Collapse();
                }
            }
            else
            {
                ExplorerObjectNode exNode = FindNode(exObject);

                if (exNode != null)
                {
                    if (exNode == treeView.SelectedNode)
                    {
                        treeView.SelectedNode = treeView.SelectedNode.Parent;
                        treeView.Nodes.Remove(exNode);

                        if (treeView.SelectedNode.Nodes.Count == 0)
                        {
                            treeView.SelectedNode.Nodes.Add(new DummyNode());
                            treeView.SelectedNode.Collapse();
                        }
                    }
                    else
                    {
                        treeView.Nodes.Remove(exNode);
                    }
                }
            }
        }