Пример #1
0
        public override ShellMenuItem[] GetMenuItems(IFolderObject[] items)
        {
            ShellMenuItem emCopy = CreateCopyMenuItem(items);

            emCopy.Bitmap = (Bitmap)Properties.Resources.ResourceManager.GetObject("copy");

            ShellMenuItem emDelete = CreateDeleteMenuItem(items);

            emDelete.Bitmap = ((Icon)Properties.Resources.ResourceManager.GetObject("delete")).ToBitmap();

            ShellMenuItem emSep = CreateExploreMenuItem("", "", "");

            emSep.Separator = true;

            ShellMenuItem emInfo = CreateInfoMenuItem(items);

            emInfo.Bitmap = (Bitmap)Properties.Resources.ResourceManager.GetObject("info");

            return(new ShellMenuItem[]
            {
                emDelete,
                emCopy,
                emSep,
                emInfo
            });
        }
Пример #2
0
        // context menu on the root folder
        protected override void MergeContextMenu(ShellFolder folder, IReadOnlyList <ShellItem> items, ShellMenu existingMenu, ShellMenu appendMenu)
        {
            if (folder == null)
            {
                throw new ArgumentNullException(nameof(folder));
            }

            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            if (appendMenu == null)
            {
                throw new ArgumentNullException(nameof(appendMenu));
            }

            if (items.Count == 0) // 0 means this is called from Explorer's tree view. We don't want to add the menus twice.
            {
                return;
            }

            var regeditItem = new ShellMenuItem(appendMenu, "Run &Regedit...");

            regeditItem.Invoke += (sender, e) => Process.Start("regedit");
            appendMenu.Items.Add(regeditItem);

            appendMenu.Items.Add(new ShellMenuSeparatorItem());

            var propertiesItem = new ShellMenuItem(appendMenu, "&Properties...");

            propertiesItem.Invoke += (sender, e) => ShowProperties(e.HwndOwner);
            appendMenu.Items.Add(propertiesItem);
        }
Пример #3
0
        private void HyperlinkExecutedEventHandler(object sender, HyperlinkExecutedEventArgs e)
        {
            if (e.Hyperlink.Data.ContainsKey("DialogId")) //Support for links with only moduleid
            {
                var node = (from n in GetMenu().SelectNodes("descendant::item").Cast <XmlNode>()
                            where n.Attributes["operation"].Value == e.Hyperlink.Data["DialogId"]
                            select n).LastOrDefault();

                if (node != null)
                {
                    ShellMenuItem temp = new ShellMenuItem();
                    temp.Operation = node.Attributes["operation"].Value;

                    AuthorizationService.CheckAuthorization(Id, new IAuthOperation[] { temp });

                    if (temp.IsAuthorized)
                    {
                        if (!string.IsNullOrEmpty(node.Attributes["assemblyFile"].Value))
                        {
                            ModuleInfo info = new ModuleInfo(node.Attributes["assemblyFile"].Value);
                            ModuleLoaderService.Load(WorkItem, info);
                        }

                        EventTopic    itemTopic = WorkItem.RootWorkItem.EventTopics.Get(node.Attributes["parameters"].Value);
                        MenuEventArgs args      = new MenuEventArgs("", HyperlinkHelper.BuildQueryString(e.Hyperlink.Data), true, null);
                        itemTopic.Fire(this, args, WorkItem, PublicationScope.Global);
                    }
                    else
                    {
                        ShellInteractionService.ShowMessageBox(StringResources.Authorization_NotAuhtorized, StringResources.Authorization_Message, null, MessageBoxButton.Ok, MessageBoxImage.Warning);
                    }
                }
            }
        }
Пример #4
0
        private void CreateStudioMenu(ShellMenuItem parent, object tag)
        {
            var item = parent.SubMenu.InsertItem("Build Debug", "BuildDebug", "Build solution in Debub configuration", 0);

            item.Tag = tag;
            item     = parent.SubMenu.InsertItem("Build Release", "BuildRelease", "Build solution in Release configuration", 1);
            item.Tag = tag;
        }
Пример #5
0
        public static ShellMenuItem CreateFavoritesItem(string caption, string dialogId, string eventTopic, string assemblyFile, object target)
        {
            var parameters = GetParameters(target);

            ShellMenuItem item = new ShellMenuItem();

            item.IsEnabled    = true;
            item.IsAuthorized = true;
            item.Operation    = dialogId;
            item.Id           = dialogId;
            item.Caption      = caption;
            item.EventTopic   = eventTopic;
            item.Parameters   = BuildQueryString(parameters);
            item.AssemblyFile = assemblyFile;

            return(item);
        }
