Example #1
0
        public static void ReplaceAllTokens(MenuItemArguments mia, string strCurrentPath)
        {
            AppLauncher launcher = new AppLauncher(null, strCurrentPath);

            launcher.ReplaceTokens_WorkingDir(mia);
            launcher.ReplaceTokens_Arguments(mia);
        }
Example #2
0
        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
            });
        }
Example #3
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);
        }
Example #4
0
 public QMenuItem(string title, MenuItemArguments mia)
     : base(title) {
     if(mia != null) {
         path = mia.Path;
         this.mia = mia;
         menuTarget = mia.Target;
         menuGenre = mia.Genre;
     }
 }
Example #5
0
        public int ReplaceTokens_Arguments(MenuItemArguments mia)
        {
            int num = 0;

            mia.TokenReplaced = true;
            if (!string.IsNullOrEmpty(mia.Argument))
            {
                if (this.iSelItemsCount > 0)
                {
                    if (reSlct.IsMatch(mia.Argument))
                    {
                        mia.Argument = reSlct.Replace(mia.Argument, this.strSelObjs);
                        num         |= 1;
                    }
                    if (reFile.IsMatch(mia.Argument))
                    {
                        mia.Argument = reFile.Replace(mia.Argument, this.strSelFiles);
                        num         |= 2;
                    }
                    if (reDirs.IsMatch(mia.Argument))
                    {
                        mia.Argument = reDirs.Replace(mia.Argument, this.strSelDirs);
                        num         |= 4;
                    }
                    if (reDrCr.IsMatch(mia.Argument))
                    {
                        if (this.strSelDirs.Length > 0)
                        {
                            mia.Argument = reDrCr.Replace(mia.Argument, this.strSelDirs);
                            num         |= 4;
                        }
                        else if (this.strCurrentPath != null)
                        {
                            mia.Argument = reDrCr.Replace(mia.Argument, this.strCurrentPath);
                            num         |= 8;
                        }
                    }
                }
                else if ((this.strCurrentPath != null) && reDrCr.IsMatch(mia.Argument))
                {
                    mia.Argument = reDrCr.Replace(mia.Argument, this.strCurrentPath);
                    num         |= 8;
                }
                else if (reAll.IsMatch(mia.Argument))
                {
                    num = 10;
                }
                if ((this.strCurrentPath != null) && reCrnt.IsMatch(mia.Argument))
                {
                    mia.Argument = reCrnt.Replace(mia.Argument, this.strCurrentPath);
                    num         |= 8;
                }
                mia.Argument = reAll.Replace(mia.Argument, string.Empty);
            }
            return(num);
        }
Example #6
0
 public QMenuItem(string title, MenuItemArguments mia)
     : base(title)
 {
     if (mia != null)
     {
         path       = mia.Path;
         this.mia   = mia;
         menuTarget = mia.Target;
         menuGenre  = mia.Genre;
     }
 }
Example #7
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);
            }
        }
Example #8
0
 public QMenuItem(string title, MenuItemArguments mia)
     : base(title)
 {
     if (mia == null)
     {
         return;
     }
     path = mia.Path;
     MenuItemArguments = mia;
     Target            = mia.Target;
     Genre             = mia.Genre;
 }
Example #9
0
        private static void virtualDirectory_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            QMenuItem clickedItem = e.ClickedItem as QMenuItem;

            if (clickedItem == null || clickedItem.Target != MenuTarget.File)
            {
                return;
            }
            MenuItemArguments mia = clickedItem.MenuItemArguments;

            AppsManager.Execute(mia.App, mia.ShellBrowser);
        }
        private void PasteFiles()
        {
            string path = null;

            if (fKeyTargetIsThis)
            {
                path = Path;
            }
            else
            {
                foreach (QMenuItem item in from ToolStripItem item in DisplayedItems
                         where item.Selected select item as QMenuItem)
                {
                    if (item != null)
                    {
                        if (item is SubDirTipForm.ToolStripMenuItemEx)
                        {
                            bool flag2;
                            if (PathIsExecutable(item.Path, out flag2) && !flag2)
                            {
                                StringCollection fileDropList = Clipboard.GetFileDropList();
                                if ((fileDropList != null) && (fileDropList.Count > 0))
                                {
                                    string            str2 = "\"" + fileDropList.StringJoin("\" \"") + "\"";
                                    MenuItemArguments mia  = new MenuItemArguments(item.Path, MenuTarget.File, MenuGenre.Application);
                                    mia.Argument = str2;
                                    AppLauncher.Execute(mia, fIsRootMenu ? Handle : IntPtr.Zero);
                                }
                                return;
                            }
                        }
                        else if (Directory.Exists(item.TargetPath))
                        {
                            path = item.TargetPath;
                        }
                    }
                    break;
                }
            }
            if (!string.IsNullOrEmpty(path))
            {
                ShellMethods.PasteFile(path, hwndDialogParent);
                if (QTUtility.IsXP)
                {
                    DropDownMenuDropTarget root = GetRoot(this);
                    if (root != null)
                    {
                        root.Close(ToolStripDropDownCloseReason.ItemClicked);
                    }
                }
            }
        }
