private void timer_HoverSubDirTipMenu_Tick(object sender, EventArgs e)
 {
     timer_HoverSubDirTipMenu.Enabled = false;
     if (Control.MouseButtons != MouseButtons.None && !(subDirTip != null && subDirTip.IsMouseOnMenus))
     {
         int iItem = GetHotItem();
         if (iItem == subDirIndex)
         {
             return;
         }
         if (subDirTip != null)
         {
             subDirTip.HideMenu();
         }
         // TODO: Check if the item is the Recycle Bin and deny if it is.
         // string.Equals(wrapper.Path, "::{645FF040-5081-101B-9F08-00AA002F954E}"
         if (ShowSubDirTip(iItem, false, true))
         {
             subDirIndex = iItem;
             if (hwndExplorer != IntPtr.Zero)
             {
                 WindowUtils.BringExplorerToFront(hwndExplorer);
             }
             PInvoke.SetFocus(ListViewController.Handle);
             PInvoke.SetForegroundWindow(ListViewController.Handle);
             HideThumbnailTooltip();
             subDirTip.ShowMenu();
             return;
         }
     }
     if (subDirTip != null && !subDirTip.IsMouseOnMenus)
     {
         HideSubDirTip(10);
     }
 }
示例#2
0
 private void contextMenuNotifyIcon_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
 {
     if ((e.ClickedItem is ToolStripSeparator))
     {
         return;
     }
     if (e.ClickedItem.Tag is IntPtr)
     {
         ShowExplorerWindow((IntPtr)e.ClickedItem.Tag, true);
     }
     else
     {
         if ((int)e.ClickedItem.Tag == 0)
         {
             RestoreAllWindowsFromTray();
         }
         else   // Close all
         {
             notifyIcon.Visible = false;
             contextMenuNotifyIcon.Hide();
             var handles = dicNotifyIcon.Values.Select(i => i.ExplorerHandle).ToList();
             dicNotifyIcon.Clear(); // <--- important, clear the dict first!
                                    // otherwise, the closing windows will try to call back
                                    // and we'll deadlock
             foreach (IntPtr ptr in handles)
             {
                 WindowUtils.CloseExplorer(ptr, 2);
             }
         }
     }
 }
示例#3
0
 internal ListViewMonitor(ShellBrowserEx shellBrowser, IntPtr hwndExplorer, IntPtr hwndSubDirTipMessageReflect)
 {
     ShellBrowser      = shellBrowser;
     this.hwndExplorer = hwndExplorer;
     this.hwndSubDirTipMessageReflect = hwndSubDirTipMessageReflect;
     hwndShellContainer = QTUtility.IsXP
             ? hwndExplorer
             : WindowUtils.FindChildWindow(hwndExplorer, hwnd => PInvoke.GetClassName(hwnd) == "ShellTabWindowClass");
     if (hwndShellContainer != IntPtr.Zero)
     {
         ContainerController = new NativeWindowController(hwndShellContainer);
         ContainerController.MessageCaptured += ContainerController_MessageCaptured;
     }
 }
示例#4
0
        private void RecaptureHandles(IntPtr hwndShellView)
        {
            bool   fIsSysListView = false;
            IntPtr hwndListView   = WindowUtils.FindChildWindow(hwndShellView, hwnd => {
                string name = PInvoke.GetClassName(hwnd);
                if (name == "SysListView32")
                {
                    fIsSysListView = true;
                    return(true);
                }
                else if (!QTUtility.IsXP && name == "DirectUIHWND")
                {
                    fIsSysListView = false;
                    return(true);
                }
                return(false);
            });

            if (CurrentListView != null)
            {
                if (CurrentListView.Handle == hwndListView)
                {
                    return;
                }
                PreviousListView = CurrentListView;
            }

            if (hwndListView == IntPtr.Zero)
            {
                CurrentListView = new AbstractListView();
            }
            else if (fIsSysListView)
            {
                CurrentListView = new ExtendedSysListView32(ShellBrowser, hwndShellView, hwndListView, hwndSubDirTipMessageReflect);
            }
            else
            {
                if (AutoMan == null)
                {
                    AutoMan = new AutomationManager();
                }
                CurrentListView = new ExtendedItemsView(ShellBrowser, hwndShellView, hwndListView, hwndSubDirTipMessageReflect, AutoMan);
            }
            CurrentListView.ListViewDestroyed += ListView_Destroyed;
            ListViewChanged(this, null);
        }
