/// <summary> /// Show to pop up a new context menu. Parent is normally displaycontrol. /// You can double call and the previous one is closed. /// It always makes sure right/bottom is within parent. /// </summary> /// <param name="parent">Parent of menu to attach to. Normally its the control display top level control</param> /// <param name="location">Location to place the menu at</param> /// <param name="changewidthifrequired">If set, it will reflow the menu to not exceed parent, making the window wider if required, </param> /// <param name="opentag">Tag to pass to Opening callback</param> public void Show(GLBaseControl parent, Point location, bool changewidthifrequired = false, Object opentag = null) { //System.Diagnostics.Debug.WriteLine("Open as context menu " + Name); Detach(this); openedascontextmenu = true; Visible = true; Location = location; AutoSize = true; TopMost = true; KeepWithinParent = changewidthifrequired; parent.Add(this); int overflowy = this.Bottom - parent.Bottom; if (overflowy > 0) { Top -= overflowy; } int overflowx = this.Right - parent.Right; if (overflowx > 0) { Left -= overflowx; } SetFocus(); Opening?.Invoke(this, opentag); }