public override void Run()
		{
			AbstractProjectBrowserTreeNode node = Owner as AbstractProjectBrowserTreeNode;
			IProject project = (node != null) ? node.Project : ProjectService.CurrentProject;
			if (project == null) {
				return;
			}
			LoggingService.Info("Show add reference dialog for " + project.FileName);
			using (SelectReferenceDialog selDialog = new SelectReferenceDialog(project)) {
				if (selDialog.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainWin32Window) == DialogResult.OK) {
					foreach (ReferenceProjectItem reference in selDialog.ReferenceInformations) {
						ProjectService.AddProjectItem(project, reference);
					}
					project.Save();
				}
			}
		}
Exemplo n.º 2
0
 public override void Execute(object parameter)
 {
     IAssemblyReferencesModel assemblyReferencesModel = parameter as IAssemblyReferencesModel;
     if (assemblyReferencesModel != null) {
         IAssemblyModel assemblyModel = assemblyReferencesModel.ParentAssemblyModel;
         if ((assemblyModel != null) && (assemblyModel.Context != null)) {
             IProject project = (parameter != null) ? assemblyModel.Context.Project : ProjectService.CurrentProject;
             if (project == null) {
                 return;
             }
             using (SelectReferenceDialog selDialog = new SelectReferenceDialog(project)) {
                 if (selDialog.ShowDialog(SD.WinForms.MainWin32Window) == System.Windows.Forms.DialogResult.OK) {
                     foreach (ReferenceProjectItem reference in selDialog.ReferenceInformations) {
                         ProjectService.AddProjectItem(project, reference);
                     }
                     project.Save();
                 }
             }
         }
     }
 }
 public override void Run()
 {
     AbstractProjectBrowserTreeNode node = Owner as AbstractProjectBrowserTreeNode;
     IProject project = (node != null) ? node.Project : ProjectService.CurrentProject;
     if (project == null) {
         return;
     }
     LoggingService.Info("Show add reference dialog for " + project.FileName);
     using (SelectReferenceDialog selDialog = new SelectReferenceDialog(project)) {
         if (selDialog.ShowDialog(SD.WinForms.MainWin32Window) == DialogResult.OK) {
             var duplicateReferences = new List<string>();
             foreach (ReferenceProjectItem reference in selDialog.ReferenceInformations) {
                 var thisReference = reference;
                 if (project.Items.OfType<ReferenceProjectItem>().All(r => r.ShortName != thisReference.ShortName)) {
                     ProjectService.AddProjectItem(project, reference);
                 }
             }
             project.Save();
         }
     }
 }
Exemplo n.º 4
0
		void AddReferences()
		{
			IProject project = ProjectService.CurrentProject;
			using (var referenceDialog = new SelectReferenceDialog(project)) {
				
				// Add existing project references to dialog.
				List<ReferenceProjectItem> references = GetReferences(project);
				AddReferences(referenceDialog as ISelectReferenceDialog, references);
				
				System.Windows.Forms.DialogResult result = referenceDialog.ShowDialog();
				if (result == System.Windows.Forms.DialogResult.OK) {
				
					ArrayList selectedReferences = referenceDialog.ReferenceInformations;
					
					// Remove any references removed in the select reference dialog.
					foreach (ReferenceProjectItem existingReference in references) {
						if (!selectedReferences.Contains(existingReference)) {
							ProjectService.RemoveProjectItem(project, existingReference);
						}
					}
					
					// Add new references.
					foreach (ReferenceProjectItem reference in referenceDialog.ReferenceInformations) {
						if (!references.Contains(reference)) {
							ProjectService.AddProjectItem(project, reference);
						}
					}
					project.Save();
				}
			}
		}
        void ReferencesToolStripMenuItemClick(object sender, EventArgs e)
        {
            IProject project = ProjectService.CurrentProject;
            using (SelectReferenceDialog referenceDialog = new SelectReferenceDialog(project)) {

                // Add existing project references to dialog.
                List<ReferenceProjectItem> references = GetReferences(project);
                AddReferences(referenceDialog as ISelectReferenceDialog, references);

                DialogResult result = referenceDialog.ShowDialog();
                if (result == DialogResult.OK) {

                    ArrayList selectedReferences = referenceDialog.ReferenceInformations;

                    // Remove any references removed in the select reference dialog.
                    foreach (ReferenceProjectItem existingReference in references) {
                        if (!selectedReferences.Contains(existingReference)) {
                            ProjectService.RemoveProjectItem(project, existingReference);
                        }
                    }

                    // Add new references.
                    foreach (ReferenceProjectItem reference in referenceDialog.ReferenceInformations) {
                        ProjectService.AddProjectItem(project, reference);
                    }
                    project.Save();
                }
            }
        }