示例#5
0
        public void Initialize()
        {
            IntPtr hwndShellView = WindowUtils.FindChildWindow(hwndExplorer, hwnd => PInvoke.GetClassName(hwnd) == "SHELLDLL_DefView");

            if (hwndShellView == IntPtr.Zero)
            {
                if (CurrentListView != null)
                {
                    CurrentListView.Dispose();
                }
                CurrentListView = new AbstractListView();
                ListViewChanged(this, null);
            }
            else
            {
                RecaptureHandles(hwndShellView);
            }
        }
示例#6
0
 protected override IntPtr GetEditControl()
 {
     return(WindowUtils.FindChildWindow(Handle, hwnd => PInvoke.GetClassName(hwnd) == "Edit"));
 }
示例#7
0
            public bool ExecuteCommand(Commands command, object arg)
            {
                if (tabBar != null)
                {
                    IntPtr ptr;
                    switch (command)
                    {
                    case Commands.GoBack:
                    case Commands.GoForward:
                        if (arg is int)
                        {
                            return(tabBar.NavigateToIndex(command == Commands.GoBack, (int)arg));
                        }
                        break;

                    case Commands.GoUpOneLevel:
                        tabBar.UpOneLevel();
                        return(true);

                    case Commands.RefreshBrowser:
                        tabBar.Explorer.Refresh();
                        return(true);

                    case Commands.CloseCurrentTab:
                        return(tabBar.CloseTab(tabBar.CurrentTab));

                    case Commands.CloseLeft:
                    case Commands.CloseRight:
                        tabBar.CloseLeftRight(command == Commands.CloseLeft, -1);
                        return(true);

                    case Commands.CloseAllButCurrent:
                        tabBar.CloseAllTabsExcept(tabBar.CurrentTab);
                        return(true);

                    case Commands.CloseAllButOne: {
                        TabWrapper wrapper = arg as TabWrapper;
                        if (wrapper == null)
                        {
                            break;
                        }
                        tabBar.CloseAllTabsExcept(wrapper.Tab);
                        return(true);
                    }

                    case Commands.CloseWindow:     // 关闭窗口 2 indiff
                        /* using (RegistryKey key = Registry.CurrentUser.CreateSubKey(RegConst.Root))
                         * {
                         *   string[] list = (from QTabItem item2 in tabControl1.TabPages
                         *                    where item2.TabLocked
                         *                    select item2.CurrentPath).ToArray();
                         *
                         *   MessageBox.Show(String.Join(",", list));
                         *   QTUtility2.WriteRegBinary(list, "TabsLocked", key);
                         * }*/
                        WindowUtils.CloseExplorer(tabBar.ExplorerHandle, 2);
                        return(true);

                    case Commands.UndoClose:
                        tabBar.RestoreLastClosed();
                        return(true);

                    case Commands.BrowseFolder:
                        tabBar.ChooseNewDirectory();
                        return(true);

                    case Commands.ToggleTopMost:
                        tabBar.ToggleTopMost();
                        TryCallButtonBar(bbar => bbar.RefreshButtons());
                        return(true);

                    case Commands.FocusFileList:
                        tabBar.listView.SetFocus();
                        return(true);

                    case Commands.OpenTabBarOptionDialog:
                        OptionsDialog.Open();
                        return(true);

                    case Commands.OpenButtonBarOptionDialog:
                        OptionsDialog.Open();     // todo: open at bbar page
                        return(true);

                    case Commands.IsFolderTreeVisible:
                        return(tabBar.ShellBrowser.IsFolderTreeVisible());

                    case Commands.IsButtonBarVisible:
                        return(InstanceManager.TryGetButtonBarHandle(tabBar.ExplorerHandle, out ptr));

                    case Commands.ShowFolderTree:
                        if (!QTUtility.IsXP || !(arg is bool))
                        {
                            break;
                        }
                        tabBar.ShowFolderTree((bool)arg);
                        return(true);

                    case Commands.ShowButtonBar:
                        if (!InstanceManager.TryGetButtonBarHandle(tabBar.ExplorerHandle, out ptr))
                        {
                        }
                        break;

                    case Commands.MD5:
                        if (!(arg is string[]))
                        {
                            break;
                        }
                        if (md5Form == null)
                        {
                            md5Form = new FileHashComputerForm();
                        }
                        if (md5Form.InvokeRequired)
                        {
                            md5Form.Invoke(new FormMethodInvoker(ShowMD5FormCore), new object[] { arg });
                        }
                        else
                        {
                            ShowMD5FormCore(arg);
                        }
                        return(true);

                    case Commands.ShowProperties: {
                        if ((arg == null) || !(arg is Address))
                        {
                            break;
                        }
                        Address address = (Address)arg;
                        using (IDLWrapper wrapper = new IDLWrapper(address)) {
                            if (!wrapper.Available)
                            {
                                break;
                            }
                            ShellMethods.ShowProperties(wrapper.IDL, tabBar.ExplorerHandle);
                            return(true);
                        }
                    }

                    case Commands.SetModalState:
                        if (((arg == null) || !(arg is bool)) || !((bool)arg))
                        {
                            tabBar.NowModalDialogShown = false;
                            break;
                        }
                        tabBar.NowModalDialogShown = true;
                        break;

                    case Commands.SetSearchBoxStr:
                        return(arg != null && arg is string &&
                               TryCallButtonBar(bbar => bbar.SetSearchBarText((string)arg)));

                    case Commands.ReorderTabsByName:
                    case Commands.ReorderTabsByPath:
                    case Commands.ReorderTabsByActv:
                    case Commands.ReorderTabsRevers:
                        if (tabBar.tabControl1.TabCount > 1)
                        {
                            bool fDescending = ((arg != null) && (arg is bool)) && ((bool)arg);
                            tabBar.ReorderTab(((int)command) - 0x18, fDescending);
                        }
                        break;
                    }
                }
                return(false);
            }
