private void PaintNodes(TreeNode node, Graphics g, ref int y) { if (node == null) { _log.Warn("node was null in ThreeStateTreeView.PaintNodes"); return; } ThreeStateTreeNode nodeThree = node as ThreeStateTreeNode; if (nodeThree != null && nodeThree.State == CheckBoxState.Indeterminate) { Point ptTL = new Point(node.Bounds.X - Indent + 6, node.Bounds.Y + 1); g.DrawImageUnscaled(_bmpIndterminate, ptTL); } if (node.IsExpanded) { y += ItemHeight; PaintNodes(node.FirstNode, g, ref y); } if (node.NextNode != null) { y += ItemHeight; PaintNodes(node.NextNode, g, ref y); } }
private void ApplyFilter() { _projects.Nodes.Clear(); foreach (var projectCollection in _projectCollections) { TreeNode projectCollectionNode = new TreeNode(projectCollection.Name); var tfsProjects = projectCollection.Projects.OrderBy(i => i.Name); foreach (var project in tfsProjects) { var projectNode = new TreeNode(project.Name); var myTfsBuildDefinitions = project.BuildDefinitions.OrderBy(i => i.Name); foreach (var buildDefinition in myTfsBuildDefinitions) { var shouldBeVisible = string.IsNullOrEmpty(_filter.Text) || buildDefinition.Name.Contains(_filter.Text, StringComparison.CurrentCultureIgnoreCase); if (!shouldBeVisible) continue; _ciEntryPointSetting.FindAddBuildDefinition(buildDefinition, _ciEntryPoint.Name); bool exists = Settings.BuildExistsAndIsActive(_ciEntryPoint.Name, buildDefinition.Name); ThreeStateTreeNode node = new ThreeStateTreeNode(buildDefinition.Name) { Tag = buildDefinition.Id, State = exists ? CheckBoxState.Checked : CheckBoxState.Unchecked }; projectNode.Nodes.Add(node); } AddIfContainsChildren(projectCollectionNode.Nodes, projectNode); } AddIfContainsChildren(_projects.Nodes, projectCollectionNode); } RefreshCheckednessOfParentNodes(); }
private void LoadProjectList() { _ciEntryPointSetting.BuildDefinitionSettings.ForEach(buildDefinition => { var travisCiBuildDefinition = TravisCiBuildDefinition.FromIdString(buildDefinition.Id); ThreeStateTreeNode node = new ThreeStateTreeNode(travisCiBuildDefinition.OwnerName + "/" + travisCiBuildDefinition.ProjectName) { Tag = buildDefinition, State = CheckBoxState.Checked }; _projects.Nodes.Add(node); }); }
private void GetProjectComplete(TravisCiBuildDefinition buildDefinition) { _ciEntryPointSetting.Url = "https://api.travis-ci.org/"; Settings.Save(); bool exists = Settings.BuildExistsAndIsActive(_travisCiEntryPoint.Name, buildDefinition.Id); ThreeStateTreeNode node = new ThreeStateTreeNode(buildDefinition.OwnerName + "/" + buildDefinition.ProjectName) { Tag = buildDefinition, State = exists ? CheckBoxState.Checked : CheckBoxState.Unchecked }; _projects.Nodes.Add(node); }
/// <summary> /// Recursiveley update child node's state based on the state of this node. /// </summary> private void UpdateChildNodeState() { foreach (TreeNode node in Nodes) { // It is possible node is not a ThreeStateTreeNode, so check first. if (node is ThreeStateTreeNode) { ThreeStateTreeNode child = node as ThreeStateTreeNode; child.State = State; child.Checked = (State != CheckBoxState.Unchecked); child.UpdateChildNodeState(); } } }
private void GetProjectComplete(TravisCiBuildDefinition buildDefinition) { _ciEntryPointSetting.Url = _travisUrl.Text; if (!string.IsNullOrEmpty(_travisApiAccessToken.Text)) { _ciEntryPointSetting.SetPassword(_travisApiAccessToken.Text); } Settings.Save(); bool exists = Settings.BuildExistsAndIsActive(_travisCiEntryPoint.Name, buildDefinition.Id); ThreeStateTreeNode node = new ThreeStateTreeNode(buildDefinition.OwnerName + "/" + buildDefinition.ProjectName) { Tag = buildDefinition, State = exists ? CheckBoxState.Checked : CheckBoxState.Unchecked }; _projects.Nodes.Add(node); }
private void ApplyFilter() { _projects.Nodes.Clear(); foreach (var project in _buildDefinitions) { var shouldBeVisible = string.IsNullOrEmpty(_filter.Text) || project.Name.Contains(_filter.Text, StringComparison.CurrentCultureIgnoreCase); if (!shouldBeVisible) continue; var exists = Settings.BuildExistsAndIsActive(_appVeyorCiEntryPoint.Name, project.Name); var node = new ThreeStateTreeNode(project.Name) { Tag = project, State = exists ? CheckBoxState.Checked : CheckBoxState.Unchecked }; _projects.Nodes.Add(node); } }
private void GetProjectsComplete(BuildBotBuildDefinition[] buildDefinitions) { _ciEntryPointSetting.Url = _url.Text; _ciEntryPointSetting.UserName = _userName.Text; _ciEntryPointSetting.SetPassword(_password.Text); Settings.Save(); _projects.Nodes.Clear(); var BuildBotBuildDefinitions = buildDefinitions.OrderBy(i => i.Name); foreach (BuildBotBuildDefinition project in BuildBotBuildDefinitions) { bool exists = Settings.BuildExistsAndIsActive(_BuildBotCiEntryPoint.Name, project.Name); ThreeStateTreeNode node = new ThreeStateTreeNode(project.Name) { Tag = project, State = exists ? CheckBoxState.Checked : CheckBoxState.Unchecked }; _projects.Nodes.Add(node); } }
/// <summary> /// Recursiveley update parent node state based on the current state of this node. /// </summary> private void UpdateParentNodeState(bool isStartingPoint) { // If isStartingPoint is false, then know this is not the initial call // to the recursive method as we want to force on the first time // this is called to set the instance's parent node state based on // the state of all the siblings of this node, including the state // of this node. So, if not the startpoint (!isStartingPoint) and // the state of this instance is indeterminate (CheckBoxState.Indeterminate) // then know to set all subsequent parents to the indeterminate // state. However, if not in an indeterminate state, then still need // to evaluate the state of all the siblings of this node, including the state // of this node before setting the state of the parent of this instance. ThreeStateTreeNode parent = Parent as ThreeStateTreeNode; if (parent != null) { CheckBoxState state; // Determine the new state if (!isStartingPoint && (State == CheckBoxState.Indeterminate)) { state = CheckBoxState.Indeterminate; } else { state = SiblingsState; } // Update parent state if not the same. if (parent.State != state) { parent.State = state; _updateCheckInternal = true; parent.Checked = (state != CheckBoxState.Unchecked); _updateCheckInternal = false; parent.UpdateParentNodeState(false); } } }
private bool AddBuildDefinition(TeamCityBuildDefinition buildDefinition, ThreeStateTreeNode parentProjectNode, IEnumerable<BuildDefinitionSetting> activeBuildDefinitionSettings) { ThreeStateTreeNode buildDefinitionNode = new ThreeStateTreeNode(buildDefinition.Name) { Tag = buildDefinition }; var buildDefSettings = activeBuildDefinitionSettings.FirstOrDefault(bd => bd.Id == buildDefinition.Id); if (buildDefSettings != null) { buildDefinitionNode.State = buildDefSettings.Active ? CheckBoxState.Checked : CheckBoxState.Unchecked; } parentProjectNode.Nodes.Add(buildDefinitionNode); buildDefinitionNode.UpdateStateOfRelatedNodes(); return buildDefinitionNode.Checked; }
private bool AddSubProjectsAndBuildDefinitions(TeamCityProject project, List<BuildDefinitionSetting> activeBuildDefinitionSettings, TreeNodeCollection treeNodeCollection) { ThreeStateTreeNode node = new ThreeStateTreeNode(project.Name); bool allChildrenChecked = true; foreach (var buildDefinition in project.BuildDefinitions) { var isChecked = AddBuildDefinition(buildDefinition, node, activeBuildDefinitionSettings); allChildrenChecked = allChildrenChecked && isChecked; } foreach (var subProject in project.SubProjects) { var isChecked = AddSubProjectsAndBuildDefinitions(subProject, activeBuildDefinitionSettings, node.Nodes); allChildrenChecked = allChildrenChecked && isChecked; } node.Checked = allChildrenChecked; treeNodeCollection.Add(node); return node.Checked; }
private void GetProjectsComplete(TeamCityProject[] projects) { _ciEntryPointSetting.Url = _url.Text; _ciEntryPointSetting.UserName = _userName.Text; _ciEntryPointSetting.SetPassword(_password.Text); Settings.Save(); ClearProjectNodes(); var teamCityProjects = projects.OrderBy(i => i.Name); foreach (TeamCityProject project in teamCityProjects) { bool exists = Settings.BuildExistsAndIsActive(_teamCityCiEntryPoint.Name, project.Name); ThreeStateTreeNode node = new ThreeStateTreeNode(project.Name) { Tag = project, State = exists ? CheckBoxState.Checked : CheckBoxState.Unchecked }; node.State = CheckBoxState.Indeterminate; node.Nodes.Add(PLACEHODER_TEXT); _projects.Nodes.Add(node); LoadBuildDefinitions(node); } }
private void LoadBuildDefinitions(TreeNode node) { if (node.Tag is TeamCityProject && node.Nodes.Count == 1 && node.Nodes[0].Text == PLACEHODER_TEXT) { _service.GetBuildDefinitions((TeamCityProject)node.Tag, _userName.Text, _password.Text, buildDefinitions => { ClearProjectNodes(node.Nodes); var activeBuildDefinitionSettings = _ciEntryPointSetting.BuildDefinitionSettings.Where(bd => bd.Active); foreach (TeamCityBuildDefinition buildDefinition in buildDefinitions) { TeamCityBuildDefinition definition = buildDefinition; ThreeStateTreeNode buildDefinitionNode = new ThreeStateTreeNode(buildDefinition.Name) { Tag = buildDefinition }; var buildDefSettings = activeBuildDefinitionSettings.FirstOrDefault(bd => bd.Id == definition.Id); if (buildDefSettings != null) { buildDefinitionNode.State = buildDefSettings.Active ? CheckBoxState.Checked : CheckBoxState.Unchecked; } node.Nodes.Add(buildDefinitionNode); buildDefinitionNode.UpdateStateOfRelatedNodes(); } }); } }