// Returns the previous sibling element in the raw hierarchy.
 // Peripheral controls have always negative values.
 // Returns null is no previous.
 internal override ProxySimple GetPreviousSibling(ProxySimple child)
 {
     return _elUpDown.GetPreviousSibling(child);
 }
Пример #2
0
 // Returns the previous sibling element in the raw hierarchy.
 // Peripheral controls have always negative values.
 // Returns null is no previous
 internal override ProxySimple GetPreviousSibling (ProxySimple child)
 {
     // If the index of the previous node would be out of range...
     int item = child._item;
     if (item > 0 && item < Count)
     {
         return CreateRebarItem (item - 1);
     }
     return null;
 }
Пример #3
0
 // Returns the previous sibling element in the raw hierarchy.
 // Peripheral controls have always negative values.
 // Returns null is no previous
 internal override ProxySimple GetPreviousSibling (ProxySimple child)
 {
     return null;
 }
Пример #4
0
 private static void HandleInvalidatedEvent(ProxySimple el, IntPtr hwnd, int eventId)
 {
     AutomationInteropProvider.RaiseAutomationEvent(SelectionPattern.InvalidatedEvent, el, new AutomationEventArgs(SelectionPattern.InvalidatedEvent));
 }
Пример #5
0
        private static void HandleTextSelectionChangedEvent(ProxySimple el, IntPtr hwnd, int eventId)
        {
            ITextProvider textProvider = el.GetPatternProvider(TextPattern.Pattern) as ITextProvider;
            if (textProvider == null)
                return;

            if (eventId == NativeMethods.EventObjectLocationChange)
            {
                // We do not want to raise the EventObjectLocationChange when it is caused by a scroll.  To do this
                // store the previous range and compare it to the current range.  The range will not change when scrolling.
                ITextRangeProvider[] currentRanges = textProvider.GetSelection();
                ITextRangeProvider currentRange = null;
                if (currentRanges != null && currentRanges.Length > 0)
                    currentRange = currentRanges[0];

                if (hwnd == _hwndLast && currentRange != null)
                {
                    if (_lastSelection != null && !currentRange.Compare(_lastSelection))
                    {
                        AutomationInteropProvider.RaiseAutomationEvent(TextPattern.TextSelectionChangedEvent, el, new AutomationEventArgs(TextPattern.TextSelectionChangedEvent));
                    }
                }
                else
                {
                    AutomationInteropProvider.RaiseAutomationEvent(TextPattern.TextSelectionChangedEvent, el, new AutomationEventArgs(TextPattern.TextSelectionChangedEvent));
                }

                //store the current range and window handle.
                _hwndLast = hwnd;
                _lastSelection = currentRange;
            }
            else if (eventId == NativeMethods.EventObjectTextSelectionChanged)
            {
                AutomationInteropProvider.RaiseAutomationEvent(
                    TextPattern.TextSelectionChangedEvent, el,
                    new AutomationEventArgs(TextPattern.TextSelectionChangedEvent));
            }
        }
        // Returns the previous sibling element in the raw hierarchy.
        // Peripheral controls have always negative values.
        // Returns null is no previous
        internal override ProxySimple GetPreviousSibling (ProxySimple child)
        {
            // start with the scrollbars
            ProxySimple ret = base.GetPreviousSibling (child);

            if (ret != null)
            {
                return ret;
            }

            // top level Treeview return the prev
            TVItem item = (TVItem)child._item;

            if (item == TVItem.TopLevel)
            {
                IntPtr hPrev = GetPreviousItem (_hwnd, ((TreeViewItem) child)._hItem);

                return hPrev != IntPtr.Zero ? new TreeViewItem (_hwnd, this, hPrev, (int) TVItem.TopLevel) : null;
            }

            // either scroll bar or nothing as prev
            IntPtr hChild = GetRoot (_hwnd);

            if (hChild != IntPtr.Zero)
            {
                // First Child found, now retrieve the last one (no specific msg, need to walk thru all of them)
                IntPtr temp;

                for (temp = GetNextItem (_hwnd, hChild); temp != IntPtr.Zero; temp = GetNextItem (_hwnd, hChild))
                {
                    hChild = temp;
                }

                return new TreeViewItem (_hwnd, this, hChild, (int) TVItem.TopLevel);
            }

            return null;
        }
