Esempio n. 1
0
        /// <summary>
        /// Enumerates the windows on a desktop.
        /// </summary>
        /// <returns>A window collection if successful, otherwise null.</returns>
        public WindowCollection GetWindows()
        {
            // make sure object isn't disposed.
            ThrowIfDisposed();

            // make sure a desktop is open.
            if (!IsOpen)
            {
                return(null);
            }

            // init the array list.
            _windows.Clear();

            // get windows.
            bool result = Win32.EnumDesktopWindows(_desktop, DesktopWindowsProc, IntPtr.Zero);

            // check for error.
            if (!result)
            {
                return(null);
            }

            // get window names.
            WindowCollection windows = new WindowCollection();
            StringBuilder    sb      = new StringBuilder(Win32.MAX_WINDOW_NAME_LENGTH);

            foreach (IntPtr wnd in _windows)
            {
                Win32.GetWindowText(wnd, sb, sb.Capacity);
                windows.Add(new Window(wnd, sb.ToString()));
            }

            return(windows);
        }
Esempio n. 2
0
        void PointCheckHit(Window TestWnd, Vector2 pt, ref WindowCollection ret)
        {
            if (TestWnd == null)
            {
                return;
            }

            if (TestWnd.Rect.IsPointInRect(pt))
            {
                ret.Add(TestWnd);

                foreach (var item in TestWnd.Children)
                {
                    PointCheckHit(item, pt, ref ret);
                }
            }
        }
Esempio n. 3
0
        private WindowCollection ReloadResource(Window parent, string pkgName, string fileName, bool renameWindow)
        {
            if (parent == null)
            {
                return(null);
            }

            WindowCollection ret    = new WindowCollection();
            Window           window = WindowManager.Instance.Deserialize(pkgName, fileName);

            if (window != null)
            {
                if (window.Name.Equals("root", StringComparison.OrdinalIgnoreCase))
                {
                    // 如果序列化的窗口时根节点,那么自处理它的子节点,约定根节点的名字为root
                    foreach (var item in window.Children)
                    {
                        item.PostSerial(parent);

                        if (renameWindow)
                        {
                            RenameWindow(item, window, renameWindow);
                        }

                        ret = window.Children;
                    }
                }
                else
                {
                    window.PostSerial(parent);

                    if (renameWindow)
                    {
                        RenameWindow(window, parent, renameWindow);
                    }

                    ret.Add(window);
                }
            }

            // 刷新界面
            RefreshContolsTree();

            return(ret);
        }
Esempio n. 4
0
        /// <summary>
        ///     Enumerates the windows on a desktop.
        /// </summary>
        /// <param name="windows">Array of Desktop.Window objects to recieve windows.</param>
        /// <returns>A window colleciton if successful, otherwise null.</returns>
        public WindowCollection GetWindows()
        {
            // make sure object isnt disposed.
            CheckDisposed();

            // make sure a desktop is open.
            if (!IsOpen)
            {
                return(null);
            }

            // init the arraylist.
            m_windows.Clear();
            var windows = new WindowCollection();

            // get windows.
            var result = EnumDesktopWindows(DesktopHandle, DesktopWindowsProc, IntPtr.Zero);

            // check for error.
            if (!result)
            {
                return(null);
            }

            // get window names.
            windows = new WindowCollection();

            var ptr = Marshal.AllocHGlobal(MaxWindowNameLength);

            foreach (IntPtr wnd in m_windows)
            {
                GetWindowText(wnd, ptr, MaxWindowNameLength);
                windows.Add(new Window(wnd, Marshal.PtrToStringAnsi(ptr)));
            }

            Marshal.FreeHGlobal(ptr);

            return(windows);
        }
Esempio n. 5
0
        public static WindowCollection LoadUIForm(Window parent, string pkgName, string fileName)
        {
            WindowCollection ret = new WindowCollection(); 
            Window window = WindowManager.Instance.Deserialize(pkgName, fileName);
            if (window != null)
            {
                if (window.Name.Equals(GUISystem.DefaultRootWindowName, StringComparison.OrdinalIgnoreCase))
                {
                    // 如果序列化的窗口时根节点,那么自处理它的子节点,约定根节点的名字为root
                    foreach (var item in window.Children)
                    {
                        item.PostSerial(parent);
                    }

                    ret = window.Children;
                }
                else
                {
                    window.PostSerial(parent);
                    ret.Add(window);
                }
            }
            return ret;
        }
Esempio n. 6
0
        /// <summary>
        ///     Enumerates the windows on a desktop.
        /// </summary>
        /// <param name="windows">Array of Desktop.Window objects to recieve windows.</param>
        /// <returns>A window colleciton if successful, otherwise null.</returns>
        public WindowCollection GetWindows()
        {
            // make sure object isnt disposed.
            CheckDisposed();

            // make sure a desktop is open.
            if (!IsOpen) return null;

            // init the arraylist.
            m_windows.Clear();
            var windows = new WindowCollection();

            // get windows.
            var result = EnumDesktopWindows(DesktopHandle, DesktopWindowsProc, IntPtr.Zero);

            // check for error.
            if (!result) return null;

            // get window names.
            windows = new WindowCollection();

            var ptr = Marshal.AllocHGlobal(MaxWindowNameLength);

            foreach (IntPtr wnd in m_windows)
            {
                GetWindowText(wnd, ptr, MaxWindowNameLength);
                windows.Add(new Window(wnd, Marshal.PtrToStringAnsi(ptr)));
            }

            Marshal.FreeHGlobal(ptr);

            return windows;
        }