internal ChangeToolStripParentVerb(string text, ToolStripDesigner designer) { this._designer = designer; this._provider = designer.Component.Site; this._host = (IDesignerHost)this._provider.GetService(typeof(IDesignerHost)); this.componentChangeSvc = (IComponentChangeService)this._provider.GetService(typeof(IComponentChangeService)); }
/// <summary> /// Create one of these things... /// </summary> internal ChangeToolStripParentVerb(string text, ToolStripDesigner designer) { Debug.Assert(designer != null, "Can't have a StandardMenuStripVerb without an associated designer"); _designer = designer; _provider = designer.Component.Site; _host = (IDesignerHost)_provider.GetService(typeof(IDesignerHost)); _componentChangeSvc = (IComponentChangeService)_provider.GetService(typeof(IComponentChangeService)); }
private void InsertIntoDropDown(ToolStripDropDown parent, System.Type t) { IDesignerHost host = (IDesignerHost)this.serviceProvider.GetService(typeof(IDesignerHost)); int index = parent.Items.IndexOf(this.currentItem); if (parent != null) { ToolStripDropDownItem ownerItem = parent.OwnerItem as ToolStripDropDownItem; if ((ownerItem != null) && ((ownerItem.DropDownDirection == ToolStripDropDownDirection.AboveLeft) || (ownerItem.DropDownDirection == ToolStripDropDownDirection.AboveRight))) { index++; } } IDesigner designer = null; DesignerTransaction transaction = host.CreateTransaction(System.Design.SR.GetString("ToolStripAddingItem")); try { IComponent component = host.CreateComponent(t); designer = host.GetDesigner(component); if (designer is ComponentDesigner) { ((ComponentDesigner)designer).InitializeNewComponent(null); } parent.Items.Insert(index, (ToolStripItem)component); ISelectionService service = (ISelectionService)this.serviceProvider.GetService(typeof(ISelectionService)); if (service != null) { service.SetSelectedComponents(new object[] { component }, SelectionTypes.Replace); } } catch (Exception exception) { if (((parent != null) && (parent.OwnerItem != null)) && (parent.OwnerItem.Owner != null)) { ToolStripDesigner designer2 = host.GetDesigner(parent.OwnerItem.Owner) as ToolStripDesigner; if (designer2 != null) { designer2.CancelPendingMenuItemTransaction(); } } this.TryCancelTransaction(ref transaction); if (System.Windows.Forms.ClientUtils.IsCriticalException(exception)) { throw; } } finally { if (transaction != null) { transaction.Commit(); transaction = null; } } }
public ToolStripActionList(ToolStripDesigner designer) : base(designer.Component) { this._toolStrip = (ToolStrip)designer.Component; this.designer = designer; this.changeParentVerb = new ChangeToolStripParentVerb(System.Design.SR.GetString("ToolStripDesignerEmbedVerb"), designer); if (!(this._toolStrip is StatusStrip)) { this.standardItemsVerb = new StandardMenuStripVerb(System.Design.SR.GetString("ToolStripDesignerStandardItemsVerb"), designer); } }
public ToolStripActionList(ToolStripDesigner designer) : base(designer.Component) { _toolStrip = (ToolStrip)designer.Component; _designer = designer; _changeParentVerb = new ChangeToolStripParentVerb(SR.ToolStripDesignerEmbedVerb, designer); if (!(_toolStrip is StatusStrip)) { _standardItemsVerb = new StandardMenuStripVerb(designer); } }
internal StandardMenuStripVerb(string text, ToolStripDesigner designer) { this._designer = designer; this._provider = designer.Component.Site; this._host = (IDesignerHost)this._provider.GetService(typeof(IDesignerHost)); this.componentChangeSvc = (IComponentChangeService)this._provider.GetService(typeof(IComponentChangeService)); if (text == null) { text = System.Design.SR.GetString("ToolStripDesignerStandardItemsVerb"); } }
private string NameFromText(string text, System.Type itemType, INameCreationService nameCreationService, bool adjustCapitalization) { string name = null; if (text == "-") { name = "toolStripSeparator"; } else { string str2 = itemType.Name; StringBuilder builder = new StringBuilder(text.Length + str2.Length); bool flag = false; for (int j = 0; j < text.Length; j++) { char c = text[j]; if (char.IsLetterOrDigit(c)) { if (!flag) { c = char.ToLower(c, CultureInfo.CurrentCulture); flag = true; } builder.Append(c); } } builder.Append(str2); name = builder.ToString(); if (adjustCapitalization) { string str3 = ToolStripDesigner.NameFromText(null, typeof(ToolStripMenuItem), this._designer.Component.Site); if (!string.IsNullOrEmpty(str3) && char.IsUpper(str3[0])) { name = char.ToUpper(name[0], CultureInfo.InvariantCulture) + name.Substring(1); } } } if (this._host.Container.Components[name] == null) { if (!nameCreationService.IsValidName(name)) { return(nameCreationService.CreateName(this._host.Container, itemType)); } return(name); } string str4 = name; for (int i = 1; !nameCreationService.IsValidName(str4); i++) { str4 = name + i.ToString(CultureInfo.InvariantCulture); } return(str4); }
private void SetParentDesignerValuesForDragDrop(ToolStripItem glyphItem, bool setValues, Point mouseLoc) { if (glyphItem.Site != null) { Size size = new Size(1, 1); IDesignerHost service = (IDesignerHost)glyphItem.Site.GetService(typeof(IDesignerHost)); if ((glyphItem.Placement == ToolStripItemPlacement.Overflow) || ((glyphItem.Placement == ToolStripItemPlacement.Main) && !glyphItem.IsOnDropDown)) { ToolStrip mainToolStrip = (service.GetDesigner(glyphItem) as ToolStripItemDesigner).GetMainToolStrip(); ToolStripDesigner designer = service.GetDesigner(mainToolStrip) as ToolStripDesigner; if (designer != null) { if (setValues) { designer.IndexOfItemUnderMouseToDrag = mainToolStrip.Items.IndexOf(glyphItem); designer.DragBoxFromMouseDown = this.dragBoxFromMouseDown = new Rectangle(new Point(mouseLoc.X - (size.Width / 2), mouseLoc.Y - (size.Height / 2)), size); } else { designer.IndexOfItemUnderMouseToDrag = -1; designer.DragBoxFromMouseDown = this.dragBoxFromMouseDown = Rectangle.Empty; } } } else if (glyphItem.IsOnDropDown) { ToolStripDropDown owner = glyphItem.Owner as ToolStripDropDown; if (owner != null) { ToolStripItem ownerItem = owner.OwnerItem; ToolStripItemDesigner designer3 = service.GetDesigner(ownerItem) as ToolStripItemDesigner; if (designer3 != null) { if (setValues) { designer3.indexOfItemUnderMouseToDrag = owner.Items.IndexOf(glyphItem); designer3.dragBoxFromMouseDown = this.dragBoxFromMouseDown = new Rectangle(new Point(mouseLoc.X - (size.Width / 2), mouseLoc.Y - (size.Height / 2)), size); } else { designer3.indexOfItemUnderMouseToDrag = -1; designer3.dragBoxFromMouseDown = this.dragBoxFromMouseDown = Rectangle.Empty; } } } } } }
public void Dispose() { if (this.toolDesigner != null) { this.toolDesigner.Dispose(); this.toolDesigner = null; } if (this.toolItemDesigner != null) { this.toolItemDesigner.Dispose(); this.toolItemDesigner = null; } if (this.componentChangeSvc != null) { this.componentChangeSvc.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved); this.componentChangeSvc = null; } }
/// <summary> /// Disposes of this object, removing all commands from the menu service. /// </summary> public void Dispose() { if (_toolDesigner != null) { _toolDesigner.Dispose(); _toolDesigner = null; } if (_toolItemDesigner != null) { _toolItemDesigner.Dispose(); _toolItemDesigner = null; } if (_componentChangeSvc != null) { _componentChangeSvc.ComponentRemoved -= new ComponentEventHandler(OnComponentRemoved); _componentChangeSvc = null; } }
internal void SetItemVisible(bool toolStripSelected, ToolStripDesigner designer) { if (toolStripSelected) { if (!this.currentVisible) { this.ToolStripItem.Visible = true; if ((designer != null) && !designer.FireSyncSelection) { designer.FireSyncSelection = true; } } } else if (!this.currentVisible) { this.ToolStripItem.Visible = this.currentVisible; } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { ToolStripDesigner designer = null; object obj3; if (provider != null) { ISelectionService service = (ISelectionService)provider.GetService(typeof(ISelectionService)); if (service != null) { object primarySelection = service.PrimarySelection; if (primarySelection is ToolStripDropDownItem) { primarySelection = ((ToolStripDropDownItem)primarySelection).Owner; } if (primarySelection is ToolStrip) { IDesignerHost host = (IDesignerHost)provider.GetService(typeof(IDesignerHost)); if (host != null) { designer = host.GetDesigner((IComponent)primarySelection) as ToolStripDesigner; } } } } try { if (designer != null) { designer.EditingCollection = true; } obj3 = base.EditValue(context, provider, value); } finally { if (designer != null) { designer.EditingCollection = false; } } return(obj3); }
internal void SelectNextItem(ISelectionService service, bool enterKeyPressed, ToolStripDesigner designer) { if (this.ToolStripItem is ToolStripDropDownItem) { this.SetSelection(enterKeyPressed); } else { ToolStrip immediateParent = (ToolStrip)this.ImmediateParent; if (immediateParent is ToolStripOverflow) { immediateParent = this.ToolStripItem.Owner; } int index = immediateParent.Items.IndexOf(this.ToolStripItem); System.Windows.Forms.ToolStripItem item2 = immediateParent.Items[index + 1]; ToolStripKeyboardHandlingService service2 = (ToolStripKeyboardHandlingService)this.GetService(typeof(ToolStripKeyboardHandlingService)); if (service2 != null) { if (item2 == designer.EditorNode) { service2.SelectedDesignerControl = item2; this.selSvc.SetSelectedComponents(null, SelectionTypes.Replace); } else { service2.SelectedDesignerControl = null; this.selSvc.SetSelectedComponents(new object[] { item2 }); } } } }
internal virtual void CommitEdit(System.Type type, string text, bool commit, bool enterKeyPressed, bool tabKeyPressed) { System.Windows.Forms.ToolStripItem component = null; SelectionManager manager = (SelectionManager)this.GetService(typeof(SelectionManager)); BehaviorService service = (BehaviorService)this.GetService(typeof(BehaviorService)); ToolStrip immediateParent = this.ImmediateParent as ToolStrip; immediateParent.SuspendLayout(); this.HideDummyNode(); IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost)); ToolStripDesigner designer = (ToolStripDesigner)host.GetDesigner(this.ToolStripItem.Owner); if ((designer != null) && (designer.EditManager != null)) { designer.EditManager.ActivateEditor(null, false); } if ((immediateParent is MenuStrip) && (type == typeof(ToolStripSeparator))) { IDesignerHost host2 = (IDesignerHost)this.GetService(typeof(IDesignerHost)); if (host2 != null) { IUIService service2 = (IUIService)host2.GetService(typeof(IUIService)); if (service2 != null) { service2.ShowError(System.Design.SR.GetString("ToolStripSeparatorError")); commit = false; if (this.selSvc != null) { this.selSvc.SetSelectedComponents(new object[] { immediateParent }); } } } } if (!commit) { if (this.dummyItemAdded) { this.dummyItemAdded = false; this.RemoveItem(); if (designer.NewItemTransaction != null) { designer.NewItemTransaction.Cancel(); designer.NewItemTransaction = null; } } goto Label_0246; } if (this.dummyItemAdded) { try { this.RemoveItem(); component = designer.AddNewItem(type, text, enterKeyPressed, false); goto Label_020B; } finally { if (designer.NewItemTransaction != null) { designer.NewItemTransaction.Commit(); designer.NewItemTransaction = null; } } } DesignerTransaction transaction = host.CreateTransaction(System.Design.SR.GetString("ToolStripItemPropertyChangeTransaction")); try { PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.ToolStripItem)["Text"]; string str = (string)descriptor.GetValue(this.ToolStripItem); if ((descriptor != null) && (text != str)) { descriptor.SetValue(this.ToolStripItem, text); } if (enterKeyPressed && (this.selSvc != null)) { this.SelectNextItem(this.selSvc, enterKeyPressed, designer); } } catch (Exception exception) { if (transaction != null) { transaction.Cancel(); transaction = null; } if (manager != null) { manager.Refresh(); } if (System.Windows.Forms.ClientUtils.IsCriticalException(exception)) { throw; } } finally { if (transaction != null) { transaction.Commit(); transaction = null; } } Label_020B: this.dummyItemAdded = false; Label_0246: immediateParent.ResumeLayout(); if ((component != null) && !component.IsOnDropDown) { ToolStripDropDownItem item2 = component as ToolStripDropDownItem; if (item2 != null) { Rectangle glyphBounds = ((ToolStripItemDesigner)host.GetDesigner(component)).GetGlyphBounds(); Control rootComponent = host.RootComponent as Control; if ((rootComponent != null) && (service != null)) { Rectangle parentBounds = service.ControlRectInAdornerWindow(rootComponent); if (!ToolStripDesigner.IsGlyphTotallyVisible(glyphBounds, parentBounds)) { item2.HideDropDown(); } } } } if (manager != null) { manager.Refresh(); } }
internal virtual void ShowEditNode(bool clicked) { if (this.ToolStripItem is ToolStripMenuItem) { if (this._editorNode == null) { this.CreateDummyNode(); } IDesignerHost host = (IDesignerHost)base.Component.Site.GetService(typeof(IDesignerHost)); ToolStrip immediateParent = this.ImmediateParent as ToolStrip; if (immediateParent != null) { ToolStripDesigner designer = (ToolStripDesigner)host.GetDesigner(immediateParent); BehaviorService service = (BehaviorService)this.GetService(typeof(BehaviorService)); Point pos = service.ControlToAdornerWindow(immediateParent); Rectangle bounds = this.ToolStripItem.Bounds; bounds.Offset(pos); this.ToolStripItem.AutoSize = false; this._editorNode.SetWidth(this.ToolStripItem.Text); if (immediateParent.Orientation == Orientation.Horizontal) { this.ToolStripItem.Width = this._editorNode.EditorToolStrip.Width + 2; } else { this.ToolStripItem.Height = this._editorNode.EditorToolStrip.Height; } if (!this.dummyItemAdded) { service.SyncSelection(); } if (this.ToolStripItem.Placement != ToolStripItemPlacement.None) { Rectangle b = this.ToolStripItem.Bounds; b.Offset(pos); if (immediateParent.Orientation == Orientation.Horizontal) { b.X++; b.Y += (this.ToolStripItem.Height - this._editorNode.EditorToolStrip.Height) / 2; b.Y++; } else { b.X += (this.ToolStripItem.Width - this._editorNode.EditorToolStrip.Width) / 2; b.X++; } this._editorNode.Bounds = b; b = Rectangle.Union(bounds, b); service.Invalidate(b); if ((designer != null) && (designer.EditManager != null)) { designer.EditManager.ActivateEditor(this.ToolStripItem, clicked); } SelectionManager manager = (SelectionManager)this.GetService(typeof(SelectionManager)); if (this.bodyGlyph != null) { manager.BodyGlyphAdorner.Glyphs.Remove(this.bodyGlyph); } } else { this.ToolStripItem.AutoSize = this.AutoSize; if (this.ToolStripItem is ToolStripDropDownItem) { ToolStripDropDownItem toolStripItem = this.ToolStripItem as ToolStripDropDownItem; if (toolStripItem != null) { toolStripItem.HideDropDown(); } this.selSvc.SetSelectedComponents(new object[] { this.ImmediateParent }); } } } } }
private void RefreshColumnCollection() { DataGridView component = (DataGridView)base.Component; ISupportInitializeNotification dataSource = component.DataSource as ISupportInitializeNotification; if ((dataSource == null) || dataSource.IsInitialized) { IComponentChangeService service = null; PropertyDescriptor member = null; IDesignerHost provider = base.Component.Site.GetService(typeof(IDesignerHost)) as IDesignerHost; if (!this.ProcessSimilarSchema(component)) { PropertyDescriptorCollection itemProperties = null; if (this.cm != null) { try { itemProperties = this.cm.GetItemProperties(); } catch (ArgumentException exception) { throw new InvalidOperationException(System.Design.SR.GetString("DataGridViewDataSourceNoLongerValid"), exception); } } IContainer container = (component.Site != null) ? component.Site.Container : null; service = base.Component.Site.GetService(typeof(IComponentChangeService)) as IComponentChangeService; member = TypeDescriptor.GetProperties(base.Component)["Columns"]; service.OnComponentChanging(base.Component, member); DataGridViewColumn[] columnArray = new DataGridViewColumn[component.Columns.Count]; int index = 0; for (int i = 0; i < component.Columns.Count; i++) { DataGridViewColumn column = component.Columns[i]; if (!string.IsNullOrEmpty(column.DataPropertyName)) { PropertyDescriptor descriptor2 = TypeDescriptor.GetProperties(column)["UserAddedColumn"]; if ((descriptor2 == null) || !((bool)descriptor2.GetValue(column))) { columnArray[index] = column; index++; } } } for (int j = 0; j < index; j++) { component.Columns.Remove(columnArray[j]); } service.OnComponentChanged(base.Component, member, null, null); if (container != null) { for (int m = 0; m < index; m++) { container.Remove(columnArray[m]); } } DataGridViewColumn[] columnArray2 = null; int num5 = 0; if (component.DataSource != null) { columnArray2 = new DataGridViewColumn[itemProperties.Count]; num5 = 0; for (int n = 0; n < itemProperties.Count; n++) { System.Type typeofDataGridViewImageColumn; DataGridViewColumn column2 = null; TypeConverter converter = TypeDescriptor.GetConverter(typeof(Image)); System.Type propertyType = itemProperties[n].PropertyType; if (typeof(IList).IsAssignableFrom(propertyType)) { if (!converter.CanConvertFrom(propertyType)) { continue; } typeofDataGridViewImageColumn = DataGridViewDesigner.typeofDataGridViewImageColumn; } else if ((propertyType == typeof(bool)) || (propertyType == typeof(CheckState))) { typeofDataGridViewImageColumn = typeofDataGridViewCheckBoxColumn; } else if (typeof(Image).IsAssignableFrom(propertyType) || converter.CanConvertFrom(propertyType)) { typeofDataGridViewImageColumn = DataGridViewDesigner.typeofDataGridViewImageColumn; } else { typeofDataGridViewImageColumn = typeofDataGridViewTextBoxColumn; } string name = ToolStripDesigner.NameFromText(itemProperties[n].Name, typeofDataGridViewImageColumn, base.Component.Site); column2 = TypeDescriptor.CreateInstance(provider, typeofDataGridViewImageColumn, null, null) as DataGridViewColumn; column2.DataPropertyName = itemProperties[n].Name; column2.HeaderText = !string.IsNullOrEmpty(itemProperties[n].DisplayName) ? itemProperties[n].DisplayName : itemProperties[n].Name; column2.Name = itemProperties[n].Name; column2.ValueType = itemProperties[n].PropertyType; column2.ReadOnly = itemProperties[n].IsReadOnly; provider.Container.Add(column2, name); columnArray2[num5] = column2; num5++; } } service.OnComponentChanging(base.Component, member); for (int k = 0; k < num5; k++) { columnArray2[k].DisplayIndex = -1; component.Columns.Add(columnArray2[k]); } service.OnComponentChanged(base.Component, member, null, null); } } }
/// <summary> /// Computes a name from a text label by removing all spaces and non-alphanumeric characters. /// </summary> private string NameFromText(string text, Type itemType, INameCreationService nameCreationService, bool adjustCapitalization) { string baseName; // for separators, name them ToolStripSeparator... if (text == "-") { baseName = "toolStripSeparator"; } else { string nameSuffix = itemType.Name; // remove all the non letter and number characters. Append length of "MenuItem" Text.StringBuilder name = new Text.StringBuilder(text.Length + nameSuffix.Length); bool firstCharSeen = false; for (int i = 0; i < text.Length; i++) { char c = text[i]; if (char.IsLetterOrDigit(c)) { if (!firstCharSeen) { c = char.ToLower(c, CultureInfo.CurrentCulture); firstCharSeen = true; } name.Append(c); } } name.Append(nameSuffix); baseName = name.ToString(); if (adjustCapitalization) { string nameOfRandomItem = ToolStripDesigner.NameFromText(null, typeof(ToolStripMenuItem), _designer.Component.Site); if (!string.IsNullOrEmpty(nameOfRandomItem) && char.IsUpper(nameOfRandomItem[0])) { baseName = char.ToUpper(baseName[0], CultureInfo.InvariantCulture) + baseName.Substring(1); } } } // see if this name matches another one in the container.. object existingComponent = _host.Container.Components[baseName]; if (existingComponent is null) { if (!nameCreationService.IsValidName(baseName)) { // we don't have a name collision but this still isn't a valid name...something is wrong and we can't make a valid identifier out of this so bail. return(nameCreationService.CreateName(_host.Container, itemType)); } else { return(baseName); } } else { // start appending numbers. string newName = baseName; for (int indexer = 1; !nameCreationService.IsValidName(newName); indexer++) { newName = baseName + indexer.ToString(CultureInfo.InvariantCulture); } return(newName); } }
public void ShowMenu() { if (this.menuItem != null) { Control parent = this.designMenu.Parent; Form component = parent as Form; if (component != null) { this.parentFormDesigner = this.host.GetDesigner(component) as FormDocumentDesigner; if ((this.parentFormDesigner != null) && (this.parentFormDesigner.Menu != null)) { this.parentMenu = this.parentFormDesigner.Menu; this.parentFormDesigner.Menu = null; } } this.selected = true; this.designMenu.Visible = true; this.designMenu.BringToFront(); this.menuItem.Visible = true; if ((this.currentParent != null) && (this.currentParent != this.menuItem)) { ToolStripMenuItemDesigner designer = this.host.GetDesigner(this.currentParent) as ToolStripMenuItemDesigner; if (designer != null) { designer.RemoveTypeHereNode(this.currentParent); } } this.menuItem.DropDown = this.dropDown; this.menuItem.DropDown.OwnerItem = this.menuItem; if (this.dropDown.Items.Count > 0) { ToolStripItem[] array = new ToolStripItem[this.dropDown.Items.Count]; this.dropDown.Items.CopyTo(array, 0); foreach (ToolStripItem item in array) { if (item is DesignerToolStripControlHost) { this.dropDown.Items.Remove(item); } } } ToolStripMenuItemDesigner designer2 = (ToolStripMenuItemDesigner)this.host.GetDesigner(this.menuItem); BehaviorService service = (BehaviorService)this.GetService(typeof(BehaviorService)); if (service != null) { if ((designer2 != null) && (parent != null)) { Rectangle parentBounds = service.ControlRectInAdornerWindow(parent); if (ToolStripDesigner.IsGlyphTotallyVisible(service.ControlRectInAdornerWindow(this.designMenu), parentBounds)) { designer2.InitializeDropDown(); } } if (this.dummyToolStripGlyph == null) { Point pos = service.ControlToAdornerWindow(this.designMenu); Rectangle bounds = this.designMenu.Bounds; bounds.Offset(pos); this.dummyToolStripGlyph = new ControlBodyGlyph(bounds, Cursor.Current, this.menuItem, new ContextMenuStripBehavior(this.menuItem)); SelectionManager manager = (SelectionManager)this.GetService(typeof(SelectionManager)); if (manager != null) { manager.BodyGlyphAdorner.Glyphs.Insert(0, this.dummyToolStripGlyph); } } ToolStripKeyboardHandlingService service2 = (ToolStripKeyboardHandlingService)this.GetService(typeof(ToolStripKeyboardHandlingService)); if (service2 != null) { int num = this.dropDown.Items.Count - 1; if (num >= 0) { service2.SelectedDesignerControl = this.dropDown.Items[num]; } } } } }
public override bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc) { bool flag = false; ToolStripItemGlyph glyph = g as ToolStripItemGlyph; ToolStripItem item = glyph.Item; ISelectionService selectionService = this.GetSelectionService(item); if (((selectionService != null) && (item.Site != null)) && !this.MouseHandlerPresent(item)) { if (!selectionService.GetComponentSelected(item)) { this.PaintInsertionMark(item); flag = false; } if (((button != MouseButtons.Left) || (glyph == null)) || ((glyph.ItemDesigner == null) || glyph.ItemDesigner.IsEditorActive)) { return(flag); } Rectangle empty = Rectangle.Empty; IDesignerHost service = (IDesignerHost)item.Site.GetService(typeof(IDesignerHost)); if ((item.Placement == ToolStripItemPlacement.Overflow) || ((item.Placement == ToolStripItemPlacement.Main) && !item.IsOnDropDown)) { ToolStrip mainToolStrip = glyph.ItemDesigner.GetMainToolStrip(); ToolStripDesigner designer = service.GetDesigner(mainToolStrip) as ToolStripDesigner; if (designer != null) { empty = designer.DragBoxFromMouseDown; } } else if (item.IsOnDropDown) { ToolStripDropDown owner = item.Owner as ToolStripDropDown; if (owner != null) { ToolStripItem ownerItem = owner.OwnerItem; ToolStripItemDesigner designer3 = service.GetDesigner(ownerItem) as ToolStripItemDesigner; if (designer3 != null) { empty = designer3.dragBoxFromMouseDown; } } } if (!(empty != Rectangle.Empty) || empty.Contains(mouseLoc.X, mouseLoc.Y)) { return(flag); } if (this._timer != null) { this._timer.Enabled = false; this._timer.Tick -= new EventHandler(this.OnDoubleClickTimerTick); this._timer.Dispose(); this._timer = null; } try { ArrayList dragComponents = new ArrayList(); foreach (IComponent component in selectionService.GetSelectedComponents()) { ToolStripItem item3 = component as ToolStripItem; if (item3 != null) { dragComponents.Add(item3); } } ToolStripItem primarySelection = selectionService.PrimarySelection as ToolStripItem; if (primarySelection != null) { ToolStrip strip2 = primarySelection.Owner; ToolStripItemDataObject data = new ToolStripItemDataObject(dragComponents, primarySelection, strip2); this.DropSource.QueryContinueDrag += new QueryContinueDragEventHandler(this.QueryContinueDrag); ToolStripDropDownItem item5 = item as ToolStripDropDownItem; if (item5 != null) { ToolStripMenuItemDesigner designer4 = service.GetDesigner(item5) as ToolStripMenuItemDesigner; if (designer4 != null) { designer4.InitializeBodyGlyphsForItems(false, item5); item5.HideDropDown(); } } else if (item.IsOnDropDown && !item.IsOnOverflow) { ToolStripDropDown currentParent = item.GetCurrentParent() as ToolStripDropDown; ToolStripDropDownItem item6 = currentParent.OwnerItem as ToolStripDropDownItem; selectionService.SetSelectedComponents(new IComponent[] { item6 }, SelectionTypes.Replace); } this.DropSource.DoDragDrop(data, DragDropEffects.Move | DragDropEffects.Copy | DragDropEffects.Scroll); } } finally { this.DropSource.QueryContinueDrag -= new QueryContinueDragEventHandler(this.QueryContinueDrag); this.SetParentDesignerValuesForDragDrop(item, false, Point.Empty); ToolStripDesigner.dragItem = null; this.dropSource = null; } } return(false); }