Пример #7
0
 private static void HandleStructureChangedEventClient(ProxySimple el, IntPtr hwnd, int eventId)
 {
     if (eventId == NativeMethods.EventObjectCreate)
     {
         AutomationInteropProvider.RaiseStructureChangedEvent (el, new StructureChangedEventArgs (StructureChangeType.ChildAdded, el.MakeRuntimeId()));
     }
     else if (eventId == NativeMethods.EventObjectDestroy)
     {
         AutomationInteropProvider.RaiseStructureChangedEvent( el, new StructureChangedEventArgs( StructureChangeType.ChildRemoved, el.MakeRuntimeId() ) );
     }
     else if ( eventId == NativeMethods.EventObjectReorder )
     {
         IGridProvider grid = el.GetPatternProvider(GridPattern.Pattern) as IGridProvider;
         if ( grid == null )
             return;
         AutomationInteropProvider.RaiseStructureChangedEvent( el, new StructureChangedEventArgs( StructureChangeType.ChildrenInvalidated, el.MakeRuntimeId() ) );
     }
 }
Пример #8
0
 // Prev Silbing: assumes none, must be overloaded by a subclass if any
 // The method is called on the parent with a reference to the child.
 // This makes the implementation a lot more clean than the UIAutomation call
 internal virtual ProxySimple GetPreviousSibling(ProxySimple child)
 {
     return(null);
 }
Пример #9
0
        private static void HandleRangeValueProperty(ProxySimple el, IntPtr hwnd, int eventId)
        {
            IRangeValueProvider rangeValue = el.GetPatternProvider(RangeValuePattern.Pattern) as IRangeValueProvider;
            if (rangeValue == null)
                return;

            RaisePropertyChangedEvent(el, RangeValuePattern.ValueProperty, rangeValue.Value);
        }
 // Returns the previous sibling element in the raw hierarchy.
 // Peripheral controls have always negative values.
 // Returns null is no previous.
 internal override ProxySimple GetPreviousSibling(ProxySimple child)
 {
     return(GetLinkItem(child._item - 1) ? CreateHyperlinkItem(_linkItem, child._item - 1) : null);
 }
Пример #11
0
        // ------------------------------------------------------
        //
        // Patterns Implementation
        //
        // ------------------------------------------------------

        #region ProxyFragment Methods

        // ------------------------------------------------------
        //
        // Default implementation for ProxyFragment members
        //
        // ------------------------------------------------------

        // Next Silbing: assumes none, must be overloaded by a subclass if any
        // The method is called on the parent with a reference to the child.
        // This makes the implementation a lot more clean than the UIAutomation call
        internal virtual ProxySimple GetNextSibling(ProxySimple child)
        {
            return(null);
        }
Пример #12
0
 // Returns the previous sibling element in the raw hierarchy.
 // Peripheral controls have always negative values.
 // Param name="child", the current child
 // Returns null is no previous
 internal override ProxySimple GetPreviousSibling(ProxySimple child)
 {
     return(null);
 }
