Exemple #1
0
        /// <summary>
        /// Only Width, Height, WidthUnit and HeightUnit properties of MeasureInfo have valid
        /// values after MeasureObject call.
        /// </summary>
        /// <param name="ro">RenderObject to measure.</param>
        /// <returns>Returns the MeasureInfo object with sizes of object.</returns>
        public MeasureInfo MeasureObject(RenderObject ro, Unit width, Unit height)
        {
            bool wasAdded = ro.Document == null;

            if (ro.Document == null)
            {
                this.Body.Children.Add(ro);
            }

            SizeD        sz           = ro.CalcSize(width, height);
            UnitTypeEnum resolvedUnit = ro.Document.ResolvedUnit;

            if (wasAdded)
            {
                this.Body.Children.Remove(ro);
            }

            return(new MeasureInfo(ro, sz, resolvedUnit));
        }