Beispiel #1
0
		public LineCountInfo(string fileName, int iconIndex, LineCountSummary projectSummary) : this(fileName, iconIndex)
		{
			m_projectSummary = projectSummary;
		}
		/// <summary>
		/// Scans the project items (files, usually) of
		/// a project's ProjectItems collection.
		/// </summary>
		/// <param name="projectItems">The ProjectItems collection to scan.</param>
		/// <param name="summary">The root summary data object that these
		/// files belong to.</param>
		private static void ScanProjectItems(ProgressBar tsprgTask, System.Collections.Generic.IList<IOTAModuleInfo> projectItems, LineCountSummary summary)
		{
			tsprgTask.Maximum += projectItems.Count;
			foreach (IOTAModuleInfo projectItem in projectItems)
			{
				tsprgTask.PerformStep();
				//if (!(projectItem is FileProjectItem)) {
				// Skip references and other special MSBuild things
				//continue;
				//}
				string projectFile = projectItem.FileName;
				if ((!String.IsNullOrEmpty(projectFile)) && (!Directory.Exists(projectFile)))
				{
					int iconIndex = 0;
					//#if IMPR1
					//iconIndex = fileImageListHelper.GetIndex(IconService.GetImageForFile(projectFile));
					//#else
					string ext = Path.GetExtension(projectFile);
					if (m_fileIconMappings.ContainsKey(ext)) {
						iconIndex = (int)m_fileIconMappings[ext];
					} else {
						iconIndex = 0;
					}
					//m_fileIconMappings.TryGetValue(Path.GetExtension(projectFile), out iconIndex);
					//#endif
					summary.FileLineCountInfo.Add(new LineCountInfo(projectFile, iconIndex, summary));
				}
			}
		}
		/// <summary>
		/// Adds a summary item to the projects list view.
		/// </summary>
		/// <param name="summary">The summary data object to reference.</param>
		/// <param name="group">The summary list view group this item
		/// should be listed under.</param>
		private static void AddSummaryListItem(Vista_Api.ListView lvSummary, LineCountSummary summary/*, Vista_Api.ListViewGroup group*/)
		{
			ListViewItem lvi = new ListViewItem();
			lvi.Text = summary.ProjectName;
			lvi.SubItems.Add("0");
			lvi.SubItems.Add("0");
			lvi.SubItems.Add("0");
			lvi.SubItems.Add("0");
			lvi.SubItems.Add("0");

			lvi.Tag = summary;
			lvi.ImageIndex = summary.IconIndex;
			//lvi.StateImageIndex = summary.IconIndex;
			//lvi.Group = group;

			summary.LinkedListViewItem = lvi;

			lvSummary.Items.Add(lvi);
		}
		/// <summary>
		/// Scans the solution and creates a hierarchy of
		/// support objects for each project and file
		/// within each project.
		/// </summary>
		internal static void ScanSolution(ProgressBar tsprgTotal, ProgressBar tsprgTask)
		{
			if (m_summaryList == null)
				m_summaryList = new List<LineCountSummary>();

			m_summaryList.Clear();

			IOTAProjectGroup solution = OtaUtils.GetCurrentProjectGroup();
			//Solution solution = ProjectService.OpenSolution;
			if (solution == null) // OpenSolution is null when no solution is opened
			{
				MessageBoxFactory.Warn(null, "No project group", "There is no project group open.");
				return;
			}
			//FileInfo fiSolution = new FileInfo(solution.FileName);
			LineCountSummary summary = new LineCountSummary("All Projects", (int)m_projIconMappings["{00000000-0000-0000-0000-000000000000}"]);
			m_summaryList.Add(summary);

			// Configure progress bars
			tsprgTotal.Minimum = 0;
			tsprgTotal.Step = 1;
			tsprgTask.Minimum = 0;
			tsprgTask.Step = 1;

			IList<IOTAProject> projects = OtaUtils.GetAllProjectsOf(solution);
			tsprgTotal.Maximum = projects.Count;
			tsprgTask.Value = 0;
			foreach (IOTAProject fiProject in projects) {
				tsprgTotal.PerformStep();
				string projName, lang;
				if (fiProject.FileName.IndexOf("://", StringComparison.Ordinal) != -1)
				{
					projName = fiProject.FileName; // this is a web project
					lang = "{00000001-0000-0000-0000-000000000000}";
				} else {
					projName = fiProject.FileName;
					lang = fiProject.ProjectGUID.ToString();
				}

				int iconIndex;
				//#if IMPR1
				//iconIndex = projectImageListHelper.GetIndex(IconService.GetImageForProjectType(fiProject.Language ?? "defaultLanguageName"));
				//#else
				if (m_projIconMappings.ContainsKey(lang))
				{
					iconIndex = (int)m_projIconMappings[lang];
				} else {
					iconIndex = 0;
				}
				//m_projIconMappings.TryGetValue(lang, out iconIndex); // default icon 0
				//#endif
				summary = new LineCountSummary(projName, iconIndex);
				m_summaryList.Add(summary);

				tsprgTask.Maximum = 0;
				tsprgTotal.Value = 0;
				ScanProjectItems(tsprgTask, OtaUtils.GetAllModuleInfoOf(fiProject), summary);
			}

			tsprgTask.Value = tsprgTask.Maximum;
			tsprgTotal.Value = tsprgTotal.Maximum;
		}