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());
     }
 }
 private void SetupNewEditNode(ToolStripTemplateNode owner, string text, Image image, IComponent currentItem)
 {
     this.renderer = new MiniToolStripRenderer(owner);
     this._miniToolStrip = new TransparentToolStrip(owner);
     ToolStrip strip = currentItem as ToolStrip;
     if (strip != null)
     {
         this._miniToolStrip.RightToLeft = strip.RightToLeft;
         strip.RightToLeftChanged += new EventHandler(this.OnRightToLeftChanged);
         this._miniToolStrip.Site = strip.Site;
     }
     ToolStripDropDownItem item = currentItem as ToolStripDropDownItem;
     if (item != null)
     {
         this._miniToolStrip.RightToLeft = item.RightToLeft;
         item.RightToLeftChanged += new EventHandler(this.OnRightToLeftChanged);
     }
     this._miniToolStrip.SuspendLayout();
     this._miniToolStrip.CanOverflow = false;
     this._miniToolStrip.Cursor = Cursors.Default;
     this._miniToolStrip.Dock = DockStyle.None;
     this._miniToolStrip.GripStyle = ToolStripGripStyle.Hidden;
     this._miniToolStrip.Name = "miniToolStrip";
     this._miniToolStrip.TabIndex = 0;
     this._miniToolStrip.Text = "miniToolStrip";
     this._miniToolStrip.Visible = true;
     this._miniToolStrip.Renderer = this.renderer;
     if ((currentItem is MenuStrip) || (currentItem is ToolStripDropDownItem))
     {
         this.SetUpMenuTemplateNode(owner, text, image, currentItem);
     }
     else
     {
         this.SetUpToolTemplateNode(owner, text, image, currentItem);
     }
     this._miniToolStrip.MouseLeave += new EventHandler(this.OnMouseLeave);
     this._miniToolStrip.ResumeLayout();
 }