Esempio n. 1
0
        //------------------------------------------------------
        //
        //  Protected Methods
        //
        //------------------------------------------------------

        #region Protected Methods

        // This method will return the leaf element that lives in ProxyFragment at Point(x,y)
        static internal ProxySimple DrillDownFragment(ProxyFragment fragment, int x, int y)
        {
            System.Diagnostics.Debug.Assert(fragment != null, "DrillDownFragment: starting point is null");

            // drill down
            ProxySimple fromPoint = fragment.ElementProviderFromPoint(x, y);

            System.Diagnostics.Debug.Assert(fromPoint != null, @"DrillDownFragment: calling ElementProviderFromPoint on Fragment should not return null");

            // Check if we got back a new fragment
            // do this check before trying to cast to ProxyFragment
            if (fragment == fromPoint || Misc.Compare(fragment, fromPoint))
            {
                // Point was on the fragment
                // but not on any element that lives inside of the fragment
                return(fragment);
            }

            fragment = fromPoint as ProxyFragment;
            if (fragment == null)
            {
                // we got back a simple element
                return(fromPoint);
            }

            // Got a new fragment, continue drilling
            return(DrillDownFragment(fragment, x, y));
        }
Esempio n. 2
0
        // Returns a Proxy element corresponding to the specified screen coordinates.
        internal override ProxySimple ElementProviderFromPoint(int x, int y)
        {
            int hit = Misc.ProxySendMessageInt(_hwnd, NativeMethods.WM_NCHITTEST, IntPtr.Zero, NativeMethods.Util.MAKELPARAM(x, y));

            switch (hit)
            {
            case NativeMethods.HTHSCROLL:
            {
                ProxyFragment ret = CreateNonClientChild(NonClientItem.HScrollBar);
                return(ret.ElementProviderFromPoint(x, y));
            }

            case NativeMethods.HTVSCROLL:
            {
                ProxyFragment ret = CreateNonClientChild(NonClientItem.VScrollBar);
                return(ret.ElementProviderFromPoint(x, y));
            }

            case NativeMethods.HTCAPTION:
            case NativeMethods.HTMINBUTTON:
            case NativeMethods.HTMAXBUTTON:
            case NativeMethods.HTHELP:
            case NativeMethods.HTCLOSE:
            case NativeMethods.HTSYSMENU:
                WindowsTitleBar tb = new WindowsTitleBar(_hwnd, this, 0);
                return(tb.ElementProviderFromPoint(x, y));

            case NativeMethods.HTGROWBOX:
                return(CreateNonClientChild(NonClientItem.Grip));

            case NativeMethods.HTBOTTOMRIGHT:
                return(FindGrip(x, y));

            case NativeMethods.HTBOTTOMLEFT:
                return(FindGripMirrored(x, y));

            case NativeMethods.HTMENU:
                return(FindMenus(x, y));

            case NativeMethods.HTLEFT:
            case NativeMethods.HTRIGHT:
            case NativeMethods.HTTOP:
            case NativeMethods.HTTOPLEFT:
            case NativeMethods.HTTOPRIGHT:
            case NativeMethods.HTBOTTOM:
            case NativeMethods.HTBORDER:
                // We do not handle the borders so return null here and let the
                // HWNDProvider handle them as the whole window.
                return(null);

            default:
                // Leave all other cases (especially including HTCLIENT) alone...
                return(null);
            }
        }
Esempio n. 3
0
        private ProxySimple FindMenus(int x, int y)
        {
            if (WindowsMenu.IsInSystemMenuMode())
            {
                // Since in system menu mode try to find point on the SystemMenu
                WindowsTitleBar titleBar = (WindowsTitleBar)CreateNonClientChild(NonClientItem.TitleBar);
                if (titleBar != null)
                {
                    ProxyFragment systemMenu = (ProxyFragment)titleBar.CreateTitleBarChild(WindowsTitleBar._systemMenu);

                    if (systemMenu != null)
                    {
                        // need to drill down ourself, since the FragmentRoot of the System Menu Bar will
                        // be NonClient area hence UIAutomation will not drill down
                        ProxySimple proxy = systemMenu.ElementProviderFromPoint(x, y);
                        if (proxy != null)
                        {
                            return(proxy);
                        }
                    }
                }
            }
            else
            {
                // Not in system menu mode so it may be a Popup Menu, have a go at it
                ProxyFragment menu = CreateNonClientChild(NonClientItem.Menu);
                if (menu != null)
                {
                    // need to drill down ourself, since the FragmentRoot of the MenuBar will
                    // be NonClient area hence UIAutomation will not drill down
                    ProxySimple proxy = menu.ElementProviderFromPoint(x, y);
                    if (proxy != null)
                    {
                        return(proxy);
                    }

                    // We may have been on the Menu but not on a menu Item
                    return(menu);
                }
            }

            return(null);
        }
        //------------------------------------------------------
        //
        //  Protected Methods
        //
        //------------------------------------------------------

        #region Protected Methods

        // This method will return the leaf element that lives in ProxyFragment at Point(x,y)
        static internal ProxySimple DrillDownFragment(ProxyFragment fragment, int x, int y)
        {
            System.Diagnostics.Debug.Assert(fragment != null, "DrillDownFragment: starting point is null");

            // drill down
            ProxySimple fromPoint = fragment.ElementProviderFromPoint(x, y);

            System.Diagnostics.Debug.Assert(fromPoint != null, @"DrillDownFragment: calling ElementProviderFromPoint on Fragment should not return null");

            // Check if we got back a new fragment
            // do this check before trying to cast to ProxyFragment
            if (fragment == fromPoint || Misc.Compare(fragment, fromPoint))
            {
                // Point was on the fragment
                // but not on any element that lives inside of the fragment
                return fragment;
            }

            fragment = fromPoint as ProxyFragment;
            if (fragment == null)
            {
                // we got back a simple element                
                return fromPoint;
            }

            // Got a new fragment, continue drilling
            return DrillDownFragment(fragment, x, y);
        }