GetRunIter() публичный Метод

public GetRunIter ( ) : IEnumerable
Результат IEnumerable
Пример #1
0
        /// <summary>
        /// Get the <paramref name="min"/> and <paramref name="maxSum"/> of the box words content and <paramref name="paddingSum"/>.<br/>
        /// </summary>
        /// <param name="box">the box to calculate for</param>
        /// <param name="min">the width that allows for each word to fit (width of the longest word)</param>
        /// <param name="maxSum">the max width a single line of words can take without wrapping</param>
        /// <param name="paddingSum">the total amount of padding the content has </param>
        /// <param name="marginSum"></param>
        /// <returns></returns>
        static void CalculateMinMaxSumWords(
            CssBox box,
            CssBox cbBox,
            IFonts iFonts,
            ref float min,
            ref float maxSum,
            ref float paddingSum,
            ref float marginSum)
        {
            //recursive 
            float? oldSum = null;
            // not inline (block) boxes start a new line so we need to reset the max sum 
            if (box.CssDisplay != CssDisplay.Inline &&
                box.CssDisplay != CssDisplay.TableCell &&
                box.WhiteSpace != CssWhiteSpace.NoWrap)
            {
                oldSum = maxSum;
                maxSum = marginSum;
            }

            // add the padding 
            paddingSum += box.ActualBorderLeftWidth + box.ActualBorderRightWidth + box.ActualPaddingRight + box.ActualPaddingLeft;
            // for tables the padding also contains the spacing between cells                
            if (box.CssDisplay == CssDisplay.Table)
            {
                paddingSum += CssTableLayoutEngine.CalculateTableSpacing(box);
            }

            if (box.HasOnlyRuns)
            {
                // calculate the min and max sum for all the words in the box 
                foreach (CssRun run in box.GetRunIter())
                {
                    maxSum += run.Width;
                    min = Math.Max(min, run.Width);
                }
            }
            else
            {
                // recursively on all the child boxes
                //if this box has containing property 
                if (box.HasContainingBlockProperty)
                {
                    foreach (CssBox childBox in box.GetChildBoxIter())
                    {
                        if (childBox.NeedComputedValueEvaluation) { childBox.ReEvaluateComputedValues(iFonts, box); }

                        float msum = childBox.ActualMarginLeft + childBox.ActualMarginRight;
                        marginSum += msum;
                        //recursive                        
                        CalculateMinMaxSumWords(childBox, box, iFonts, ref min, ref maxSum, ref paddingSum, ref marginSum);
                        marginSum -= msum;
                    }
                }
                else
                {
                    foreach (CssBox childBox in box.GetChildBoxIter())
                    {
                        if (childBox.NeedComputedValueEvaluation) { childBox.ReEvaluateComputedValues(iFonts, cbBox); }

                        float msum = childBox.ActualMarginLeft + childBox.ActualMarginRight;
                        marginSum += msum;
                        //recursive
                        CalculateMinMaxSumWords(childBox, cbBox, iFonts, ref min, ref maxSum, ref paddingSum, ref marginSum);
                        marginSum -= msum;
                    }
                }
            }

            // max sum is max of all the lines in the box
            if (oldSum.HasValue)
            {
                maxSum = Math.Max(maxSum, oldSum.Value);
            }
        }