private static string getRowNumberData(string title, long userStat, long contribStat) { string userStatStr = SoftwareCoUtil.FormatNumber(userStat); string contribStatStr = SoftwareCoUtil.FormatNumber(contribStat); List <string> labels = new List <string>(); labels.Add(title); labels.Add(userStatStr); labels.Add(contribStatStr); return(getRowLabels(labels)); }
public async Task RebuildCodeMetricsAsync() { if (!SoftwareCoPackage.PLUGIN_READY) { return; } SessionSummary summary = SessionSummaryManager.Instance.GetSessionSummayData(); CodeTimeSummary ctSummary = TimeDataManager.Instance.GetCodeTimeSummary(); string editortimeToday = "Today: " + SoftwareCoUtil.HumanizeMinutes(ctSummary.codeTimeMinutes); if (Editortime.HasItems) { // update TreeViewItem parentItem = await GetParent(Editortime, "editortime"); UpdateNodeValue(parentItem, "editortimetodayval", editortimeToday, "rocket.png"); } else { List <TreeViewItem> editortimeChildren = new List <TreeViewItem>(); editortimeChildren.Add(BuildMetricNode("editortimetodayval", editortimeToday, "rocket.png")); TreeViewItem editorParent = BuildMetricNodes("editortime", "Code time", editortimeChildren); Editortime.Items.Add(editorParent); } string codetimeBoltIcon = ctSummary.activeCodeTimeMinutes > summary.averageDailyMinutes ? "bolt.png" : "bolt-grey.png"; string codetimeToday = "Today: " + SoftwareCoUtil.HumanizeMinutes(ctSummary.activeCodeTimeMinutes); string codetimeAvg = "Your average: " + SoftwareCoUtil.HumanizeMinutes(summary.averageDailyMinutes); string codetimeGlobal = "Global average: " + SoftwareCoUtil.HumanizeMinutes(summary.globalAverageDailyMinutes); if (Codetime.HasItems) { // update TreeViewItem parentItem = await GetParent(Codetime, "codetime"); UpdateNodeValue(parentItem, "codetimetodayval", codetimeToday, "rocket.png"); UpdateNodeValue(parentItem, "codetimeavgval", codetimeAvg, codetimeBoltIcon); UpdateNodeValue(parentItem, "codetimeglobalval", codetimeGlobal, "global-grey.png"); } else { List <TreeViewItem> codetimeChildren = new List <TreeViewItem>(); codetimeChildren.Add(BuildMetricNode("codetimetodayval", codetimeToday, "rocket.png")); codetimeChildren.Add(BuildMetricNode("codetimeavgval", codetimeAvg, codetimeBoltIcon)); codetimeChildren.Add(BuildMetricNode("codetimeglobalval", codetimeGlobal, "global-grey.png")); TreeViewItem codetimeParent = BuildMetricNodes("codetime", "Active code time", codetimeChildren); Codetime.Items.Add(codetimeParent); } string linesaddedBoltIcon = summary.currentDayLinesAdded > summary.averageDailyLinesAdded ? "bolt.png" : "bolt-grey.png"; string linesaddedToday = "Today: " + SoftwareCoUtil.FormatNumber(summary.currentDayLinesAdded); string linesaddedAvg = "Your average: " + SoftwareCoUtil.FormatNumber(summary.averageDailyLinesAdded); string linesaddedGlobal = "Global average: " + SoftwareCoUtil.FormatNumber(summary.globalAverageLinesAdded); if (Linesadded.HasItems) { // update TreeViewItem parentItem = await GetParent(Linesadded, "linesadded"); UpdateNodeValue(parentItem, "linesaddedtodayval", linesaddedToday, "rocket.png"); UpdateNodeValue(parentItem, "linesaddedavgval", linesaddedAvg, linesaddedBoltIcon); UpdateNodeValue(parentItem, "linesaddedglobalval", linesaddedGlobal, "global-grey.png"); } else { List <TreeViewItem> linesaddedChildren = new List <TreeViewItem>(); linesaddedChildren.Add(BuildMetricNode("linesaddedtodayval", linesaddedToday, "rocket.png")); linesaddedChildren.Add(BuildMetricNode("linesaddedavgval", linesaddedAvg, linesaddedBoltIcon)); linesaddedChildren.Add(BuildMetricNode("linesaddedglobalval", linesaddedGlobal, "global-grey.png")); TreeViewItem linesaddedParent = BuildMetricNodes("linesadded", "Lines added", linesaddedChildren); Linesadded.Items.Add(linesaddedParent); } string linesremovedBoltIcon = summary.currentDayLinesRemoved > summary.averageDailyLinesRemoved ? "bolt.png" : "bolt-grey.png"; string linesremovedToday = "Today: " + SoftwareCoUtil.FormatNumber(summary.currentDayLinesRemoved); string linesremovedAvg = "Your average: " + SoftwareCoUtil.FormatNumber(summary.averageDailyLinesRemoved); string linesremovedGlobal = "Global average: " + SoftwareCoUtil.FormatNumber(summary.globalAverageLinesRemoved); if (Linesremoved.HasItems) { // update TreeViewItem parentItem = await GetParent(Codetime, "linesremoved"); UpdateNodeValue(parentItem, "linesremovedtodayval", linesremovedToday, "rocket.png"); UpdateNodeValue(parentItem, "linesremovedavgval", linesremovedAvg, linesremovedBoltIcon); UpdateNodeValue(parentItem, "linesremovedglobalval", linesremovedGlobal, "global-grey.png"); } else { List <TreeViewItem> linesremovedChildren = new List <TreeViewItem>(); linesremovedChildren.Add(BuildMetricNode("linesremovedtodayval", linesremovedToday, "rocket.png")); linesremovedChildren.Add(BuildMetricNode("linesremovedavgval", linesremovedAvg, linesremovedBoltIcon)); linesremovedChildren.Add(BuildMetricNode("linesremovedglobalval", linesremovedGlobal, "global-grey.png")); TreeViewItem linesremovedParent = BuildMetricNodes("linesremoved", "Lines removed", linesremovedChildren); Linesremoved.Items.Add(linesremovedParent); } string keystrokesBoltIcon = summary.currentDayLinesRemoved > summary.averageDailyLinesRemoved ? "bolt.png" : "bolt-grey.png"; string keystrokesToday = "Today: " + SoftwareCoUtil.FormatNumber(summary.currentDayKeystrokes); string keystrokesAvg = "Your average: " + SoftwareCoUtil.FormatNumber(summary.averageDailyKeystrokes); string keystrokesGlobal = "Global average: " + SoftwareCoUtil.FormatNumber(summary.globalAverageDailyKeystrokes); if (Keystrokes.HasItems) { // update TreeViewItem parentItem = await GetParent(Keystrokes, "keystrokes"); UpdateNodeValue(parentItem, "keystrokestodayval", keystrokesToday, "rocket.png"); UpdateNodeValue(parentItem, "keystrokesavgval", keystrokesAvg, keystrokesBoltIcon); UpdateNodeValue(parentItem, "keystrokesglobalval", keystrokesGlobal, "global-grey.png"); } else { List <TreeViewItem> keystrokeChildren = new List <TreeViewItem>(); keystrokeChildren.Add(BuildMetricNode("keystrokestodayval", keystrokesToday, "rocket.png")); keystrokeChildren.Add(BuildMetricNode("keystrokesavgval", keystrokesAvg, keystrokesBoltIcon)); keystrokeChildren.Add(BuildMetricNode("keystrokesglobalval", keystrokesGlobal, "global-grey.png")); TreeViewItem keystrokesParent = BuildMetricNodes("keystrokes", "Keystrokes", keystrokeChildren); Keystrokes.Items.Add(keystrokesParent); } // get the top keystrokes and code time files List <FileChangeInfo> topKeystrokeFiles = FileChangeInfoDataManager.Instance.GetTopKeystrokeFiles(); if (topKeystrokeFiles.Count == 0) { TopKeystrokeFiles.Visibility = Visibility.Hidden; } else { TopKeystrokeFiles.Visibility = Visibility.Visible; // add or update if (TopKeystrokeFiles.HasItems) { /** * TreeViewItem parentItem = await GetParent(TopKeystrokeFiles, "topcodetimefiles"); * foreach (FileChangeInfo changeInfo in topKeystrokeFiles) * { * string keystrokeNumStr = SoftwareCoUtil.FormatNumber(changeInfo.keystrokes); * string label = changeInfo.name + " | " + keystrokeNumStr; * UpdateNodeValue(parentItem, "topkeystrokes-" + changeInfo.name, label, "files.png"); * } **/ } List <TreeViewItem> topKeystrokeChildren = new List <TreeViewItem>(); foreach (FileChangeInfo changeInfo in topKeystrokeFiles) { string keystrokeNumStr = SoftwareCoUtil.FormatNumber(changeInfo.keystrokes); string label = changeInfo.name + " | " + keystrokeNumStr; topKeystrokeChildren.Add(BuildMetricNode("topkeystrokes-" + changeInfo.name, label, "files.png")); } if (topKeystrokesParent == null) { topKeystrokesParent = BuildMetricNodes("topkeystrokesfiles", "Top files by keystrokes", topKeystrokeChildren); TopKeystrokeFiles.Items.Add(topKeystrokesParent); } else { topKeystrokesParent.Items.Clear(); foreach (TreeViewItem item in topKeystrokeChildren) { topKeystrokesParent.Items.Add(item); } } } List <FileChangeInfo> topCodetimeFiles = FileChangeInfoDataManager.Instance.GetTopCodeTimeFiles(); if (topCodetimeFiles.Count == 0) { TopCodeTimeFiles.Visibility = Visibility.Hidden; } else { TopCodeTimeFiles.Visibility = Visibility.Visible; // add or update if (TopCodeTimeFiles.HasItems) { /** * TreeViewItem parentItem = await GetParent(TopCodeTimeFiles, "topcodetimefiles"); * foreach (FileChangeInfo changeInfo in topCodetimeFiles) * { * string codetimeMinStr = SoftwareCoUtil.HumanizeMinutes(changeInfo.duration_seconds / 60); * string label = changeInfo.name + " | " + codetimeMinStr; * UpdateNodeValue(parentItem, "topcodetime-" + changeInfo.name, label, "files.png"); * } **/ } List <TreeViewItem> topCodetimeFilesChildren = new List <TreeViewItem>(); foreach (FileChangeInfo changeInfo in topCodetimeFiles) { string codetimeMinStr = SoftwareCoUtil.HumanizeMinutes(changeInfo.duration_seconds / 60); string label = changeInfo.name + " | " + codetimeMinStr; topCodetimeFilesChildren.Add(BuildMetricNode("topcodetime-" + changeInfo.name, label, "files.png")); } if (topCodetimeParent == null) { topCodetimeParent = BuildMetricNodes("topcodetimefiles", "Top files by code time", topCodetimeFilesChildren); TopCodeTimeFiles.Items.Add(topCodetimeParent); } else { topCodetimeParent.Items.Clear(); foreach (TreeViewItem item in topCodetimeFilesChildren) { topCodetimeParent.Items.Add(item); } } } }