protected override void OnOpening(CancelEventArgs e) { base.Groups["StandardList"].Items.Clear(); base.Groups["CustomList"].Items.Clear(); base.Populated = false; foreach (ToolStripItem item in ToolStripDesignerUtils.GetStandardItemMenuItems(this.component, this.onClick, this.convertTo)) { base.Groups["StandardList"].Items.Add(item); if (this.convertTo) { ItemTypeToolStripMenuItem item2 = item as ItemTypeToolStripMenuItem; if (((item2 != null) && (this.currentItem != null)) && (item2.ItemType == this.currentItem.GetType())) { item2.Enabled = false; } } } foreach (ToolStripItem item3 in ToolStripDesignerUtils.GetCustomItemMenuItems(this.component, this.onClick, this.convertTo, this.serviceProvider)) { base.Groups["CustomList"].Items.Add(item3); if (this.convertTo) { ItemTypeToolStripMenuItem item4 = item3 as ItemTypeToolStripMenuItem; if (((item4 != null) && (this.currentItem != null)) && (item4.ItemType == this.currentItem.GetType())) { item4.Enabled = false; } } } base.OnOpening(e); }
private void AddNewItemClick(object sender, EventArgs e) { ItemTypeToolStripMenuItem item = (ItemTypeToolStripMenuItem)sender; System.Type itemType = item.ItemType; this.InsertItem(itemType); }
private void AddNewItemClick(object sender, EventArgs e) { ItemTypeToolStripMenuItem item = (ItemTypeToolStripMenuItem)sender; System.Type itemType = item.ItemType; if (item.ConvertTo) { this.MorphToolStripItem(itemType); } else { this.InsertItem(itemType); } }
public static ToolStripItem[] GetCustomItemMenuItems(IComponent component, EventHandler onClick, bool convertTo, IServiceProvider serviceProvider) { System.Type[] customItemTypes = GetCustomItemTypes(component, serviceProvider); ToolStripItem[] itemArray = new ToolStripItem[customItemTypes.Length]; for (int i = 0; i < customItemTypes.Length; i++) { ItemTypeToolStripMenuItem item = new ItemTypeToolStripMenuItem(customItemTypes[i]) { ConvertTo = convertTo }; if (onClick != null) { item.Click += onClick; } itemArray[i] = item; } return itemArray; }
/// <summary> /// wraps the result of GetCustomItemTypes in ItemTypeToolStripMenuItems. /// </summary> public static ToolStripItem[] GetCustomItemMenuItems(IComponent component, EventHandler onClick, bool convertTo, IServiceProvider serviceProvider) { Type[] customTypes = GetCustomItemTypes(component, serviceProvider); ToolStripItem[] items = new ToolStripItem[customTypes.Length]; for (int i = 0; i < customTypes.Length; i++) { ItemTypeToolStripMenuItem item = new ItemTypeToolStripMenuItem(customTypes[i]) { ConvertTo = convertTo }; if (onClick != null) { item.Click += onClick; } items[i] = item; } return(items); }
/// <summary> /// wraps the result of GetStandardItemTypes in ItemTypeToolStripMenuItems. /// </summary> public static ToolStripItem[] GetStandardItemMenuItems(IComponent component, EventHandler onClick, bool convertTo) { Type[] standardTypes = GetStandardItemTypes(component); ToolStripItem[] items = new ToolStripItem[standardTypes.Length]; for (int i = 0; i < standardTypes.Length; i++) { ItemTypeToolStripMenuItem item = new ItemTypeToolStripMenuItem(standardTypes[i]) { ConvertTo = convertTo }; if (onClick != null) { item.Click += onClick; } items[i] = item; } return(items); }
public static ToolStripDropDown GetNewItemDropDown(IComponent component, ToolStripItem currentItem, EventHandler onClick, bool convertTo, IServiceProvider serviceProvider) { NewItemsContextMenuStrip strip = new NewItemsContextMenuStrip(component, currentItem, onClick, convertTo, serviceProvider); strip.GroupOrdering.Add("StandardList"); strip.GroupOrdering.Add("CustomList"); foreach (ToolStripItem item in GetStandardItemMenuItems(component, onClick, convertTo)) { strip.Groups["StandardList"].Items.Add(item); if (convertTo) { ItemTypeToolStripMenuItem item2 = item as ItemTypeToolStripMenuItem; if (((item2 != null) && (currentItem != null)) && (item2.ItemType == currentItem.GetType())) { item2.Enabled = false; } } } foreach (ToolStripItem item3 in GetCustomItemMenuItems(component, onClick, convertTo, serviceProvider)) { strip.Groups["CustomList"].Items.Add(item3); if (convertTo) { ItemTypeToolStripMenuItem item4 = item3 as ItemTypeToolStripMenuItem; if (((item4 != null) && (currentItem != null)) && (item4.ItemType == currentItem.GetType())) { item4.Enabled = false; } } } IUIService service = serviceProvider.GetService(typeof(IUIService)) as IUIService; if (service != null) { strip.Renderer = (ToolStripProfessionalRenderer)service.Styles["VsRenderer"]; strip.Font = (Font)service.Styles["DialogFont"]; } strip.Populate(); return(strip); }
public static ToolStripItem[] GetStandardItemMenuItems(IComponent component, EventHandler onClick, bool convertTo) { System.Type[] standardItemTypes = GetStandardItemTypes(component); ToolStripItem[] itemArray = new ToolStripItem[standardItemTypes.Length]; for (int i = 0; i < standardItemTypes.Length; i++) { ItemTypeToolStripMenuItem item = new ItemTypeToolStripMenuItem(standardItemTypes[i]) { ConvertTo = convertTo }; if (onClick != null) { item.Click += onClick; } itemArray[i] = item; } return itemArray; }
private void AddNewItemClick(object sender, EventArgs e) { if (this.addItemButton != null) { this.addItemButton.DropDown.Visible = false; } if ((this.component is ToolStrip) && (this.SelectionService != null)) { ToolStripDesigner designer = this._designerHost.GetDesigner(this.component) as ToolStripDesigner; try { if (designer != null) { designer.DontCloseOverflow = true; } this.SelectionService.SetSelectedComponents(new object[] { this.component }); } finally { if (designer != null) { designer.DontCloseOverflow = false; } } } ItemTypeToolStripMenuItem item = (ItemTypeToolStripMenuItem) sender; if (this.lastSelection != null) { this.lastSelection.Checked = false; } item.Checked = true; this.lastSelection = item; this.ToolStripItemType = item.ItemType; if (this.controlHost.GetCurrentParent() is MenuStrip) { this.CommitEditor(true, true, false); } else { this.CommitEditor(true, false, false); } if (this.KeyboardService != null) { this.KeyboardService.TemplateNodeActive = false; } }
internal void CloseEditor() { if (this._miniToolStrip != null) { this.Active = false; if (this.lastSelection != null) { this.lastSelection.Dispose(); this.lastSelection = null; } ToolStrip component = this.component as ToolStrip; if (component != null) { component.RightToLeftChanged -= new EventHandler(this.OnRightToLeftChanged); } else { ToolStripDropDownItem item = this.component as ToolStripDropDownItem; if (item != null) { item.RightToLeftChanged -= new EventHandler(this.OnRightToLeftChanged); } } if (this.centerLabel != null) { this.centerLabel.MouseUp -= new MouseEventHandler(this.CenterLabelClick); this.centerLabel.MouseEnter -= new EventHandler(this.CenterLabelMouseEnter); this.centerLabel.MouseMove -= new MouseEventHandler(this.CenterLabelMouseMove); this.centerLabel.MouseLeave -= new EventHandler(this.CenterLabelMouseLeave); this.centerLabel.Dispose(); this.centerLabel = null; } if (this.addItemButton != null) { this.addItemButton.MouseMove -= new MouseEventHandler(this.OnMouseMove); this.addItemButton.MouseUp -= new MouseEventHandler(this.OnMouseUp); this.addItemButton.MouseDown -= new MouseEventHandler(this.OnMouseDown); this.addItemButton.DropDownOpened -= new EventHandler(this.OnAddItemButtonDropDownOpened); this.addItemButton.DropDown.Dispose(); this.addItemButton.Dispose(); this.addItemButton = null; } if (this.contextMenu != null) { this.contextMenu.Closed -= new ToolStripDropDownClosedEventHandler(this.OnContextMenuClosed); this.contextMenu.Opened -= new EventHandler(this.OnContextMenuOpened); this.contextMenu = null; } this._miniToolStrip.MouseLeave -= new EventHandler(this.OnMouseLeave); this._miniToolStrip.Dispose(); this._miniToolStrip = null; if (this._designSurface != null) { this._designSurface.Flushed -= new EventHandler(this.OnLoaderFlushed); this._designSurface = null; } this._designer = null; this.OnClosed(new EventArgs()); } }