private void OnDesignerLoadComplete(object sender, EventArgs e) { IDesignerHost host = (IDesignerHost)sender; TypeDescriptor.AddAttributes(host.GetDesigner(host.RootComponent), new Attribute[] { new ToolboxItemFilterAttribute(MultiverseInterfaceStudioFilterName, ToolboxItemFilterType.Require) }); IToolboxService toolboxService = (IToolboxService)GetService(typeof(IToolboxService)); toolboxService.Refresh(); }
/// <include file='doc\VsWindowPane.uex' path='docs/doc[@for="VsWindowPane.SetEnabledAttributes"]/*' /> /// <devdoc> /// Set the current set of attributes that determine whether a given component /// on the toolbox is enabled or disabled or "grayed out". If all .Net Framework Classes components are /// to displayed, null is specified. /// </devdoc> public virtual void SetEnabledAttributes(Attribute[] attrs) { if (attrs == null) { enabledTbxAttributes = null; } else { enabledTbxAttributes = new Attribute[attrs.Length]; Array.Copy(attrs, 0, enabledTbxAttributes, 0, attrs.Length); } if (toolboxService == null) { toolboxService = (IToolboxService)GetService((typeof(IToolboxService))); } toolboxService.Refresh(); }
//</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(); }
private void OnRefreshToolbox(object sender, EventArgs e) { toolboxService = (IToolboxService)GetService(typeof(IToolboxService)); IVsToolbox vsToolbox = GetService(typeof(IVsToolbox)) as IVsToolbox; if (toolboxService == null || vsToolbox == null) { return; } PetriNetEditorToolboxProvider toolboxProvider = new PetriNetEditorToolboxProvider(); var itemList = toolboxProvider.GetToolboxItemList(); if (itemList == null || itemList.Count == 0) { return; } string toolboxCategoryName = PetriNetEditorToolboxProvider.ToolboxCategoryName; //Remove target tab and all controls under it. foreach (ToolboxItem oldItem in toolboxService.GetToolboxItems(toolboxCategoryName)) { toolboxService.RemoveToolboxItem(oldItem); } vsToolbox.RemoveTab(PetriNetEditorToolboxProvider.ToolboxCategoryName); foreach (ToolboxItem item in itemList) { toolboxService.AddToolboxItem(item, toolboxCategoryName); } toolboxService.SelectedCategory = toolboxCategoryName; toolboxService.Refresh(); }