Exemplo n.º 1
0
        private void Reset()
        {
            backgroundWorker.CancelAsync();
            m_toExpand.Clear();
            treeView.BeginUpdate();
            treeView.Nodes.Clear();
            TreeNodeLocalItem root = AttachTreeNode(null, m_workspace != null ? m_workspace.Name : "wat?", new TempItemSet.TempItem());

            treeView.SelectedNode = root;
            if (m_workspace != null)
            {
                var             roots = WorkingFolder.GetWorkspaceRoots(m_workspace.Folders);
                List <ItemSpec> specs = new List <ItemSpec>();
                foreach (string s in roots)
                {
                    specs.Add(new ItemSpec(s, RecursionType.None));
                }
                var items = m_workspace.GetExtendedItems(specs.ToArray(), DeletedState.Any, ItemType.Folder);
                foreach (var i in items)
                {
                    foreach (var j in i)
                    {
                        AttachTreeNode(root, j.LocalItem, new TempItemSet.TempItem {
                            LocalPath = j.LocalItem, ServerItem = j
                        });
                    }
                }
            }
            treeView.EndUpdate();
        }
Exemplo n.º 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;
                    }
                }
            }
        }