Example #11
0
        public static bool IsTokened(MenuItemArguments mia)
        {
            bool flag = false;

            if (!string.IsNullOrEmpty(mia.OriginalWorkingDirectory))
            {
                flag = reAll.IsMatch(mia.OriginalWorkingDirectory);
            }
            if (!flag && !string.IsNullOrEmpty(mia.OriginalArgument))
            {
                flag = reAll.IsMatch(mia.OriginalArgument);
            }
            return(flag);
        }
Example #12
0
        public static QMenuItem CreateMenuItem(MenuItemArguments mia)
        {
            QMenuItem item = new QMenuItem(QTUtility2.MakePathDisplayText(mia.Path, false), mia);

            if (((mia.Genre == MenuGenre.Navigation) && mia.IsBack) && (mia.Index == 0))
            {
                item.ImageKey = "current";
            }
            else
            {
                item.SetImageReservationKey(mia.Path, null);
            }
            item.ToolTipText = QTUtility2.MakePathDisplayText(mia.Path, true);
            return(item);
        }
Example #13
0
        public bool ReplaceTokens_WorkingDir(MenuItemArguments mia)
        {
            bool flag = false;

            mia.TokenReplaced = true;
            if (!string.IsNullOrEmpty(mia.WorkingDirectory))
            {
                if (this.iSelItemsCount == 1)
                {
                    if (reSlct.IsMatch(mia.WorkingDirectory) && Directory.Exists(this.strSelDirs.Trim(new char[] { '"' })))
                    {
                        mia.WorkingDirectory = reSlct.Replace(mia.WorkingDirectory, this.strSelDirs);
                        flag = true;
                    }
                    else if (reDirs.IsMatch(mia.WorkingDirectory) && (this.strSelDirs.Length > 0))
                    {
                        mia.WorkingDirectory = reDirs.Replace(mia.WorkingDirectory, this.strSelDirs);
                        flag = true;
                    }
                    else if (reDrCr.IsMatch(mia.WorkingDirectory) && Directory.Exists(this.strSelDirs.Trim(new char[] { '"' })))
                    {
                        mia.WorkingDirectory = reDrCr.Replace(mia.WorkingDirectory, this.strSelDirs);
                        flag = true;
                    }
                }
                if (!flag && (this.strCurrentPath != null))
                {
                    if (reDrCr.IsMatch(mia.WorkingDirectory))
                    {
                        mia.WorkingDirectory = reDrCr.Replace(mia.WorkingDirectory, this.strCurrentPath);
                        flag = true;
                    }
                    else if (reCrnt.IsMatch(mia.WorkingDirectory))
                    {
                        mia.WorkingDirectory = reCrnt.Replace(mia.WorkingDirectory, this.strCurrentPath);
                        flag = true;
                    }
                }
                mia.WorkingDirectory = reAll.Replace(mia.WorkingDirectory, string.Empty);
            }
            return(flag);
        }
