public static void UninstallPluginAssembly(PluginAssembly pa) { List <string> pids = pa.PluginInformations.Select(pi => pi.PluginID).ToList(); InstanceManager.LocalTabBroadcast(tabbar => pids.ForEach(pid => tabbar.pluginServer.UnloadPluginInstance(pid, EndCode.Removed))); foreach (PluginInformation info in pa.PluginInformations) { Plugin plugin; if (!dicStaticPluginInstances.TryGetValue(info.PluginID, out plugin)) { continue; } if (info.PluginType == PluginType.Static) { plugin.Close(EndCode.Removed); } dicStaticPluginInstances.Remove(info.PluginID); } dicPluginAssemblies.Remove(pa.Path); pa.Uninstall(); pa.Dispose(); }
public static void Open() { InstanceManager.ExecuteOnServerProcess(OpenInternal, false); }
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); }
/// <summary> /// Displays shell shortcut menu. /// </summary> /// <param name="idlw">IDLWrapper object that specifies shell item</param> /// <param name="pntShow">location of the shortcut menu, in screen coordinates.</param> /// <param name="hwndParent">Handle of parent control. Parent control will get focus, and receives the messages about drawing 'Send to' submenues.</param> /// <param name="fCanRemove">set true to add 'remove this' menu item.</param> /// <returns> /// 0xFFFF user selected "Remove this item from menu". /// 0xFFFE user selected "Open containing folder". /// 0xFFFD If the user cancels the menu without making a selection, or if an error occurs /// </returns> public int Open(IDLWrapper idlw, Point pntShow, IntPtr hwndParent, bool fCanRemove) { const uint MF_STRING = 0x00000000; const uint MF_SEPARATOR = 0x00000800; const uint CMF_NORMAL = 0x00000000; const uint CMF_EXTENDEDVERBS = 0x00000100; const uint TPM_RETURNCMD = 0x0100; const uint S_OK = 0; const int COMMANDID_REMOVEITEM = 0xffff; // todo: move to const class const int COMMANDID_OPENPARENT = 0xfffe; const int COMMANDID_USERCANCEL = 0xfffd; IShellFolder shellFolderParent = null; try { // get IShellFolder IntPtr pIDLRelative; if (idlw.Available && S_OK == PInvoke.SHBindToParent(idlw.PIDL, ExplorerGUIDs.IID_IShellFolder, out shellFolderParent, out pIDLRelative) && shellFolderParent != null) { // get IContextMenu2 IntPtr[] pIDLs = new IntPtr[] { pIDLRelative }; uint reserved = 0; object oUnk; if (S_OK == shellFolderParent.GetUIObjectOf(IntPtr.Zero, (uint)pIDLs.Length, pIDLs, ExplorerGUIDs.IID_IContextMenu, ref reserved, out oUnk)) { pIContextMenu2 = oUnk as IContextMenu2; if (pIContextMenu2 != null) { using (ContextMenu contextMenu = new ContextMenu()) { int nResult = -1; uint uFlags = CMF_NORMAL; if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) { uFlags |= CMF_EXTENDEDVERBS; } pIContextMenu2.QueryContextMenu(contextMenu.Handle, 0, 1, 0xffff, uFlags); // append optional menus if (fCanRemove) { // "Remove this item from menu" PInvoke.AppendMenu(contextMenu.Handle, MF_SEPARATOR, IntPtr.Zero, null); PInvoke.AppendMenu(contextMenu.Handle, MF_STRING, new IntPtr(COMMANDID_REMOVEITEM), QTUtility.ResMain[25]); } if (idlw.HasPath && idlw.Path.Length > 3 && idlw.IsFileSystem /*&& ( idlw.IsFileSystemFolder || idlw.IsFileSystemFile )*/) { // "Open containing folder" if (!fCanRemove) { // separator PInvoke.AppendMenu(contextMenu.Handle, MF_SEPARATOR, IntPtr.Zero, null); } PInvoke.AppendMenu(contextMenu.Handle, MF_STRING, new IntPtr(COMMANDID_OPENPARENT), QTUtility.ResMain[26]); } uint commandID = PInvoke.TrackPopupMenu(contextMenu.Handle, TPM_RETURNCMD, pntShow.X, pntShow.Y, 0, hwndParent, IntPtr.Zero); if (commandID != 0) { if (commandID == COMMANDID_REMOVEITEM) { return(COMMANDID_REMOVEITEM); } else if (commandID == COMMANDID_OPENPARENT) { if (idlw.HasPath) { try { QTTabBarClass tabbar = InstanceManager.GetThreadTabBar(); if (tabbar != null) { using (IDLWrapper idlwParent = idlw.GetParent()) { if (idlwParent.Available) { tabbar.OpenNewTabOrWindow(idlwParent); } } } // DesktopTool will handle it by itself nResult = COMMANDID_OPENPARENT; } catch { System.Media.SystemSounds.Asterisk.Play(); } } } else { CMINVOKECOMMANDINFO cmInfo = new CMINVOKECOMMANDINFO { cbSize = Marshal.SizeOf(typeof(CMINVOKECOMMANDINFO)), fMask = 0, hwnd = hwndParent, lpVerb = (IntPtr)((commandID - 1) & 0xFFFF), lpParameters = IntPtr.Zero, lpDirectory = IntPtr.Zero, nShow = 1, //SW_SHOWNORMAL; dwHotKey = 0, hIcon = IntPtr.Zero }; // returns S_OK if successful, or an error value otherwise. // E_ABORT when user clicked "Open folder link target exists" of link file...( E_ABORT _HRESULT_TYPEDEF_(0x80004004L) ) nResult = pIContextMenu2.InvokeCommand(ref cmInfo); } } else { // 'if the user cancels the menu without making a selection, or if an error occurs' (MSDN) nResult = COMMANDID_USERCANCEL; } return(nResult); } } } } // if failed to create shell context menu, show 'remove this' menu instead if (fCanRemove) { using (ContextMenu contextMenu = new ContextMenu()) { PInvoke.AppendMenu(contextMenu.Handle, MF_STRING, new IntPtr(COMMANDID_REMOVEITEM), QTUtility.ResMain[25]); if (COMMANDID_REMOVEITEM == PInvoke.TrackPopupMenu(contextMenu.Handle, TPM_RETURNCMD, pntShow.X, pntShow.Y, 0, hwndParent, IntPtr.Zero)) { return(COMMANDID_REMOVEITEM); } } } return(COMMANDID_USERCANCEL); } catch { } finally { if (shellFolderParent != null) { Marshal.ReleaseComObject(shellFolderParent); } if (pIContextMenu2 != null) { Marshal.ReleaseComObject(pIContextMenu2); pIContextMenu2 = null; } } return(-1); }