public AssemblyItem(AssemblySelectionDialog.AssemblyItem item)
     : this(item.AssemblyName)
 {
 }
Exemple #2
0
 public override bool Customize(int command, IServiceProvider serviceProvider)
 {
     switch (command)
     {
         case 0:
         {
             IComponentGalleryService service = (IComponentGalleryService) serviceProvider.GetService(typeof(IComponentGalleryService));
             try
             {
                 Library library = service.BrowseGallery(this.ComponentType.FullName);
                 if (library != null)
                 {
                     this.AddComponents(library, serviceProvider);
                 }
             }
             catch (UnauthorizedAccessException exception)
             {
                 this.ShowMessage("Error", exception.Message + Environment.NewLine + "The assembly may be in use.  Please save your work, restart the application, and try again.", serviceProvider);
             }
             catch (Exception exception2)
             {
                 this.ShowMessage("Error", exception2.Message, serviceProvider);
             }
             return true;
         }
         case 1:
         {
             AssemblySelectionDialog dialog = new AssemblySelectionDialog(serviceProvider);
             if (dialog.ShowDialog() == DialogResult.OK)
             {
                 try
                 {
                     this.AddComponents(dialog.SelectedAssemblies, serviceProvider);
                     Library[] selectedLibraries = dialog.SelectedLibraries;
                     for (int i = 0; i < selectedLibraries.Length; i++)
                     {
                         this.AddComponents(selectedLibraries[i], serviceProvider);
                     }
                 }
                 catch (UnauthorizedAccessException exception3)
                 {
                     this.ShowMessage("Error", exception3.Message + Environment.NewLine + "The assembly may be in use. Please save your work, restart the application, and try again.", serviceProvider);
                 }
                 catch (Exception exception4)
                 {
                     this.ShowMessage("Error", exception4.Message, serviceProvider);
                 }
             }
             return true;
         }
         case 2:
         {
             ArrayList list = new ArrayList(base.ToolboxDataItems);
             this.ClearToolboxDataItems();
             Hashtable hashtable = new Hashtable(base.ToolboxDataItems.Count);
             foreach (ToolboxDataItem item in list)
             {
                 Type type = Type.GetType(item.ToolboxData, false, true);
                 if (type != null)
                 {
                     Assembly key = type.Assembly;
                     if (!hashtable.Contains(key))
                     {
                         foreach (Type type2 in key.GetTypes())
                         {
                             if (this.IsValidToolboxComponent(type2))
                             {
                                 ToolboxDataItem item2 = this.CreateToolboxDataItem(type2.AssemblyQualifiedName);
                                 base.AddToolboxDataItem(item2);
                             }
                         }
                         hashtable[key] = string.Empty;
                     }
                 }
             }
             return true;
         }
     }
     return false;
 }
