Example #1
0
        public override IAutomationFocusChangedEventHandler RegisterFocusChangedEvent(Action <AutomationElement> action)
        {
            var eventHandler = new UIA3FocusChangedEventHandler(this, action);

            ComCallWrapper.Call(() => NativeAutomation.AddFocusChangedEventHandler(null, eventHandler));
            return(eventHandler);
        }
Example #2
0
        public ITextRange FindAttribute(TextAttributeId attribute, object value, bool backward)
        {
            var nativeValue     = ValueConverter.ToNative(value);
            var nativeTextRange = ComCallWrapper.Call(() => NativeRange.FindAttribute(attribute.Id, nativeValue, backward.ToInt()));

            return(TextRangeConverter.NativeToManaged(Automation, nativeTextRange));
        }
Example #3
0
        public ITextRange RangeFromAnnotation(AutomationElement annotation)
        {
            var nativeInputElement = AutomationElementConverter.ToNative(annotation);
            var nativeElement      = ComCallWrapper.Call(() => ExtendedNativePattern.RangeFromAnnotation(nativeInputElement));

            return(TextRangeConverter.NativeToManaged((UIA3Automation)BasicAutomationElement.Automation, nativeElement));
        }
Example #4
0
        public override ITextRange RangeFromChild(AutomationElement child)
        {
            var nativeChild = child.ToNative();
            var nativeRange = ComCallWrapper.Call(() => NativePattern.RangeFromChild(nativeChild));

            return(TextRangeConverter.NativeToManaged((UIA3Automation)BasicAutomationElement.Automation, nativeRange));
        }
Example #5
0
        public ITextRange GetCaretRange(out bool isActive)
        {
            var rawIsActive     = 0;
            var nativeTextRange = ComCallWrapper.Call(() => ExtendedNativePattern.GetCaretRange(out rawIsActive));

            isActive = rawIsActive != 0;
            return(TextRangeConverter.NativeToManaged((UIA3Automation)BasicAutomationElement.Automation, nativeTextRange));
        }
Example #6
0
        public TextRange GetCaretRange(out bool isActive)
        {
            var rawIsActive     = 0;
            var nativeTextRange = ComCallWrapper.Call(() => ExtendedNativePattern.GetCaretRange(out rawIsActive));

            isActive = (rawIsActive != 0);
            return(NativeValueConverter.NativeToManaged(Automation, nativeTextRange));
        }
Example #7
0
        public AutomationElement FindItemByProperty(AutomationElement startAfter, PropertyId property, object value)
        {
            var foundNativeElement = ComCallWrapper.Call(() =>
                                                         NativePattern.FindItemByProperty(
                                                             startAfter?.ToNative(),
                                                             property?.Id ?? 0, ValueConverter.ToNative(value)));

            return(AutomationElementConverter.NativeToManaged((UIA3Automation)BasicAutomationElement.Automation, foundNativeElement));
        }
Example #8
0
        public Element FindItemByProperty(Element startAfter, PropertyId property, object value)
        {
            var foundNativeElement = ComCallWrapper.Call(() =>
                                                         NativePattern.FindItemByProperty(
                                                             startAfter == null ? null : startAfter.NativeElement,
                                                             property == null ? 0 : property.Id, NativeValueConverter.ToNative(value)));

            return(ToAutomationElement(foundNativeElement));
        }
Example #9
0
 public override AutomationElement FocusedElement()
 {
     return(ComCallWrapper.Call(() =>
     {
         var nativeElement = CacheRequest.IsCachingActive
             ? NativeAutomation.GetFocusedElementBuildCache(CacheRequest.Current.ToNative(this))
             : NativeAutomation.GetFocusedElement();
         return WrapNativeElement(nativeElement);
     }));
 }
Example #10
0
 /// <summary>
 /// Creates an <see cref="AutomationElement" /> from a given windows handle (HWND)
 /// </summary>
 public override AutomationElement FromHandle(IntPtr hwnd)
 {
     return(ComCallWrapper.Call(() =>
     {
         var nativeElement = CacheRequest.IsCachingActive
             ? NativeAutomation.ElementFromHandleBuildCache(hwnd, CacheRequest.Current.ToNative(this))
             : NativeAutomation.ElementFromHandle(hwnd);
         return WrapNativeElement(nativeElement);
     }));
 }
Example #11
0
 public override AutomationElement GetDesktop()
 {
     return(ComCallWrapper.Call(() =>
     {
         var desktop = CacheRequest.IsCachingActive
             ? NativeAutomation.GetRootElementBuildCache(CacheRequest.Current.ToNative(this))
             : NativeAutomation.GetRootElement();
         return WrapNativeElement(desktop);
     }));
 }
Example #12
0
        public override bool TryGetClickablePoint(out Point point)
        {
            var tagPoint = new UIA.tagPOINT {
                x = 0, y = 0
            };
            var success = ComCallWrapper.Call(() => NativeElement.GetClickablePoint(out tagPoint)) != 0;

            point = success ? new Point(tagPoint.x, tagPoint.y) : null;
            return(success);
        }
