internal void AddNewTemplateNode(ToolStripDropDown dropDown)
 {
     foreach (ToolStripItem item in dropDown.Items)
     {
         if (item is DesignerToolStripControlHost)
         {
             this.typeHereNode = (DesignerToolStripControlHost) item;
         }
     }
     if (this.typeHereNode != null)
     {
         dropDown.Items.Remove(this.typeHereNode);
     }
     this.typeHereTemplateNode = new ToolStripTemplateNode(base.Component, System.Design.SR.GetString("ToolStripDesignerTemplateNodeEnterText"), null);
     int width = this.typeHereTemplateNode.EditorToolStrip.Width;
     this.typeHereNode = new DesignerToolStripControlHost(this.typeHereTemplateNode.EditorToolStrip);
     this.typeHereTemplateNode.ControlHost = this.typeHereNode;
     this.typeHereNode.AutoSize = false;
     this.typeHereNode.Width = width;
     dropDown.Items.Add(this.typeHereNode);
 }
 internal void ActivateEditor(ToolStripItem item, bool clicked)
 {
     if (item != this.currentItem)
     {
         if (this.editor != null)
         {
             this.behaviorService.AdornerWindowControl.Controls.Remove(this.editor);
             this.behaviorService.Invalidate(this.editor.Bounds);
             this.editorUI = null;
             this.editor = null;
             this.currentItem = null;
             this.itemDesigner.IsEditorActive = false;
             if (this.currentItem != null)
             {
                 this.currentItem = null;
             }
         }
         if (item != null)
         {
             this.currentItem = item;
             if (this.designerHost != null)
             {
                 this.itemDesigner = (ToolStripItemDesigner) this.designerHost.GetDesigner(this.currentItem);
             }
             this.editorUI = this.itemDesigner.Editor;
             if (this.editorUI != null)
             {
                 this.itemDesigner.IsEditorActive = true;
                 this.editor = new ToolStripEditorControl(this.editorUI.EditorToolStrip, this.editorUI.Bounds);
                 this.behaviorService.AdornerWindowControl.Controls.Add(this.editor);
                 this.lastKnownEditorBounds = this.editor.Bounds;
                 this.editor.BringToFront();
                 this.editorUI.ignoreFirstKeyUp = true;
                 this.editorUI.FocusEditor(this.currentItem);
             }
         }
     }
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 private void HideDummyNode()
 {
     this.ToolStripItem.AutoSize = this.AutoSize;
     if (this._editorNode != null)
     {
         this._editorNode.CloseEditor();
         this._editorNode = null;
     }
 }
 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);
 }
 private void CreateDummyMenuItem(ToolStripItem item, string text, Image image)
 {
     this.commitedTemplateNode = new ToolStripTemplateNode(base.Component, text, image);
     this.commitedTemplateNode.ActiveItem = item;
     int width = this.commitedTemplateNode.EditorToolStrip.Width;
     this.commitedEditorNode = new DesignerToolStripControlHost(this.commitedTemplateNode.EditorToolStrip);
     this.commitedEditorNode.AutoSize = false;
     this.commitedEditorNode.Width = width;
 }