Example #14
0
        private static void virtualDirectory_ReorderFinished(object sender, ToolStripItemClickedEventArgs e)
        {
            DropDownMenuReorderable reorderable = (DropDownMenuReorderable)sender;

            using (RegistryKey key = Registry.CurrentUser.CreateSubKey(reorderable.Name)) {
                if (key != null)
                {
                    foreach (string str in key.GetValueNames())
                    {
                        key.DeleteValue(str, false);
                    }
                    int      num   = 1;
                    string[] array = new string[] { "separator", string.Empty, string.Empty };
                    foreach (ToolStripItem item in reorderable.Items)
                    {
                        if (item is ToolStripSeparator)
                        {
                            QTUtility2.WriteRegBinary <string>(array, "Separator" + num++, key);
                        }
                        else
                        {
                            QMenuItem item2 = item as QMenuItem;
                            if (item2 != null)
                            {
                                MenuItemArguments menuItemArguments = item2.MenuItemArguments;
                                if (menuItemArguments.Target == MenuTarget.VirtualFolder)
                                {
                                    key.SetValue(item.Name, new byte[0]);
                                    continue;
                                }
                                string[] strArray2 = new string[] { menuItemArguments.Path, menuItemArguments.OriginalArgument, menuItemArguments.OriginalWorkingDirectory, menuItemArguments.KeyShortcut.ToString() };
                                QTUtility2.WriteRegBinary <string>(strArray2, item.Name, key);
                            }
                        }
                    }
                    QTUtility.fRequiredRefresh_App = true;
                    QTTabBarClass.SyncTaskBarMenu();
                }
            }
        }
Example #15
0
 private static TreeNode CreateUserAppNode(string key, string[] appVals) {
     int result = 0;
     if(appVals.Length == 4) {
         int.TryParse(appVals[3], out result);
     }
     MenuItemArguments arguments = new MenuItemArguments(appVals[0], appVals[1], appVals[2], result, MenuGenre.Application);
     TreeNode node = new TreeNode();
     node.Tag = arguments;
     if(((appVals[0] == null) || (appVals[0].Length == 0)) || (appVals[0] == "separator")) {
         node.Text = "----------- Separator -----------";
         node.ForeColor = SystemColors.GrayText;
         node.ImageKey = node.SelectedImageKey = "noimage";
         return node;
     }
     string name = appVals[0];
     try {
         name = Environment.ExpandEnvironmentVariables(name);
     }
     catch {
     }
     string ext = null;
     if(!name.StartsWith("::")) {
         ext = Directory.Exists(name) ? null : Path.GetExtension(name);
     }
     node.Text = key;
     node.ImageKey = node.SelectedImageKey = QTUtility.GetImageKey(name, ext);
     return node;
 }
Example #16
0
 public static void Execute(MenuItemArguments mia, IntPtr hwnd)
 {
     if (((mia == null) || (mia.Genre != MenuGenre.Application)) || string.IsNullOrEmpty(mia.Path))
     {
         QTUtility2.MakeErrorLog(null, "Applauncher.Execute bug found");
     }
     else
     {
         string path             = mia.Path;
         string argument         = mia.Argument;
         string workingDirectory = mia.WorkingDirectory;
         if (!string.Equals(path, "separator", StringComparison.OrdinalIgnoreCase))
         {
             bool flag = false;
             if (path.StartsWith("::"))
             {
                 using (IDLWrapper wrapper = new IDLWrapper(path)) {
                     if (wrapper.Available)
                     {
                         SHELLEXECUTEINFO structure = new SHELLEXECUTEINFO();
                         structure.cbSize   = Marshal.SizeOf(structure);
                         structure.nShow    = 1;
                         structure.fMask    = 4;
                         structure.lpIDList = wrapper.PIDL;
                         structure.hwnd     = hwnd;
                         PInvoke.ShellExecuteEx(ref structure);
                         return;
                     }
                 }
                 flag = true;
             }
             if (path.StartsWith(@"\\"))
             {
                 using (IDLWrapper wrapper2 = new IDLWrapper(path)) {
                     if (!wrapper2.Available)
                     {
                         flag = true;
                     }
                 }
             }
             if (!flag && Directory.Exists(path))
             {
                 ProcessStartInfo startInfo = new ProcessStartInfo(path);
                 startInfo.ErrorDialog = true;
                 try {
                     Process.Start(startInfo);
                 }
                 catch {
                 }
                 return;
                 //flag = true;
             }
             if (!flag)
             {
                 SHELLEXECUTEINFO shellexecuteinfo2 = new SHELLEXECUTEINFO();
                 shellexecuteinfo2.cbSize = Marshal.SizeOf(shellexecuteinfo2);
                 shellexecuteinfo2.nShow  = 1;
                 shellexecuteinfo2.fMask  = 0x4000200;
                 shellexecuteinfo2.hwnd   = hwnd;
                 try {
                     shellexecuteinfo2.lpFile = Marshal.StringToHGlobalUni(path);
                     if (!string.IsNullOrEmpty(argument))
                     {
                         shellexecuteinfo2.lpParameters = Marshal.StringToHGlobalUni(argument);
                     }
                     if (!string.IsNullOrEmpty(workingDirectory))
                     {
                         workingDirectory = workingDirectory.Trim(new char[] { '"', '\'' });
                         shellexecuteinfo2.lpDirectory = Marshal.StringToHGlobalUni(workingDirectory);
                     }
                     else
                     {
                         try {
                             shellexecuteinfo2.lpDirectory = Marshal.StringToHGlobalUni(Path.GetDirectoryName(path));
                         }
                         catch {
                         }
                     }
                     if (PInvoke.ShellExecuteEx(ref shellexecuteinfo2))
                     {
                         string extension = Path.GetExtension(path);
                         if (!string.Equals(".exe", extension, StringComparison.OrdinalIgnoreCase) && !string.Equals(".com", extension, StringComparison.OrdinalIgnoreCase))
                         {
                             QTUtility.ExecutedPathsList.Add(path);
                         }
                     }
                 }
                 finally {
                     if (shellexecuteinfo2.lpFile != IntPtr.Zero)
                     {
                         Marshal.FreeHGlobal(shellexecuteinfo2.lpFile);
                     }
                     if (shellexecuteinfo2.lpParameters != IntPtr.Zero)
                     {
                         Marshal.FreeHGlobal(shellexecuteinfo2.lpParameters);
                     }
                     if (shellexecuteinfo2.lpDirectory != IntPtr.Zero)
                     {
                         Marshal.FreeHGlobal(shellexecuteinfo2.lpDirectory);
                     }
                 }
             }
             else
             {
                 if (!string.IsNullOrEmpty(argument))
                 {
                     path = path + ", " + argument;
                 }
                 if (!string.IsNullOrEmpty(workingDirectory))
                 {
                     path = path + ", " + workingDirectory;
                 }
                 MessageBox.Show("Operation failed.\r\nPlease make sure the file or the target of link exists:\r\n\r\n" + path, "Error - QTTabBar", MessageBoxButtons.OK, MessageBoxIcon.Hand);
             }
         }
     }
 }
