private WindowCollection(IntPtr handle)
 {
     _shellHook = new ShellHook(handle);
     _shellHook.WindowCreated   += ShellHookWindowCreated;
     _shellHook.WindowDestroyed += ShellHookWindowDestroyed;
     _shellHook.EnumWindows();
 }
        private void ShellHookWindowDestroyed(ShellHook sender, IntPtr hwnd)
        {
            Win32Window window;

            if (_windows.TryGetValue(hwnd, out window))
            {
                OnWindowDestroyed(window);
                _windows.Remove(hwnd);
            }
        }
        public void Dispose()
        {
            if (_shellHook == null)
            {
                return;
            }

            Trace.WriteLine("Dispose Shell Hook");
            _shellHook.Dispose();
            _shellHook = null;
        }
        private void ShellHookWindowCreated(ShellHook sender, IntPtr hWnd)
        {
            Win32Window window;

            if (_windows.TryGetValue(hWnd, out window))
            {
                window = new Win32Window(hWnd);
                _windows.Add(hWnd, window);
            }

            OnWindowCreated(window);
        }