コード例 #7
0
 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();
 }
 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);
 }
 internal void RemoveTypeHereNode(ToolStripDropDownItem ownerItem)
 {
     Rectangle bounds = ownerItem.DropDown.Bounds;
     if ((ownerItem.DropDownItems.Count > 0) && (ownerItem.DropDownItems[0] is DesignerToolStripControlHost))
     {
         ownerItem.DropDownItems.RemoveAt(0);
     }
     if ((this.typeHereTemplateNode != null) && this.typeHereTemplateNode.Active)
     {
         this.typeHereTemplateNode.RollBack();
         this.typeHereTemplateNode.CloseEditor();
         this.typeHereTemplateNode = null;
     }
     if (this.typeHereNode != null)
     {
         this.typeHereNode.Dispose();
         this.typeHereNode = null;
     }
     if (this.toolStripAdornerWindowService != null)
     {
         this.toolStripAdornerWindowService.Invalidate(bounds);
     }
 }
 internal override void CommitEdit(System.Type type, string text, bool commit, bool enterKeyPressed, bool tabKeyPressed)
 {
     base.IsEditorActive = false;
     if (!(this.MenuItem.Owner is ToolStripDropDown) && (base.Editor != null))
     {
         base.CommitEdit(type, text, commit, enterKeyPressed, tabKeyPressed);
         return;
     }
     if (!commit)
     {
         if (this.commitedEditorNode != null)
         {
             this.MenuItem.DropDown.SuspendLayout();
             bool flag2 = base.dummyItemAdded;
             base.dummyItemAdded = false;
             int index = this.MenuItem.DropDownItems.IndexOf(this.commitedEditorNode);
             ToolStripItem item4 = this.MenuItem.DropDownItems[index + 1];
             this.MenuItem.DropDown.Items.Remove(this.commitedEditorNode);
             item4.Visible = true;
             if (this.commitedTemplateNode != null)
             {
                 this.commitedTemplateNode.CloseEditor();
                 this.commitedTemplateNode = null;
             }
             if (this.commitedEditorNode != null)
             {
                 this.commitedEditorNode.Dispose();
                 this.commitedEditorNode = null;
             }
             if (flag2)
             {
                 this.MenuItem.DropDownItems.Remove(item4);
                 try
                 {
                     this.designerHost.DestroyComponent(item4);
                 }
                 catch
                 {
                     if (this.newMenuItemTransaction != null)
                     {
                         try
                         {
                             this.newMenuItemTransaction.Cancel();
                         }
                         catch
                         {
                         }
                         this.newMenuItemTransaction = null;
                     }
                 }
                 item4 = null;
             }
             this.MenuItem.DropDown.ResumeLayout();
             if (item4 != null)
             {
                 this.AddItemBodyGlyph(item4);
             }
             if (flag2)
             {
                 SelectionManager service = (SelectionManager) this.GetService(typeof(SelectionManager));
                 service.NeedRefresh = false;
                 if (this.newMenuItemTransaction != null)
                 {
                     try
                     {
                         base.dummyItemAdded = true;
                         this.newMenuItemTransaction.Cancel();
                         this.newMenuItemTransaction = null;
                         if (this.MenuItem.DropDownItems.Count == 0)
                         {
                             this.CreatetypeHereNode();
                         }
                     }
                     finally
                     {
                         base.dummyItemAdded = false;
                     }
                 }
                 flag2 = false;
             }
             this.MenuItem.DropDown.PerformLayout();
         }
         return;
     }
     int dummyIndex = -1;
     bool dummyItemAdded = base.dummyItemAdded;
     base.dummyItemAdded = false;
     this.MenuItem.DropDown.SuspendLayout();
     if (this.commitedEditorNode != null)
     {
         dummyIndex = this.MenuItem.DropDownItems.IndexOf(this.commitedEditorNode);
         ToolStripItem component = this.MenuItem.DropDownItems[dummyIndex + 1];
         this.MenuItem.DropDown.Items.Remove(this.commitedEditorNode);
         if (this.commitedTemplateNode != null)
         {
             this.commitedTemplateNode.CloseEditor();
             this.commitedTemplateNode = null;
         }
         if (this.commitedEditorNode != null)
         {
             this.commitedEditorNode.Dispose();
             this.commitedEditorNode = null;
         }
         if (text == "-")
         {
             ToolStripItemDesigner designer = this.designerHost.GetDesigner(component) as ToolStripItemDesigner;
             if (designer == null)
             {
                 goto Label_028C;
             }
             try
             {
                 try
                 {
                     component = designer.MorphCurrentItem(typeof(ToolStripSeparator));
                     this.RemoveItemBodyGlyph(component);
                 }
                 catch
                 {
                     if (this.newMenuItemTransaction != null)
                     {
                         try
                         {
                             this.newMenuItemTransaction.Cancel();
                         }
                         catch
                         {
                         }
                         this.newMenuItemTransaction = null;
                     }
                 }
                 goto Label_028C;
             }
             finally
             {
                 if (this.newMenuItemTransaction != null)
                 {
                     this.newMenuItemTransaction.Commit();
                     this.newMenuItemTransaction = null;
                 }
             }
         }
         if (dummyItemAdded)
         {
             try
             {
                 try
                 {
                     base.dummyItemAdded = true;
                     this.CreateNewItem(type, dummyIndex, text);
                     this.designerHost.DestroyComponent(component);
                     if (enterKeyPressed)
                     {
                         this.typeHereNode.SelectControl();
                     }
                 }
                 catch
                 {
                     if (this.newMenuItemTransaction != null)
                     {
                         try
                         {
                             this.newMenuItemTransaction.Cancel();
                         }
                         catch
                         {
                         }
                         this.newMenuItemTransaction = null;
                     }
                 }
                 goto Label_028C;
             }
             finally
             {
                 if (this.newMenuItemTransaction != null)
                 {
                     this.newMenuItemTransaction.Commit();
                     this.newMenuItemTransaction = null;
                 }
                 base.dummyItemAdded = false;
             }
         }
         component.Visible = true;
         DesignerTransaction transaction = this.designerHost.CreateTransaction(System.Design.SR.GetString("ToolStripItemPropertyChangeTransaction"));
         try
         {
             PropertyDescriptor descriptor = TypeDescriptor.GetProperties(component)["Text"];
             string str = (string) descriptor.GetValue(component);
             if ((descriptor != null) && (text != str))
             {
                 descriptor.SetValue(component, text);
             }
         }
         catch
         {
             if (transaction != null)
             {
                 transaction.Cancel();
                 transaction = null;
             }
         }
         finally
         {
             if (transaction != null)
             {
                 transaction.Commit();
                 transaction = null;
             }
         }
     }
     else
     {
         dummyIndex = this.MenuItem.DropDownItems.IndexOf(this.typeHereNode);
         try
         {
             base.dummyItemAdded = true;
             this.CreateNewItem(type, dummyIndex, text);
         }
         finally
         {
             base.dummyItemAdded = false;
         }
         this.typeHereNode.SelectControl();
     }
 Label_028C:
     this.MenuItem.DropDown.ResumeLayout(true);
     this.MenuItem.DropDown.PerformLayout();
     this.ResetGlyphs(this.MenuItem);
     if (this.selSvc != null)
     {
         if (enterKeyPressed)
         {
             ToolStripItem item2 = null;
             if (((this.MenuItem.DropDownDirection == ToolStripDropDownDirection.AboveLeft) || (this.MenuItem.DropDownDirection == ToolStripDropDownDirection.AboveRight)) && (dummyIndex >= 1))
             {
                 item2 = this.MenuItem.DropDownItems[dummyIndex - 1];
             }
             else
             {
                 item2 = this.MenuItem.DropDownItems[dummyIndex + 1];
             }
             if (this.KeyboardHandlingService != null)
             {
                 if (item2 != null)
                 {
                     ToolStripDropDownItem item3 = this.MenuItem.DropDownItems[dummyIndex] as ToolStripDropDownItem;
                     if (item3 != null)
                     {
                         item3.HideDropDown();
                     }
                 }
                 if (item2 == this.typeHereNode)
                 {
                     this.KeyboardHandlingService.SelectedDesignerControl = item2;
                     this.selSvc.SetSelectedComponents(null, SelectionTypes.Replace);
                 }
                 else
                 {
                     this.KeyboardHandlingService.SelectedDesignerControl = null;
                     this.selSvc.SetSelectedComponents(new object[] { item2 });
                 }
             }
         }
         else if (tabKeyPressed)
         {
             this.selSvc.SetSelectedComponents(new object[] { this.MenuItem.DropDownItems[dummyIndex] }, SelectionTypes.Replace);
         }
     }
 }
