void onCloseTargetClick(int x, int y, MouseButton button) { if (button == MouseButton.Right) { m_closeTarget.Dispose(); } }
/// <summary> /// Adds or toggles the passed control to the list of active controls. /// </summary> /// <param name="control">The control to be opened or toggled.</param> /// <param name="x">C coordinate where new control should be placed.</param> /// <param name="y">Y coordinate where new control should be placed.</param> /// <param name="addType">By default, always adds the control. /// If OnlyAllowOne, then any controls of the same type that are active are disposed of, and the passed control is added. /// If Toggle, then only adds the control is another control of the same type is not active; else, disposes of all controls of the passed type, including the passed control.</param> /// <returns>If the control was added to the list of active controls, then returns the added control. If the control was not added, returns null.</returns> public AControl AddControl(AControl control, int x, int y, AddControlType addType = AddControlType.Always) { bool addControl = false; if (addType == AddControlType.Always) { addControl = true; } else if (addType == AddControlType.Toggle) { bool alreadyActive = false; foreach (AControl c in m_Controls) { if (c.Equals(control) && control.Equals(c)) { alreadyActive = true; c.Dispose(); } } addControl = !alreadyActive; } else if (addType == AddControlType.OnlyAllowOne) { foreach (AControl c in m_Controls) { if (c.Equals(control) && control.Equals(c)) { c.Dispose(); } } addControl = true; } if (addControl) { control.Position = new Point(x, y); m_Controls.Add(control); return(control); } else { control.Dispose(); return(null); } }