Esempio n. 1
0
        // Returns an item corresponding to the focused element (if there is one), or null otherwise.
        internal override ProxySimple GetFocus()
        {
            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.GetFocus();
                        if (proxy != null)
                        {
                            return(proxy);
                        }
                    }
                }
            }

            return(base.GetFocus());
        }
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, (IntPtr)NativeMethods.Util.MAKELONG(x, y));

            switch (hit)
            {
            case NativeMethods.HTCAPTION:
                return(this);

            case NativeMethods.HTMINBUTTON:
                return(CreateTitleBarChild(NativeMethods.INDEX_TITLEBAR_MINBUTTON));

            case NativeMethods.HTMAXBUTTON:
                return(CreateTitleBarChild(NativeMethods.INDEX_TITLEBAR_MAXBUTTON));

            case NativeMethods.HTHELP:
                return(CreateTitleBarChild(NativeMethods.INDEX_TITLEBAR_HELPBUTTON));

            case NativeMethods.HTCLOSE:
                return(CreateTitleBarChild(NativeMethods.INDEX_TITLEBAR_CLOSEBUTTON));

            case NativeMethods.HTSYSMENU:
            {
                // this gets us the system menu bar...
                WindowsMenu sysmenu = WindowsMenu.CreateSystemMenu(_hwnd, this);
                // now drill into the menu item...
                return(sysmenu.CreateMenuItem(0));
            }
            }
            return(null);
        }
Esempio n. 3
0
        public string Draw(string operatingSystem)
        {
            IWidget button;

            if (operatingSystem.Equals("Linux"))
            {
                button = new LinuxButton();
            }
            else
            {
                button = new WindowsButton();
            }

            IWidget menu;

            if (button.GetType() == typeof(LinuxButton))
            {
                menu = new LinuxMenu();
            }
            else
            {
                menu = new WindowsMenu();
            }

            return(button.Draw() + " & " + menu.Draw());
        }
Esempio n. 4
0
        private static void RaiseMenuEventsOnClient(IntPtr hwnd, int eventId, object idProp, int idObject, int idChild)
        {
            ProxySimple el = WindowsMenu.CreateMenuItemFromEvent(hwnd, eventId, idChild, idObject);

            if (el != null)
            {
                el.DispatchEvents(eventId, idProp, idObject, idChild);
            }
        }
Esempio n. 5
0
        internal ProxySimple CreateTitleBarChild(int item)
        {
            switch (item)
            {
            case _systemMenu:
                return(WindowsMenu.CreateSystemMenu(_hwnd, this));

            case NativeMethods.INDEX_TITLEBAR_HELPBUTTON:
            case NativeMethods.INDEX_TITLEBAR_MINBUTTON:
            case NativeMethods.INDEX_TITLEBAR_MAXBUTTON:
            case NativeMethods.INDEX_TITLEBAR_CLOSEBUTTON:
                return(new TitleBarButton(_hwnd, this, item));
            }

            return(null);
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        internal ProxyHwnd CreateNonClientMenu()
        {
            // child windows don't have menus
            int style = WindowStyle;

            if (!Misc.IsBitSet(style, NativeMethods.WS_CHILD))
            {
                ProxyHwnd menuProxy = null;

                if (WindowsMenu.IsInSystemMenuMode())
                {
                    // Since in system menu mode try to find point on the SystemMenu
                    WindowsTitleBar titleBar = (WindowsTitleBar)CreateNonClientChild(NonClientItem.TitleBar);
                    if (titleBar != null)
                    {
                        menuProxy = (ProxyHwnd)titleBar.CreateTitleBarChild(WindowsTitleBar._systemMenu);
                    }
                }
                else
                {
                    IntPtr menu = UnsafeNativeMethods.GetMenu(_hwnd);
                    if (menu != IntPtr.Zero)
                    {
                        menuProxy = new WindowsMenu(_hwnd, this, menu, WindowsMenu.MenuType.Toplevel, (int)NonClientItem.Menu);
                    }
                }

                if (menuProxy != null)
                {
                    // if this menu is not visible its really not there
                    if (menuProxy.BoundingRectangle.Width != 0 && menuProxy.BoundingRectangle.Height != 0)
                    {
                        return(menuProxy);
                    }
                }
            }

            return(null);
        }
Esempio n. 8
0
        private static IRawElementProviderSimple CreateMenuBarItem(IntPtr hwnd, int idChild)
        {
            IntPtr menu = UnsafeNativeMethods.GetMenu(hwnd);

            if (menu == IntPtr.Zero)
            {
                return(null);
            }

            NonClientArea nonClientArea = new NonClientArea(hwnd);

            WindowsMenu appMenu = new WindowsMenu(hwnd, nonClientArea, menu, WindowsMenu.MenuType.Toplevel, (int)NonClientItem.Menu);

            if (idChild == 0)
            {
                return(appMenu);
            }
            else
            {
                return(appMenu.CreateMenuItem(idChild - 1));
            }
        }