コード例 #11
0
 public TemplateTextBox(ToolStripTemplateNode.TransparentToolStrip parent, ToolStripTemplateNode owner)
 {
     this.parent = parent;
     this.owner = owner;
     this.AutoSize = false;
     this.Multiline = false;
 }
コード例 #12
0
 public TransparentToolStrip(ToolStripTemplateNode owner)
 {
     this.owner = owner;
     this.currentItem = owner.component;
     base.TabStop = true;
     base.SetStyle(ControlStyles.Selectable, true);
     this.AutoSize = false;
 }
コード例 #13
0
 public MiniToolStripRenderer(ToolStripTemplateNode owner)
 {
     this.owner = owner;
     this.selectedBorderColor = Color.FromArgb(0x2e, 0x6a, 0xc5);
     this.defaultBorderColor = Color.FromArgb(0xab, 0xab, 0xab);
     this.dropDownMouseOverColor = Color.FromArgb(0xc1, 210, 0xee);
     this.dropDownMouseDownColor = Color.FromArgb(0x98, 0xb5, 0xe2);
     this.toolStripBorderColor = Color.White;
 }
コード例 #14
0
 private void SetUpToolTemplateNode(ToolStripTemplateNode owner, string text, Image image, IComponent component)
 {
     this.addItemButton = new ToolStripSplitButton();
     this.addItemButton.AutoSize = false;
     this.addItemButton.Margin = new Padding(1);
     this.addItemButton.Size = this._miniToolStrip.DisplayRectangle.Size - this.addItemButton.Margin.Size;
     this.addItemButton.DropDownButtonWidth = MINITOOLSTRIP_DROPDOWN_BUTTON_WIDTH;
     this.addItemButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
     if (component is StatusStrip)
     {
         this.addItemButton.ToolTipText = System.Design.SR.GetString("ToolStripDesignerTemplateNodeSplitButtonStatusStripToolTip");
     }
     else
     {
         this.addItemButton.ToolTipText = System.Design.SR.GetString("ToolStripDesignerTemplateNodeSplitButtonToolTip");
     }
     this.addItemButton.MouseDown += new MouseEventHandler(this.OnMouseDown);
     this.addItemButton.MouseMove += new MouseEventHandler(this.OnMouseMove);
     this.addItemButton.MouseUp += new MouseEventHandler(this.OnMouseUp);
     this.addItemButton.DropDownOpened += new EventHandler(this.OnAddItemButtonDropDownOpened);
     this.contextMenu = ToolStripDesignerUtils.GetNewItemDropDown(component, null, new EventHandler(this.AddNewItemClick), false, component.Site, false);
     this.contextMenu.Text = "ItemSelectionMenu";
     this.contextMenu.Closed += new ToolStripDropDownClosedEventHandler(this.OnContextMenuClosed);
     this.contextMenu.Opened += new EventHandler(this.OnContextMenuOpened);
     this.addItemButton.DropDown = this.contextMenu;
     try
     {
         if (this.addItemButton.DropDownItems.Count > 0)
         {
             ItemTypeToolStripMenuItem item = (ItemTypeToolStripMenuItem) this.addItemButton.DropDownItems[0];
             this.addItemButton.ImageTransparentColor = Color.Lime;
             Bitmap logicalBitmap = new Bitmap(System.Drawing.BitmapSelector.GetResourceStream(typeof(ToolStripTemplateNode), "ToolStripTemplateNode.bmp"));
             if (System.Windows.Forms.DpiHelper.IsScalingRequired)
             {
                 System.Windows.Forms.DpiHelper.ScaleBitmapLogicalToDevice(ref logicalBitmap);
             }
             this.addItemButton.Image = logicalBitmap;
             this.addItemButton.DefaultItem = item;
         }
     }
     catch (Exception exception)
     {
         if (System.Windows.Forms.ClientUtils.IsCriticalException(exception))
         {
             throw;
         }
     }
     this._miniToolStrip.Items.AddRange(new ToolStripItem[] { this.addItemButton });
 }