Пример #13
0
 // Returns the next sibling element in the raw hierarchy.
 // Peripheral controls have always negative values.
 // Param name="child", the current child
 // Returns null if no next child
 internal override ProxySimple GetNextSibling(ProxySimple child)
 {
     return(null);
 }
        private static void RaiseEventsOnScroll(IntPtr hwnd, int eventId, object idProp, int idObject, int idChild)
        {
            if ((idProp == ScrollPattern.VerticalScrollPercentProperty && idObject != NativeMethods.OBJID_VSCROLL) ||
                (idProp == ScrollPattern.HorizontalScrollPercentProperty && idObject != NativeMethods.OBJID_HSCROLL))
            {
                return;
            }

            ProxyFragment el = new NonClientArea(hwnd);

            if (el == null)
            {
                return;
            }

            if (idProp == InvokePattern.InvokedEvent)
            {
                NonClientItem item      = idObject == NativeMethods.OBJID_HSCROLL ? NonClientItem.HScrollBar : NonClientItem.VScrollBar;
                int           sbFlag    = idObject == NativeMethods.OBJID_HSCROLL ? NativeMethods.SB_HORZ : NativeMethods.SB_VERT;
                ProxyFragment scrollBar = new WindowsScrollBar(hwnd, el, (int)item, sbFlag);
                if (scrollBar != null)
                {
                    ProxySimple scrollBarBit = WindowsScrollBarBits.CreateFromChildId(hwnd, scrollBar, idChild, sbFlag);
                    if (scrollBarBit != null)
                    {
                        scrollBarBit.DispatchEvents(eventId, idProp, idObject, idChild);
                    }
                }

                return;
            }

            if (eventId == NativeMethods.EventObjectStateChange && idProp == ValuePattern.IsReadOnlyProperty)
            {
                if (idChild == 0)
                {
                    // This code is never exercised. The code in User needs to change to send
                    // EventObjectStateChange with a client ID of zero
                    //
                    // UIA works differently than MSAA. Events are set for elements rather than hwnd
                    // Scroll bar are processed the same way whatever they are part of the non client area
                    // or stand alone hwnd. OBJID_HSCROLL and OBJID_VSCROLL are mapped to OBJID_WINDOW
                    // so they behave the same for NC and hwnd SB.
                    // Parameters are setup so that the dispatch will send the proper notification and
                    // recursively will send notifications to all of the children
                    if (idObject == NativeMethods.OBJID_HSCROLL || idObject == NativeMethods.OBJID_VSCROLL)
                    {
                        idObject = NativeMethods.OBJID_WINDOW;
                    }
                    el.DispatchEvents(eventId, idProp, idObject, idChild);
                }
                return;
            }

            if (idProp == ValuePattern.ValueProperty && eventId == NativeMethods.EVENT_OBJECT_VALUECHANGE)
            {
                NonClientItem    item      = idObject == NativeMethods.OBJID_HSCROLL ? NonClientItem.HScrollBar : NonClientItem.VScrollBar;
                WindowsScrollBar scrollBar = new WindowsScrollBar(hwnd, el, (int)item, idObject == NativeMethods.OBJID_HSCROLL ? NativeMethods.SB_HORZ : NativeMethods.SB_VERT);
                scrollBar.DispatchEvents(0, ValuePattern.ValueProperty, NativeMethods.OBJID_CLIENT, 0);
                return;
            }

            if (Misc.GetClassName(hwnd) == "ComboLBox")
            {
                el = (ProxyFragment)WindowsListBox.Create(hwnd, 0);
            }

            if (el != null)
            {
                el.DispatchEvents(eventId, idProp, idObject, idChild);
            }
        }
Пример #15
0
        // Compares 2 raw elements and returns true if equal, false otherwise
        internal static bool Compare(ProxySimple el1, ProxySimple el2)
        {
            int[] a1 = el1.GetRuntimeId();
            int[] a2 = el2.GetRuntimeId();
            int l = a1.Length;

            if (l != a2.Length)
                return false;

            for (int i = 0; i < l; i++)
            {
                if (a1[i] != a2[i])
                {
                    return false;
                }
            }

            return true;
        }
Пример #16
0
 private static void HandleExpandCollapseStateProperty(ProxySimple el, IntPtr hwnd, int eventId)
 {
     IExpandCollapseProvider expandCollapse = el.GetPatternProvider(ExpandCollapsePattern.Pattern) as IExpandCollapseProvider;
     if (expandCollapse == null)
         return;
     
     RaisePropertyChangedEvent(el, ExpandCollapsePattern.ExpandCollapseStateProperty, expandCollapse.ExpandCollapseState);
 }
            // Returns the previous sibling element in the raw hierarchy.
            // Peripheral controls have always negative values.
            // Returns null is no previous.
            private ProxySimple PreviousSibling (ProxySimple child)
            {
                IntPtr hPrev = WindowsTreeView.GetPreviousItem (_hwnd, ((TreeViewItem) child)._hItem);

                return hPrev != IntPtr.Zero ? new TreeViewItem(_hwnd, this, hPrev, _item + 1) : null;
            }
