Пример #1
0
        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);
        }
Пример #2
0
        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);
            }
        }