// ------------------------------------------------------------------- /// <summary> /// Updates the read-only text field that displays a string /// representation of the selected projects to be submitted. /// </summary> private void UpdateSubmittablesField() { if (submittables.Length == 0) { projectsToSubmitField.Text = Messages.ChooseProjectsPrompt; } else if (submittables[0] is SubmittableSolution) { SubmittableSolution ss = (SubmittableSolution)submittables[0]; projectsToSubmitField.Text = String.Format(Messages.EntireSolutionMessage, Path.GetFileNameWithoutExtension(ss.SolutionName)); } else { SubmittableProject sp = (SubmittableProject)submittables[0]; StringBuilder builder = new StringBuilder(); builder.Append(sp.HierarchyItem["Name"]); for (int i = 1; i < submittables.Length; i++) { builder.Append(", "); builder.Append(((SubmittableProject)submittables[i]). HierarchyItem["Name"]); } projectsToSubmitField.Text = builder.ToString(); } }
// ------------------------------------------------------------------- /// <summary> /// Searches the current selection to determine if the given solution /// is contained in it. /// </summary> /// <param name="solution"> /// The solution to search for. /// </param> /// <returns> /// True if the solution was found in the selection; otherwise, false. /// </returns> private bool FindSolutionInSelection(IVsSolution solution) { foreach (ISubmittableItem item in selection) { SubmittableSolution ss = item as SubmittableSolution; if (ss != null) { if (ss.Solution == solution) { return(true); } } } return(false); }
// ------------------------------------------------------------------- /// <summary> /// Appends to a selection list the submittable item in the given node, /// if it is checked. /// </summary> /// <remarks> /// This method handles nested elements -- if the parent of an item is /// checked, that means that all of its children are as well, so only /// the parent needs to be added to the selection. If a parent node is /// not checked, then we recursively look at its children to determine /// if any of them need to be added to the selection. /// </remarks> /// <param name="items"> /// The list that will be built up to contain the selection. /// </param> /// <param name="node"> /// The node to possibly add to the selection. /// </param> private void AppendSelectionFromNode(List <ISubmittableItem> items, TreeNode node) { if (node.Checked) { string solutionDir, solutionFile, solutionUser; IVsSolution solution = VsShellUtils.GetSolution(serviceProvider); solution.GetSolutionInfo(out solutionDir, out solutionFile, out solutionUser); ISubmittableItem item = null; if (node.Tag is IVsSolution) { item = new SubmittableSolution((IVsSolution)node.Tag); } else if (node.Tag is HierarchyItem) { HierarchyItem hierarchy = (HierarchyItem)node.Tag; item = new SubmittableProject(solutionDir, hierarchy); } if (item != null) { items.Add(item); } } else { foreach (TreeNode child in node.Nodes) { AppendSelectionFromNode(items, child); } } }