public int Add(Link value) { if (value is not null && value.Length != 0) { LinksAdded = true; } // check for the special case where the list is in the "magic" // state of having only the default link in it. In that case // we want to clear the list before adding this link. // if (_owner._links.Count == 1 && this[0].Start == 0 && this[0]._length == -1) { _owner._links.Clear(); _owner.FocusLink = null; } // Set the owner control for this link value.Owner = _owner; _owner._links.Add(value); if (_owner.AutoSize) { LayoutTransaction.DoLayout(_owner.ParentInternal, _owner, PropertyNames.Links); _owner.AdjustSize(); _owner.Invalidate(); } if (_owner.Links.Count > 1) { _owner._links.Sort(LinkLabel.s_linkComparer); } _owner.ValidateNoOverlappingLinks(); _owner.UpdateSelectability(); _owner.InvalidateTextLayout(); _owner.Invalidate(); if (_owner.Links.Count > 1) { return(IndexOf(value)); } else { return(0); } }
public int Add(Link value) { if (value == null) { return(-1); } if (owner.links.Count == 1 && this[0].Start == 0 && this[0].length == -1) { owner.links.Clear(); owner.FocusLink = null; } value.owner = this.owner; owner.links.Add(value); if (owner.AutoSize) { owner.AdjustSize(); owner.Invalidate(); } if (owner.Links.Count > 1) { owner.links.Sort(linkComparer); } owner.Invalidate(); if (owner.Links.Count > 1) { return(IndexOf(value)); } return(0); }