Пример #18
0
        private static void HandleColumnCountProperty(ProxySimple el, IntPtr hwnd, int eventId)
        {
            IGridProvider grid = el.GetPatternProvider(GridPattern.Pattern) as IGridProvider;
            if (grid == null)
                return;

            RaisePropertyChangedEvent(el, GridPattern.ColumnCountProperty, grid.ColumnCount);
        }
 // Prev Silbing: assumes none, must be overloaded by a subclass if any
 // The method is called on the parent with a reference to the child.
 // This makes the implementation a lot more clean than the UIAutomation call
 internal override ProxySimple GetPreviousSibling(ProxySimple child)
 {
     return(ReturnNextNonClientChild(false, (NonClientItem)child._item - 1));
 }
Пример #20
0
        private static void HandleRowProperty(ProxySimple el, IntPtr hwnd, int eventId)
        {
            IGridItemProvider gridItem = el.GetPatternProvider(GridItemPattern.Pattern) as IGridItemProvider;
            if (gridItem == null)
                return;

            RaisePropertyChangedEvent(el, GridItemPattern.RowProperty, gridItem.Row);
        }
Пример #21
0
 private static void HandleHorizontalScrollPercentProperty(ProxySimple el, IntPtr hwnd, int eventId)
 {
     IScrollProvider scroll = el.GetPatternProvider (ScrollPattern.Pattern) as IScrollProvider;
     if (scroll == null || scroll.HorizontalScrollPercent == ScrollPattern.NoScroll)
         return;
     
     RaisePropertyChangedEvent(el, ScrollPattern.HorizontalScrollPercentProperty, scroll.HorizontalScrollPercent);
 }
Пример #22
0
        private static void HandleRowHeadersProperty(ProxySimple el, IntPtr hwnd, int eventId)
        {
            ITableProvider table = el.GetPatternProvider(TablePattern.Pattern) as ITableProvider;
            if (table == null)
                return;

            RaisePropertyChangedEvent(el, TablePattern.RowHeadersProperty, table.GetRowHeaders());
        }
Пример #23
0
 private static void RaisePropertyChangedEvent(ProxySimple el, AutomationProperty property, object propertyValue)
 {
     if (propertyValue != null && propertyValue != AutomationElement.NotSupported)
     {
         AutomationInteropProvider.RaiseAutomationPropertyChangedEvent(el, new AutomationPropertyChangedEventArgs(property, null, propertyValue));
     }
 }
Пример #24
0
        private static void HandleIsSelectionRequiredProperty(ProxySimple el, IntPtr hwnd, int eventId)
        {
            ISelectionProvider selection = el.GetPatternProvider(SelectionPattern.Pattern) as ISelectionProvider;
            if (selection == null)
                return;

            RaisePropertyChangedEvent(el, SelectionPattern.IsSelectionRequiredProperty, selection.IsSelectionRequired);
        }
