private void HideDummyNode() { this.ToolStripItem.AutoSize = this.AutoSize; if (this._editorNode != null) { this._editorNode.CloseEditor(); this._editorNode = null; } }
/// <summary> /// Activates the editor for the given item.If there's still an editor around for the previous-edited item, it is deactivated. Pass in 'null' to deactivate and remove the current editor, if any. /// </summary> internal void ActivateEditor(ToolStripItem item, bool clicked) { if (item != _currentItem) { // Remove old editor if (_editor != null) { _behaviorService.AdornerWindowControl.Controls.Remove(_editor); _behaviorService.Invalidate(_editor.Bounds); _editorUI = null; _editor = null; _currentItem = null; _itemDesigner.IsEditorActive = false; // Show the previously edited glyph if (_currentItem != null) { _currentItem = null; } } if (item != null) { // Add new editor from the item... _currentItem = item; if (_designerHost != null) { _itemDesigner = (ToolStripItemDesigner)_designerHost.GetDesigner(_currentItem); } _editorUI = (ToolStripTemplateNode)_itemDesigner.Editor; // If we got an editor, position and focus it. if (_editorUI != null) { // Hide this glyph while it's being edited _itemDesigner.IsEditorActive = true; _editor = new ToolStripEditorControl(_editorUI.EditorToolStrip, _editorUI.Bounds); _behaviorService.AdornerWindowControl.Controls.Add(_editor); _lastKnownEditorBounds = _editor.Bounds; _editor.BringToFront(); // this is important since the ToolStripEditorControl listens to textchanged messages from TextBox. _editorUI.ignoreFirstKeyUp = true; // Select the Editor... Put Text and Select it ... _editorUI.FocusEditor(_currentItem); } } } }
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); }
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); } } } }
// Constructors public TransparentToolStrip(ToolStripTemplateNode owner) { }
// Constructors public MiniToolStripRenderer(ToolStripTemplateNode owner) { }
private void CreateDummyNode() { this._editorNode = new ToolStripTemplateNode(this.ToolStripItem, this.ToolStripItem.Text, this.ToolStripItem.Image); }