Пример #6
0
 public void BuildMenu()
 {
     foreach (var command in _defaultCommand)
     {
         ICommandSourceParent commandVisual;
         if (!_commandInformations.TryGetValue(command, out commandVisual))
         {
             commandVisual = new ShellMenuItem(command);
             _commandInformations.Add(command, commandVisual);
         }
         var parentCommand = command.MenuCommandParent;
         if (parentCommand != null)
         {
             BuildMenuCommandHierarchy(parentCommand, commandVisual, _shellMenu);
         }
     }
 }
        protected override void MergeContextMenu(ShellFolder folder, IReadOnlyList <ShellItem> items, ShellMenu existingMenu, ShellMenu appendMenu)
        {
            // only with selected items
            if (items.OfType <SimplePngItem>().Count() > 0)
            {
                var clearLocal = new ShellMenuItem(appendMenu, "Clear Cache");
                clearLocal.Invoke += (s, e) =>
                {
                    foreach (var item in e.Items.OfType <SimplePngItem>())
                    {
                        item.ClearCache();
                    }
                };

                appendMenu.Items.Add(clearLocal);
            }
        }
        public void AddToFavorites(ShellMenuItem item)
        {
            ShellDrillDownMenuItem drillDownItem = new ShellDrillDownMenuItem();

            drillDownItem.EventTopic   = item.EventTopic;
            drillDownItem.Id           = item.Id;
            drillDownItem.Caption      = item.Caption;
            drillDownItem.Operation    = item.Operation;
            drillDownItem.IsAuthorized = item.IsAuthorized;
            drillDownItem.IsEnabled    = item.IsEnabled;
            drillDownItem.Parameters   = item.Parameters;
            drillDownItem.AssemblyFile = item.AssemblyFile;

            EventHandler <DataEventArgs <ShellDrillDownMenuItem> > temp = FavoriteAdded;

            if (temp != null)
            {
                temp(_module, new DataEventArgs <ShellDrillDownMenuItem>(drillDownItem));
            }
        }
Пример #9
0
        public void SaveSearch(string searchStr)
        {
            char[]   delimiter   = { ';' };
            string[] strArray    = searchStr.Split(delimiter);
            string   caption     = strArray[0];
            string   programName = strArray[1];
            string   parameters  = strArray[2];

            ShellMenuItem item = new ShellMenuItem();

            item.IsEnabled    = true;
            item.IsAuthorized = true;
            item.Operation    = programName;
            item.Id           = programName;
            item.Caption      = caption;
            item.EventTopic   = Imi.SupplyChain.UX.Modules.OrderManagement.Views.Constants.EventTopicNames.StartOMSProgramWithData;
            item.Parameters   = parameters;
            item.AssemblyFile = ASSEMBLY_FILE;

            ShellInteractionService.AddToFavorites(item);
        }
Пример #10
0
 private void BuildMenuCommandHierarchy(ICommandEx parentCommand, ICommandSourceParent commandVisual, ShellMenu shellMenu)
 {
     if (parentCommand != null)
     {
         ICommandSourceParent parentCommandVisual;
         if (_commandInformations.TryGetValue(parentCommand, out parentCommandVisual))
         {
             parentCommandVisual.AddItem(commandVisual);
             return;
         }
         parentCommandVisual = new ShellMenuItem(parentCommand);
         parentCommandVisual.AddItem(commandVisual);
         _commandInformations.Add(parentCommand, parentCommandVisual);
         parentCommand = parentCommand.MenuCommandParent;
         BuildMenuCommandHierarchy(parentCommand, parentCommandVisual, shellMenu);
     }
     else
     {
         shellMenu.AddItem(commandVisual);
     }
 }
