System\Windows\Forms\Design\ToolStripMenuItemDesigner.cs (203)
87if (MenuItem.DropDown.IsAutoGenerated)
89foreach (ToolStripItem item in MenuItem.DropDownItems)
130if (MenuItem.DropDown is not null)
132RemoveTypeHereNode(MenuItem);
135if (MenuItem.DropDown.IsAutoGenerated && MenuItem.DropDownItems.Count > 0)
141foreach (ToolStripItem item in MenuItem.DropDownItems)
154ToolStripItem[] items = new ToolStripItem[MenuItem.DropDownItems.Count];
155MenuItem.DropDownItems.CopyTo(items, 0);
158MenuItem.DropDownItems.Remove(item);
163MenuItem.HideDropDown();
167MenuItem.DropDown = value;
191MenuItem.DropDown.OwnerItem = MenuItem;
192MenuItem.DropDown.Disposed += OnDropDownDisposed;
195if (MenuItem.Equals(_selectionService.PrimarySelection))
286return (toolItem == MenuItem);
295return (parentItem == MenuItem);
299return (toolItem == MenuItem);
305&& MenuItem.DropDown == selectedItem)
333if (MenuItem.Owner is ToolStripDropDown dropDown)
428if (!(MenuItem.Owner is ToolStripDropDown) && base.Editor is not null) // we are on Base MenuStrip !!
436MenuItem.DropDown.SuspendLayout();
441index = MenuItem.DropDownItems.IndexOf(_commitedEditorNode);
442ToolStripItem editedItem = MenuItem.DropDownItems[index + 1];
445MenuItem.DropDown.Items.Remove(_commitedEditorNode);
568index = MenuItem.DropDownItems.IndexOf(_typeHereNode);
584MenuItem.DropDown.ResumeLayout(true);
585MenuItem.DropDown.PerformLayout();
587ResetGlyphs(MenuItem);
593ToolStripItem nextItem = (MenuItem.DropDownDirection == ToolStripDropDownDirection.AboveLeft ||
594MenuItem.DropDownDirection == ToolStripDropDownDirection.AboveRight) && index >= 1
595? MenuItem.DropDownItems[index - 1]
596: MenuItem.DropDownItems[index + 1];
602if (MenuItem.DropDownItems[index] is ToolStripDropDownItem currentItem)
623_selectionService.SetSelectedComponents(new object[] { MenuItem.DropDownItems[index] }, SelectionTypes.Replace);
633MenuItem.DropDown.SuspendLayout();
636int index = MenuItem.DropDownItems.IndexOf(_commitedEditorNode);
637ToolStripItem editedItem = MenuItem.DropDownItems[index + 1];
638MenuItem.DropDown.Items.Remove(_commitedEditorNode);
655MenuItem.DropDownItems.Remove(editedItem);
680MenuItem.DropDown.ResumeLayout();
701if (MenuItem.DropDownItems.Count == 0)
714MenuItem.DropDown.PerformLayout();
726AddNewTemplateNode(MenuItem.DropDown);
728if (MenuItem.DropDown.Site is null)
730MenuItem.DropDown.Text = $"{MenuItem.Name}.DropDown";
733else if (_typeHereNode is not null && MenuItem.DropDownItems.IndexOf(_typeHereNode) == -1)
735MenuItem.DropDown.Items.Add(_typeHereNode);
740MenuItem.DropDown.PerformLayout();
775if (MenuItem.DropDownDirection is ToolStripDropDownDirection.AboveLeft or ToolStripDropDownDirection.AboveRight)
850if (MenuItem.DropDownDirection is ToolStripDropDownDirection.AboveLeft or ToolStripDropDownDirection.AboveRight)
866newItem = (ToolStripItem)_designerHost.CreateComponent(t, ToolStripDesigner.NameFromText(newText, t, MenuItem.Site));
949int index = MenuItem.DropDownItems.IndexOf(_commitedEditorNode);
951if (index != -1 && MenuItem.DropDownItems.Count > index)
953if (MenuItem.DropDownItems[index] is ToolStripDropDownItem newItem)
965ToolStripDropDownItem currentItem = MenuItem;
996if (MenuItem is not null && MenuItem.HasDropDown)
998MenuItem.DropDown.Hide();
1066if (_selectionService is not null && MenuItem is not null)
1068foreach (ToolStripItem item in MenuItem.DropDownItems)
1235if (MenuItem is null)
1245_selectionService.SetSelectedComponents(new object[] { MenuItem }, SelectionTypes.Replace);
1267if (selectedItem is not null && selectedItem != MenuItem)
1272MenuItem.DropDown.SuspendLayout();
1274int index = MenuItem.DropDownItems.IndexOf(_typeHereNode);
1304MenuItem.DropDown.ResumeLayout();
1321if (MenuItem.Owner is ToolStripDropDown dropDown)
1331MenuItem.HideDropDown();
1332menuItemDesigner.EnterInSituEdit(MenuItem);
1343MenuItem.DropDown.SuspendLayout();
1359int index = MenuItem.DropDownItems.IndexOf(toolItem);
1361MenuItem.DropDownItems.Insert(index, _commitedEditorNode);
1368MenuItem.DropDown.ResumeLayout();
1405return MenuItem;
1411ToolStripDropDown topmost = GetFirstDropDown(MenuItem);
1418return MenuItem.Owner;
1428if (MenuItem.Owner is ToolStripDropDown dropDown)
1461ToolStripItem ownerItem = MenuItem;
1486if (MenuItem is not null)
1488MenuItem.DropDown.Closing += OnDropDownClosing;
1489MenuItem.DropDownOpening += DropDownItem_DropDownOpening;
1490MenuItem.DropDownOpened += DropDownItem_DropDownOpened;
1491MenuItem.DropDownClosed += DropDownItem_DropDownClosed;
1492MenuItem.DropDown.Resize += DropDownResize;
1493MenuItem.DropDown.ItemAdded += OnItemAdded;
1494MenuItem.DropDown.Paint += DropDownPaint;
1495MenuItem.DropDown.Click += DropDownClick;
1496MenuItem.DropDown.LocationChanged += DropDownLocationChanged;
1509DoubleClickEnabled = MenuItem.DoubleClickEnabled;
1522MenuItem.DoubleClickEnabled = true;
1560ToolStripDropDown firstDropDown = GetFirstDropDown(MenuItem);
1576if (MenuItem.DropDown.OwnerItem is ToolStripDropDownItem currentOwner && currentOwner != MenuItem)
1587if (MenuItem.DropDown.Site is not null)
1589if (_designerHost.GetDesigner(MenuItem.DropDown) is ToolStripDropDownDesigner designer)
1591designer._currentParent = MenuItem as ToolStripMenuItem;
1596MenuItem.DropDown.TopLevel = false;
1599MenuItem.DropDown.AllowDrop = true;
1601MenuItem.DropDown.AutoClose = false;
1602MenuItem.ShowDropDown();
1603ShowOwnerDropDown(MenuItem);
1606ResetGlyphs(MenuItem);
1614GetService<BehaviorService>()?.Invalidate(MenuItem.Owner.Bounds);
1622ToolStripDropDown startDropDown = MenuItem.Owner as ToolStripDropDown;
1652Rectangle hostingDropDownBounds = (MenuItem.GetCurrentParent()).Bounds;
1654Rectangle itemDropDownBounds = MenuItem.DropDown.Bounds;
1656InitializeBodyGlyphsForItems(false /*remove*/, MenuItem);
1679if (IsOnContextMenu && MenuItem.DropDown.Site is not null)
1683MemberDescriptor member = TypeDescriptor.GetProperties(MenuItem.DropDown)["Items"];
1684changeService.OnComponentChanging(MenuItem.DropDown, member);
1689RaiseComponentChanging(TypeDescriptor.GetProperties(MenuItem)["DropDownItems"]);
1693int count = MenuItem.DropDownItems.Count;
1698if (IsOnContextMenu && MenuItem.DropDown.Site is not null)
1700MenuItem.DropDown.Items.Insert(_indexToInsertNewItem, newItem);
1704MenuItem.DropDownItems.Insert(_indexToInsertNewItem, newItem);
1710if (_selectionService.PrimarySelection is ToolStripItem selectedItem && selectedItem != MenuItem)
1712int index = MenuItem.DropDownItems.IndexOf(selectedItem);
1713if (MenuItem.DropDownDirection is ToolStripDropDownDirection.AboveLeft or ToolStripDropDownDirection.AboveRight)
1716if (IsOnContextMenu && MenuItem.DropDown.Site is not null)
1718MenuItem.DropDown.Items.Insert(index + 1, newItem);
1722MenuItem.DropDownItems.Insert(index + 1, newItem);
1727if (IsOnContextMenu && MenuItem.DropDown.Site is not null)
1729MenuItem.DropDown.Items.Insert(index, newItem);
1733MenuItem.DropDownItems.Insert(index, newItem);
1741if (MenuItem.DropDownDirection is not ToolStripDropDownDirection.AboveLeft and not ToolStripDropDownDirection.AboveRight)
1744if (IsOnContextMenu && MenuItem.DropDown.Site is not null)
1746MenuItem.DropDown.Items.Insert(count - 1, newItem);
1750MenuItem.DropDownItems.Insert(count - 1, newItem);
1756if (IsOnContextMenu && MenuItem.DropDown.Site is not null)
1758MenuItem.DropDown.Items.Add(newItem);
1762MenuItem.DropDownItems.Add(newItem);
1774ResetGlyphs(MenuItem);
1782if (IsOnContextMenu && MenuItem.DropDown.Site is not null)
1786MemberDescriptor member = TypeDescriptor.GetProperties(MenuItem.DropDown)["Items"];
1787changeService.OnComponentChanged(MenuItem.DropDown, member);
1792RaiseComponentChanged(TypeDescriptor.GetProperties(MenuItem)["DropDownItems"], null, null);
1883if (ownerItem is not null && ownerItem == MenuItem)
1921regionToInvalidate.Exclude(MenuItem.DropDown.Bounds);
1936KeyboardHandlingService.OwnerItemAfterCut = MenuItem;
1966if (ownerItem is not null && ownerItem == MenuItem)
2011if (MenuItem is not null)
2013if (MenuItem.DropDown is not null)
2015MenuItem.DropDown.Disposed -= OnDropDownDisposed;
2019MenuItem.DropDown = null;
2029if (MenuItem.DropDownDirection is not ToolStripDropDownDirection.AboveLeft and not ToolStripDropDownDirection.AboveRight)
2033int currentIndexOfEditor = MenuItem.DropDown.Items.IndexOf(_typeHereNode);
2034if (currentIndexOfEditor >= 0 && currentIndexOfEditor < MenuItem.DropDown.Items.Count - 1)
2037MenuItem.DropDown.ItemAdded -= OnItemAdded;
2038MenuItem.DropDown.SuspendLayout();
2039MenuItem.DropDown.Items.Remove(_typeHereNode);
2040MenuItem.DropDown.Items.Add(_typeHereNode);
2041MenuItem.DropDown.ResumeLayout();
2042MenuItem.DropDown.ItemAdded += OnItemAdded;
2060if (_dropDownSet && MenuItem.DropDown.IsAutoGenerated)
2067MenuItem.DropDownItems.Insert(0, item);
2073ResetGlyphs(MenuItem);
2077if (MenuItem is not null && _selectionService.GetComponentSelected(MenuItem))
2080MenuItem.DropDown.PerformLayout();
2088if (_selectionService.GetComponentSelected(MenuItem) && !_dropDownSetFailed)
2104if (!IsOnContextMenu && MenuItem.DropDown.Visible)
2106MenuItem.HideDropDown();
2108if (!MenuItem.DropDown.IsAutoGenerated)
2130if (MenuItem is null)
2152if (MenuItem.Equals(selectionSvc.PrimarySelection))
2157ToolStripDesignerUtils.InvalidateSelection(origSel, MenuItem, MenuItem.Site, false /*shift pressed*/);
2160if (IsOnContextMenu && !MenuItem.Owner.Visible)
2162ToolStripDropDown firstDropDown = GetFirstDropDown(MenuItem);
2213if (parent.OwnerItem == MenuItem || parent.OwnerItem is null)
2224if (MenuItem.DropDown.Visible)
2229if (selectedObj is ToolStripDropDown selectedDropDown && MenuItem.DropDown == selectedDropDown)
2241if (parent == MenuItem.DropDown)
2254if (MenuItem.DropDown.OwnerItem == MenuItem)
2256MenuItem.HideDropDown();
2307private void RestoreVisible() => MenuItem.Visible = Visible;
2345int index = MenuItem.DropDownItems.IndexOf(_commitedEditorNode);
2347ToolStripDropDownItem editedItem = (ToolStripDropDownItem)MenuItem.DropDownItems[index + 1];
2353MenuItem.DropDown.Items.Remove(_commitedEditorNode);
2443if (MenuItem.DropDownDirection is not ToolStripDropDownDirection.AboveLeft and not ToolStripDropDownDirection.AboveRight)
2446count = MenuItem.DropDownItems.Count;
2450_selectionService.SetSelectedComponents(new object[] { MenuItem }, SelectionTypes.Replace);
2453KeyboardHandlingService.SelectedDesignerControl = MenuItem.DropDownItems[count];
2490if (MenuItem is null)
2497if (MenuItem.Owner is ToolStripDropDown dropDown)
2506menuItemDesigner.EnterInSituEdit(MenuItem);
2536ToolStripDropDown ownerDropDown = (ToolStripDropDown)MenuItem.Owner;
2537int maxIndex = Math.Max(ownerDropDown.Items.IndexOf(oldSelection), ownerDropDown.Items.IndexOf(MenuItem));
2538int minIndex = Math.Min(ownerDropDown.Items.IndexOf(oldSelection), ownerDropDown.Items.IndexOf(MenuItem));
2580if (MenuItem is not null)
2582MenuItem.DropDown.Closing -= OnDropDownClosing;
2583MenuItem.DropDownOpening -= DropDownItem_DropDownOpening;
2584MenuItem.DropDownOpened -= DropDownItem_DropDownOpened;
2585MenuItem.DropDownClosed -= DropDownItem_DropDownClosed;
2586MenuItem.DropDown.Resize -= DropDownResize;
2587MenuItem.DropDown.ItemAdded -= OnItemAdded;
2588MenuItem.DropDown.Paint -= DropDownPaint;
2589MenuItem.DropDown.LocationChanged -= DropDownLocationChanged;
2590MenuItem.DropDown.Click -= DropDownClick;