示例#1
0
        private void PopulateFolders(TreeNode ownerNode, string queryPath)
        {
            ownerNode.Nodes.Clear();

            ItemSet folders = Context.ControlServer.GetItems(queryPath, VersionSpec.Latest, RecursionType.OneLevel,
                                                             DeletedState.NonDeleted,
                                                             ItemType.Folder);

            foreach (Item folderItem in folders.Items)
            {
                if (folderItem.ServerItem == queryPath)
                {
                    continue;
                }

                int icon = VersionControlPath.GetFolderDepth(folderItem.ServerItem) == 1 ? 1 : 2;

                TreeNode newNode = AddNode(ownerNode.Nodes, VersionControlPath.GetFileName(folderItem.ServerItem), icon);
                newNode.Tag = folderItem.ServerItem;

                var dummyNode = new TreeNode(queryPath + "/dummy");
                newNode.Nodes.Add(dummyNode);
            }
        }
示例#2
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (e.Cancel)
            {
                return;
            }

            string[]   queryItems = (string[])e.Argument;
            ItemSpec[] array      = new ItemSpec[queryItems.Length];
            for (int i = 0; i < queryItems.Length; i++)
            {
                array[i] = new ItemSpec(VersionControlPath.Combine(queryItems[i], "*"), RecursionType.OneLevel);
            }
            ExtendedItem[][] itemSets;
            itemSets = m_workspace.GetExtendedItems(array, m_deletedState, ShowFiles ? ItemType.Any : ItemType.Folder, GetItemsOptions.IncludeBranchInfo);
            TempItemSet[] result = new TempItemSet[itemSets.Length];
            for (int i = 0; i < itemSets.Length; i++)
            {
                result[i] = new TempItemSet
                {
                    QueryPath = VersionControlPath.GetFolderName(array[i].Item),
                    Items     = itemSets[i].Where((item) => (item.TargetServerItem != queryItems[i] && (item.IsInWorkspace || !m_limitToWorkspace))).ToArray()
                };
            }

            if (m_limitToWorkspace)
            {
                Workspace ws = m_workspace;
                ws.RefreshIfNeeded();
                var folders = ws.Folders;
                foreach (TempItemSet its in result)
                {
                    int             desiredCloakDepth = VersionControlPath.GetFolderDepth(its.QueryPath) + 1;
                    string          cloakedWeSaw      = null;
                    List <ItemSpec> newItems          = new List <ItemSpec>();
                    foreach (var fldr in folders)
                    {
                        if (fldr.IsCloaked && fldr.Depth != RecursionType.None && VersionControlPath.IsSubItem(fldr.ServerItem, its.QueryPath) &&
                            VersionControlPath.GetFolderDepth(fldr.ServerItem) == desiredCloakDepth)
                        {
                            cloakedWeSaw = fldr.ServerItem;
                        }
                        else if (!fldr.IsCloaked && cloakedWeSaw != null && VersionControlPath.IsSubItem(fldr.ServerItem, cloakedWeSaw))
                        {
                            //we need this to keep going even if it's cloaked
                            newItems.Add(new ItemSpec(cloakedWeSaw, RecursionType.None));
                            cloakedWeSaw = null;
                        }
                    }
                    if (newItems.Count > 0)
                    {
                        ExtendedItem[] newExItems = new ExtendedItem[its.Items.Length + newItems.Count];
                        Array.Copy(its.Items, newExItems, its.Items.Length);
                        ExtendedItem[][] tempExItems = m_sourceControl.GetExtendedItems(newItems.ToArray(), m_deletedState, ItemType.Folder, GetItemsOptions.IncludeBranchInfo);
                        for (int i = 0; i < tempExItems.Length; i++)
                        {
                            newExItems[i + its.Items.Length] = tempExItems[i][0];
                        }

                        its.Items = newExItems;
                    }
                }
            }

            foreach (TempItemSet its in result)
            {
                Array.Sort(its.Items, (a, b) => a.TargetServerItem.CompareTo(b.TargetServerItem));
            }

            e.Result = result;
        }
示例#3
0
        private TreeNodeServerItem AttachTreeNode(TreeNode parent, ExtendedItem item)
        {
            TreeNodeServerItem node;

            if (item == null)
            {
                //the root
                node = new TreeNodeServerItem(item, m_sourceControl.TeamProjectCollection.Name, 6, 6);
                node.Nodes.Add(new TreeNodeWorking());
            }
            else
            {
                string fileName = VersionControlPath.GetFileName(item.TargetServerItem);
                if (item.IsBranch)
                {
                    if (item.DeletionId != 0)
                    {
                        node = new TreeNodeServerItem(item, fileName, 2, 2);
                    }
                    else
                    {
                        node = new TreeNodeServerItem(item, fileName, 1, 1);
                    }
                    node.Nodes.Add(new TreeNodeWorking());
                }
                else if (item.ItemType == ItemType.Folder)
                {
                    if (VersionControlPath.GetFolderDepth(item.TargetServerItem) == 1)
                    {
                        if (item.DeletionId != 0)
                        {
                            node = new TreeNodeServerItem(item, fileName, 3, 3);
                        }
                        else
                        {
                            node = new TreeNodeServerItem(item, fileName, 7, 7);
                        }
                    }
                    else
                    {
                        if (item.DeletionId != 0)
                        {
                            node = new TreeNodeServerItem(item, fileName, 3, 3);
                        }
                        else
                        {
                            node = new TreeNodeServerItem(item, fileName, 4, 5);
                        }
                    }
                    node.Nodes.Add(new TreeNodeWorking());
                }
                else if (item.ItemType == ItemType.File)
                {
                    if (item.DeletionId != 0)
                    {
                        node = new TreeNodeServerItem(item, fileName, 3, 3);
                    }
                    else
                    {
                        node = new TreeNodeServerItem(item, fileName, 12, 12);
                    }
                }
                else
                {
                    return(null);
                }
            }

            if (parent != null)
            {
                parent.Nodes.Add(node);
            }
            else
            {
                treeView.Nodes.Add(node);
            }

            if (m_selectedItems.ContainsKey(node.ServerItem))
            {
                node.ColorSelected();
                m_selectedItems[node.ServerItem] = node;
            }



            return(node);
        }