Example #17
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;
     }
 }
Example #18
0
 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
     };
 }
Example #19
0
 public static void ReplaceAllTokens(MenuItemArguments mia, string strCurrentPath) {
     AppLauncher launcher = new AppLauncher(null, strCurrentPath);
     launcher.ReplaceTokens_WorkingDir(mia);
     launcher.ReplaceTokens_Arguments(mia);
 }
Example #20
0
 public static bool IsTokened(MenuItemArguments mia) {
     bool flag = false;
     if(!string.IsNullOrEmpty(mia.OriginalWorkingDirectory)) {
         flag = reAll.IsMatch(mia.OriginalWorkingDirectory);
     }
     if(!flag && !string.IsNullOrEmpty(mia.OriginalArgument)) {
         flag = reAll.IsMatch(mia.OriginalArgument);
     }
     return flag;
 }
Example #21
0
 public QMenuItem(string title, MenuItemArguments mia)
     : base(title)
 {
     if(mia == null) return;
     path = mia.Path;
     MenuItemArguments = mia;
     Target = mia.Target;
     Genre = mia.Genre;
 }
Example #22
0
 public int ReplaceTokens_Arguments(MenuItemArguments mia) {
     int num = 0;
     mia.TokenReplaced = true;
     if(!string.IsNullOrEmpty(mia.Argument)) {
         if(this.iSelItemsCount > 0) {
             if(reSlct.IsMatch(mia.Argument)) {
                 mia.Argument = reSlct.Replace(mia.Argument, this.strSelObjs);
                 num |= 1;
             }
             if(reFile.IsMatch(mia.Argument)) {
                 mia.Argument = reFile.Replace(mia.Argument, this.strSelFiles);
                 num |= 2;
             }
             if(reDirs.IsMatch(mia.Argument)) {
                 mia.Argument = reDirs.Replace(mia.Argument, this.strSelDirs);
                 num |= 4;
             }
             if(reDrCr.IsMatch(mia.Argument)) {
                 if(this.strSelDirs.Length > 0) {
                     mia.Argument = reDrCr.Replace(mia.Argument, this.strSelDirs);
                     num |= 4;
                 }
                 else if(this.strCurrentPath != null) {
                     mia.Argument = reDrCr.Replace(mia.Argument, this.strCurrentPath);
                     num |= 8;
                 }
             }
         }
         else if((this.strCurrentPath != null) && reDrCr.IsMatch(mia.Argument)) {
             mia.Argument = reDrCr.Replace(mia.Argument, this.strCurrentPath);
             num |= 8;
         }
         else if(reAll.IsMatch(mia.Argument)) {
             num = 10;
         }
         if((this.strCurrentPath != null) && reCrnt.IsMatch(mia.Argument)) {
             mia.Argument = reCrnt.Replace(mia.Argument, this.strCurrentPath);
             num |= 8;
         }
         mia.Argument = reAll.Replace(mia.Argument, string.Empty);
     }
     return num;
 }
