コード例 #1
0
        private IEnumerable <IContextMenuItem> GetMenus(object obj)
        {
            FileData fd = (FileData)obj;
            List <IContextMenuItem> workingList = new List <IContextMenuItem>(this._menuItems.Value.Count);
            MenuItemInfo            last        = null;

            foreach (MenuItemInfo item in this._menuItems.Value)
            {
                if (item == MenuItemInfo.Empty && last == MenuItemInfo.Empty)
                {
                    continue;
                }

                if (item.Predicate != null && !item.Predicate(fd))
                {
                    continue;
                }

                workingList.Add(item.Convert());
                last = item;
            }

            return(workingList);
        }
コード例 #2
0
        private static List<MenuItemInfo> CreateMenuItemDefinitions()
        {
            MenuItemInfo addmenu = new MenuItemInfo("Add", o => o.IsDirectory, null);
            List<MenuItemInfo> items = new List<MenuItemInfo>
            {
                new MenuItemInfo(
                    "Open Solution",
                    o => o.FullPath.EndsWith(".sln", StringComparison.OrdinalIgnoreCase),
                    new OpenSolutionCommand()),
                new MenuItemInfo(
                    "Open Project",
                    o => Regex.IsMatch(o.FullPath, ".*\\..*proj"),
                    new OpenProjectCommand()),
                new MenuItemInfo(
                    "Exclude from Folder Explorer",
                    o => o.IsDirectory && o.Parent == null,
                    new RemoveFolderCommand()),
                new MenuItemInfo("Open in Windows Explorer", o => true, new BrowseCommand()),
                MenuItemInfo.Empty,
                addmenu,
                MenuItemInfo.Empty,
                new MenuItemInfo("Delete", o => true, new DeleteCommand()),
                new MenuItemInfo("Rename", o => true, new RenameCommand())
            };

            addmenu.Children = new List<MenuItemInfo>
            {
                new MenuItemInfo("New Folder", o => o.IsDirectory, new CreateFolderCommand()),
                new MenuItemInfo("New File", o => o.IsDirectory, new CreateFileCommand())
            };

            return items;
        }