public override GroupItems FindItems(string search) { List<ToolStripGroupItem> foundItems = new List<ToolStripGroupItem>(); List<ITabbedDocument> matches = SearchUtil.getMatchedItems(PluginBase.MainForm.Documents, search, "\\", 0); foreach (ITabbedDocument document in matches) { string fileName = Path.GetFileName(document.FileName); string path = Path.GetDirectoryName(document.FileName); if (path.Length > 50) path = "..." + path.Substring(path.Length - 47); ToolStripGroupItem foundItem = new ToolStripGroupItem(fileName, path, document.Icon.ToBitmap(), OpenDocument); foundItem.Tag = document; foundItems.Add(foundItem); } return new GroupItems(Name, foundItems); }
public override GroupItems FindItems(string search) { List<ToolStripGroupItem> foundItems = new List<ToolStripGroupItem>(); List<MemberModel> matches = SearchUtil.getMatchedItems(ASContext.Context.GetAllProjectClasses(), search, 0); foreach (MemberModel member in matches) { int index = member.Name.LastIndexOf('.'); string name = member.Name.Substring(index + 1); string packageName = index >= 0 ? member.Name.Substring(0, member.Name.Length - name.Length - 1) : string.Empty; ToolStripGroupItem foundItem = new ToolStripGroupItem(name, packageName, null, OpenType); foundItem.Tag = member; foundItems.Add(foundItem); } return new GroupItems(Name, foundItems); }
private List<ToolStripGroupItem> FindItems(string search, ToolStripItemCollection items, string path) { List<ToolStripGroupItem> foundItems = new List<ToolStripGroupItem>(); foreach (ToolStripItem stripItem in items) { ToolStripMenuItem item = stripItem as ToolStripMenuItem; if (item == null) continue; if (item.Name == "ReopenMenu") continue; string itemText = item.Text.Replace("&", ""); if (item.HasDropDownItems) { foundItems.AddRange(FindItems(search, item.DropDownItems, path + itemText + " → ")); } else { if (itemText.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0) { ToolStripGroupItem foundItem; string shortcutString = string.Empty; if (!string.IsNullOrEmpty(item.ShortcutKeyDisplayString)) shortcutString = item.ShortcutKeyDisplayString; else if (item.ShortcutKeys != Keys.None) shortcutString = TypeDescriptor.GetConverter(typeof(Keys)).ConvertToString(item.ShortcutKeys); foundItem = new ToolStripGroupItem(string.Format("{0}{1}", path, itemText), shortcutString, item.Image, ClickItem); foundItem.Tag = item; foundItems.Add(foundItem); } } } return foundItems; }