/// <summary> /// Performs layout changes based on the element given as a paramater. /// Sizes and places are determined by the concrete layout panel that is used. /// Since all layout panels update their layout automatically through events, /// this function is rarely used directly. /// </summary> /// <param name="affectedElement"></param> public override void PerformLayoutCore(RadElement affectedElement) { int nextLeftTop = 0, nextRightBottom = 0; Rectangle bounds = this.Bounds; bounds.Size = TelerikLayoutEngine.CheckSize(this.Size, this.MaxSize, this.MinSize); List <PreferredSizeData> prefSizelist = new List <PreferredSizeData>(); FillPrefSizeList(prefSizelist, bounds); if (!this.ShouldIgnoreChildSizes()) { bounds.Size = GetChildrenListSize(prefSizelist); } foreach (PreferredSizeData data in prefSizelist) { if (data.Element.Visibility != ElementVisibility.Collapsed) { StripPosition pos = GetInvariantPosition(data.Element.Alignment); switch (pos) { case StripPosition.First: SetElementBoundsAuto(bounds, data, nextLeftTop); nextLeftTop += GetInvariantLength(data.Element.BoundingRectangle.Size, data.Element.Margin); break; case StripPosition.Middle: SetElementBoundsAuto(bounds, data, 0); break; case StripPosition.Last: SetElementBoundsAuto(bounds, data, nextRightBottom); nextRightBottom -= GetInvariantLength(data.Element.BoundingRectangle.Size, data.Element.Margin); break; } } } }
protected virtual void SetElementBoundsAuto(Rectangle bounds, PreferredSizeData data, int offset) { Point location = ItemsOffset; if (this.Orientation == Orientation.Horizontal) { location.X += offset; } else { location.Y += offset; } if (data.Element.AutoSize && data.Element.ElementState == ElementState.Loaded) { Size prefSize = this.GetElementPreferredSize(bounds, data); if (this.IsFitInSize()) { Size availableSize = Size.Subtract(bounds.Size, this.LayoutEngine.GetBorderSize()); availableSize = Size.Subtract(availableSize, data.Element.Margin.Size); prefSize = TelerikLayoutEngine.CheckSize(prefSize, availableSize, Size.Empty); } Size tempSize = Size.Subtract(this.Size, data.Element.Margin.Size); if (this.ForceElementsWidth && prefSize.Width < tempSize.Width) { prefSize.Width = tempSize.Width; } if (this.ForceElementsHeight && prefSize.Height < tempSize.Height) { prefSize.Height = tempSize.Height; } data.Element.SetBounds(new Rectangle(location, prefSize)); } else { data.Element.Location = location; } }