예제 #1
0
		/// <summary>
		/// Adds a file information item to the file list view.
		/// </summary>
		/// <param name="info">The file information data object.</param>
		private static void AddFileListItem(Vista_Api.ListView lvFileList, LineCountInfo info)
		{
			FileInfo fileInfo = new FileInfo(info.FileName);

			ListViewItem lvi = new ListViewItem();
			lvi.Text = fileInfo.Name;
			lvi.SubItems.Add(info.LineCountInfoDetails.TotalLines.ToString(CultureInfo.InvariantCulture));
			lvi.SubItems.Add(info.LineCountInfoDetails.CodeLines.ToString(CultureInfo.InvariantCulture));
			lvi.SubItems.Add(info.LineCountInfoDetails.CommentLines.ToString(CultureInfo.InvariantCulture));
			lvi.SubItems.Add(info.FileType);
			lvi.SubItems.Add(info.SumMode);

			lvi.Tag = info;

			lvi.ImageIndex = info.IconIndex;
			//lvi.StateImageIndex = iconIndex;


//			if (tsmiGroupByType.Checked)
//			{
//				Vista_Api.ListViewGroup group = lvFileList.Groups["groupType" + info.FileType.Substring(1)];
//				if (group == null)
//				{
//					group = new Vista_Api.ListViewGroup("groupType" + info.FileType.Substring(1), info.FileType.Substring(1).ToUpperInvariant() + " Files");
//					lvFileList.Groups.Add(group);
//				}
//
//				lvi.Group = group;
//			}
//			else if (tsmiGroupByProj.Checked)
//			{
//				Vista_Api.ListViewGroup group = lvFileList.Groups["groupProj" + info.ProjectSummary.ProjectName];
//				if (group == null)
//				{
//					group = new Vista_Api.ListViewGroup("groupProj" + info.ProjectSummary.ProjectName, info.ProjectSummary.ProjectName + " Files");
//					lvFileList.Groups.Add(group);
//				}
//
//				lvi.Group = group;
//			}

			lvFileList.Items.Add(lvi);
		}
예제 #2
0
		internal static void CountLinesDelphiStyle(LineCountInfo info) {
			using(StreamReader reader = new StreamReader(info.FileName))
			{
				string line;
				bool multiLineComment = false;
				bool hasCode = false;
				bool hasComments = false;
				char commentChar = char.MinValue;
				while ((line = reader.ReadLine()) != null)
				{
					ParseDelphiLine(line, ref commentChar, ref multiLineComment, ref hasCode, ref hasComments);

					if (hasComments)
					{
						info.LineCountInfoDetails.Add("normcmtlines", 1);
					}

					if (hasCode)
					{
						info.LineCountInfoDetails.Add("codelines", 1);
					}

					if (!hasCode && !hasComments)
					{
						info.LineCountInfoDetails.Add("blanklines", 1);
					}

					info.LineCountInfoDetails.Add("totallines", 1);
				}
				
				reader.Close();
			}
			info.SumMode = "Delphi-Style";
		}
예제 #3
0
		/// <summary>
		/// Count each line in an xml source file, scanning
		/// for comments, code, and blank lines.
		/// </summary>
		/// <param name="info">The file information data to use.</param>
		/// <remarks>This algorithm is based on one created by Oz Solomon,
		/// for his PLC line counter add-in for Visual Studio 2002/2003.</remarks>
		internal static void CountLinesXMLStyle(LineCountInfo info)
		{
			try
			{
				StreamReader reader = new StreamReader(info.FileName);

				string line;
				bool multiLineComment = false;
				bool hasCode = false;
				bool hasComments = false;
				while ((line = reader.ReadLine()) != null)
				{
					ParseXMLLine(line, ref multiLineComment, ref hasCode, ref hasComments);

					if (hasComments)
					{
						info.LineCountInfoDetails.Add("normcmtlines", 1);
					}

					if (hasCode)
					{
						info.LineCountInfoDetails.Add("codelines", 1);
					}

					if (!hasCode && !hasComments)
					{
						info.LineCountInfoDetails.Add("blanklines", 1);
					}

					info.LineCountInfoDetails.Add("totallines", 1);
				}

				reader.Close();

				info.SumMode = "XML";
			}
			catch (Exception ex)
			{
				Lextm.Windows.Forms.MessageBoxFactory.Fatal(null, ex);
				throw;
			}
		}
예제 #4
0
		/// <summary>
		/// Count each line in a text file, logging
		/// blank lines.
		/// </summary>
		/// <param name="info">The file information data to use.</param>
		internal static void CountLinesGeneric(LineCountInfo info)
		{
			StreamReader sr = new StreamReader(info.FileName);

			string line;
			while ((line = sr.ReadLine()) != null)
			{
				info.LineCountInfoDetails.Add("TotalLines", 1);
				if (string.IsNullOrEmpty(line.Trim()))
				{
					info.LineCountInfoDetails.Add("BlankLines", 1);
				}

				info.SumMode = "Generic";
			}

			sr.Close();
		}