Пример #11
0
        protected override void MergeContextMenu(ShellFolder folder, IReadOnlyList <ShellItem> items, ShellMenu existingMenu, ShellMenu appendMenu)
        {
            if (folder.IsRoot && items.Count == 0) // context menu in Explorer's left TreeView
            {
                var properties = new ShellMenuItem(appendMenu, "&Properties");
                properties.Invoke += OnRootProperties;
                appendMenu.Items.Add(properties);
            }
            else
            {
                // only with selected items
                if (items.Count > 0)
                {
                    var folderItem = new ShellMenuItem(appendMenu, "Cloud Folder");
                    folderItem.BitmapPath = FolderServer.MenuIconBitmapPath;

                    var clearLocal = new ShellMenuItem(appendMenu, "Free up space");
                    clearLocal.Verb    = "CloudFolder.free";
                    clearLocal.Invoke += OnClearLocal;
                    folderItem.Items.Add(clearLocal);

                    var downloadLocally = new ShellMenuItem(appendMenu, "Download on this device");
                    downloadLocally.Verb    = "CloudFolder.download";
                    downloadLocally.Invoke += DownloadLocally;
                    folderItem.Items.Add(downloadLocally);

                    var pushToServer = new ShellMenuItem(appendMenu, "Push to server");
                    pushToServer.Verb    = "CloudFolder.push";
                    pushToServer.Invoke += PushToServer;
                    folderItem.Items.Add(pushToServer);

                    appendMenu.Items.Add(folderItem);

                    // add the "Sent To" menu
                    appendMenu.Items.Add(new ShellMenuSendToItem());
                }
            }
        }
        // context menu on the root folder
        protected override void MergeContextMenu(ShellFolder folder, IReadOnlyList <ShellItem> items, ShellMenu existingMenu, ShellMenu appendMenu)
        {
            if (folder == null)
            {
                throw new ArgumentNullException(nameof(folder));
            }

            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            if (appendMenu == null)
            {
                throw new ArgumentNullException(nameof(appendMenu));
            }

            if (items.Count == 0) // 0 means this is called from Explorer's tree view. We don't want to add the menus twice.
            {
                return;
            }

            // since we added ShellFolderInitializationOptions.AddSelfToContextMenu, we must use some verb (unique to us) to make sure our menu items are not duplicated

            var regeditItem = new ShellMenuItem(appendMenu, "Run &Regedit...");

            regeditItem.Verb    = "shellboost.sample.regedit";
            regeditItem.Invoke += (sender, e) => Process.Start("regedit");
            appendMenu.Items.Add(regeditItem);

            appendMenu.Items.Add(new ShellMenuSeparatorItem());

            var propertiesItem = new ShellMenuItem(appendMenu, "&Properties...");

            propertiesItem.Verb    = "shellboost.sample.properties";
            propertiesItem.Invoke += (sender, e) => ShowProperties(e.HwndOwner);
            appendMenu.Items.Add(propertiesItem);
        }
Пример #13
0
        protected override void MergeContextMenu(ShellFolder folder, IReadOnlyList <ShellItem> items, ShellMenu existingMenu, ShellMenu appendMenu)
        {
            if (folder == null)
            {
                throw new ArgumentNullException(nameof(folder));
            }

            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            if (appendMenu == null)
            {
                throw new ArgumentNullException(nameof(appendMenu));
            }

            appendMenu.AddInvokeItemHandler(OnShellMenuItemInvoke);
            if (items.Count == 1 && !items[0].IsFolder)
            {
                // only for one non-folder item
                var modifyItem = new ShellMenuItem(appendMenu, "Modify...");
                modifyItem.Tag       = MenuCommand.Modify;
                modifyItem.IsDefault = true;
                appendMenu.Items.Add(modifyItem);
            }
            else
            {
                if (existingMenu.Items.FirstOrDefault(i => i.Text == "New") == null)
                {
                    var newItem = new ShellMenuItem(appendMenu, "New");
                    appendMenu.Items.Add(newItem);

                    newItem.Items.Add(new ShellMenuItem(appendMenu, "Key")
                    {
                        Tag = MenuCommand.NewKey
                    });
                    newItem.Items.Add(new ShellMenuSeparatorItem());
                    newItem.Items.Add(new ShellMenuItem(appendMenu, "String Value")
                    {
                        Tag = MenuCommand.NewValueString
                    });
                    newItem.Items.Add(new ShellMenuItem(appendMenu, "Binary Value")
                    {
                        Tag = MenuCommand.NewValueBinary
                    });
                    newItem.Items.Add(new ShellMenuItem(appendMenu, "DWORD (32-bit) Value")
                    {
                        Tag = MenuCommand.NewValueDWord
                    });
                    newItem.Items.Add(new ShellMenuItem(appendMenu, "QWORD (64-bit) Value")
                    {
                        Tag = MenuCommand.NewValueQWord
                    });
                    newItem.Items.Add(new ShellMenuItem(appendMenu, "Multi-String Value")
                    {
                        Tag = MenuCommand.NewValueMultiString
                    });
                    newItem.Items.Add(new ShellMenuItem(appendMenu, "Expandable String Value")
                    {
                        Tag = MenuCommand.NewValueExpandString
                    });
                }
            }

            if (items.Count > 0)
            {
                // add the "Send To" menu
                appendMenu.Items.Add(new ShellMenuSendToItem());
            }
        }
Пример #14
0
 public ShellMenuSelectedMessage(object sender, ShellMenuItem selectedMenuItem) : base(sender)
 {
     this.SelectedMenuItem = selectedMenuItem;
 }
