/// <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 void ScanProjectItems(IList <ProjectItem> projectItems, LineCountSummary summary)
 {
     tsprgTask.Maximum += projectItems.Count;
     foreach (ProjectItem projectItem in projectItems)
     {
         tsprgTask.PerformStep();
         if (!(projectItem is FileProjectItem))
         {
             // Skip references and other special MSBuild things
             continue;
         }
         string projectFile = projectItem.FileName;
         if (!Directory.Exists(projectFile))
         {
             int iconIndex = 0;
                                 #if IMPR1
             iconIndex = fileImageListHelper.GetIndex(IconService.GetImageForFile(projectFile));
                                 #else
             m_fileIconMappings.TryGetValue(Path.GetExtension(projectFile), out iconIndex);
                                 #endif
             summary.FileLineCountInfo.Add(new LineCountInfo(projectFile, iconIndex, summary));
         }
     }
 }
        /// <summary>
        /// Scans the solution and creates a hierarchy of
        /// support objects for each project and file
        /// within each project.
        /// </summary>
        private void ScanSolution()
        {
            if (m_summaryList == null)
            {
                m_summaryList = new List <LineCountSummary>();
            }

            m_summaryList.Clear();

            Solution solution = ProjectService.OpenSolution;

            if (solution != null)             // OpenSolution is null when no solution is opened
            {
                FileInfo         fiSolution = new FileInfo(solution.FileName);
                LineCountSummary summary    = new LineCountSummary("All Projects", 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;

                List <IProject> projects = new List <IProject>(solution.Projects);
                tsprgTotal.Maximum = projects.Count;
                tsprgTask.Value    = 0;
                foreach (IProject fiProject in projects)
                {
                    tsprgTotal.PerformStep();
                    string projName, lang;
                    if (fiProject.FileName.IndexOf("://") != -1)
                    {
                        projName = fiProject.FileName;                         // this is a web project
                        lang     = "{00000001-0000-0000-0000-000000000000}";
                    }
                    else
                    {
                        projName = fiProject.Name;
                        lang     = fiProject.TypeGuid;
                    }

                    int iconIndex;
                                        #if IMPR1
                    iconIndex = projectImageListHelper.GetIndex(IconService.GetImageForProjectType(fiProject.Language ?? "defaultLanguageName"));
                                        #else
                    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(fiProject.Items, summary);
                }

                tsprgTask.Value  = tsprgTask.Maximum;
                tsprgTotal.Value = tsprgTotal.Maximum;
            }
            else
            {
                MessageBox.Show("There is no solution open in SharpDevelop.", "Line Counter");
            }
        }