Example #23
0
 private static void InitializeStaticFields() {
     if(!fInitialized) {
         fInitialized = true;
         MIA_GROUPSEP = new MenuItemArguments("sep", null, null, 0, MenuGenre.Group);
         RefreshTexts();
         QTUtility.ImageListGlobal.Images.Add("groupRoot", Resources_Image.imgGroupRoot);
         QTUtility.ImageListGlobal.Images.Add("userAppsRoot", Resources_Image.imgUserAppsRoot);
         QTUtility.ImageListGlobal.Images.Add("noimage", Resources_Image.icoEmpty);
     }
 }
Example #24
0
 public static QMenuItem CreateMenuItem(MenuItemArguments mia) {
     QMenuItem item = new QMenuItem(QTUtility2.MakePathDisplayText(mia.Path, false), mia);
     if(((mia.Genre == MenuGenre.Navigation) && mia.IsBack) && (mia.Index == 0)) {
         item.ImageKey = "current";
     }
     else {
         item.SetImageReservationKey(mia.Path, null);
     }
     item.ToolTipText = QTUtility2.MakePathDisplayText(mia.Path, true);
     return item;
 }
 private void PasteFiles() {
     string path = null;
     if(this.fKeyTargetIsThis) {
         path = base.Path;
     }
     else {
         foreach(ToolStripItem item in this.DisplayedItems) {
             if(!item.Selected) {
                 continue;
             }
             QMenuItem item2 = item as QMenuItem;
             if(item2 != null) {
                 if(item2 is SubDirTipForm.ToolStripMenuItemEx) {
                     bool flag2;
                     if(PathIsExecutable(item2.Path, out flag2) && !flag2) {
                         StringCollection fileDropList = Clipboard.GetFileDropList();
                         if((fileDropList != null) && (fileDropList.Count > 0)) {
                             string str2 = string.Empty;
                             foreach(string str3 in fileDropList) {
                                 str2 = str2 + "\"" + str3 + "\" ";
                             }
                             str2 = str2.Trim();
                             if(str2.Length > 0) {
                                 MenuItemArguments mia = new MenuItemArguments(item2.Path, MenuTarget.File, MenuGenre.Application);
                                 mia.Argument = str2;
                                 AppLauncher.Execute(mia, this.fIsRootMenu ? base.Handle : IntPtr.Zero);
                             }
                         }
                         return;
                     }
                 }
                 else if(Directory.Exists(item2.TargetPath)) {
                     path = item2.TargetPath;
                 }
             }
             break;
         }
     }
     if(!string.IsNullOrEmpty(path)) {
         ShellMethods.PasteFile(path, this.hwndDialogParent);
         if(!QTUtility.IsVista) {
             DropDownMenuDropTarget root = GetRoot(this);
             if(root != null) {
                 root.Close(ToolStripDropDownCloseReason.ItemClicked);
             }
         }
     }
 }
 private void PasteFiles() {
     string path = null;
     if(fKeyTargetIsThis) {
         path = Path;
     }
     else {
         foreach(QMenuItem item in from ToolStripItem item in DisplayedItems
                 where item.Selected select item as QMenuItem) {
             if(item != null) {
                 if(item is SubDirTipForm.ToolStripMenuItemEx) {
                     bool flag2;
                     if(PathIsExecutable(item.Path, out flag2) && !flag2) {
                         StringCollection fileDropList = Clipboard.GetFileDropList();
                         if((fileDropList != null) && (fileDropList.Count > 0)) {
                             string str2 = "\"" + fileDropList.StringJoin("\" \"") + "\"";
                             MenuItemArguments mia = new MenuItemArguments(item.Path, MenuTarget.File, MenuGenre.Application);
                             mia.Argument = str2;
                             AppLauncher.Execute(mia, fIsRootMenu ? Handle : IntPtr.Zero);
                         }
                         return;
                     }
                 }
                 else if(Directory.Exists(item.TargetPath)) {
                     path = item.TargetPath;
                 }
             }
             break;
         }
     }
     if(!string.IsNullOrEmpty(path)) {
         ShellMethods.PasteFile(path, hwndDialogParent);
         if(QTUtility.IsXP) {
             DropDownMenuDropTarget root = GetRoot(this);
             if(root != null) {
                 root.Close(ToolStripDropDownCloseReason.ItemClicked);
             }
         }
     }
 }
