public IAcceptGroups Add(Grouping grouping, object group, int indent) { ToolStripMenuItem menuItem = new ToolStripMenuItem(); IXenObject o = group as IXenObject; if (o != null) { // Pad the item name with spaces on the left. This is nasty, but we // don't know any way to specify a width or padding in pixels and have // it affect the area on which we can write or the width of the tool // strip; so it seems necessary to fool the framework in this way. menuItem.Text = INDENT; for (int i = 0; i < indent; ++i) { menuItem.Text += INDENT; } menuItem.Text += Helpers.GetName(o).EscapeAmpersands(); menuItem.Tag = o; if (scope != null && !scope.WantType(o)) { menuItem.Enabled = false; menuItem.BackColor = System.Drawing.Color.Gainsboro; menuItem.ForeColor = DefaultForeColor; } AddItem(menuItem); } return(this); }
// Do we want this grouping type, based on the search-for? private bool WantGroupingType(GroupingType gt) { QueryScope scope = (searcher == null ? null : searcher.QueryScope); if (scope == null) { return(true); } if (scope.WantType(ObjectTypes.Folder)) { return(false); // searching for folder forbids all grouping types (we add group by folder back in separately) } return(scope.WantAnyOf(gt.AppliesTo)); }