public void RefreshNodesGlyphs(IList<VSITEMSELECTION> selectedNodes)
{
foreach (VSITEMSELECTION vsItemSel in selectedNodes)
{
IVsSccProject2 sccProject2 = vsItemSel.pHier as IVsSccProject2;
if (vsItemSel.itemid == VSConstants.VSITEMID_ROOT)
{
if (sccProject2 == null)
{
// Note: The solution's hierarchy does not implement IVsSccProject2, IVsSccProject interfaces
// It may be a pain to treat the solution as special case everywhere; a possible workaround is
// to implement a solution-wrapper class, that will implement IVsSccProject2, IVsSccProject and
// IVsHierarhcy interfaces, and that could be used in provider's code wherever a solution is needed.
// This approach could unify the treatment of solution and projects in the provider's code.
// Until then, solution is treated as special case
string[] rgpszFullPaths = new string[1];
rgpszFullPaths[0] = GetSolutionFileName();
VsStateIcon[] rgsiGlyphs = new VsStateIcon[1];
uint[] rgdwSccStatus = new uint[1];
sccService.GetSccGlyph(1, rgpszFullPaths, rgsiGlyphs, rgdwSccStatus);
// Set the solution's glyph directly in the hierarchy
IVsHierarchy solHier = (IVsHierarchy)GetService(typeof(SVsSolution));
solHier.SetProperty(VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_StateIconIndex, rgsiGlyphs[0]);
}
else
{
// Refresh all the glyphs in the project; the project will call back GetSccGlyphs()
// with the files for each node that will need new glyph
sccProject2.SccGlyphChanged(0, null, null, null);
}
}
else
{
// It may be easier/faster to simply refresh all the nodes in the project,
// and let the project call back on GetSccGlyphs, but just for the sake of the demo,
// let's refresh ourselves only one node at a time
IList<string> sccFiles = GetNodeFiles(sccProject2, vsItemSel.itemid);
// We'll use for the node glyph just the Master file's status (ignoring special files of the node)
if (sccFiles.Count > 0)
{
string[] rgpszFullPaths = new string[1];
rgpszFullPaths[0] = sccFiles[0];
VsStateIcon[] rgsiGlyphs = new VsStateIcon[1];
uint[] rgdwSccStatus = new uint[1];
sccService.GetSccGlyph(1, rgpszFullPaths, rgsiGlyphs, rgdwSccStatus);
uint[] rguiAffectedNodes = new uint[1];
rguiAffectedNodes[0] = vsItemSel.itemid;
sccProject2.SccGlyphChanged(1, rguiAffectedNodes, rgsiGlyphs, rgdwSccStatus);
}
}
}
}