示例#1
0
        internal static bool ClickablePointRight(
            this AutomationElement currentElement,
            AutomationElement rectElement,
            ScrollPattern scrollPattern)
        {
            try
            {
                Point point;
                if (!AutomationElementHelper.TryGetClickablePoint(currentElement, out point))
                {
                    if (!AutomationElementHelper.TryGetBoundingRectangleCenter(currentElement, out point))
                    {
                        throw new OperationCanceledException(OperationCanceledExceptionText);
                    }
                }

                var rect = rectElement.GetPropertyValue <Rect>(AutomationElement.BoundingRectangleProperty);

                if (scrollPattern == null || scrollPattern.Current.HorizontalScrollPercent < 0)
                {
                    return(point.X > rect.Right);
                }

                return(point.X > rect.Right - CruciatusFactory.Settings.ScrollBarWidth);
            }
            catch (Exception exc)
            {
                throw new OperationCanceledException(OperationCanceledExceptionText, exc);
            }
        }
示例#2
0
        internal static bool ContainsClickablePoint(
            this AutomationElement externalElement,
            AutomationElement internalElement)
        {
            try
            {
                Point point;
                if (!AutomationElementHelper.TryGetClickablePoint(internalElement, out point))
                {
                    if (!AutomationElementHelper.TryGetBoundingRectangleCenter(internalElement, out point))
                    {
                        throw new OperationCanceledException(OperationCanceledExceptionText);
                    }
                }

                var externalRect = externalElement.GetPropertyValue <Rect>(AutomationElement.BoundingRectangleProperty);

                return(externalRect.Contains(point));
            }
            catch (Exception exc)
            {
                throw new OperationCanceledException(
                          "Could not determine if element is contained by another element\n",
                          exc);
            }
        }
        internal static bool ClickablePointOver(this AutomationElement currentElement, AutomationElement rectElement)
        {
            try
            {
                Point point;
                if (!AutomationElementHelper.TryGetClickablePoint(currentElement, out point))
                {
                    if (!AutomationElementHelper.TryGetBoundingRectangleCenter(currentElement, out point))
                    {
                        throw new OperationCanceledException(
                                  "Не удалось определить расположение элемента относительно точки.\n");
                    }
                }

                var rect = rectElement.GetPropertyValue <Rect>(AutomationElement.BoundingRectangleProperty);

                return(point.Y < rect.Top);
            }
            catch (Exception exc)
            {
                throw new OperationCanceledException(
                          "Не удалось определить расположение элемента относительно точки.\n",
                          exc);
            }
        }
        internal static bool ContainsClickablePoint(
            this AutomationElement externalElement,
            AutomationElement internalElement)
        {
            try
            {
                Point point;
                if (!AutomationElementHelper.TryGetClickablePoint(internalElement, out point))
                {
                    if (!AutomationElementHelper.TryGetBoundingRectangleCenter(internalElement, out point))
                    {
                        throw new OperationCanceledException(
                                  "Не удалось определить расположение элемента относительно точки.\n");
                    }
                }

                var externalRect = externalElement.GetPropertyValue <Rect>(AutomationElement.BoundingRectangleProperty);

                return(externalRect.Contains(point));
            }
            catch (Exception exc)
            {
                throw new OperationCanceledException("Не удалось определить вхождение одного элемента в другой.\n", exc);
            }
        }
        internal static bool ClickablePointUnder(
            this AutomationElement currentElement,
            AutomationElement rectElement,
            ScrollPattern scrollPattern)
        {
            try
            {
                Point point;
                if (!AutomationElementHelper.TryGetClickablePoint(currentElement, out point))
                {
                    if (!AutomationElementHelper.TryGetBoundingRectangleCenter(currentElement, out point))
                    {
                        throw new OperationCanceledException(
                                  "Не удалось определить расположение элемента относительно точки.\n");
                    }
                }

                var rect = rectElement.GetPropertyValue <Rect>(AutomationElement.BoundingRectangleProperty);

                if (scrollPattern == null || scrollPattern.Current.HorizontalScrollPercent < 0)
                {
                    return(point.Y > rect.Bottom);
                }

                return(point.Y > rect.Bottom - CruciatusFactory.Settings.ScrollBarHeight);
            }
            catch (Exception exc)
            {
                throw new OperationCanceledException(
                          "Не удалось определить расположение элемента относительно точки.\n",
                          exc);
            }
        }
示例#6
0
        internal static bool ClickablePointOver(this AutomationElement currentElement, AutomationElement rectElement)
        {
            try
            {
                Point point;
                if (!AutomationElementHelper.TryGetClickablePoint(currentElement, out point))
                {
                    if (!AutomationElementHelper.TryGetBoundingRectangleCenter(currentElement, out point))
                    {
                        throw new OperationCanceledException(OperationCanceledExceptionText);
                    }
                }

                var rect = rectElement.GetPropertyValue <Rect>(AutomationElement.BoundingRectangleProperty);

                return(point.Y < rect.Top);
            }
            catch (Exception exc)
            {
                throw new OperationCanceledException(OperationCanceledExceptionText, exc);
            }
        }