// Gets whether the menu item at the specified index is included // in the context menu private bool Included(ShellMenuItem item) { if (bDefaultOnly) { return(ItemIsDefault(item)); } return(true); }
// Gets whether the item at the specified index is the default // item; the default item can change between the 'Explore' and 'Open' // menu items depending on whether the shell set the Explore context // menu option private bool ItemIsDefault(ShellMenuItem item) { if (!bExplore && IsOpenItem(item)) { return(true); } else if (bExplore && IsExploreItem(item)) { return(true); } else if ( (!bExplore && !HasOpenItem) || (bExplore && !HasExploreItem)) { return(item.Default); } else { return(false); } }
void IContextMenu.GetCommandString(int idCmd, CommandStringOptions uFlags, IntPtr pwReserved, byte[] pszName, uint cchMax) { if (idCmd > menuItems.Length - 1) { idCmd = 0; //return; } ShellMenuItem menuItem = menuItems[idCmd]; string text; switch (uFlags) { case CommandStringOptions.HelpTextA: case CommandStringOptions.HelpTextW: text = menuItem.HelpText; break; case CommandStringOptions.VerbA: case CommandStringOptions.VerbW: text = menuItem.Verb; break; case CommandStringOptions.ValidateA: case CommandStringOptions.ValidateW: if (idCmd < 0 || idCmd >= menuItems.Length) { Marshal.ThrowExceptionForHR(1); // S_FALSE } throw new Exception(); // unreachable default: throw new ArgumentOutOfRangeException("uFlags", uFlags.ToString()); } if (text == null) { text = string.Empty; } byte[] buf; if ((uFlags & CommandStringOptions.Unicode) == CommandStringOptions.Unicode) { buf = Encoding.Unicode.GetBytes(text); } else { buf = Encoding.ASCII.GetBytes(text); } int cch = Math.Min(buf.Length, pszName.Length - 1); if (cch > 0) { Array.Copy(buf, 0, pszName, 0, cch); } else { // null terminate the buffer pszName[0] = 0; } }
private bool IsNewFolderItem(ShellMenuItem item) { return(item.Verb == ExploreMenuItem.NewFolderVerb); }
// Gets whether the specified menu item is the 'open' menu item private bool IsDeleteItem(ShellMenuItem item) { return(item.Verb == ExploreMenuItem.DeleteVerb); }
// Gets whether the specified menu item is the 'open' menu item private bool IsCopyItem(ShellMenuItem item) { return(item.Verb == ExploreMenuItem.CopyVerb); }
private bool IsRenameItem(ShellMenuItem item) { return(item.Verb == ExploreMenuItem.RenameVerb); }
// Gets whether the specified menu item is the 'open' menu item private bool IsOpenItem(ShellMenuItem item) { return(item.Verb == ExploreMenuItem.OpenVerb); }
// Gets whether the specified menu item is the 'explore' menu item private bool IsExploreItem(ShellMenuItem item) { return(item.Verb == ExploreMenuItem.ExploreVerb); }