System.Windows.Automation.Text.TextPatternRange.GetBoundingRectangles C# (CSharp) Method

GetBoundingRectangles() public method

public GetBoundingRectangles ( ) : Rect[]
return Rect[]
        public Rect[] GetBoundingRectangles()
        {
            try
            {
                double[] unrolledRects = (double[])this._range.GetBoundingRectangles();
                Rect[] result = null;
                if (unrolledRects != null)
                {
                    Debug.Assert(unrolledRects.Length % 4 == 0);
                    // If unrolledRects is somehow not a multiple of 4, we still will not 
                    // overrun it, since (x / 4) * 4 <= x for C# integer math.
                    result = new Rect[unrolledRects.Length / 4];
                    for (int i = 0; i < result.Length; i++)
                    {
                        int j = i * 4; ;
                        result[i] = new Rect(unrolledRects[j], unrolledRects[j + 1], unrolledRects[j + 2], unrolledRects[j + 3]);
                    }
                }
                return result;
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
            }
        }

Usage Example

Example #1
0
        //---------------------------------------------------------------------------
        // Wrapper for TextPatternRange.GetBoundingRectangles Method
        //---------------------------------------------------------------------------
        internal void Range_GetBoundingRectangles(TextPatternRange callingRange, ref Rect[] boundRects, Type expectedException, CheckType checkType)
        {
            string call = "TextPatternRange.GetBoundingRectangles()";

            if (callingRange == null)
                throw new ArgumentNullException(call + " requires non-NULL TextPatterncallingRange");

            try
            {
                boundRects = callingRange.GetBoundingRectangles();
                Comment("---Called " + call + ", returning array size = " + boundRects.Length);
            }
            catch (Exception actualException)
            {
                if (Library.IsCriticalException(actualException))
                    throw;

                Comment("---Calling " + call); // Exception was raised, so log it here...

                TestException(expectedException, actualException, call, checkType);
                return;
            }
            TestNoExceptionQuiet(expectedException, call, checkType);
        }