Example #27
0
 public static void Execute(MenuItemArguments mia, IntPtr hwnd) {
     if(((mia == null) || (mia.Genre != MenuGenre.Application)) || string.IsNullOrEmpty(mia.Path)) {
         QTUtility2.MakeErrorLog(null, "Applauncher.Execute bug found");
     }
     else {
         string path = mia.Path;
         string argument = mia.Argument;
         string workingDirectory = mia.WorkingDirectory;
         if(!string.Equals(path, "separator", StringComparison.OrdinalIgnoreCase)) {
             bool flag = false;
             if(path.StartsWith("::")) {
                 using(IDLWrapper wrapper = new IDLWrapper(path)) {
                     if(wrapper.Available) {
                         SHELLEXECUTEINFO structure = new SHELLEXECUTEINFO();
                         structure.cbSize = Marshal.SizeOf(structure);
                         structure.nShow = 1;
                         structure.fMask = 4;
                         structure.lpIDList = wrapper.PIDL;
                         structure.hwnd = hwnd;
                         PInvoke.ShellExecuteEx(ref structure);
                         return;
                     }
                 }
                 flag = true;
             }
             if(path.StartsWith(@"\\")) {
                 using(IDLWrapper wrapper2 = new IDLWrapper(path)) {
                     if(!wrapper2.Available) {
                         flag = true;
                     }
                 }
             }
             if(!flag && Directory.Exists(path)) {
                 ProcessStartInfo startInfo = new ProcessStartInfo(path);
                 startInfo.ErrorDialog = true;
                 try {
                     Process.Start(startInfo);
                 }
                 catch {
                 }
                 return;
                 //flag = true;
             }
             if(!flag) {
                 SHELLEXECUTEINFO shellexecuteinfo2 = new SHELLEXECUTEINFO();
                 shellexecuteinfo2.cbSize = Marshal.SizeOf(shellexecuteinfo2);
                 shellexecuteinfo2.nShow = 1;
                 shellexecuteinfo2.fMask = 0x4000200;
                 shellexecuteinfo2.hwnd = hwnd;
                 try {
                     shellexecuteinfo2.lpFile = Marshal.StringToHGlobalUni(path);
                     if(!string.IsNullOrEmpty(argument)) {
                         shellexecuteinfo2.lpParameters = Marshal.StringToHGlobalUni(argument);
                     }
                     if(!string.IsNullOrEmpty(workingDirectory)) {
                         workingDirectory = workingDirectory.Trim(new char[] { '"', '\'' });
                         shellexecuteinfo2.lpDirectory = Marshal.StringToHGlobalUni(workingDirectory);
                     }
                     else {
                         try {
                             shellexecuteinfo2.lpDirectory = Marshal.StringToHGlobalUni(Path.GetDirectoryName(path));
                         }
                         catch {
                         }
                     }
                     if(PInvoke.ShellExecuteEx(ref shellexecuteinfo2)) {
                         string extension = Path.GetExtension(path);
                         if(!string.Equals(".exe", extension, StringComparison.OrdinalIgnoreCase) && !string.Equals(".com", extension, StringComparison.OrdinalIgnoreCase)) {
                             QTUtility.ExecutedPathsList.Add(path);
                         }
                     }
                 }
                 finally {
                     if(shellexecuteinfo2.lpFile != IntPtr.Zero) {
                         Marshal.FreeHGlobal(shellexecuteinfo2.lpFile);
                     }
                     if(shellexecuteinfo2.lpParameters != IntPtr.Zero) {
                         Marshal.FreeHGlobal(shellexecuteinfo2.lpParameters);
                     }
                     if(shellexecuteinfo2.lpDirectory != IntPtr.Zero) {
                         Marshal.FreeHGlobal(shellexecuteinfo2.lpDirectory);
                     }
                 }
             }
             else {
                 if(!string.IsNullOrEmpty(argument)) {
                     path = path + ", " + argument;
                 }
                 if(!string.IsNullOrEmpty(workingDirectory)) {
                     path = path + ", " + workingDirectory;
                 }
                 MessageBox.Show("Operation failed.\r\nPlease make sure the file or the target of link exists:\r\n\r\n" + path, "Error - QTTabBar", MessageBoxButtons.OK, MessageBoxIcon.Hand);
             }
         }
     }
 }