コード例 #15
0
 private void CreateDummyNode()
 {
     this._editorNode = new ToolStripTemplateNode(this.ToolStripItem, this.ToolStripItem.Text, this.ToolStripItem.Image);
 }
 internal void AddNewTemplateNode(System.Windows.Forms.ToolStrip wb)
 {
     this.tn = new ToolStripTemplateNode(base.Component, System.Design.SR.GetString("ToolStripDesignerTemplateNodeEnterText"), null);
     this._miniToolStrip = this.tn.EditorToolStrip;
     int width = this.tn.EditorToolStrip.Width;
     this.editorNode = new DesignerToolStripControlHost(this.tn.EditorToolStrip);
     this.tn.ControlHost = this.editorNode;
     this.editorNode.Width = width;
     this.ToolStrip.Items.Add(this.editorNode);
     this.editorNode.Visible = false;
 }
 private void RollBack()
 {
     if (this.commitedEditorNode != null)
     {
         int index = this.MenuItem.DropDownItems.IndexOf(this.commitedEditorNode);
         ToolStripDropDownItem item = (ToolStripDropDownItem) this.MenuItem.DropDownItems[index + 1];
         if (item != null)
         {
             item.Visible = true;
         }
         this.MenuItem.DropDown.Items.Remove(this.commitedEditorNode);
         if (this.commitedTemplateNode != null)
         {
             this.commitedTemplateNode.RollBack();
             this.commitedTemplateNode.CloseEditor();
             this.commitedTemplateNode = null;
         }
         if (this.commitedEditorNode != null)
         {
             this.commitedEditorNode.Dispose();
             this.commitedEditorNode = null;
         }
     }
 }
 public void RemoveCommands()
 {
     IMenuCommandService menuService = this.MenuService;
     if (((menuService != null) && this.commandsAdded) && (this.newCommands != null))
     {
         foreach (MenuCommand command in this.newCommands)
         {
             menuService.RemoveCommand(command);
         }
     }
     if (this.newCommandPaste != null)
     {
         menuService.RemoveCommand(this.newCommandPaste);
         this.newCommandPaste = null;
     }
     if (this.oldCommandPaste != null)
     {
         this.oldCommandPaste = null;
     }
     if (this.newCommands != null)
     {
         this.newCommands.Clear();
         this.newCommands = null;
     }
     if (this.oldCommands != null)
     {
         this.oldCommands.Clear();
         this.oldCommands = null;
     }
     if (this.selectionService != null)
     {
         this.selectionService.SelectionChanging -= new EventHandler(this.OnSelectionChanging);
         this.selectionService.SelectionChanged -= new EventHandler(this.OnSelectionChanged);
         this.selectionService = null;
     }
     if (this.componentChangeSvc != null)
     {
         this.componentChangeSvc.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved);
         this.componentChangeSvc = null;
     }
     this.currentSelection = null;
     this.shiftPrimary = null;
     this.provider = null;
     this.menuCommandService = null;
     this.activeTemplateNode = null;
 }
コード例 #19
0
 private void SetUpMenuTemplateNode(ToolStripTemplateNode owner, string text, Image image, IComponent currentItem)
 {
     this.centerLabel = new ToolStripLabel();
     this.centerLabel.Text = text;
     this.centerLabel.AutoSize = false;
     this.centerLabel.IsLink = false;
     this.centerLabel.Margin = new Padding(1);
     if (currentItem is ToolStripDropDownItem)
     {
         this.centerLabel.Margin = new Padding(1, 2, 1, 3);
     }
     this.centerLabel.Padding = new Padding(0, 1, 0, 0);
     this.centerLabel.Name = "centerLabel";
     this.centerLabel.Size = this._miniToolStrip.DisplayRectangle.Size - this.centerLabel.Margin.Size;
     this.centerLabel.ToolTipText = System.Design.SR.GetString("ToolStripDesignerTemplateNodeLabelToolTip");
     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._miniToolStrip.Items.AddRange(new ToolStripItem[] { this.centerLabel });
 }