Esempio n. 1
0
            // Process all the Logical and Raw Element Properties
            internal override object GetElementProperty(AutomationProperty idProp)
            {
                if (idProp == AutomationElement.IsControlElementProperty)
                {
                    IntPtr hwndTabParent = GetTabParent();
                    if (hwndTabParent != IntPtr.Zero)
                    {
                        return(WindowsTab.IsValidControl(hwndTabParent));
                    }
                }

                return(base.GetElementProperty(idProp));
            }
 // Process events for the associated UpDown control, and relay
 // them to the WindowsTab control instead.
 internal static void UpDownControlRaiseEvents(
     IntPtr hwnd, int eventId, object idProp, int idObject, int idChild)
 {
     if (eventId == NativeMethods.EventObjectValueChange &&
         idProp == ScrollPattern.HorizontalScrollPercentProperty)
     {
         IntPtr hwndParent = NativeMethodsSetLastError.GetAncestor(hwnd, NativeMethods.GA_PARENT);
         if (hwndParent != IntPtr.Zero &&
             Misc.ProxyGetClassName(hwndParent).Contains("SysTabControl32"))
         {
             WindowsTab el = new WindowsTab(hwndParent, null, 0);
             el.DispatchEvents(eventId, idProp, 0, 0);
         }
     }
 }
        //------------------------------------------------------
        //
        //  Interface IRawElementProviderHwndOverride
        //
        //------------------------------------------------------
        #region IRawElementProviderHwndOverride Interface

        IRawElementProviderSimple IRawElementProviderHwndOverride.GetOverrideProviderForHwnd(IntPtr hwnd)
        {
            // return the appropriate placeholder for the given hwnd...
            // loop over all the tabs to find it.

            IntPtr hwndTab;
            int    item;

            if (IsTabPage(hwnd, out hwndTab, out item))
            {
                WindowsTab wTab = new WindowsTab(hwndTab, null, 0);
                return(new WindowsTabChildOverrideProxy(hwnd, wTab.CreateTabItem(item), item));
            }

            return(null);
        }
        void IScrollItemProvider.ScrollIntoView()
        {
            // Make sure that the control is enabled
            if (!SafeNativeMethods.IsWindowEnabled(_hwnd))
            {
                throw new ElementNotEnabledException();
            }

            WindowsTab parent = (WindowsTab)_parent;

            if (!parent.IsScrollable())
            {
                throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed));
            }

            parent.ScrollToItem(_item);
        }
        // Sets the focus to this item.
        internal override bool SetFocus()
        {
            if (Misc.IsBitSet(WindowStyle, NativeMethods.TCS_FOCUSNEVER))
            {
                return(false);
            }

            WindowsTab  tab     = (WindowsTab)_parent;
            ProxySimple focused = tab.GetFocus();

            if (focused == null || _item != focused._item)
            {
                Misc.ProxySendMessage(_hwnd, NativeMethods.TCM_SETCURFOCUS, new IntPtr(_item), IntPtr.Zero);
            }

            return(true);
        }
        // Returns an enumerator over the current selection.
        IRawElementProviderSimple[] ISelectionProvider.GetSelection()
        {
            IRawElementProviderSimple[] selection = null;

            // If only one selection allowed, get selected item, if any, and add to list
            if (!WindowsTab.SupportMultipleSelection(_hwnd))
            {
                int selectedItem = WindowsTabItem.GetCurrentSelectedItem(_hwnd);

                if (selectedItem >= 0)
                {
                    selection    = new IRawElementProviderSimple[1];
                    selection[0] = CreateTabItem(selectedItem);
                }
            }

            // If multiple selections allowed, check each tab for selected state
            else
            {
                ArrayList list = new ArrayList();
                for (ProxySimple child = GetFirstChild(); child != null; child = GetNextSibling(child))
                {
                    if (((ISelectionItemProvider)child).IsSelected)
                    {
                        list.Add(child);
                    }
                }

                int count = list.Count;
                if (count <= 0)
                {
                    return(null);
                }

                selection = new IRawElementProviderSimple[count];
                for (int i = 0; i < count; i++)
                {
                    selection[i] = (ProxySimple)list[i];
                }
            }

            return(selection);
        }
        // Adds this element to the selection
        void ISelectionItemProvider.AddToSelection()
        {
            // Make sure that the control is enabled
            if (!SafeNativeMethods.IsWindowEnabled(_hwnd))
            {
                throw new ElementNotEnabledException();
            }

            // If not selectable, can't add to selection
            if (!IsSelectable())
            {
                throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed));
            }

            // If already selected, done
            if (((ISelectionItemProvider)this).IsSelected)
            {
                return;
            }

            // If multiple selections allowed, add requested selection
            if (WindowsTab.SupportMultipleSelection(_hwnd) == true)
            {
                // Press ctrl and mouse click tab
                NativeMethods.Win32Point pt = new NativeMethods.Win32Point();
                if (GetClickablePoint(out pt, true))
                {
                    Input.SendKeyboardInput(Key.LeftCtrl, true);
                    Misc.MouseClick(pt.x, pt.y);
                    Input.SendKeyboardInput(Key.LeftCtrl, false);
                    return;
                }

                throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed));
            }
            // else only single selection allowed
            else
            {
                throw new InvalidOperationException(SR.Get(SRID.DoesNotSupportMultipleSelection));
            }
        }
        // Static Create method called by the event tracker system
        // WinEvents are one throwns because items exist. so it makes sense to create the item and
        // check for details afterward.
        internal static void RaiseEvents(IntPtr hwnd, int eventId, object idProp, int idObject, int idChild)
        {
            ProxySimple el = null;

            switch (idObject)
            {
            case NativeMethods.OBJID_CLIENT:
            {
                WindowsTab wlv = new WindowsTab(hwnd, null, -1);

                if (eventId == NativeMethods.EventObjectSelection || eventId == NativeMethods.EventObjectSelectionRemove || eventId == NativeMethods.EventObjectSelectionAdd)
                {
                    el = wlv.CreateTabItem(idChild - 1);
                }
                else
                {
                    el = wlv;
                }

                break;
            }

            default:
                if ((idProp == ScrollPattern.VerticalScrollPercentProperty && idObject != NativeMethods.OBJID_VSCROLL) ||
                    (idProp == ScrollPattern.HorizontalScrollPercentProperty && idObject != NativeMethods.OBJID_HSCROLL))
                {
                    return;
                }

                el = new WindowsTab(hwnd, null, -1);
                break;
            }
            if (el != null)
            {
                el.DispatchEvents(eventId, idProp, idObject, idChild);
            }
        }
        // Removes this element from the selection
        void ISelectionItemProvider.RemoveFromSelection()
        {
            // Make sure that the control is enabled
            if (!SafeNativeMethods.IsWindowEnabled(_hwnd))
            {
                throw new ElementNotEnabledException();
            }

            // If not selected, done
            if (!((ISelectionItemProvider)this).IsSelected)
            {
                return;
            }

            // If multiple selections allowed, unselect element
            if (WindowsTab.SupportMultipleSelection(_hwnd) == true)
            {
                NativeMethods.Win32Point pt = new NativeMethods.Win32Point();
                if (GetClickablePoint(out pt, true))
                {
                    Input.SendKeyboardInput(Key.LeftCtrl, true);
                    Misc.MouseClick(pt.x, pt.y);
                    Input.SendKeyboardInput(Key.LeftCtrl, false);
                    return;
                }

                throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed));
            }
            // else if button style and single select, send deselectall message
            else if (Misc.IsBitSet(WindowStyle, NativeMethods.TCS_BUTTONS))
            {
                Misc.ProxySendMessage(_hwnd, NativeMethods.TCM_DESELECTALL, IntPtr.Zero, IntPtr.Zero);
                return;
            }

            throw new InvalidOperationException(SR.Get(SRID.OperationCannotBePerformed));
        }
        private static IRawElementProviderSimple Create(IntPtr hwnd, int idChild)
        {
            WindowsTab wTab = new WindowsTab(hwnd, null, 0);

            return(idChild == 0 ? wTab : wTab.CreateTabItem(idChild - 1));
        }
