/// <summary> /// Adds a <see cref="Control"/> to the end of the <see cref="ControlCollection"/>. /// </summary> /// <param name="child">The <see cref="Control"/> to be added to the end of the <see cref="ControlCollection"/>.</param> /// <param name="x">The x-coordinate of the child's location.</param> /// <param name="y">The y-coordinate of the child's location.</param> /// <param name="width">The width of the child.</param> /// <param name="height">The height of the child.</param> /// <param name="hexpand">The horizontal expand of <paramref name="child"/>.</param> /// <param name="vexpand">The vertical expand of <paramref name="child"/>.</param> /// <param name="alignment">The alignment of <paramref name="child"/>.</param> public void Add(Control child, int x, int y, int width, int height, int hexpand, int vexpand, Alignment alignment) { if (child == null) { throw new ArgumentNullException(nameof(child)); } if (child.IsInvalid) { throw new InvalidHandleException(); } if (x < 0) { throw new ArgumentOutOfRangeException(nameof(x)); } if (y < 0) { throw new ArgumentOutOfRangeException(nameof(y)); } if (width < 0) { throw new ArgumentOutOfRangeException(nameof(width)); } if (height < 0) { throw new ArgumentOutOfRangeException(nameof(height)); } if (Owner.IsInvalid) { throw new InvalidHandleException(); } if (Contains(child)) { throw new InvalidOperationException("Cannot add the same control more than once."); } if (child.TopLevel) { throw new ArgumentException("Cannot add a top-level control to a ControlCollectionBase."); } ToLibuiAligns(alignment, out Libui.Align halign, out Libui.Align valign); Libui.GridAppend(Owner.Handle, child.Handle, x, y, width, height, hexpand, halign, vexpand, valign); base.Add(child); }