Ejemplo n.º 1
0
        static public void AppendMenuItems(ContextMenuStrip strip, IExplorerObject ExplorerObject)
        {
            if (ExplorerObject == null)
            {
                return;
            }

            Guid          ExplorerObjectGUID = PlugInManager.PlugInID(ExplorerObject);
            PlugInManager compManager        = new PlugInManager();

            var commands = compManager.GetPlugins(Plugins.Type.IExplorerCommand);

            if (commands == null)
            {
                return;
            }

            foreach (var commandType in commands)
            {
                try
                {
                    IExplorerCommand command = compManager.CreateInstance <IExplorerCommand>(commandType);
                    if (command == null ||
                        (command.ExplorerObjectGUID != ExplorerObjectGUID && command.ExplorerObjectGUID != KnownExplorerObjectIDs.Any))
                    {
                        continue;
                    }

                    foreach (XmlNode node in command.CommandDefs)
                    {
                        if (node.Attributes["name"] == null)
                        {
                            continue;
                        }

                        ToolStripItem item = new CommandToolStripItem(ExplorerObject, node);
                        item.Click += new EventHandler(CommandItem_Click);

                        if (strip.Items.Count == 0)
                        {
                            strip.Items.Add(new ToolStripSeparator());
                        }

                        strip.Items.Add(item);
                    }
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 2
0
 public MainWindowViewModel(IDataProvider dataProvider, IExplorerCommand explorerCommand)
 {
     _dataProvider         = dataProvider ?? throw new ArgumentNullException();
     _explorerCommand      = explorerCommand ?? throw new ArgumentNullException();
     ExploreFile.Executed += ExploreFileCommandExecuted;
 }