internal _ContextMenuStrip(AMenu am, bool isMain) { _m = am; _isMain = isMain; this.Name = _m._name; this.Text = _m._name; }
void _CreateMenu2() { _m = _tb._CreateMenu(this, ref _action); _mi = _m.Control.Items.OfType <ToolStripMenuItem>().FirstOrDefault(); if (_mi != null) { _mi.Font = new Font(_mi.Font, FontStyle.Bold); } }
protected override void OnMouseUp(MouseEventArgs e) { if (e.Button != MouseButtons.Right) { return; } var m = new AMenu(); m["Retry\tF3"] = o => { this.DialogResult = DialogResult.Retry; this.Close(); }; m["Cancel\tEsc"] = o => this.Close(); m.Show(this); }
void _ContextMenu() { if (_m._name == null) { return; } if (!CanGoToEdit_) { return; } var p = this.MouseClientXY(); var contextItem = this.GetItemAt(p); if (contextItem == null) //maybe p is at the left or rigt of a textbox, label etc { foreach (ToolStripItem v in this.Items) { var k = v.Bounds; if (p.y >= k.Y && p.y < k.Bottom) { contextItem = v; break; } } } #if true using var m = new Util.ClassicPopupMenu_(); m.Add(100, "Edit"); _cancelClosing = true; //in some cases .NET installs a message hook to catch clicks int r = m.Show(this.Hwnd()); _cancelClosing = false; switch (r) { case 100: _m.Close(); _m.GoToEdit_(contextItem); break; } #else //.NET does not like it. Tries to close the main menu, and if we cancel it, menu partially stops working. var m = new AMenu(); m["Edit"] = o => _m.GoToEdit_(contextItem); m.Control.RenderMode = ToolStripRenderMode.System; m.Show(this); #endif }
AMenu _CreateMenu(ToolStripDropDownItem item, ref Action <AMenu> menu) { if (menu == null) { return(null); } var m = new AMenu(this.Name + " + " + item.Text, _sourceFile, GetItemSourceLine_(item)) { MultiShow = true, ItemThread = this.ItemThread, }; item.DropDown = m.Control; //attaches m.Control.OwnerItem = item; //the callback may ned it menu(m); if (m.MultiShow) { menu = null; //default true, but callback may set false to call it each time } return(m); }
void _ContextMenu(ToolStrip ts) //ts is either this or the overflow dropdown { if (_contextMenu == null) { var m = new AMenu { MultiShow = true, Modal = false }; m.Control.RenderMode = ToolStripRenderMode.System; m["Edit"] = o => _tb.GoToEdit_(_cmItem); m.Separator(); using (m.Submenu("Anchor")) { m.LastMenuItem.DropDown.Opening += (sender, _) => { var dd = sender as ToolStripDropDownMenu; foreach (ToolStripMenuItem v in dd.Items) { if (v.Tag is TBAnchor an) { v.Checked = an == _tb._anchor; } } }; void _AddAnchor(TBAnchor an) => m.Add(an.ToString(), _ => _tb.Anchor = an).Tag = an; _AddAnchor(TBAnchor.None); _AddAnchor(TBAnchor.TopLeft); _AddAnchor(TBAnchor.TopRight); _AddAnchor(TBAnchor.BottomLeft); _AddAnchor(TBAnchor.BottomRight); _AddAnchor(TBAnchor.Top); _AddAnchor(TBAnchor.Bottom); _AddAnchor(TBAnchor.Left); _AddAnchor(TBAnchor.Right); _AddAnchor(TBAnchor.All); } using (m.Submenu("Border")) { m.LastMenuItem.DropDown.Opening += (sender, _) => { var dd = sender as ToolStripDropDownMenu; foreach (ToolStripMenuItem v in dd.Items) { if (v.Tag is TBBorder b) { v.Checked = b == _tb._border; } } }; void _AddBorder(TBBorder b) => m.Add(b.ToString(), _ => _tb.Border = b).Tag = b; _AddBorder(TBBorder.None); _AddBorder(TBBorder.Width1); _AddBorder(TBBorder.Width2); _AddBorder(TBBorder.Width3); _AddBorder(TBBorder.Width4); _AddBorder(TBBorder.ThreeD); _AddBorder(TBBorder.Thick); _AddBorder(TBBorder.Caption); _AddBorder(TBBorder.CaptionX); } var sizable = m.Add("Sizable", _ => _tb.Sizable ^= true); var autoSize = m.Add("AutoSize", _ => _tb.AutoSize ^= true); m.Control.Opening += (sender, _) => { var dd = sender as ToolStripDropDownMenu; sizable.Checked = _tb.Sizable; autoSize.Checked = _tb.AutoSize; }; using (m.Submenu("More")) { m.LastMenuItem.DropDown.Opening += (sender, _) => { var dd = sender as ToolStripDropDownMenu; foreach (ToolStripMenuItem v in dd.Items) { if (v.Tag is TBFlags f) { v.Checked = _tb._SatPlanetOrThis.MiscFlags.Has(f); } } }; void _AddFlag(TBFlags f) => m.Add(_EnumToString(f), _ => _tb._SatPlanetOrThis.MiscFlags ^= f).Tag = f; if (_tb._SatPlanetOrThis.IsOwned) { _AddFlag(TBFlags.DontActivateOwner); } _AddFlag(TBFlags.HideIfFullScreen); } m["Toolbars..."] = o => new _Form().Show();