Esempio n. 11
0
        // Static Create method called by the event tracker system
        // WinEvents are one throwns because items exist. so it makes sense to create the item and
        // check for details afterward.
        internal static void RaiseEvents (IntPtr hwnd, int eventId, object idProp, int idObject, int idChild)
        {
            ProxySimple el = null;

            switch (idObject)
            {
                case NativeMethods.OBJID_CLIENT :
                {
                    WindowsTab wlv = new WindowsTab (hwnd, null, -1);

                    if (eventId == NativeMethods.EventObjectSelection || eventId == NativeMethods.EventObjectSelectionRemove || eventId == NativeMethods.EventObjectSelectionAdd)
                    {
                        el = wlv.CreateTabItem (idChild - 1);
                    }
                    else
                    {
                        el = wlv;
                    }

                    break;
                }

                default :
                    if ((idProp == ScrollPattern.VerticalScrollPercentProperty && idObject != NativeMethods.OBJID_VSCROLL) ||
                        (idProp == ScrollPattern.HorizontalScrollPercentProperty && idObject != NativeMethods.OBJID_HSCROLL))
                    {
                        return;
                    }

                    el = new WindowsTab(hwnd, null, -1);
                    break;
            }
            if (el != null)
            {
                el.DispatchEvents (eventId, idProp, idObject, idChild);
            }
        }
Esempio n. 12
0
 // Process events for the associated UpDown control, and relay
 // them to the WindowsTab control instead.
 internal static void UpDownControlRaiseEvents(
     IntPtr hwnd, int eventId, object idProp, int idObject, int idChild)
 {
     if (eventId == NativeMethods.EventObjectValueChange
         && idProp == ScrollPattern.HorizontalScrollPercentProperty)
     {
         IntPtr hwndParent = NativeMethodsSetLastError.GetAncestor(hwnd, NativeMethods.GA_PARENT);
         if (hwndParent != IntPtr.Zero
            && Misc.ProxyGetClassName(hwndParent).Contains("SysTabControl32"))
         {
             WindowsTab el = new WindowsTab(hwndParent, null, 0);
             el.DispatchEvents(eventId, idProp, 0, 0);
         }
     }
 }
Esempio n. 13
0
        private static IRawElementProviderSimple Create(IntPtr hwnd, int idChild)
        {
            WindowsTab wTab = new WindowsTab(hwnd, null, 0);

            return idChild == 0 ? wTab : wTab.CreateTabItem (idChild - 1);
        }
Esempio n. 14
0
        //------------------------------------------------------
        //
        //  Interface IRawElementProviderHwndOverride
        //
        //------------------------------------------------------
        #region IRawElementProviderHwndOverride Interface

        IRawElementProviderSimple IRawElementProviderHwndOverride.GetOverrideProviderForHwnd(IntPtr hwnd)
        {
            // return the appropriate placeholder for the given hwnd...
            // loop over all the tabs to find it.

            IntPtr hwndTab;
            int item;

            if (IsTabPage(hwnd, out hwndTab, out item))
            {
                WindowsTab wTab = new WindowsTab(hwndTab, null, 0);
                return new WindowsTabChildOverrideProxy(hwnd, wTab.CreateTabItem(item), item);
            }

            return null;
        }