Exemple #3
0
 private void OnAddLocalButtonClicked(object sender, EventArgs e)
 {
     AssemblySelectionDialog dialog = new AssemblySelectionDialog(base.ServiceProvider);
     if (dialog.ShowDialog() == DialogResult.OK)
     {
         IApplicationIdentity identity = base.ServiceProvider.GetService(typeof(IApplicationIdentity)) as IApplicationIdentity;
         bool flag = false;
         AssemblyName[] selectedAssemblies = dialog.SelectedAssemblies;
         try
         {
             for (int i = 0; i < selectedAssemblies.Length; i++)
             {
                 Assembly assembly = Assembly.Load(selectedAssemblies[i]);
                 if (!assembly.GlobalAssemblyCache)
                 {
                     Uri uri = new Uri(assembly.CodeBase);
                     string localPath = uri.LocalPath;
                     if (!Directory.Exists(identity.PluginsPath))
                     {
                         Directory.CreateDirectory(identity.PluginsPath);
                     }
                     string path = Path.Combine(identity.PluginsPath, Path.GetFileName(localPath));
                     if (localPath.ToLower() != path.ToLower())
                     {
                         if (File.Exists(path))
                         {
                             IMxUIService service = (IMxUIService) base.ServiceProvider.GetService(typeof(IMxUIService));
                             if ((service != null) && (service.ShowMessage("The assembly " + Path.GetFileName(path) + "' has previously been added. Do you wish to replace it?", "Add-in Organizer", MessageBoxIcon.Question, MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button1) == DialogResult.No))
                             {
                                 continue;
                             }
                         }
                         File.Copy(localPath, path, true);
                     }
                 }
                 flag |= this.ProcessAssembly(assembly);
             }
         }
         catch (Exception exception)
         {
             this.ReportError("A problem was encountered.\n\nDetails:\n" + exception.Message, false);
         }
         if (flag)
         {
             this._addInList.SelectedIndex = this._addInList.Items.Count - 1;
         }
         else
         {
             this.ReportError("No new add-ins were found.", true);
         }
     }
 }
        bool ICommandHandler.HandleCommand(Microsoft.Matrix.UIComponents.Command command)
        {
            bool flag = false;
            bool flag2 = false;
            bool flag3 = false;
            if (command.CommandGroup == typeof(ClassViewCommands))
            {
                switch (command.CommandID)
                {
                    case 1:
                    {
                        ClassViewProjectData projectData = this._project.ProjectData;
                        ICollection assemblyEntries = projectData.AssemblyEntries;
                        ArrayList list = new ArrayList(assemblyEntries.Count);
                        foreach (ClassViewProjectData.AssemblyEntry entry in assemblyEntries)
                        {
                            try
                            {
                                list.Add(entry.AssemblyName);
                                continue;
                            }
                            catch
                            {
                                continue;
                            }
                        }
                        AssemblyName[] initialList = (AssemblyName[]) list.ToArray(typeof(AssemblyName));
                        IUIService service = (IUIService) base.ServiceProvider.GetService(typeof(IUIService));
                        AssemblySelectionDialog form = new AssemblySelectionDialog(base.ServiceProvider, initialList);
                        if (service.ShowDialog(form) == DialogResult.OK)
                        {
                            projectData.ClearAssemblyEntries();
                            foreach (AssemblyName name in form.SelectedAssemblies)
                            {
                                projectData.AddAssemblyEntry(name);
                            }
                            flag3 = true;
                        }
                        flag = true;
                        break;
                    }
                    case 2:
                        if (this.Mode != ClassViewToolWindowMode.Browse)
                        {
                            ClassViewListViewItem item2 = (ClassViewListViewItem) this._listView.SelectedItems[0];
                            TypeProjectItem projectItem = item2.ProjectItem;
                            this.OpenTypeView(projectItem.Type);
                        }
                        else
                        {
                            ClassViewTreeNode selectedNode = this._treeView.SelectedNode as ClassViewTreeNode;
                            if (selectedNode != null)
                            {
                                TypeProjectItem item = selectedNode.ProjectItem as TypeProjectItem;
                                if (item != null)
                                {
                                    this.OpenTypeView(item.Type);
                                }
                            }
                        }
                        flag = true;
                        break;

                    case 5:
                    {
                        if (this._searchTask != null)
                        {
                            TypeSearchTask task = this._searchTask;
                            this._searchTask = null;
                            task.Cancel();
                        }
                        string searchValue = command.Text.Trim();
                        if (searchValue.Length != 0)
                        {
                            this._listView.Items.Clear();
                            if ((this.SearchMode == ClassViewToolWindowSearchMode.MemberName) && !searchValue.StartsWith("::"))
                            {
                                searchValue = "::" + searchValue;
                            }
                            TypeSearchTask searchTask = TypeSearchTask.CreateSearchTask(this._project.ProjectData, searchValue);
                            if (searchTask != null)
                            {
                                this.PerformSearch(searchTask);
                            }
                            else
                            {
                                IMxUIService service2 = (IMxUIService) this.GetService(typeof(IMxUIService));
                                if (service2 != null)
                                {
                                    string error = "The specified search string did not have a valid syntax.\r\n\r\nUse the following syntax to define your search criteria:\r\n<TypeName> - Search for types by their name.\r\n<Namespace>.<TypeName> - Search for types by their full name.\r\n::<MemberName> - Search for types containing a matching field, property, event or method.";
                                    service2.ReportError(error, "Type Search", true);
                                }
                            }
                        }
                        flag = true;
                        break;
                    }
                    case 6:
                        this.SearchMode = ClassViewToolWindowSearchMode.TypeName;
                        flag = true;
                        flag2 = true;
                        break;

                    case 7:
                        this.SearchMode = ClassViewToolWindowSearchMode.MemberName;
                        flag = true;
                        flag2 = true;
                        break;

                    case 10:
                        this._project.ProjectData.SortMode = ClassViewProjectSortMode.Alphabetical;
                        flag3 = true;
                        flag = true;
                        break;

                    case 11:
                        this._project.ProjectData.SortMode = ClassViewProjectSortMode.ByClassType;
                        flag3 = true;
                        flag = true;
                        break;

                    case 12:
                        this._project.ProjectData.SortMode = ClassViewProjectSortMode.ByClassVisibility;
                        flag3 = true;
                        flag = true;
                        break;

                    case 13:
                        this._project.ProjectData.ViewMode = ClassViewProjectViewMode.Assembly;
                        if (this.Mode != ClassViewToolWindowMode.Browse)
                        {
                            this.Mode = ClassViewToolWindowMode.Browse;
                            flag2 = true;
                        }
                        flag3 = true;
                        flag = true;
                        break;

                    case 14:
                        this._project.ProjectData.ViewMode = ClassViewProjectViewMode.Namespace;
                        if (this.Mode != ClassViewToolWindowMode.Browse)
                        {
                            this.Mode = ClassViewToolWindowMode.Browse;
                            flag2 = true;
                        }
                        flag3 = true;
                        flag = true;
                        break;

                    case 15:
                        if (this.Mode != ClassViewToolWindowMode.Search)
                        {
                            this.Mode = ClassViewToolWindowMode.Search;
                            flag2 = true;
                        }
                        flag = true;
                        break;

                    case 0x10:
                        this._project.ProjectData.ShowNonPublicMembers = !this._project.ProjectData.ShowNonPublicMembers;
                        flag3 = true;
                        flag = true;
                        break;
                }
            }
            if (flag3)
            {
                this.LoadTree(true);
                return flag;
            }
            if (flag2)
            {
                this.UpdateCommands();
            }
            return flag;
        }