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); }