Пример #25
0
        // ------------------------------------------------------
        //
        // Constructors
        //
        // ------------------------------------------------------

        #region Constructors

        
        #endregion
        
        //------------------------------------------------------
        //
        //  Internal Methods
        //
        //------------------------------------------------------

        #region Internal Methods

        internal static void DispatchEvent(ProxySimple el, IntPtr hwnd, int eventId, object idProp, int idObject)
        {
            // This logic uses a hastables in order to get to a delegate that will raise the correct Automation event
            // that may be a property change event a Automation event or a structure changed event. 
            // There are three hashtables one for each idObject we support.  Depending on the idObject that gets
            // passed in we access one of these hashtables with a key of an automation identifier and then retrieve 
            // the data which ia a delegate of type RasieEvent.  This delegate is called to raise the correct type of event.
            RaiseEvent raiseEvent = null;

            switch (idObject)
            {
                case NativeMethods.OBJID_WINDOW:
                    lock (_classLock)
                    {
                        if (_objectIdWindow == null)
                            InitObjectIdWindow();
                    }
                    
                    raiseEvent = (RaiseEvent)_objectIdWindow[idProp];
                    break;
                    
                case NativeMethods.OBJID_CLIENT:
                    lock (_classLock)
                    {
                        if (_objectIdClient == null)
                            InitObjectIdClient();
                    }

                    raiseEvent = (RaiseEvent)_objectIdClient[idProp];
                    break;
                    
                case NativeMethods.OBJID_VSCROLL:
                case NativeMethods.OBJID_HSCROLL:
                    lock (_classLock)
                    {
                        if (_objectIdScroll == null)
                            InitObjectIdScroll();
                    }

                    raiseEvent = (RaiseEvent)_objectIdScroll[idProp];
                    break;

                case NativeMethods.OBJID_CARET:
                    lock (_classLock)
                    {
                        if (_objectIdCaret == null)
                            InitObjectIdCaret();
                    }

                    raiseEvent = (RaiseEvent)_objectIdCaret[idProp];
                    break;

                case NativeMethods.OBJID_SYSMENU:
                case NativeMethods.OBJID_MENU:
                    lock (_classLock)
                    {
                        if (_objectIdMenu == null)
                            InitObjectIdMenu();
                    }

                    raiseEvent = (RaiseEvent)_objectIdMenu[idProp];
                    break;

                default:
                    // Commented out to remove annoying asserts temporarily.
                    // (See work item PS1254940.)
                    //System.Diagnostics.Debug.Assert(false, "Unexpected idObject " + idObject);
                    return;
            }
            
            
            if (raiseEvent != null)
            {
                raiseEvent(el, hwnd, eventId);
            }
            else
            {
                // If there is no delegate then we need to handle this property genericly by just getting the property value
                // and raising the a property changed event.
                AutomationProperty property = idProp as AutomationProperty;
                if (property == null)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Unexpected idProp {0} for idOject 0x{1:x8} on element {2} for event {3}", idProp, idObject, el, eventId));
                    return;
                }

                object propertyValue = ((IRawElementProviderSimple)el).GetPropertyValue(property.Id);

                RaisePropertyChangedEvent(el, property,  propertyValue);
            }
        }
Пример #26
0
        private static void HandleVerticalViewSizeProperty(ProxySimple el, IntPtr hwnd, int eventId)
        {
            IScrollProvider scroll = el.GetPatternProvider(ScrollPattern.Pattern) as IScrollProvider;
            if (scroll == null)
                return;

            RaisePropertyChangedEvent(el, ScrollPattern.VerticalViewSizeProperty, scroll.VerticalViewSize);
        }
Пример #27
0
 // Returns the next sibling element in the raw hierarchy.
 // Peripheral controls have always negative values.
 // Returns null if no next child
 internal override ProxySimple GetNextSibling (ProxySimple child)
 {
     return null;
 }
Пример #28
0
        private static void HandleToggleStateProperty(ProxySimple el, IntPtr hwnd, int eventId)
        {
            IToggleProvider toggle = el.GetPatternProvider(TogglePattern.Pattern) as IToggleProvider;
            if (toggle == null)
                return;

            RaisePropertyChangedEvent(el, TogglePattern.ToggleStateProperty, toggle.ToggleState);
        }
Пример #29
0
        //------------------------------------------------------
        //
        //  Patterns Implementation
        //
        //------------------------------------------------------

        #region ProxyFragment Interface

        // Returns the next sibling element in the raw hierarchy.
        // Peripheral controls have always negative values.
        // Returns null if no next child
        internal override ProxySimple GetNextSibling (ProxySimple child)
        {
            int item = child._item;

            // If the index of the next node would be out of range...
            if (item >= 0 && (item + 1) < Count)
            {
                // return a node to represent the requested item.
                return CreateRebarItem (item + 1);
            }
            return null;
        }
Пример #30
0
        private static void HandleScrollInvokedEvent(ProxySimple el, IntPtr hwnd, int eventId)
        {
            IInvokeProvider invoke = el.GetPatternProvider(InvokePattern.Pattern) as IInvokeProvider;
            if (invoke == null)
                return;

            if (eventId == NativeMethods.EventObjectStateChange)
            {
                AutomationInteropProvider.RaiseAutomationEvent(InvokePattern.InvokedEvent, el, new AutomationEventArgs(InvokePattern.InvokedEvent));
            }
        }
