/**************************************************************/ /* Protected /**************************************************************/ /// <summary> /// Selects an item. /// </summary> /// <param name="aListView">List view</param> /// <param name="aListViewItem">Item</param> private static void SelectItem(Vista_Api.ListView aListView, ListViewItem aListViewItem) { if (aListViewItem != null) { aListView.SelectedItems.Clear(); aListViewItem.Selected = true; aListViewItem.Focused = true; aListViewItem.EnsureVisible(); } }
/// <summary> /// Selects next item. /// </summary> /// <param name="aListView">List view</param> private static void SelectNextItem(Vista_Api.ListView aListView) { if (aListView.Items.Count > 0) { ListViewItem _Item = null; if (aListView.SelectedItems.Count == 0) { _Item = aListView.Items[0]; } else if (aListView.SelectedIndices[0] < (aListView.Items.Count -1)) { _Item = aListView.Items[aListView.SelectedIndices[0] + 1]; } SelectItem(aListView, _Item); } }
/// <summary> /// Sends key to list view. /// </summary> /// <param name="aListView">List view</param> /// <param name="e">Key event</param> public static void SendKeyToListView(Vista_Api.ListView aListView, System.Windows.Forms.KeyEventArgs e) { if ((e.KeyCode == Keys.Up) || (e.KeyCode == Keys.Down) || (e.KeyCode == Keys.Home) || (e.KeyCode == Keys.End) || (e.KeyCode == Keys.PageUp) || (e.KeyCode == Keys.PageDown)) { if ((!e.Shift) || (e.KeyCode == Keys.Up) || (e.KeyCode == Keys.Down)) { if ((!e.Control) || ((e.KeyCode != Keys.Up) && (e.KeyCode != Keys.Down))) { if (aListView.MultiSelect && e.Control && ((e.KeyCode == Keys.Home) || (e.KeyCode == Keys.End))) { if (e.KeyCode == Keys.Home) { SelectFirstItem(aListView); } else if (e.KeyCode == Keys.End) { SelectLastItem(aListView); } } else if (e.KeyCode == Keys.Up) { SelectPreviousItem(aListView); } else if (e.KeyCode == Keys.Down) { SelectNextItem(aListView); } else { WinApi.PostMessage(aListView.Handle, WinApi.WM_KEYDOWN, e.KeyValue, 0); } e.Handled = true; } } } }
/// <summary> /// Selects previous item. /// </summary> /// <param name="aListView">List view</param> private static void SelectPreviousItem(Vista_Api.ListView aListView) { if (aListView.Items.Count > 0) { ListViewItem _Item = null; if (aListView.SelectedItems.Count == 0) { _Item = aListView.Items[0]; } else if (aListView.SelectedIndices[0] != 0) { _Item = aListView.Items[aListView.SelectedIndices[0] - 1]; } SelectItem(aListView, _Item); } }
/// <summary> /// Selects last item. /// </summary> /// <param name="aListView">List view</param> private static void SelectLastItem(Vista_Api.ListView aListView) { if (aListView.Items.Count > 0) { SelectItem(aListView, aListView.Items[aListView.Items.Count-1]); } }
protected virtual void InitializeListView(Vista_Api.ListView aListView) { ColumnHeader _Col = new ColumnHeader(); _Col.Text = "Names"; _Col.Width = lvItems.Width -4; lvItems.Columns.Add(_Col); lvItems.View = View.Details; }
/// <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); }
/// <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> /// Performs a complete counting and summation of all lines /// in all projects and files. /// </summary> internal static void SumSolution(ProgressBar tsprgTotal, ProgressBar tsprgTask, Vista_Api.ListView lvFileList, Vista_Api.ListView lvSummary) { // Clean the list lvSummary.Items.Clear(); lvFileList.Items.Clear(); //lvFileList.Groups.Clear(); // Configure progress bars tsprgTotal.Minimum = 0; tsprgTotal.Step = 1; tsprgTask.Minimum = 0; tsprgTask.Step = 1; // Skip if there are no projects if (m_summaryList == null || (m_summaryList != null && m_summaryList.Count == 1)) { MessageBoxFactory.Warn(null, "No projects loaded", "There are no projects loaded to summarize."); return; } // Get all projects summary LineCountSummary allProjects = (LineCountSummary)m_summaryList[0]; allProjects.LineCountSummaryDetails.Reset(); AddSummaryListItem(lvSummary, allProjects/*, lvSummary.Groups["lvgAllProj"]*/); tsprgTotal.Maximum = m_summaryList.Count; tsprgTotal.Value = 0; for (int s = 1; s < m_summaryList.Count; s++) { tsprgTotal.PerformStep(); LineCountSummary summary = (LineCountSummary)m_summaryList[s]; summary.LineCountSummaryDetails.Reset(); AddSummaryListItem(lvSummary, summary/*, lvSummary.Groups["lvgEachProj"]*/); tsprgTask.Maximum = summary.FileLineCountInfo.Count; tsprgTask.Value = 0; for (int i = 0; i < summary.FileLineCountInfo.Count; i++) { tsprgTask.PerformStep(); LineCountInfo info = (LineCountInfo)summary.FileLineCountInfo[i]; if (m_countableTypes.Contains(info.FileType)) { info.LineCountInfoDetails.Reset(); #if IMPR2 foreach (CountingAlgorithmDescriptor desc in countingAlgorithms) { if (desc.CanCountLines(info)) { desc.GetAlgorithm().CountLines(info); break; } } #else try { CountLines counter = (CountLines)m_countAlgorithms[info.FileType]; counter(info); } catch (Exception ex) { Lextm.Windows.Forms.MessageBoxFactory.Fatal(null, ex); throw; } #endif info.LineCountInfoDetails.Summarize(); allProjects.LineCountSummaryDetails.Add(info.LineCountInfoDetails); summary.LineCountSummaryDetails.Add(info.LineCountInfoDetails); //tstxtLinesCounted.Text = allProjects.LineCountSummaryDetails.TotalLines.ToString(); AddFileListItem(lvFileList, info); } } summary.LineCountSummaryDetails.Summarize(); LineCountDetails details = summary.LineCountSummaryDetails; summary.LinkedListViewItem.SubItems[1].Text = details.TotalLines.ToString(CultureInfo.InvariantCulture); summary.LinkedListViewItem.SubItems[2].Text = details.CodeLines.ToString(CultureInfo.InvariantCulture); summary.LinkedListViewItem.SubItems[3].Text = details.CommentLines.ToString(CultureInfo.InvariantCulture); summary.LinkedListViewItem.SubItems[4].Text = details.BlankLines.ToString(CultureInfo.InvariantCulture); summary.LinkedListViewItem.SubItems[5].Text = details.NetLines.ToString(CultureInfo.InvariantCulture); details = null; } allProjects.LineCountSummaryDetails.Summarize(); LineCountDetails totals = allProjects.LineCountSummaryDetails; allProjects.LinkedListViewItem.SubItems[1].Text = totals.TotalLines.ToString(CultureInfo.InvariantCulture); allProjects.LinkedListViewItem.SubItems[2].Text = totals.CodeLines.ToString(CultureInfo.InvariantCulture); allProjects.LinkedListViewItem.SubItems[3].Text = totals.CommentLines.ToString(CultureInfo.InvariantCulture); allProjects.LinkedListViewItem.SubItems[4].Text = totals.BlankLines.ToString(CultureInfo.InvariantCulture); allProjects.LinkedListViewItem.SubItems[5].Text = totals.NetLines.ToString(CultureInfo.InvariantCulture); tsprgTotal.Value = tsprgTotal.Maximum; }