public ContextMenuItem(ContextMenuShowMenu parent, ContextMenuItemEntry entry) { CanCloseWithRightClick = false; _entry = entry; _label = new Label(entry.Text, true, 1150, 0, style: FontStyle.BlackBorder) { X = 25 }; Add(_label); if (entry.CanBeSelected) { _selectedPic = new GumpPic(3, 0, 0x838, 0) { IsVisible = entry.IsSelected, IsEnabled = false }; Add(_selectedPic); } Height = 25; _label.Y = (Height >> 1) - (_label.Height >> 1); if (_selectedPic != null) { //_label.X = _selectedPic.X + _selectedPic.Width + 6; _selectedPic.Y = (Height >> 1) - (_selectedPic.Height >> 1); } Width = _label.X + _label.Width + 20; if (Width < 100) { Width = 100; } // it is a bit tricky, but works :D if (_entry.Items != null && _entry.Items.Count != 0) { _subMenu = new ContextMenuShowMenu(_entry.Items); parent.Add(_subMenu); if (parent._subMenus == null) { parent._subMenus = new List <ContextMenuShowMenu>(); } parent._subMenus.Add(_subMenu); } WantUpdateSize = false; }
public void Show() { _menu?.Dispose(); if (_items.Count == 0) { return; } _menu = new ContextMenuShowMenu(_items) { X = Mouse.Position.X, Y = Mouse.Position.Y }; UIManager.Add(_menu); }
protected override void OnMouseUp(int x, int y, MouseButton button) { if (button != MouseButton.Right) { base.OnMouseUp(x, y, button); return; } _menu?.Dispose(); _menu = new ContextMenuShowMenu(_items) { X = Mouse.Position.X, Y = Mouse.Position.Y }; UIManager.Add(_menu); }