Пример #31
0
        // Returns the previous sibling element in the raw hierarchy.
        // Peripheral controls have always negative values.
        // Returns null is no previous.
        internal override ProxySimple GetPreviousSibling (ProxySimple child)
        {
            ScrollBarItem item = (ScrollBarItem) child._item;

            if (item != ScrollBarItem.UpArrow)
            {
                // skip the Large increment/decrement if there is no thumb
                if (item == ScrollBarItem.DownArrow && !IsScrollBarWithThumb (_hwnd, _sbFlag))
                {
                    item = ScrollBarItem.UpArrow + 1;
                }
                return CreateScrollBitsItem ((ScrollBarItem) ((int) item - 1));
            }

            return null;
        }
Пример #32
0
        private static void HandleWindowInvokedEvent(ProxySimple el, IntPtr hwnd, int eventId)
        {
            IInvokeProvider invoke = el.GetPatternProvider(InvokePattern.Pattern) as IInvokeProvider;
            if (invoke == null)
                return;

            if (eventId == NativeMethods.EventSystemCaptureEnd )
            {
                AutomationInteropProvider.RaiseAutomationEvent(InvokePattern.InvokedEvent, el, new AutomationEventArgs(InvokePattern.InvokedEvent));
            }
        }
            // Returns the next sibling element in the raw hierarchy.
            // Peripheral controls have always negative values.
            // Returns null if no next child.
            private ProxySimple NextSibling (ProxySimple child)
            {
                IntPtr hNext = WindowsTreeView.GetNextItem (_hwnd, ((TreeViewItem) child)._hItem);

                return hNext != IntPtr.Zero ? new TreeViewItem(_hwnd, this, hNext, _item + 1) : null;
            }
Пример #34
0
 private static void HandleMenuItemInvokedEvent(ProxySimple el, IntPtr hwnd, int eventId)
 {
     // Skip the check for InvokePattern because el is just a wrapper on a dead element and
     // GetPatternProvider will fail to return the pattern.  Later, if the caller tries to
     // use this element most properties and methods will throw ElementNotAvailable.
     if (eventId == NativeMethods.EventObjectInvoke)
     {
         AutomationInteropProvider.RaiseAutomationEvent(InvokePattern.InvokedEvent, el, new AutomationEventArgs(InvokePattern.InvokedEvent));
     }
 }
        // Returns the next sibling element in the raw hierarchy.
        // Peripheral controls have always negative values.
        // Returns null if no next child
        internal override ProxySimple GetNextSibling (ProxySimple child)
        {
            TVItem item = (TVItem)child._item;

            // root child
            if (item == TVItem.TopLevel)
            {
                IntPtr hNext = GetNextItem (_hwnd, ((TreeViewItem) child)._hItem);

                if (hNext != IntPtr.Zero)
                    return new TreeViewItem (_hwnd, this, hNext, (int) TVItem.TopLevel);
            }

            return base.GetNextSibling (child);
        }
Пример #36
0
        private static void HandleElementRemovedFromSelectionEvent(ProxySimple el, IntPtr hwnd, int eventId)
        {
            ISelectionItemProvider selProvider = el.GetPatternProvider(SelectionItemPattern.Pattern) as ISelectionItemProvider;
            if (selProvider == null)
                return;

            if (eventId == NativeMethods.EventObjectSelectionRemove)
            {
                AutomationInteropProvider.RaiseAutomationEvent(SelectionItemPattern.ElementRemovedFromSelectionEvent, el, new AutomationEventArgs(SelectionItemPattern.ElementRemovedFromSelectionEvent));
            }
        }
 // Returns the previous sibling element in the raw hierarchy.
 // Peripheral controls have always negative values.
 // Returns null is no previous
 internal override ProxySimple GetPreviousSibling (ProxySimple child)
 {
     CheckForElementAvailable ();
     return IsItemExpanded (_hwnd, _hItem) ? PreviousSibling (child) : null;
 }
 // Next Silbing: assumes none, must be overloaded by a subclass if any
 // The method is called on the parent with a reference to the child.
 // This makes the implementation a lot more clean than the UIAutomation call
 internal override ProxySimple GetNextSibling(ProxySimple child)
 {
     return(ReturnNextNonClientChild(true, (NonClientItem)child._item + 1));
 }