/// <summary> /// Generate a list of all files included in the Visual Studio solutions. /// </summary> /// <param name="projectName"></param> /// <param name="projectItems"></param> /// <param name="fileDetails"></param> private void CreateFileList(string projectName, ProjectItems projectItems, ref List<FileDetails> fileDetails) { foreach (ProjectItem projItem in projectItems) { if (projItem.ProjectItems != null && projItem.ProjectItems.Count > 0) { // This is a sub project... CreateFileList(projectName, projItem.ProjectItems, ref fileDetails); } if (projItem.Kind == Constants.vsProjectItemKindPhysicalFile) { string entirePathAndFile = projItem.Properties.Item("FullPath").Value as string; string fileName = Path.GetFileName(entirePathAndFile); string path = Path.GetDirectoryName(entirePathAndFile); FileDetails details = new FileDetails(); details.FileName = fileName; details.Path = path; details.Project = projectName; fileDetails.Add(details); } } }
/// <summary> /// Opens the selected file. If there is only one file in the list, that file is opened. /// </summary> private void OpenSelectedFile() { if (listFiles.SelectedItems.Count == 0) _resultFile = listFiles.Items[0].Tag as FileDetails; else _resultFile = listFiles.SelectedItems[0].Tag as FileDetails; this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// Check if a specific project file matches the search criteria. /// </summary> /// <returns>true if the project file matches the search criteria</returns> private bool Match(FileDetails fileDetails, string searchString) { if (fileDetails.FileName.ToLower().Contains(searchString)) { return true; } return false; }