private ShellContextMenuHelper(IWin32Window owner, IContextMenu contextMenu, ContextMenuOptions options, EventHandler<ExecuteVerbEventArgs> onExecuteVerb)
 {
     this.ItemContainer = new Container();
     this.OnExecuteVerb = null;
     this.Owner = owner;
     this.ContextMenu = contextMenu;
     this.Options = ((((options & ContextMenuOptions.Explore) > 0) ? (CMF.CMF_NORMAL | CMF.CMF_EXPLORE) : CMF.CMF_NORMAL) | (((options & ContextMenuOptions.CanRename) > 0) ? CMF.CMF_CANRENAME : CMF.CMF_NORMAL)) | (((options & ContextMenuOptions.VerbsOnly) > 0) ? (CMF.CMF_NORMAL | CMF.CMF_VERBSONLY) : CMF.CMF_NORMAL);
     this.OnExecuteVerb = onExecuteVerb;
 }
 private ShellContextMenuHelper(IWin32Window owner, string[] fileNames, ContextMenuOptions options, EventHandler<ExecuteVerbEventArgs> onExecuteVerb)
 {
     this.ItemContainer = new Container();
     this.OnExecuteVerb = null;
     this.Owner = owner;
     ParseFileNames(fileNames, out this.ParentName, out this.FileNames);
     this.Options = ((((options & ContextMenuOptions.Explore) > 0) ? (CMF.CMF_NORMAL | CMF.CMF_EXPLORE) : CMF.CMF_NORMAL) | (((options & ContextMenuOptions.CanRename) > 0) ? CMF.CMF_CANRENAME : CMF.CMF_NORMAL)) | (((options & ContextMenuOptions.VerbsOnly) > 0) ? (CMF.CMF_NORMAL | CMF.CMF_VERBSONLY) : CMF.CMF_NORMAL);
     this.OnExecuteVerb = onExecuteVerb;
 }
Example #3
0
 public ExperimentNode(string expName)
 {
     Name      = expName;
     Type      = "Experiment";
     IconPath  = Util.IconRegistry[Type];
     HoverText = string.Format("This is a {0} node", Type);
     ContextMenuOptions.Add("Item1", new ActionCommand(Item1Execute));
     ContextMenuOptions.Add("Item2", new ActionCommand(Item2Execute));
 }
        /// <summary>
        /// Opens the menu.
        /// </summary>
        /// <param name="args">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
        /// <param name="options">The options.</param>
        public async Task Open(MouseEventArgs args, ContextMenuOptions options)
        {
            menus.Clear();
            menus.Add(new ContextMenu()
            {
                Options = options, MouseEventArgs = args
            });

            await InvokeAsync(() => { StateHasChanged(); });
        }
Example #5
0
 public LibraryLocationItem(ShellLibraryItem shellLibrary)
 {
     Section     = SectionType.Library;
     MenuOptions = new ContextMenuOptions
     {
         IsLocationItem = true,
         ShowProperties = true,
         ShowShellItems = true,
         ShowUnpinItem  = !shellLibrary.IsPinned,
     };
     Text = shellLibrary.DisplayName;
     Path = shellLibrary.FullPath;
     DefaultSaveFolder = shellLibrary.DefaultSaveFolder;
     Folders           = shellLibrary.Folders is null ? null : new ReadOnlyCollection <string>(shellLibrary.Folders);
     IsDefaultLocation = shellLibrary.IsPinned;
 }
        internal MenuOrderEnumerator(ShellMenuItem[] menuItems, ContextMenuOptions opts)
        {
            if (menuItems == null)
            {
                throw new ArgumentNullException("menuItems");
            }

            this.menuItems = menuItems;

            bNormal        = (opts & ContextMenuOptions.Normal) == ContextMenuOptions.Normal;
            bDefaultOnly   = (opts & ContextMenuOptions.DefaultOnly) == ContextMenuOptions.DefaultOnly;
            bVerbsOnly     = (opts & ContextMenuOptions.VerbsOnly) == ContextMenuOptions.VerbsOnly;
            bExplore       = (opts & ContextMenuOptions.Explore) == ContextMenuOptions.Explore;
            bNoVerbs       = (opts & ContextMenuOptions.NoVerbs) == ContextMenuOptions.NoVerbs;
            bCanRename     = (opts & ContextMenuOptions.CanRename) == ContextMenuOptions.CanRename;
            bNoDefault     = (opts & ContextMenuOptions.NoDefault) == ContextMenuOptions.NoDefault;
            bIncludeStatic = (opts & ContextMenuOptions.IncludeStatic) == ContextMenuOptions.IncludeStatic;
            bExtendedVerbs = (opts & ContextMenuOptions.ExtendedVerbs) == ContextMenuOptions.ExtendedVerbs;
            bReserved      = (opts & ContextMenuOptions.Reserved) == ContextMenuOptions.Reserved;
        }
 public PreviewContextMenuEventArgs(IVirtualItem item, ContextMenuStrip contextMenu, ContextMenuOptions options) : base(item)
 {
     this.ContextMenu = contextMenu;
     this.Options = options;
 }
 public static ContextMenuStrip CreateContextMenu(IWin32Window owner, string[] fileNames, ContextMenuOptions options, EventHandler<ExecuteVerbEventArgs> onExecuteVerb)
 {
     ShellContextMenuHelper helper = new ShellContextMenuHelper(owner, fileNames, options, onExecuteVerb);
     ContextMenuStrip component = new ContextMenuStrip {
         Tag = helper
     };
     component.Items.Add(string.Empty);
     component.Closed += new ToolStripDropDownClosedEventHandler(helper.ContextMenuStrip_Closed);
     component.Opening += new CancelEventHandler(helper.ContextMenuStrip_Opening);
     component.ItemClicked += new ToolStripItemClickedEventHandler(helper.ToolStrip_ItemClick);
     component.Disposed += new EventHandler(helper.ContextMenuStrip_Disposed);
     helper.ItemContainer.Add(component);
     return component;
 }
 void OnOpen(MouseEventArgs args, ContextMenuOptions options)
 {
     Open(args, options).ConfigureAwait(false);
 }
