Beispiel #1
0
		/// <summary>
		/// Shows the warning form
		/// </summary>
		/// <param name="title">The Form's title</param>
		/// <param name="message">The warning</param>
		/// <param name="parent">The Form's parent</param>
		public static void ShowWarning( string title, string message, Control parent )
		{
			if ( parent != null && parent.IsDisposed == false )
			{
				using ( WarningForm warningForm = new WarningForm( title, message ) )
				{
					warningForm.StartPosition = FormStartPosition.CenterParent;
					warningForm.ShowDialog( parent );
				}
			}
		}
Beispiel #2
0
		private void menuFileOpenSolution_Click (object sender, System.EventArgs e)
		{
			if (project.IsDirty)
			{
				DialogResult result = PromptToSave();
				switch (result)
				{
					case DialogResult.Yes:
						SaveOrSaveAs();
						break;
					case DialogResult.No:
						break;
					case DialogResult.Cancel:
						return;
				}
			}
			OpenFileDialog openFileDlg = new OpenFileDialog();
			openFileDlg.InitialDirectory = Directory.GetCurrentDirectory();
			openFileDlg.Filter = "Visual Studio Solution files (*.sln)|*.sln|All files (*.*)|*.*" ;

			if(openFileDlg.ShowDialog() == DialogResult.OK)
			{
				VS.Solution sol = new VS.Solution(openFileDlg.FileName);

				try
				{
					this.Cursor = Cursors.WaitCursor;

					string warningMessages=String.Empty;

					if (sol.ProjectCount==0)
					{
						warningMessages = "There are no projects in this solution that NDoc can import.\n\n";
						warningMessages += "Either the solution is blank, or the projects contained within\n";
						warningMessages += "the solution are not of a type NDoc can import.\n"; 
						WarningForm warningForm = new WarningForm("VS Solution Import Warnings", warningMessages);
						warningForm.ShowDialog(this);
						return;
					}

					SolutionForm sf = new SolutionForm();
					sf.Text = "Solution " + sol.Name;

					sf.ConfigList.Items.Clear();
					foreach (string configkey in sol.GetConfigurations())
					{
						sf.ConfigList.Items.Add(configkey);
					}

					sf.ShowDialog(this);
					if (sf.ConfigList.SelectedIndex < 0)
						return;

					string solconfig = (string)sf.ConfigList.SelectedItem;

					//clear current ndoc project settings
					Clear();

					foreach (VS.Project p in sol.GetProjects())
					{
						string projid = p.ID.ToString();
						string projconfig = sol.GetProjectConfigName(solconfig, projid);

						if (projconfig == null)
						{
							warningMessages += String.Format("VS Project {0} could not be imported.\n- There are no settings in the project file for configuration '{1}'\n\n",p.Name,solconfig);
							continue;
						}

						string apath = p.GetRelativeOutputPathForConfiguration(projconfig);
						string xpath = p.GetRelativePathToDocumentationFile(projconfig);
						string spath = sol.Directory;

						AssemblySlashDoc asd = new AssemblySlashDoc();
						asd.Assembly.Path=Path.Combine(spath, apath);

						if (!File.Exists(asd.Assembly.Path))
						{
							warningMessages += String.Format("VS Project '{0}' has been imported, but the specified assembly does not exist.\n- You will not be able to build documentation for this project until its assembly has been successfully compiled...\n\n",p.Name);
						}

						if (xpath!=null && xpath.Length>0)
						{
							asd.SlashDoc.Path=Path.Combine(spath, xpath);
							if (!File.Exists(asd.SlashDoc.Path))
							{
							warningMessages += String.Format("VS Project '{0}' has been imported, but the XML documentation file specified in the project cannot be found.\n- This can occur if the project is set to do 'incremental' compiles.\n- NDoc output will be very limited until the VS project is rebuilt with XML documntation...\n",p.Name);
						
							}
						}
						else
						{
							warningMessages += String.Format("VS Project '{0}' has been imported, but the project is not set to produce XML documentation.\n- NDoc output for this assembly will be very limited...\n\n",p.Name);
						}

						project.AssemblySlashDocs.Add(asd);
						AddRowToListView(asd);
					}

					EnableMenuItems(true);
					EnableAssemblyItems();

					projectFilename =  Path.Combine(sol.Directory, sol.Name + ".ndoc");

					if (warningMessages.Length>0)
					{
						WarningForm warningForm = new WarningForm("VS Solution Import Warnings", warningMessages);
						warningForm.ShowDialog(this);
					}
				}
				finally
				{
					this.Cursor = Cursors.Arrow;
				}
			}
		}
Beispiel #3
0
		private void FileOpen(string fileName)
		{
			bool  bFailed = true;

			try
			{
				string directoryName = Path.GetDirectoryName(fileName);
				Directory.SetCurrentDirectory(directoryName);

				try
				{
					project.Read(fileName);
				}
				catch (DocumenterPropertyFormatException e)
				{
					WarningForm warningForm = new WarningForm("Invalid Properties in Project File.",
						e.Message  + "Documenter defaults will be used....");
					warningForm.ShowDialog(this);
				}

				projectFilename = fileName;
				SetWindowTitle();

				RefreshPropertyGrid();

				// Update the ListView
				assembliesListView.Items.Clear();
				foreach (AssemblySlashDoc assemblySlashDoc2 in project.AssemblySlashDocs)
				{
					AddRowToListView(assemblySlashDoc2);
				}

				UpdateMRUList();

				EnableMenuItems(true);

				bFailed = false;
			}
			catch (DocumenterException docEx)
			{
				ErrorForm errorForm = new ErrorForm("Unable to read in project file", docEx);
				errorForm.ShowDialog(this);
			}
			catch (Exception ex)
			{
				string msg = "An error occured while trying to read in project file:\n" + fileName + ".";
				ErrorForm errorForm = new ErrorForm(msg, ex);
				errorForm.ShowDialog(this);
			}

			if (bFailed)
			{
				recentProjectFilenames.Remove(fileName);
				MakeMRUMenu();
				Clear();
			}
		}