private void CreateToolboxData(string pToolboxItemName, string pData, string pTabInToolbox, bool pRemoveTabItems = false) { // Create the data object that will store the data for the menu item. OleDataObject toolboxData = new OleDataObject(); toolboxData.SetData(typeof(ToolboxData), new ToolboxData(pData)); // Get the toolbox service IVsToolbox toolbox = (IVsToolbox)GetService(typeof(SVsToolbox)); //IVsToolbox2 vsToolbox2 = (IVsToolbox2)toolbox; //IVsToolbox3 vsToolbox3 = (IVsToolbox3)vsToolbox2; if (pRemoveTabItems) { bool succeed = ErrorHandler.Succeeded(toolbox.RemoveTab(pTabInToolbox)); } // Create the array of TBXITEMINFO structures to describe the items // we are adding to the toolbox. TBXITEMINFO[] itemInfo = new TBXITEMINFO[1]; itemInfo[0].bstrText = pToolboxItemName; itemInfo[0].clrTransparent = ColorToUInt(Color.Black); itemInfo[0].hBmp = Resources.cartForToolboxItem.GetHbitmap(); itemInfo[0].dwFlags = (uint)__TBXITEMINFOFLAGS.TBXIF_DONTPERSIST; //itemInfo[0].iImageIndex = 0; //itemInfo[0].iImageWidth = 16; ErrorHandler.ThrowOnFailure(toolbox.AddItem(toolboxData, itemInfo, pTabInToolbox)); }
void SQLitePackage_ToolboxUpgraded(object sender, EventArgs e) { IVsToolbox vstbx = GetService(typeof(SVsToolbox)) as IVsToolbox; vstbx.RemoveTab("SQLite"); SQLitePackage_ToolboxInitialized(sender, e); }
private void OnToolboxUpgraded(object sender, EventArgs e) { IVsToolbox toolbox = this.GetService(typeof(SVsToolbox)) as IVsToolbox; if (toolbox == null) { throw new InvalidOperationException(); } toolbox.RemoveTab(toolboxTabName); OnToolboxInitialized(sender, e); }
//</Snippet10> //<Snippet11> void OnRefreshToolbox(object sender, EventArgs e) { // Add new instances of all ToolboxItems contained in ToolboxItemList. IToolboxService service = GetService(typeof(IToolboxService)) as IToolboxService; IVsToolbox toolbox = GetService(typeof(IVsToolbox)) as IVsToolbox; //Remove target tab and all controls under it. foreach (ToolboxItem oldItem in service.GetToolboxItems(CategoryTab)) { service.RemoveToolboxItem(oldItem); } toolbox.RemoveTab(CategoryTab); foreach (ToolboxItem itemFromList in ToolboxItemList) { service.AddToolboxItem(itemFromList, CategoryTab); } service.SelectedCategory = CategoryTab; service.Refresh(); }
//<Snippet10> // Add new instances of all ToolboxItems to the toolbox item list. void OnRefreshToolbox(object sender, EventArgs e) { IToolboxService service = GetService(typeof(IToolboxService)) as IToolboxService; IVsToolbox toolbox = GetService(typeof(IVsToolbox)) as IVsToolbox; // Remove target tab and all items under it. foreach (ToolboxItem item in service.GetToolboxItems(CategoryTab)) { service.RemoveToolboxItem(item); } toolbox.RemoveTab(CategoryTab); // Recreate the target tab with the items from the current list. foreach (ToolboxItem item in ToolboxItemList) { service.AddToolboxItem(item, CategoryTab); } service.SelectedCategory = CategoryTab; service.Refresh(); }