示例#8
0
        public static void Initialize(bool skipServer = false)
        {
            uint desktopPID;

            PInvoke.GetWindowThreadProcessId(WindowUtils.GetShellTrayWnd(), out desktopPID);
            isServer = desktopPID == PInvoke.GetCurrentProcessId();

            const string PipeName = "QTTabBarPipe";
            string       address  = "net.pipe://localhost/" + PipeName + desktopPID;
            Thread       thread   = null;

            // WFC channels should never be opened on any thread that has a message loop!
            // Otherwise reentrant calls will deadlock, for some reason.
            // So, create a new thread and open the channels there.
            thread = new Thread(() => {
                if (isServer && !skipServer)
                {
                    serviceHost = new ServiceHost(
                        typeof(CommService),
                        new Uri[] { new Uri(address) });
                    serviceHost.AddServiceEndpoint(
                        typeof(ICommService),
                        new NetNamedPipeBinding(NetNamedPipeSecurityMode.None)
                    {
                        ReceiveTimeout         = TimeSpan.MaxValue,
                        ReaderQuotas           = { MaxArrayLength = int.MaxValue },
                        MaxBufferSize          = int.MaxValue,
                        MaxReceivedMessageSize = int.MaxValue,
                    },
                        new Uri(address));
                    serviceHost.Open();
                }


                commClient = new DuplexClient(new InstanceContext(new CommClient()),
                                              new NetNamedPipeBinding(NetNamedPipeSecurityMode.None)
                {
                    ReceiveTimeout         = TimeSpan.MaxValue,
                    ReaderQuotas           = { MaxArrayLength = int.MaxValue },
                    MaxBufferSize          = int.MaxValue,
                    MaxReceivedMessageSize = int.MaxValue,
                },
                                              new EndpointAddress(address));
                try {
                    commClient.Open();
                    commClient.Channel.Subscribe();
                    using (new Keychain(rwLockTabBar, false)) {
                        foreach (IntPtr handle in sdTabHandles.Keys)
                        {
                            commClient.Channel.PushInstance(handle);
                        }
                    }
                }
                catch (EndpointNotFoundException) {
                }
                lock (thread) {
                    Monitor.Pulse(thread);
                }
                // Yes, we can just let the thread die here.
            });
            thread.Start();
            lock (thread) {
                Monitor.Wait(thread);
            }
        }