コード例 #1
0
 void listBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.listBox.SelectedItem.ToString() == "Etc...")
     {
         TypeSelectorForm assembliesForm = new TypeSelectorForm();
         if (assembliesForm.ShowDialog() == DialogResult.OK)
         {
             this.selectedType = assembliesForm.SelectedType;
         }
     }
     else
     {
         this.selectedType = this.listBox.SelectedItem as Type;
     }
     this.editorService.CloseDropDown();
 }
コード例 #2
0
        object CreateInstanceBySelectingType()
        {
            IDesignerHost designerHost = GetService(typeof(IDesignerHost)) as IDesignerHost;
            IReferenceService refService = GetService(typeof(IReferenceService)) as IReferenceService;
            ITypeResolutionService resService = GetService(typeof(ITypeResolutionService)) as ITypeResolutionService;
            DTE dte = GetService(typeof(DTE)) as DTE;

            if (dte.ActiveWindow.Project.Object is VSProject)
            {
                VSProject vsproj = dte.ActiveWindow.Project.Object as VSProject;

                List<Assembly> assemblies = new List<Assembly>();

                try
                {
                    Assembly projectAseembly = Assembly.Load(dte.ActiveWindow.Project.Name);
                    if (projectAseembly != null)
                        assemblies.Add(projectAseembly);
                }
                catch (Exception)
                {
                }

                for (int i = 1; i <= vsproj.References.Count; i++)
                {
                    Reference reference = vsproj.References.Item(i);
                    Assembly assembly = resService.GetAssembly(new AssemblyName(reference.Name));
                    assemblies.Add(assembly);
                }

                TypeSelectorForm form = new TypeSelectorForm(assemblies.ToArray());

                if (form.ShowDialog() == DialogResult.OK)
                {
                    return ColumnCollection.CreateColumnInstance(this.Context, form.SelectedType);
                }
            }

            return null;
        }