public static List <ToolStripItem> CreateAppLauncherItems(IntPtr hwndParent, bool fReorderEnabled, ItemRightClickedEventHandler rightClickHandler, EventHandler dirDoubleClickEvent, bool fFromTaskBar) { QTUtility.RefreshUserAppDic(false); List <ToolStripItem> list = new List <ToolStripItem>(); EventPack ep = new EventPack(hwndParent, rightClickHandler, dirDoubleClickEvent, fFromTaskBar); foreach (string str in QTUtility.UserAppsDic.Keys) { string[] appVals = QTUtility.UserAppsDic[str]; if (appVals != null) { list.Add(CreateMenuItem_AppLauncher(str, appVals, ep)); } else { using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Quizo\QTTabBar\UserApps\" + str, false)) { if (key != null) { ToolStripItem item = CreateMenuItem_AppLauncher_Virtual(str, fReorderEnabled, key, ep); if (item != null) { list.Add(item); } } continue; } } } return(list); }
// TODO: this is absent from Quizo's sources. Figure out why. private static void AddChildrenOnOpening(DirectoryMenuItem parentItem) { bool fTruncated; DirectoryInfo info = new DirectoryInfo(parentItem.Path); EventPack eventPack = parentItem.EventPack; foreach (DirectoryInfo info2 in info.GetDirectories() .Where(info2 => (info2.Attributes & FileAttributes.Hidden) == 0)) { string text = QTUtility2.MakeNameEllipsis(info2.Name, out fTruncated); DropDownMenuReorderable reorderable = new DropDownMenuReorderable(null); reorderable.MessageParent = eventPack.MessageParentHandle; reorderable.ItemRightClicked += eventPack.ItemRightClickEventHandler; reorderable.ImageList = QTUtility.ImageListGlobal; DirectoryMenuItem item = new DirectoryMenuItem(text); item.SetImageReservationKey(info2.FullName, null); item.Path = info2.FullName; item.EventPack = eventPack; item.ModifiedDate = info2.LastWriteTime; if (fTruncated) { item.ToolTipText = info2.Name; } item.DropDown = reorderable; item.DoubleClickEnabled = true; item.DropDownItems.Add(new ToolStripMenuItem()); item.DropDownItemClicked += realDirectory_DropDownItemClicked; item.DropDownOpening += realDirectory_DropDownOpening; item.DoubleClick += eventPack.DirDoubleClickEventHandler; parentItem.DropDownItems.Add(item); } foreach (FileInfo info3 in info.GetFiles() .Where(info3 => (info3.Attributes & FileAttributes.Hidden) == 0)) { string fileNameWithoutExtension; string ext = info3.Extension.ToLower(); switch (ext) { case ".lnk": case ".url": fileNameWithoutExtension = Path.GetFileNameWithoutExtension(info3.Name); break; default: fileNameWithoutExtension = info3.Name; break; } string str4 = fileNameWithoutExtension; QMenuItem item2 = new QMenuItem(QTUtility2.MakeNameEllipsis(fileNameWithoutExtension, out fTruncated), MenuTarget.File, MenuGenre.Application); item2.Path = info3.FullName; item2.SetImageReservationKey(info3.FullName, ext); item2.MouseMove += qmi_File_MouseMove; if (fTruncated) { item2.ToolTipText = str4; } parentItem.DropDownItems.Add(item2); } }
public static List<ToolStripItem> CreateAppLauncherItems(IntPtr hwndParent, ShellBrowserEx shellBrowser, bool fReorderEnabled, ItemRightClickedEventHandler rightClickHandler, EventHandler dirDoubleClickEvent, bool fFromTaskBar) { // todo: refresh? EventPack ep = new EventPack(hwndParent, rightClickHandler, dirDoubleClickEvent, fFromTaskBar); return AppsManager.BuildNestedStructure( userApp => CreateMenuItem_AppLauncher(userApp, ep, shellBrowser), (folderName, children) => CreateMenuItem_AppLauncher_Virtual( folderName, children, fReorderEnabled, ep)).ToList(); }
public static List <ToolStripItem> CreateAppLauncherItems(IntPtr hwndParent, ShellBrowserEx shellBrowser, bool fReorderEnabled, ItemRightClickedEventHandler rightClickHandler, EventHandler dirDoubleClickEvent, bool fFromTaskBar) { // todo: refresh? EventPack ep = new EventPack(hwndParent, rightClickHandler, dirDoubleClickEvent, fFromTaskBar); return(AppsManager.BuildNestedStructure( userApp => CreateMenuItem_AppLauncher(userApp, ep, shellBrowser), (folderName, children) => CreateMenuItem_AppLauncher_Virtual( folderName, children, fReorderEnabled, ep)).ToList()); }
private static ToolStripItem CreateMenuItem_AppLauncher(UserApp app, EventPack ep, ShellBrowserEx shellBrowser) { string path = app.Path; try { path = Environment.ExpandEnvironmentVariables(path); } catch { } MenuItemArguments mia = new MenuItemArguments(app, shellBrowser, MenuGenre.Application); if (path.StartsWith(@"\\") || path.StartsWith("::") || !Directory.Exists(path)) { mia.Target = MenuTarget.File; QMenuItem item = new QMenuItem(app.Name, mia) { Name = app.Name }; item.SetImageReservationKey(path, Path.GetExtension(path)); item.MouseMove += qmi_File_MouseMove; if (!ep.FromTaskBar && app.ShortcutKey != Keys.None) { item.ShortcutKeyDisplayString = QTUtility2.MakeKeyString(app.ShortcutKey).Replace(" ", string.Empty); } return(item); } else { mia.Target = MenuTarget.Folder; DropDownMenuReorderable reorderable = new DropDownMenuReorderable(null) { MessageParent = ep.MessageParentHandle, ImageList = QTUtility.ImageListGlobal }; reorderable.ItemRightClicked += ep.ItemRightClickEventHandler; DirectoryMenuItem item = new DirectoryMenuItem(app.Name) { Name = app.Name, Path = path, MenuItemArguments = mia, EventPack = ep, ModifiedDate = Directory.GetLastWriteTime(path), DropDown = reorderable, DoubleClickEnabled = true }; item.DropDownItems.Add(new ToolStripMenuItem()); item.DropDownItemClicked += realDirectory_DropDownItemClicked; item.DropDownOpening += realDirectory_DropDownOpening; item.DoubleClick += ep.DirDoubleClickEventHandler; item.SetImageReservationKey(path, null); return(item); } }
public static List<ToolStripItem> CreateAppLauncherItems(IntPtr hwndParent, bool fReorderEnabled, ItemRightClickedEventHandler rightClickHandler, EventHandler dirDoubleClickEvent, bool fFromTaskBar) { QTUtility.RefreshUserAppDic(false); List<ToolStripItem> list = new List<ToolStripItem>(); EventPack ep = new EventPack(hwndParent, rightClickHandler, dirDoubleClickEvent, fFromTaskBar); foreach(string str in QTUtility.UserAppsDic.Keys) { string[] appVals = QTUtility.UserAppsDic[str]; if(appVals != null) { list.Add(CreateMenuItem_AppLauncher(str, appVals, ep)); } else { using(RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Quizo\QTTabBar\UserApps\" + str, false)) { if(key != null) { ToolStripItem item = CreateMenuItem_AppLauncher_Virtual(str, fReorderEnabled, key, ep); if(item != null) { list.Add(item); } } continue; } } } return list; }
private static ToolStripItem CreateMenuItem_AppLauncher_Virtual(string key, bool fReorderEnabled, RegistryKey rkSub, EventPack ep) { string[] valueNames = rkSub.GetValueNames(); if ((valueNames != null) && (valueNames.Length > 0)) { List <ToolStripItem> list = new List <ToolStripItem>(); foreach (string str in valueNames) { string[] appVals = QTUtility2.ReadRegBinary <string>(str, rkSub); if (appVals != null) { if ((appVals.Length == 3) || (appVals.Length == 4)) { list.Add(CreateMenuItem_AppLauncher(str, appVals, ep)); } } else { using (RegistryKey key2 = rkSub.OpenSubKey(str, false)) { if (key2 != null) { ToolStripItem item = CreateMenuItem_AppLauncher_Virtual(str, fReorderEnabled, key2, ep); if (item != null) { list.Add(item); } } } } } if (list.Count > 0) { QMenuItem item2 = new QMenuItem(key, new MenuItemArguments(key, MenuTarget.VirtualFolder, MenuGenre.Application)); item2.ImageKey = "folder"; item2.Name = key; DropDownMenuReorderable reorderable = new DropDownMenuReorderable(null); reorderable.ReorderEnabled = fReorderEnabled; reorderable.MessageParent = ep.MessageParentHandle; reorderable.ItemRightClicked += ep.ItemRightClickEventHandler; reorderable.ImageList = QTUtility.ImageListGlobal; reorderable.AddItemsRange(list.ToArray(), "userappItem"); reorderable.ItemClicked += new ToolStripItemClickedEventHandler(MenuUtility.virtualDirectory_DropDownItemClicked); reorderable.ReorderFinished += new MenuReorderedEventHandler(MenuUtility.virtualDirectory_ReorderFinished); string name = rkSub.Name; reorderable.Name = name.Substring(name.IndexOf(@"Software\Quizo\QTTabBar\UserApps\")); item2.DropDown = reorderable; return(item2); } } return(null); }
private static ToolStripItem CreateMenuItem_AppLauncher(string key, string[] appVals, EventPack ep) { string name = appVals[0]; try { name = Environment.ExpandEnvironmentVariables(name); } catch { } MenuItemArguments mia = new MenuItemArguments(name, appVals[1], appVals[2], 0, MenuGenre.Application); if ((appVals[0].Length == 0) || string.Equals(appVals[0], "separator", StringComparison.OrdinalIgnoreCase)) { ToolStripSeparator separator = new ToolStripSeparator(); separator.Name = "appSep"; return(separator); } if (appVals.Length == 4) { int.TryParse(appVals[3], out mia.KeyShortcut); } if ((name.StartsWith(@"\\") || name.StartsWith("::")) || !Directory.Exists(name)) { mia.Target = MenuTarget.File; QMenuItem item = new QMenuItem(key, mia); item.Name = key; item.SetImageReservationKey(name, Path.GetExtension(name)); item.MouseMove += new MouseEventHandler(MenuUtility.qmi_File_MouseMove); if (!ep.FromTaskBar && (mia.KeyShortcut > 0x100000)) { int num = mia.KeyShortcut & -1048577; item.ShortcutKeyDisplayString = QTUtility2.MakeKeyString((Keys)num).Replace(" ", string.Empty); } return(item); } mia.Target = MenuTarget.Folder; DropDownMenuReorderable reorderable = new DropDownMenuReorderable(null); reorderable.MessageParent = ep.MessageParentHandle; reorderable.ItemRightClicked += ep.ItemRightClickEventHandler; reorderable.ImageList = QTUtility.ImageListGlobal; DirectoryMenuItem item2 = new DirectoryMenuItem(key); item2.SetImageReservationKey(name, null); item2.Name = key; item2.Path = name; item2.MenuItemArguments = mia; item2.EventPack = ep; item2.ModifiiedDate = Directory.GetLastWriteTime(name); item2.DropDown = reorderable; item2.DoubleClickEnabled = true; item2.DropDownItems.Add(new ToolStripMenuItem()); item2.DropDownItemClicked += new ToolStripItemClickedEventHandler(MenuUtility.realDirectory_DropDownItemClicked); item2.DropDownOpening += new EventHandler(MenuUtility.realDirectory_DropDownOpening); item2.DoubleClick += ep.DirDoubleClickEventHandler; return(item2); }
private static ToolStripItem CreateMenuItem_AppLauncher_Virtual(string name, ToolStripItem[] items, bool fReorderEnabled, EventPack ep) { if (items.Length == 0) { return(null); } MenuItemArguments mia = new MenuItemArguments(name, MenuTarget.VirtualFolder, MenuGenre.Application) { App = new UserApp(name) }; DropDownMenuReorderable reorderable = new DropDownMenuReorderable(null) { ReorderEnabled = fReorderEnabled, MessageParent = ep.MessageParentHandle, ImageList = QTUtility.ImageListGlobal }; reorderable.AddItemsRange(items, "userappItem"); reorderable.ItemRightClicked += ep.ItemRightClickEventHandler; reorderable.ItemClicked += virtualDirectory_DropDownItemClicked; reorderable.ReorderFinished += virtualDirectory_ReorderFinished; return(new QMenuItem(name, mia) { ImageKey = "folder", Name = name, DropDown = reorderable }); }
private static ToolStripItem CreateMenuItem_AppLauncher_Virtual(string key, bool fReorderEnabled, RegistryKey rkSub, EventPack ep) { string[] valueNames = rkSub.GetValueNames(); if((valueNames != null) && (valueNames.Length > 0)) { List<ToolStripItem> list = new List<ToolStripItem>(); foreach(string str in valueNames) { string[] appVals = QTUtility2.ReadRegBinary<string>(str, rkSub); if(appVals != null) { if((appVals.Length == 3) || (appVals.Length == 4)) { list.Add(CreateMenuItem_AppLauncher(str, appVals, ep)); } } else { using(RegistryKey key2 = rkSub.OpenSubKey(str, false)) { if(key2 != null) { ToolStripItem item = CreateMenuItem_AppLauncher_Virtual(str, fReorderEnabled, key2, ep); if(item != null) { list.Add(item); } } } } } if(list.Count > 0) { QMenuItem item2 = new QMenuItem(key, new MenuItemArguments(key, MenuTarget.VirtualFolder, MenuGenre.Application)); item2.ImageKey = "folder"; item2.Name = key; DropDownMenuReorderable reorderable = new DropDownMenuReorderable(null); reorderable.ReorderEnabled = fReorderEnabled; reorderable.MessageParent = ep.MessageParentHandle; reorderable.ItemRightClicked += ep.ItemRightClickEventHandler; reorderable.ImageList = QTUtility.ImageListGlobal; reorderable.AddItemsRange(list.ToArray(), "userappItem"); reorderable.ItemClicked += virtualDirectory_DropDownItemClicked; reorderable.ReorderFinished += virtualDirectory_ReorderFinished; string name = rkSub.Name; reorderable.Name = name.Substring(name.IndexOf(@"Software\Quizo\QTTabBar\UserApps\")); item2.DropDown = reorderable; return item2; } } return null; }
private static ToolStripItem CreateMenuItem_AppLauncher(string key, string[] appVals, EventPack ep) { string name = appVals[0]; try { name = Environment.ExpandEnvironmentVariables(name); } catch { } MenuItemArguments mia = new MenuItemArguments(name, appVals[1], appVals[2], 0, MenuGenre.Application); if((appVals[0].Length == 0) || appVals[0].PathEquals("separator")) { ToolStripSeparator separator = new ToolStripSeparator(); separator.Name = "appSep"; return separator; } if(appVals.Length == 4) { int.TryParse(appVals[3], out mia.KeyShortcut); } if((name.StartsWith(@"\\") || name.StartsWith("::")) || !Directory.Exists(name)) { mia.Target = MenuTarget.File; QMenuItem item = new QMenuItem(key, mia); item.Name = key; item.SetImageReservationKey(name, Path.GetExtension(name)); item.MouseMove += qmi_File_MouseMove; if(!ep.FromTaskBar && (mia.KeyShortcut > 0x100000)) { int num = mia.KeyShortcut & -1048577; item.ShortcutKeyDisplayString = QTUtility2.MakeKeyString((Keys)num).Replace(" ", string.Empty); } return item; } mia.Target = MenuTarget.Folder; DropDownMenuReorderable reorderable = new DropDownMenuReorderable(null); reorderable.MessageParent = ep.MessageParentHandle; reorderable.ItemRightClicked += ep.ItemRightClickEventHandler; reorderable.ImageList = QTUtility.ImageListGlobal; DirectoryMenuItem item2 = new DirectoryMenuItem(key); item2.SetImageReservationKey(name, null); item2.Name = key; item2.Path = name; item2.MenuItemArguments = mia; item2.EventPack = ep; item2.ModifiiedDate = Directory.GetLastWriteTime(name); item2.DropDown = reorderable; item2.DoubleClickEnabled = true; item2.DropDownItems.Add(new ToolStripMenuItem()); item2.DropDownItemClicked += realDirectory_DropDownItemClicked; item2.DropDownOpening += realDirectory_DropDownOpening; item2.DoubleClick += ep.DirDoubleClickEventHandler; return item2; }
private static ToolStripItem CreateMenuItem_AppLauncher_Virtual(string name, ToolStripItem[] items, bool fReorderEnabled, EventPack ep) { if(items.Length == 0) return null; MenuItemArguments mia = new MenuItemArguments(name, MenuTarget.VirtualFolder, MenuGenre.Application) { App = new UserApp(name) }; DropDownMenuReorderable reorderable = new DropDownMenuReorderable(null) { ReorderEnabled = fReorderEnabled, MessageParent = ep.MessageParentHandle, ImageList = QTUtility.ImageListGlobal }; reorderable.AddItemsRange(items, "userappItem"); reorderable.ItemRightClicked += ep.ItemRightClickEventHandler; reorderable.ItemClicked += virtualDirectory_DropDownItemClicked; reorderable.ReorderFinished += virtualDirectory_ReorderFinished; return new QMenuItem(name, mia) { ImageKey = "folder", Name = name, DropDown = reorderable }; }
private static ToolStripItem CreateMenuItem_AppLauncher(UserApp app, EventPack ep, ShellBrowserEx shellBrowser) { string path = app.Path; try { path = Environment.ExpandEnvironmentVariables(path); } catch { } MenuItemArguments mia = new MenuItemArguments(app, shellBrowser, MenuGenre.Application); if(path.StartsWith(@"\\") || path.StartsWith("::") || !Directory.Exists(path)) { mia.Target = MenuTarget.File; QMenuItem item = new QMenuItem(app.Name, mia) { Name = app.Name }; item.SetImageReservationKey(path, Path.GetExtension(path)); item.MouseMove += qmi_File_MouseMove; if(!ep.FromTaskBar && app.ShortcutKey != Keys.None) { item.ShortcutKeyDisplayString = QTUtility2.MakeKeyString(app.ShortcutKey).Replace(" ", string.Empty); } return item; } else { mia.Target = MenuTarget.Folder; DropDownMenuReorderable reorderable = new DropDownMenuReorderable(null) { MessageParent = ep.MessageParentHandle, ImageList = QTUtility.ImageListGlobal }; reorderable.ItemRightClicked += ep.ItemRightClickEventHandler; DirectoryMenuItem item = new DirectoryMenuItem(app.Name) { Name = app.Name, Path = path, MenuItemArguments = mia, EventPack = ep, ModifiedDate = Directory.GetLastWriteTime(path), DropDown = reorderable, DoubleClickEnabled = true }; item.DropDownItems.Add(new ToolStripMenuItem()); item.DropDownItemClicked += realDirectory_DropDownItemClicked; item.DropDownOpening += realDirectory_DropDownOpening; item.DoubleClick += ep.DirDoubleClickEventHandler; item.SetImageReservationKey(path, null); return item; } }