Example #13
0
 /// <summary>
 /// Creates an <see cref="AutomationElement" /> from a given point
 /// </summary>
 public override AutomationElement FromPoint(Point point)
 {
     return(ComCallWrapper.Call(() =>
     {
         var nativePoint = point.ToTagPoint();
         var nativeElement = CacheRequest.IsCachingActive
             ? NativeAutomation.ElementFromPointBuildCache(nativePoint, CacheRequest.Current.ToNative(this))
             : NativeAutomation.ElementFromPoint(nativePoint);
         return WrapNativeElement(nativeElement);
     }));
 }
        public override bool TryGetClickablePoint(out Point point)
        {
            var tagPoint = new UIA.tagPOINT {
                x = 0, y = 0
            };
            var success = ComCallWrapper.Call(() => NativeElement.GetClickablePoint(out tagPoint)) != 0;

            if (success)
            {
                point = new Point(tagPoint.x, tagPoint.y);
            }
            else
            {
                success = Properties.ClickablePoint.TryGetValue(out point);
            }
            return(success);
        }
Example #15
0
        public Rectangle[] GetBoundingRectangles()
        {
            var unrolledRects = ComCallWrapper.Call(() => NativeRange.GetBoundingRectangles());

            if (unrolledRects == null)
            {
                return(null);
            }
            // If unrolledRects is somehow not a multiple of 4, we still will not
            // overrun it, since (x / 4) * 4 <= x for C# integer math.
            var result = new Rectangle[unrolledRects.Length / 4];

            for (var i = 0; i < result.Length; i++)
            {
                var j = i * 4;
                result[i] = new Rectangle(unrolledRects[j], unrolledRects[j + 1], unrolledRects[j + 2], unrolledRects[j + 3]);
            }
            return(result);
        }
Example #16
0
 public void Select()
 {
     ComCallWrapper.Call(() => NativeRange.Select());
 }
 public override void SetValue(string value)
 {
     ComCallWrapper.Call(() => NativePattern.SetValue(value));
 }
 public override void Select(int flagsSelect)
 {
     ComCallWrapper.Call(() => NativePattern.Select(flagsSelect));
 }
 public override IAccessible GetIAccessible()
 {
     // ReSharper disable once SuspiciousTypeConversion.Global
     return(ComCallWrapper.Call(() => (IAccessible)NativePattern.GetIAccessible()));
 }
 public override void DoDefaultAction()
 {
     ComCallWrapper.Call(() => NativePattern.DoDefaultAction());
 }
Example #21
0
        public object GetAttributeValue(TextAttributeId attribute)
        {
            var nativeValue = ComCallWrapper.Call(() => NativeRange.GetAttributeValue(attribute.Id));

            return(attribute.Convert <object>(nativeValue));
        }
Example #22
0
 public int MoveEndpointByUnit(TextPatternRangeEndpoint endpoint, TextUnit unit, int count)
 {
     return(ComCallWrapper.Call(() => NativeRange.MoveEndpointByUnit((UIA.TextPatternRangeEndpoint)endpoint, (UIA.TextUnit)unit, count)));
 }
Example #23
0
        public ITextRange FindText(string text, bool backward, bool ignoreCase)
        {
            var nativeTextRange = ComCallWrapper.Call(() => NativeRange.FindText(text, backward.ToInt(), ignoreCase.ToInt()));

            return(TextRangeConverter.NativeToManaged(Automation, nativeTextRange));
        }
Example #24
0
        public int CompareEndpoints(TextPatternRangeEndpoint srcEndPoint, ITextRange targetRange, TextPatternRangeEndpoint targetEndPoint)
        {
            var nativeRange = ToNativeRange(targetRange);

            return(ComCallWrapper.Call(() => NativeRange.CompareEndpoints((UIA.TextPatternRangeEndpoint)srcEndPoint, nativeRange, (UIA.TextPatternRangeEndpoint)targetEndPoint)));
        }
Example #25
0
 public void ExpandToEnclosingUnit(TextUnit textUnit)
 {
     ComCallWrapper.Call(() => NativeRange.ExpandToEnclosingUnit((UIA.TextUnit)textUnit));
 }
Example #26
0
        public bool Compare(ITextRange range)
        {
            var nativeRange = ToNativeRange(range);

            return(ComCallWrapper.Call(() => NativeRange.Compare(nativeRange)) != 0);
        }
Example #27
0
        public ITextRange Clone()
        {
            var clonedTextRangeNative = ComCallWrapper.Call(() => NativeRange.Clone());

            return(TextRangeConverter.NativeToManaged(Automation, clonedTextRangeNative));
        }
Example #28
0
 public void AddToSelection()
 {
     ComCallWrapper.Call(() => NativeRange.AddToSelection());
 }
Example #29
0
 public void RemoveFromSelection()
 {
     ComCallWrapper.Call(() => NativeRange.RemoveFromSelection());
 }
Example #30
0
 public void ScrollIntoView(bool alignToTop)
 {
     ComCallWrapper.Call(() => NativeRange.ScrollIntoView(alignToTop.ToInt()));
 }