Пример #15
0
        public void AddMenuItems(ref ShellMenuItem parentMenuItem, string targetFolder, string[] targetFiles)
        {
            if (this.ExtentionFilter != null && this.ExtentionFilter.Length > 0)
            {
                foreach (string TargetFile in targetFiles)
                {
                    Boolean FoundMatch = false;
                    foreach (string Filter in this.ExtentionFilter)
                    {
                        if (!Regex.IsMatch(TargetFile, Filter))
                            FoundMatch = false;
                        else
                        {
                            FoundMatch = true;
                            break;
                        }
                    }
                    if (!FoundMatch)
                        return;
                }
            }

            ShellMenuItem MenuItem;

            if (!String.IsNullOrEmpty(this.Verb) && !String.IsNullOrEmpty(this.Help))
                MenuItem = parentMenuItem.SubMenu.AddItem(this.Name, this.Verb, this.Help);
            else
                MenuItem = parentMenuItem.SubMenu.AddItem(this.Name);

            if (!String.IsNullOrEmpty(this.IconFilePath) && File.Exists(this.IconFilePath))
            {
                MenuItem.OwnerDraw = true;
            }

            if (this.Actions != null && this.Actions.Count > 0)
            {
                MenuItem.HasSubMenu = true;
                this.Actions.AddMenuItems(ref MenuItem, targetFolder, targetFiles);
            }
        }
Пример #16
0
        public void StartMenuItemExecutedEventHandler(object sender, StartMenuItemExecutedEventArgs e)
        {
            ShellMenuItem shellMenuItem = new ShellMenuItem();

            shellMenuItem.Id           = e.MenuItem.Id;
            shellMenuItem.EventTopic   = e.MenuItem.EventTopic;
            shellMenuItem.Caption      = e.MenuItem.Caption;
            shellMenuItem.IsAuthorized = e.MenuItem.IsAuthorized;
            shellMenuItem.IsEnabled    = e.MenuItem.IsEnabled;
            shellMenuItem.Parameters   = e.MenuItem.Parameters;
            shellMenuItem.Operation    = e.MenuItem.Operation;
            shellMenuItem.AssemblyFile = e.MenuItem.AssemblyFile;

            if (!shellMenuItem.IsAuthorized)
            {
                IMessageBoxView messageBoxView = WorkItem.SmartParts.AddNew <MessageBoxView>();
                messageBoxView.Show(StringResources.Authorization_NotAuhtorized
                                    , StringResources.Authorization_Message
                                    , null
                                    , Infrastructure.MessageBoxButton.Ok
                                    , Infrastructure.MessageBoxImage.Warning);

                return;
            }

            try
            {
                _shellView.ShowProgress();

                try
                {
                    if (!string.IsNullOrEmpty(shellMenuItem.AssemblyFile))
                    {
                        ModuleInfo info = new ModuleInfo(shellMenuItem.AssemblyFile);
                        ModuleLoaderService.Load(ShellModuleService.GetWorkItem(e.Module), info);
                    }

                    MenuItemExecutedEventArgs mappedEventArgs = new MenuItemExecutedEventArgs();
                    mappedEventArgs.MenuItem        = shellMenuItem;
                    mappedEventArgs.OpenInNewWindow = (e.StartOption == StartOption.NewWindow || e.StartOption == StartOption.Dashboard);

                    ShellInteractionService interactionService = ShellModuleService.GetWorkItem(e.Module).Services.Get <IShellInteractionService>() as ShellInteractionService;
                    interactionService.OnMenuItemExecuted(mappedEventArgs);

                    if (!string.IsNullOrEmpty(shellMenuItem.EventTopic))
                    {
                        EventTopic itemTopic = WorkItem.RootWorkItem.EventTopics.Get(shellMenuItem.EventTopic);

                        if (itemTopic != null)
                        {
                            itemTopic.Fire(this, mappedEventArgs, WorkItem.RootWorkItem, PublicationScope.Global);
                        }
                    }
                }
                finally
                {
                    _shellView.HideProgress();
                }
            }
            catch (Exception ex)
            {
                IMessageBoxView messageBoxView = WorkItem.SmartParts.AddNew <MessageBoxView>();
                messageBoxView.Show(StringResources.ActionException_Text, ex.Message, ex.ToString(), Infrastructure.MessageBoxButton.Ok, Infrastructure.MessageBoxImage.Error);
            }
        }
        protected override void CreateInformationBarMenu(InformationBar bar, ShellMenu appendMenu)
        {
            var item = new ShellMenuItem(appendMenu, "What is my UAC level?");

            appendMenu.Items.Add(item);
        }
Пример #18
0
 public WrapperShellMenuItem(ShellMenuItem menuItem)
 {
     this.WrappedSubject = menuItem;
 }