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

GetEnclosingElement() public method

public GetEnclosingElement ( ) : AutomationElement
return AutomationElement
        public AutomationElement GetEnclosingElement()
        {
            try
            {
                return AutomationElement.Wrap(this._range.GetEnclosingElement());
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
            }
        }

Usage Example

Ejemplo n.º 1
0
        public static int CountTextUnit(TextUnit tu, TextPatternRange rangeToCount)
        {
            ValidateArgumentNonNull(rangeToCount, "rangeToCount argument cannot be null");  // Sanity check

            TextPatternRange clone = rangeToCount.Clone();

            int count = clone.MoveEndpointByUnit(TextPatternRangeEndpoint.Start, tu, Int32.MaxValue);
        
            // Provider / Text Unit specific offsets    
            switch(typeOfProvider)
            {
            case "win32":
            case "winform":
                {
                    // This is to correct the fact that our line count will skip the last line if it 
                    // DOES NOT have a trailing \r, \n or \r\n
                    if( tu == TextUnit.Line ) 
                    {
                        string text = rangeToCount.GetText(-1);
                        AutomationElement element = rangeToCount.GetEnclosingElement();
                        if( IsTrailingCRLF(element, text) == 0 )
                            count++;
                    }
                }
                break;
            case "wpf":
                break;
            } 
            
            return count;
        }
All Usage Examples Of System.Windows.Automation.Text.TextPatternRange::GetEnclosingElement