ComponentFactory.Quicksilver.Layout.GridLayout.TargetChildren C# (CSharp) Method

TargetChildren() public method

Calculate target state for each element based on layout algorithm.
public TargetChildren ( string layoutId, MetaPanelBase metaPanel, MetaElementStateDict stateDict, ICollection elements, Size finalSize ) : void
layoutId string Identifier of the layout to be used.
metaPanel MetaPanelBase Reference to owning panel instance.
stateDict MetaElementStateDict Dictionary of per-element state.
elements ICollection Collection of elements to be arranged.
finalSize System.Windows.Size Size that layout should use to arrange child elements.
return void
        public override void TargetChildren(string layoutId,
                                            MetaPanelBase metaPanel,
                                            MetaElementStateDict stateDict,
                                            ICollection elements,
                                            Size finalSize)
        {
            // Only apply if we match the incoming layout identifier
            if (string.IsNullOrEmpty(Id) || Id.Equals(layoutId))
            {
                // If there are no column/row definitions then arrange to entire final size
                if ((_columns.Count == 0) && (_rows.Count == 0))
                {
                    Rect newTargetRect = new Rect(Utility.PointZero, finalSize);
                    foreach (UIElement element in elements)
                    {
                        // We ignore items being removed
                        if (stateDict[element].Status != MetaElementStatus.Removing)
                        {
                            // Store the new target rectangle
                            if (!stateDict[element].TargetRect.Equals(newTargetRect))
                            {
                                stateDict[element].TargetChanged = true;
                                stateDict[element].TargetRect = newTargetRect;
                            }
                        }
                    }
                }
                else
                {
                    // Calculate final width/height of col/row definitions
                    PreTarget(finalSize);

                    // Update new target rectangle for each non-removing element
                    foreach (UIElement element in elements)
                    {
                        // We ignore items being removed
                        if (stateDict[element].Status != MetaElementStatus.Removing)
                        {
                            // Find the arrange size for the element
                            Rect newTargetRect = TargetArrangeSize(element);

                            // Store the new target rectangle
                            if (!stateDict[element].TargetRect.Equals(newTargetRect))
                            {
                                stateDict[element].TargetChanged = true;
                                stateDict[element].TargetRect = newTargetRect;
                            }
                        }
                    }
                }
            }

            // Update rows and columns with actual widths/heights
            for (int i = 0; i < ColumnDefinitions.Count; i++)
                ColumnDefinitions[i].ActualWidth = _proxyColumns[i].MinSize;

            for (int i = 0; i < RowDefinitions.Count; i++)
                RowDefinitions[i].ActualHeight = _proxyRows[i].MinSize;
        }
        #endregion