コード例 #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 TryClickOnBoundingRectangleCenter(
            MouseButton button,
            CruciatusElement element,
            bool doubleClick)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            Point point;

            if (!AutomationElementHelper.TryGetBoundingRectangleCenter(element.Instance, out point))
            {
                Logger.Debug("Element '{0}' have empty BoundingRectangle", element);
                return(false);
            }

            if (doubleClick)
            {
                CruciatusFactory.Mouse.DoubleClick(button, point.X, point.Y);
            }
            else
            {
                CruciatusFactory.Mouse.Click(button, point.X, point.Y);
            }

            Logger.Info(
                "{0} on '{1}' element at ({2}, {3}) BoundingRectangle center",
                doubleClick ? "DoubleClick" : "Click",
                element,
                point.X,
                point.Y);
            return(true);
        }
コード例 #3
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);
            }
        }
コード例 #4
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(
                                  "Не удалось определить расположение элемента относительно точки.\n");
                    }
                }

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

                return(point.Y < rect.Top);
            }
            catch (Exception exc)
            {
                throw new OperationCanceledException(
                          "Не удалось определить расположение элемента относительно точки.\n",
                          exc);
            }
        }
コード例 #5
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(
                                  "Не удалось определить расположение элемента относительно точки.\n");
                    }
                }

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

                return(externalRect.Contains(point));
            }
            catch (Exception exc)
            {
                throw new OperationCanceledException("Не удалось определить вхождение одного элемента в другой.\n", exc);
            }
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
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);
            }
        }