Example #28
0
 public bool ReplaceTokens_WorkingDir(MenuItemArguments mia) {
     bool flag = false;
     mia.TokenReplaced = true;
     if(!string.IsNullOrEmpty(mia.WorkingDirectory)) {
         if(this.iSelItemsCount == 1) {
             if(reSlct.IsMatch(mia.WorkingDirectory) && Directory.Exists(this.strSelDirs.Trim(new char[] { '"' }))) {
                 mia.WorkingDirectory = reSlct.Replace(mia.WorkingDirectory, this.strSelDirs);
                 flag = true;
             }
             else if(reDirs.IsMatch(mia.WorkingDirectory) && (this.strSelDirs.Length > 0)) {
                 mia.WorkingDirectory = reDirs.Replace(mia.WorkingDirectory, this.strSelDirs);
                 flag = true;
             }
             else if(reDrCr.IsMatch(mia.WorkingDirectory) && Directory.Exists(this.strSelDirs.Trim(new char[] { '"' }))) {
                 mia.WorkingDirectory = reDrCr.Replace(mia.WorkingDirectory, this.strSelDirs);
                 flag = true;
             }
         }
         if(!flag && (this.strCurrentPath != null)) {
             if(reDrCr.IsMatch(mia.WorkingDirectory)) {
                 mia.WorkingDirectory = reDrCr.Replace(mia.WorkingDirectory, this.strCurrentPath);
                 flag = true;
             }
             else if(reCrnt.IsMatch(mia.WorkingDirectory)) {
                 mia.WorkingDirectory = reCrnt.Replace(mia.WorkingDirectory, this.strCurrentPath);
                 flag = true;
             }
         }
         mia.WorkingDirectory = reAll.Replace(mia.WorkingDirectory, string.Empty);
     }
     return flag;
 }
        private void PasteFiles()
        {
            string path = null;

            if (this.fKeyTargetIsThis)
            {
                path = base.Path;
            }
            else
            {
                foreach (ToolStripItem item in this.DisplayedItems)
                {
                    if (!item.Selected)
                    {
                        continue;
                    }
                    QMenuItem item2 = item as QMenuItem;
                    if (item2 != null)
                    {
                        if (item2 is SubDirTipForm.ToolStripMenuItemEx)
                        {
                            bool flag2;
                            if (PathIsExecutable(item2.Path, out flag2) && !flag2)
                            {
                                StringCollection fileDropList = Clipboard.GetFileDropList();
                                if ((fileDropList != null) && (fileDropList.Count > 0))
                                {
                                    string str2 = string.Empty;
                                    foreach (string str3 in fileDropList)
                                    {
                                        str2 = str2 + "\"" + str3 + "\" ";
                                    }
                                    str2 = str2.Trim();
                                    if (str2.Length > 0)
                                    {
                                        MenuItemArguments mia = new MenuItemArguments(item2.Path, MenuTarget.File, MenuGenre.Application);
                                        mia.Argument = str2;
                                        AppLauncher.Execute(mia, this.fIsRootMenu ? base.Handle : IntPtr.Zero);
                                    }
                                }
                                return;
                            }
                        }
                        else if (Directory.Exists(item2.TargetPath))
                        {
                            path = item2.TargetPath;
                        }
                    }
                    break;
                }
            }
            if (!string.IsNullOrEmpty(path))
            {
                ShellMethods.PasteFile(path, this.hwndDialogParent);
                if (!QTUtility.IsVista)
                {
                    DropDownMenuDropTarget root = GetRoot(this);
                    if (root != null)
                    {
                        root.Close(ToolStripDropDownCloseReason.ItemClicked);
                    }
                }
            }
        }
Example #30
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) || 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;
 }