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

CompareEndpoints() public method

public CompareEndpoints ( TextPatternRangeEndpoint endpoint, TextPatternRange targetRange, TextPatternRangeEndpoint targetEndpoint ) : int
endpoint TextPatternRangeEndpoint
targetRange TextPatternRange
targetEndpoint TextPatternRangeEndpoint
return int
        public int CompareEndpoints(TextPatternRangeEndpoint endpoint, TextPatternRange targetRange, TextPatternRangeEndpoint targetEndpoint)
        {
            try
            {
                return this._range.CompareEndpoints(
                    (UIAutomationClient.TextPatternRangeEndpoint)endpoint,
                    targetRange.NativeRange,
                    (UIAutomationClient.TextPatternRangeEndpoint)targetEndpoint);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
            }
        }

Usage Example

コード例 #1
0
        //---------------------------------------------------------------------------
        // Compares the start and end points of two ranges to determine if they are identical
        //---------------------------------------------------------------------------
        static internal void TS_IsMatchingEndPoints(TextPatternRange range, TextPatternRange targetRange, bool expectMatch, CheckType checkType)
        {
            bool actualMatch;
            int startPoint;
            int endPoint;
            string expectMatchString = (expectMatch == true ? "matches" : "doesn't match");

            // Get start/end point offsets
            startPoint = range.CompareEndpoints(TextPatternRangeEndpoint.Start, targetRange,
                                                 TextPatternRangeEndpoint.Start);
            endPoint = range.CompareEndpoints(TextPatternRangeEndpoint.End, targetRange,
                                              TextPatternRangeEndpoint.End);

            // if the ranges Match than the return value of both calls to CompareEndPoints = 0
            actualMatch = ((startPoint == 0) && (endPoint == 0));

            Comment("Start point offset = " + startPoint + ", End point offset = " + endPoint + ", expected " +
                     (expectMatch == true
                        ? "non-zero"
                        : "zero") +
                     " offsets");

            // Report results
            if (actualMatch == expectMatch)
                Comment("Start/End point(s) " + expectMatchString + ", as expected");
            else
            {
                ThrowMe(checkType, "Start/End point(s) " + expectMatchString + ", which is not expected result");
            }
            m_TestStep++;
        }
All Usage Examples Of System.Windows.Automation.Text.TextPatternRange::CompareEndpoints