Пример #1
0
        private void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (BackgroundWorkEnded != null)
            {
                BackgroundWorkEnded(this, EventArgs.Empty);
            }

            if (e.Cancelled)
            {
                return;
            }

            TempItemSet[] itemSets = e.Result as TempItemSet[];
            if (itemSets != null)
            {
                treeView.BeginUpdate();
                TreeNodeLocalItem treeNodeServerFolder = null;
                foreach (TempItemSet itemSet in itemSets)
                {
                    if (itemSet.QueryPath != null)
                    {
                        if (treeNodeServerFolder != null && !FileSpec.IsSubItem(itemSet.QueryPath, treeNodeServerFolder.LocalItem))
                        {
                            treeNodeServerFolder = null;
                        }
                        TreeNodeLocalItem treeNodeServerFolder2;
                        if (TryFindNodeByServerItem(itemSet.QueryPath, treeNodeServerFolder, out treeNodeServerFolder2) && NodeNeedsExpansion(treeNodeServerFolder2))
                        {
                            treeNodeServerFolder2.Nodes.Clear();
                            foreach (TempItemSet.TempItem i in itemSet.Items)
                            {
                                AttachTreeNode(treeNodeServerFolder2, Path.GetFileName(i.LocalPath), i);
                            }
                            if (!treeNodeServerFolder2.IsExpanded && m_navigateToWhenLoaded == null)
                            {
                                treeNodeServerFolder2.Expand();
                            }
                            treeNodeServerFolder = treeNodeServerFolder2;
                        }
                    }
                }
                if (m_navigateToWhenLoaded != null)
                {
                    TreeNodeLocalItem treeNodeServerFolder3;
                    TryFindNodeByServerItem(m_navigateToWhenLoaded, null, out treeNodeServerFolder3);
                    if (treeNodeServerFolder3 != null)
                    {
                        treeNodeServerFolder3.EnsureVisible();
                        treeView.SelectedNode = treeNodeServerFolder3;
                    }
                    m_navigateToWhenLoaded = null;
                }
                treeView.EndUpdate();
            }
        }
Пример #2
0
        public void Navigate(string initialPath)
        {
            if (initialPath != null && initialPath.Trim().Length > 0)
            {
                initialPath = FileSpec.GetFullPath(initialPath);

                TreeNodeLocalItem foundItem = null;
                if (TryFindNodeByServerItem(initialPath, null, out foundItem))
                {
                    foundItem.EnsureVisible();
                    m_navigateToWhenLoaded = null;
                    return;
                }

                var roots = WorkingFolder.GetWorkspaceRoots(m_workspace.Folders);
                foreach (String root in roots)
                {
                    if (FileSpec.IsSubItem(initialPath, root))
                    {
                        string[] folders  = initialPath.Substring(root.Length + 1).Split('\\');
                        string   curPath  = root;
                        string   prevPath = root;
                        foundItem = null;
                        m_navigateToWhenLoaded = null;
                        for (int i = 0; i < folders.Length; i++)
                        {
                            prevPath = curPath;
                            curPath  = curPath + "\\" + folders[i];
                            if (TryFindNodeByServerItem(curPath, foundItem, out foundItem))
                            {
                                foundItem.EnsureVisible();
                            }
                            else
                            {
                                m_toExpand.Add(prevPath);
                                m_navigateToWhenLoaded = initialPath;
                            }
                        }
                        StartBackgroundWorkerIfNeeded();
                        break;
                    }
                }
            }
        }
        protected override bool Execute(WorkspaceInfo workspaceInfo)
        {
            using (var collection = new TfsTeamProjectCollection(workspaceInfo.ServerUri))
            {
                var vcServer  = collection.GetService <VersionControlServer>();
                var workspace = vcServer.GetWorkspace(workspaceInfo);
                var evaluator = new LocalItemExclusionEvaluator(workspace, startLocalItem: ""); // TODO?

                var result = new List <ITaskItem>();
                foreach (var item in SourceFiles)
                {
                    if (FileSpec.IsSubItem(item.ItemSpec, evaluator.StartLocalItem) &&
                        evaluator.IsExcluded(item.ItemSpec, isFolder: false))
                    {
                        result.Add(item);
                    }
                }

                UntrackedFiles = result.ToArray();
            }

            return(true);
        }