private void LoadSubProjects(TreeNode treeNode) { var node = (Node)treeNode.Tag; if (node.IsProject && !node.Loaded) { treeNode.Nodes.Clear(); var project = _teamCityAdapter.GetProjectChildren(node.Name); treeNode.Nodes.AddRange(project.Projects.Select(p => new TreeNode(p) { Tag = new Node { IsProject = true, Loaded = false, Name = p, ParentProject = node.Name } }).ToArray()); treeNode.Nodes.AddRange(project.Builds.Select(b => new TreeNode(b.Id + ": " + b.Name) { Tag = new Node { IsProject = false, Loaded = true, Name = b.Id, ParentProject = node.Name } }).ToArray()); } }
private void LoadSubProjects(TreeNode treeNode) { var node = (Node)treeNode.Tag; if (node.IsProject && !node.Loaded) { treeNode.Nodes.Clear(); var project = _teamCityAdapter.GetProjectChildren(node.Name); var projectNodes = project.Projects.Select(p => new TreeNode(p) { Name = p, Tag = new Node { IsProject = true, Loaded = false, Name = p, ParentProject = node.Name } }).OrderBy(p => p.Name).ToArray(); treeNode.Nodes.AddRange(projectNodes); var buildNodes = project.Builds.Select(b => new TreeNode(b.Name + " (" + b.Id + ")") { Name = b.Id, Tag = new Node { IsProject = false, Loaded = true, Name = b.Id, ParentProject = node.Name } }).OrderBy(p => p.Name).ToArray(); treeNode.Nodes.AddRange(buildNodes); //Find previous already selected build in the treeview var previouslySelectedBuild = buildNodes.FirstOrDefault(n => n.Name == TeamCityBuildIdFilter && n.Parent.Name == TeamCityProjectName); if (previouslySelectedBuild != null) { _previouslySelectedBuild = previouslySelectedBuild; } } }