System.Windows.Automation.TextPattern.RangeFromChild C# (CSharp) Method

RangeFromChild() public method

public RangeFromChild ( AutomationElement childElement ) : TextPatternRange
childElement AutomationElement
return System.Windows.Automation.Text.TextPatternRange
        public TextPatternRange RangeFromChild(AutomationElement childElement)
        {
            Utility.ValidateArgumentNonNull(childElement, "childElement");
            try
            {
                return TextPatternRange.Wrap(this._pattern.RangeFromChild(childElement.NativeElement), this);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
            }
        }

Usage Example

Beispiel #1
0
        //---------------------------------------------------------------------------
        // Wrapper for TextPattern.RangeFromChild Method
        //---------------------------------------------------------------------------
        internal void Pattern_RangeFromChild(TextPattern textPattern, ref TextPatternRange returnedRange, AutomationElement childElem, Type expectedException, CheckType checkType)
        {
            string call = "TextPattern.RangeFromChild(" + childElem + ")";
            Comment("---Calling " + call);

            try
            {
                returnedRange = textPattern.RangeFromChild(childElem);
            }
            catch (Exception actualException)
            {
                if (Library.IsCriticalException(actualException))
                    throw;

                if( (actualException is ArgumentException) || (actualException is InvalidOperationException))
                {
                    // Win32 Edit Controls don't support children. InvalidOperationException here is expected
                    if ((TextLibrary.typeOfProvider == "win32") || (TextLibrary.typeOfProvider == "winform"))
                    {
                        if ((childElem != null) && (TextLibrary.IsRichEdit(childElem) == false))
                        {
                            // Yes, this is a hard-coded CheckType. This is by-design/a good thing
                            ThrowMe(CheckType.IncorrectElementConfiguration, "Win32 Edit controls do not support children");
                        }
                    }
                }

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

            if (returnedRange == null)
                ThrowMe(checkType, call + " should not give a null TextPatternRange");

            TestNoExceptionQuiet(expectedException, call, checkType);
        }