Example #10
0
        int IContextMenu.QueryContextMenu(IntPtr hmenu, uint indexMenu, uint idCmdFirst, uint idCmdLast, ContextMenuOptions uFlags)
        {
            bool bNormal        = (uFlags & ContextMenuOptions.Normal) == ContextMenuOptions.Normal;
            bool bDefaultOnly   = (uFlags & ContextMenuOptions.DefaultOnly) == ContextMenuOptions.DefaultOnly;
            bool bVerbsOnly     = (uFlags & ContextMenuOptions.VerbsOnly) == ContextMenuOptions.VerbsOnly;
            bool bExplore       = (uFlags & ContextMenuOptions.Explore) == ContextMenuOptions.Explore;
            bool bNoVerbs       = (uFlags & ContextMenuOptions.NoVerbs) == ContextMenuOptions.NoVerbs;
            bool bCanRename     = (uFlags & ContextMenuOptions.CanRename) == ContextMenuOptions.CanRename;
            bool bNoDefault     = (uFlags & ContextMenuOptions.NoDefault) == ContextMenuOptions.NoDefault;
            bool bIncludeStatic = (uFlags & ContextMenuOptions.IncludeStatic) == ContextMenuOptions.IncludeStatic;
            bool bExtendedVerbs = (uFlags & ContextMenuOptions.ExtendedVerbs) == ContextMenuOptions.ExtendedVerbs;
            bool bReserved      = (uFlags & ContextMenuOptions.Reserved) == ContextMenuOptions.Reserved;

            Debug.WriteLine(string.Format("QueryContextMenu: \r\nNormal:{0}\r\nDefaultOnly:{1}\r\nbVerbsOnly:{2}\r\nExplore:{3}\r\nNoVerbs:{4}\r\nCanRename:{5}\r\nNoDefault:{6}\r\nIncludeStatic:{7}\r\nExtendedVerbs:{8}\r\nReserved:{9}", bNormal, bDefaultOnly, bVerbsOnly, bExplore, bNoVerbs, bCanRename, bNoDefault, bIncludeStatic, bExtendedVerbs, bReserved));

            MenuOrderEnumerator m = new MenuOrderEnumerator(menuItems, uFlags);


            int items = User32.GetMenuItemCount(hmenu);

            if (items == 8 || items == 9)
            {
                for (uint i = 5; i < items; i++)
                {
                    User32.RemoveMenu(hmenu, 5, User32.MF_BYPOSITION);
                }
            }


            while (m.MoveNext())
            {
                ((ShellMenuItem)m.Current).CreateMenuItem(hmenu, indexMenu++, (int)idCmdFirst + m.CurrentId, m.CurrentIsDefault & !bNoDefault, false);
            }

            return(menuItems.Length);
        }
        private string Write149_ContextMenuOptions(ContextMenuOptions v)
        {
            switch (v)
            {
                case ContextMenuOptions.Explore:
                    return "Explore";

                case ContextMenuOptions.CanRename:
                    return "CanRename";

                case ContextMenuOptions.VerbsOnly:
                    return "VerbsOnly";
            }
            return XmlSerializationWriter.FromEnum((long) v, new string[] { "Explore", "CanRename", "VerbsOnly" }, new long[] { 1L, 2L, 4L }, "Nomad.FileSystem.Virtual.ContextMenuOptions");
        }