private void OnComponentRemoved(object source, ComponentEventArgs ce) { if (ce.Component is System.Windows.Forms.Menu) { if (ce.Component == this.Menu) { TypeDescriptor.GetProperties(base.Component)["Menu"].SetValue(base.Component, null); this.hasMenu = false; } else if ((base.menuEditorService != null) && (ce.Component == base.menuEditorService.GetMenu())) { base.menuEditorService.SetMenu(this.Menu); } } if ((ce.Component is ToolStrip) && (this.toolStripAdornerWindowService != null)) { this.toolStripAdornerWindowService = null; } if (ce.Component is IButtonControl) { if (ce.Component == base.ShadowProperties["AcceptButton"]) { this.AcceptButton = null; } if (ce.Component == base.ShadowProperties["CancelButton"]) { this.CancelButton = null; } } }
private void EnsureToolStripWindowAdornerService() { if (this.toolStripAdornerWindowService == null) { this.toolStripAdornerWindowService = (ToolStripAdornerWindowService)this.GetService(typeof(ToolStripAdornerWindowService)); } }
private void HideMenu() { if (this.menuItem != null) { if ((this.parentMenu != null) && (this.parentFormDesigner != null)) { this.parentFormDesigner.Menu = this.parentMenu; } this.selected = false; if (this.host.RootComponent is Control) { this.menuItem.DropDown.AutoClose = true; this.menuItem.HideDropDown(); this.menuItem.Visible = false; this.designMenu.Visible = false; ToolStripAdornerWindowService service = (ToolStripAdornerWindowService)this.GetService(typeof(ToolStripAdornerWindowService)); if (service != null) { service.Invalidate(); } if (((BehaviorService)this.GetService(typeof(BehaviorService))) != null) { if (this.dummyToolStripGlyph != null) { SelectionManager manager = (SelectionManager)this.GetService(typeof(SelectionManager)); if (manager != null) { if (manager.BodyGlyphAdorner.Glyphs.Contains(this.dummyToolStripGlyph)) { manager.BodyGlyphAdorner.Glyphs.Remove(this.dummyToolStripGlyph); } manager.Refresh(); } } this.dummyToolStripGlyph = null; } if (this.menuItem != null) { ToolStripMenuItemDesigner designer = this.host.GetDesigner(this.menuItem) as ToolStripMenuItemDesigner; if (designer != null) { designer.UnHookEvents(); designer.RemoveTypeHereNode(this.menuItem); } } } } }
protected override void Dispose(bool disposing) { if (disposing) { if (this._editorNode != null) { this._editorNode.CloseEditor(); this._editorNode = null; } if (this.ToolStripItem != null) { this.ToolStripItem.Paint -= new PaintEventHandler(this.OnItemPaint); } IComponentChangeService service = (IComponentChangeService)this.GetService(typeof(IComponentChangeService)); if (service != null) { service.ComponentRename -= new ComponentRenameEventHandler(this.OnComponentRename); } if (this.selSvc != null) { this.selSvc.SelectionChanged -= new EventHandler(this.OnSelectionChanged); } if (this.bodyGlyph != null) { ToolStripAdornerWindowService service2 = (ToolStripAdornerWindowService)this.GetService(typeof(ToolStripAdornerWindowService)); if ((service2 != null) && service2.DropDownAdorner.Glyphs.Contains(this.bodyGlyph)) { service2.DropDownAdorner.Glyphs.Remove(this.bodyGlyph); } } if ((this.toolStripItemCustomMenuItemCollection != null) && (this.toolStripItemCustomMenuItemCollection.Count > 0)) { foreach (System.Windows.Forms.ToolStripItem item in this.toolStripItemCustomMenuItemCollection) { item.Dispose(); } this.toolStripItemCustomMenuItemCollection.Clear(); } this.toolStripItemCustomMenuItemCollection = null; } base.Dispose(disposing); }
public override void Initialize(IComponent component) { base.Initialize(component); base.AutoResizeHandles = true; this.host = (IDesignerHost) this.GetService(typeof(IDesignerHost)); if (this.host != null) { this.componentChangeSvc = (IComponentChangeService) this.host.GetService(typeof(IComponentChangeService)); } if (this.undoEngine == null) { this.undoEngine = this.GetService(typeof(UndoEngine)) as UndoEngine; if (this.undoEngine != null) { this.undoEngine.Undoing += new EventHandler(this.OnUndoing); this.undoEngine.Undone += new EventHandler(this.OnUndone); } } this.editManager = new ToolStripEditorManager(component); if (this.Control.IsHandleCreated) { this.InitializeNewItemDropDown(); } else { this.Control.HandleCreated += new EventHandler(this.Control_HandleCreated); } if (this.componentChangeSvc != null) { this.componentChangeSvc.ComponentRemoved += new ComponentEventHandler(this.ComponentChangeSvc_ComponentRemoved); this.componentChangeSvc.ComponentRemoving += new ComponentEventHandler(this.ComponentChangeSvc_ComponentRemoving); this.componentChangeSvc.ComponentAdded += new ComponentEventHandler(this.ComponentChangeSvc_ComponentAdded); this.componentChangeSvc.ComponentAdding += new ComponentEventHandler(this.ComponentChangeSvc_ComponentAdding); this.componentChangeSvc.ComponentChanged += new ComponentChangedEventHandler(this.ComponentChangeSvc_ComponentChanged); } this.toolStripAdornerWindowService = (ToolStripAdornerWindowService) this.GetService(typeof(ToolStripAdornerWindowService)); this.SelectionService.SelectionChanging += new EventHandler(this.selSvc_SelectionChanging); this.SelectionService.SelectionChanged += new EventHandler(this.selSvc_SelectionChanged); this.ToolStrip.Resize += new EventHandler(this.ToolStrip_Resize); this.ToolStrip.DockChanged += new EventHandler(this.ToolStrip_Resize); this.ToolStrip.LayoutCompleted += new EventHandler(this.ToolStrip_LayoutCompleted); this.ToolStrip.OverflowButton.DropDown.TopLevel = false; if (this.CanAddItems) { new EditorServiceContext(this, TypeDescriptor.GetProperties(base.Component)["Items"], System.Design.SR.GetString("ToolStripItemCollectionEditorVerb")); this.keyboardHandlingService = (ToolStripKeyboardHandlingService) this.GetService(typeof(ToolStripKeyboardHandlingService)); if (this.keyboardHandlingService == null) { this.keyboardHandlingService = new ToolStripKeyboardHandlingService(base.Component.Site); } if (((ISupportInSituService) this.GetService(typeof(ISupportInSituService))) == null) { ISupportInSituService service = new ToolStripInSituService(base.Component.Site); } } this.toolStripSelected = true; if (this.keyboardHandlingService != null) { this.KeyboardHandlingService.SelectedDesignerControl = null; } }
protected override void Dispose(bool disposing) { if (disposing) { this.disposed = true; if (this.items != null) { this.items = null; } if (this.undoEngine != null) { this.undoEngine.Undoing -= new EventHandler(this.OnUndoing); this.undoEngine.Undone -= new EventHandler(this.OnUndone); } if (this.componentChangeSvc != null) { this.componentChangeSvc.ComponentRemoved -= new ComponentEventHandler(this.ComponentChangeSvc_ComponentRemoved); this.componentChangeSvc.ComponentRemoving -= new ComponentEventHandler(this.ComponentChangeSvc_ComponentRemoving); this.componentChangeSvc.ComponentAdded -= new ComponentEventHandler(this.ComponentChangeSvc_ComponentAdded); this.componentChangeSvc.ComponentAdding -= new ComponentEventHandler(this.ComponentChangeSvc_ComponentAdding); this.componentChangeSvc.ComponentChanged -= new ComponentChangedEventHandler(this.ComponentChangeSvc_ComponentChanged); } if (this._selectionSvc != null) { this._selectionSvc.SelectionChanged -= new EventHandler(this.selSvc_SelectionChanged); this._selectionSvc.SelectionChanging -= new EventHandler(this.selSvc_SelectionChanging); this._selectionSvc = null; } base.EnableDragDrop(false); if (this.editManager != null) { this.editManager.CloseManager(); this.editManager = null; } if (this.tn != null) { this.tn.RollBack(); this.tn.CloseEditor(); this.tn = null; } if (this._miniToolStrip != null) { this._miniToolStrip.Dispose(); this._miniToolStrip = null; } if (this.editorNode != null) { this.editorNode.Dispose(); this.editorNode = null; } if (this.ToolStrip != null) { this.ToolStrip.OverflowButton.DropDown.Closing -= new ToolStripDropDownClosingEventHandler(this.OnOverflowDropDownClosing); this.ToolStrip.OverflowButton.DropDownOpening -= new EventHandler(this.OnOverFlowDropDownOpening); this.ToolStrip.OverflowButton.DropDownOpened -= new EventHandler(this.OnOverFlowDropDownOpened); this.ToolStrip.OverflowButton.DropDownClosed -= new EventHandler(this.OnOverFlowDropDownClosed); this.ToolStrip.OverflowButton.DropDown.Resize -= new EventHandler(this.OnOverflowDropDownResize); this.ToolStrip.OverflowButton.DropDown.Paint -= new PaintEventHandler(this.OnOverFlowDropDownPaint); this.ToolStrip.Move -= new EventHandler(this.OnToolStripMove); this.ToolStrip.VisibleChanged -= new EventHandler(this.OnToolStripVisibleChanged); this.ToolStrip.ItemAdded -= new ToolStripItemEventHandler(this.OnItemAdded); this.ToolStrip.Resize -= new EventHandler(this.ToolStrip_Resize); this.ToolStrip.DockChanged -= new EventHandler(this.ToolStrip_Resize); this.ToolStrip.LayoutCompleted -= new EventHandler(this.ToolStrip_LayoutCompleted); } if (this.toolStripContextMenu != null) { this.toolStripContextMenu.Dispose(); this.toolStripContextMenu = null; } this.RemoveBodyGlyphsForOverflow(); if (this.ToolStrip.OverflowButton.DropDown.Visible) { this.ToolStrip.OverflowButton.HideDropDown(); } if (this.toolStripAdornerWindowService != null) { this.toolStripAdornerWindowService = null; } } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { if (disposing) { if (this.selSvc != null) { this.selSvc.SelectionChanged -= new EventHandler(this.OnSelectionChanged); } if (this.undoEngine != null) { this.undoEngine.Undoing -= new EventHandler(this.OnUndoing); this.undoEngine.Undone -= new EventHandler(this.OnUndone); } if (this.MenuItem != null) { this.MenuItem.DropDown.Hide(); this.UnHookEvents(); } if (this.toolStripAdornerWindowService != null) { this.toolStripAdornerWindowService = null; } IComponentChangeService service = (IComponentChangeService) this.GetService(typeof(IComponentChangeService)); if (service != null) { service.ComponentRemoved -= new ComponentEventHandler(this.ComponentChangeSvc_ComponentRemoved); service.ComponentRemoving -= new ComponentEventHandler(this.ComponentChangeSvc_ComponentRemoving); service.ComponentAdding -= new ComponentEventHandler(this.ComponentChangeSvc_ComponentAdding); service.ComponentAdded -= new ComponentEventHandler(this.ComponentChangeSvc_ComponentAdded); } if (this.typeHereTemplateNode != null) { this.typeHereTemplateNode.RollBack(); this.typeHereTemplateNode.CloseEditor(); this.typeHereTemplateNode = null; } if (this.typeHereNode != null) { this.typeHereNode.Dispose(); this.typeHereNode = null; } if (this.commitedTemplateNode != null) { this.commitedTemplateNode.RollBack(); this.commitedTemplateNode.CloseEditor(); this.commitedTemplateNode = null; } if (this.commitedEditorNode != null) { this.commitedEditorNode.Dispose(); this.commitedEditorNode = null; } if (this.parentItem != null) { this.parentItem = null; } } base.Dispose(disposing); }
internal override ToolStripItem MorphCurrentItem(System.Type t) { Rectangle bounds = this.MenuItem.GetCurrentParent().Bounds; Rectangle b = this.MenuItem.DropDown.Bounds; this.InitializeBodyGlyphsForItems(false, this.MenuItem); Rectangle rect = Rectangle.Union(bounds, b); ToolStripAdornerWindowService toolStripAdornerWindowService = this.toolStripAdornerWindowService; ToolStripItem item = base.MorphCurrentItem(t); if (toolStripAdornerWindowService != null) { toolStripAdornerWindowService.Invalidate(rect); toolStripAdornerWindowService = null; } return item; }
public override void Initialize(IComponent component) { base.Initialize(component); base.Visible = true; this.DoubleClickEnabled = this.MenuItem.DoubleClickEnabled; this.selSvc = (ISelectionService) this.GetService(typeof(ISelectionService)); if (this.selSvc != null) { this.selSvc.SelectionChanged += new EventHandler(this.OnSelectionChanged); } this.toolStripAdornerWindowService = (ToolStripAdornerWindowService) this.GetService(typeof(ToolStripAdornerWindowService)); this.designerHost = (IDesignerHost) this.GetService(typeof(IDesignerHost)); this.MenuItem.DoubleClickEnabled = true; IComponentChangeService service = (IComponentChangeService) this.GetService(typeof(IComponentChangeService)); if (service != null) { service.ComponentRemoved += new ComponentEventHandler(this.ComponentChangeSvc_ComponentRemoved); service.ComponentRemoving += new ComponentEventHandler(this.ComponentChangeSvc_ComponentRemoving); service.ComponentAdding += new ComponentEventHandler(this.ComponentChangeSvc_ComponentAdding); service.ComponentAdded += new ComponentEventHandler(this.ComponentChangeSvc_ComponentAdded); } if (this.undoEngine == null) { this.undoEngine = this.GetService(typeof(UndoEngine)) as UndoEngine; if (this.undoEngine != null) { this.undoEngine.Undoing += new EventHandler(this.OnUndoing); this.undoEngine.Undone += new EventHandler(this.OnUndone); } } }