private void UpdateUI(LineCounter lineCounter, string linesOfCodePerLanguageText, decimal[] extensionValues, string[] extensionLabels) { TotalLinesOfTestCode.Text = string.Format(_linesOfTestCode.Text, lineCounter.NumberTestCodeLines); TestCodePie.SetValues(new decimal[] { lineCounter.NumberTestCodeLines, lineCounter.NumberCodeLines - lineCounter.NumberTestCodeLines }); string percent_t = ((double)lineCounter.NumberTestCodeLines / lineCounter.NumberCodeLines).ToString("P1"); string percent_p = ((double)(lineCounter.NumberCodeLines - lineCounter.NumberTestCodeLines) / lineCounter.NumberCodeLines).ToString( "P1"); TestCodePie.ToolTips = new[] { string.Format(_linesOfTestCodeP.Text, lineCounter.NumberTestCodeLines, percent_t), string.Format(_linesOfProductionCodeP.Text, lineCounter.NumberCodeLines - lineCounter.NumberTestCodeLines, percent_p) }; TestCodeText.Text = string.Format(_linesOfTestCodeP.Text, lineCounter.NumberTestCodeLines, percent_t) + Environment.NewLine + string.Format(_linesOfProductionCodeP.Text, lineCounter.NumberCodeLines - lineCounter.NumberTestCodeLines, percent_p); string percentBlank = ((double)lineCounter.NumberBlankLines / lineCounter.NumberLines).ToString("P1"); string percentComments = ((double)lineCounter.NumberCommentsLines / lineCounter.NumberLines).ToString("P1"); string percentCode = ((double)lineCounter.NumberCodeLines / lineCounter.NumberLines).ToString("P1"); string percentDesigner = ((double)lineCounter.NumberLinesInDesignerFiles / lineCounter.NumberLines).ToString("P1"); LinesOfCodePie.SetValues(new decimal[] { lineCounter.NumberBlankLines, lineCounter.NumberCommentsLines, lineCounter.NumberCodeLines, lineCounter.NumberLinesInDesignerFiles }); LinesOfCodePie.ToolTips = new[] { string.Format(_blankLinesP.Text, lineCounter.NumberBlankLines, percentBlank), string.Format(_commentLinesP.Text, lineCounter.NumberCommentsLines, percentComments), string.Format(_linesOfCodeP.Text, lineCounter.NumberCodeLines, percentCode), string.Format(_linesOfDesignerFilesP.Text, lineCounter.NumberLinesInDesignerFiles, percentDesigner) }; LinesOfCodePerTypeText.Text = LinesOfCodePie.ToolTips[0] + Environment.NewLine; LinesOfCodePerTypeText.Text += LinesOfCodePie.ToolTips[1] + Environment.NewLine; LinesOfCodePerTypeText.Text += LinesOfCodePie.ToolTips[2] + Environment.NewLine; LinesOfCodePerTypeText.Text += LinesOfCodePie.ToolTips[3] + Environment.NewLine; LinesOfCodePerLanguageText.Text = linesOfCodePerLanguageText; LinesOfCodeExtensionPie.SetValues(extensionValues); LinesOfCodeExtensionPie.ToolTips = extensionLabels; TotalLinesOfCode2.Text = TotalLinesOfCode.Text = string.Format(_linesOfCode.Text, lineCounter.NumberCodeLines); }
private void UpdateUI(LineCounter lineCounter, string linesOfCodePerLanguageText, decimal[] extensionValues, string[] extensionLabels) { TotalLinesOfTestCode.Text = string.Format(_linesOfTestCode.Text, lineCounter.TestCodeLineCount); TestCodePie.SetValues(new decimal[] { lineCounter.TestCodeLineCount, lineCounter.CodeLineCount - lineCounter.TestCodeLineCount }); var percentTest = (double)lineCounter.TestCodeLineCount / lineCounter.CodeLineCount; var percentProd = (double)(lineCounter.CodeLineCount - lineCounter.TestCodeLineCount) / lineCounter.CodeLineCount; TestCodePie.ToolTips = new[] { string.Format(_linesOfTestCodeP.Text, lineCounter.TestCodeLineCount, percentTest), string.Format(_linesOfProductionCodeP.Text, lineCounter.CodeLineCount - lineCounter.TestCodeLineCount, percentProd) }; TestCodeText.Text = string.Format(_linesOfTestCodeP.Text, lineCounter.TestCodeLineCount, percentTest) + Environment.NewLine + string.Format(_linesOfProductionCodeP.Text, lineCounter.CodeLineCount - lineCounter.TestCodeLineCount, percentProd); var percentBlank = (double)lineCounter.BlankLineCount / lineCounter.TotalLineCount; var percentComments = (double)lineCounter.CommentLineCount / lineCounter.TotalLineCount; var percentCode = (double)lineCounter.CodeLineCount / lineCounter.TotalLineCount; var percentDesigner = (double)lineCounter.DesignerLineCount / lineCounter.TotalLineCount; LinesOfCodePie.SetValues(new decimal[] { lineCounter.BlankLineCount, lineCounter.CommentLineCount, lineCounter.CodeLineCount, lineCounter.DesignerLineCount }); LinesOfCodePie.ToolTips = new[] { string.Format(_blankLinesP.Text, lineCounter.BlankLineCount, percentBlank), string.Format(_commentLinesP.Text, lineCounter.CommentLineCount, percentComments), string.Format(_linesOfCodeP.Text, lineCounter.CodeLineCount, percentCode), string.Format(_linesOfDesignerFilesP.Text, lineCounter.DesignerLineCount, percentDesigner) }; LinesOfCodePerTypeText.Text = string.Join(Environment.NewLine, LinesOfCodePie.ToolTips); LinesOfCodePerLanguageText.Text = linesOfCodePerLanguageText; LinesOfCodeExtensionPie.SetValues(extensionValues); LinesOfCodeExtensionPie.ToolTips = extensionLabels; TotalLinesOfCode2.Text = TotalLinesOfCode.Text = string.Format(_linesOfCode.Text, lineCounter.CodeLineCount); }
void lineCounter_LinesOfCodeUpdated(object sender, EventArgs e) { LineCounter lineCounter = (LineCounter)sender; //Must do this synchronously becuase lineCounter.LinesOfCodePerExtension might change while we are iterating over it otherwise. var extensionValues = new Decimal[lineCounter.LinesOfCodePerExtension.Count]; var extensionLabels = new string[lineCounter.LinesOfCodePerExtension.Count]; List <KeyValuePair <string, int> > LinesOfCodePerExtension = new List <KeyValuePair <string, int> >(lineCounter.LinesOfCodePerExtension); LinesOfCodePerExtension.Sort( delegate(KeyValuePair <string, int> first, KeyValuePair <string, int> next) { return(-first.Value.CompareTo(next.Value)); } ); var n = 0; string linesOfCodePerLanguageText = ""; foreach (var keyValuePair in LinesOfCodePerExtension) { string percent = ((double)keyValuePair.Value / lineCounter.NumberCodeLines).ToString("P1"); linesOfCodePerLanguageText += keyValuePair.Value + " Lines of code in " + keyValuePair.Key + " files (" + percent + ")" + Environment.NewLine; extensionValues[n] = keyValuePair.Value; extensionLabels[n] = keyValuePair.Value + " Lines of code in " + keyValuePair.Key + " files (" + percent + ")"; n++; } //Sync rest to UI thread syncContext.Post(o => { TotalLinesOfTestCode.Text = lineCounter.NumberTestCodeLines + " Lines of test code"; TestCodePie.SetValues(new Decimal[] { lineCounter.NumberTestCodeLines, lineCounter.NumberCodeLines - lineCounter.NumberTestCodeLines }); string percent_t = ((double)lineCounter.NumberTestCodeLines / lineCounter.NumberCodeLines).ToString("P1"); string percent_p = ((double)(lineCounter.NumberCodeLines - lineCounter.NumberTestCodeLines) / lineCounter.NumberCodeLines).ToString("P1"); TestCodePie.ToolTips = new[] { lineCounter.NumberTestCodeLines + " Lines of testcode (" + percent_t + ")", lineCounter.NumberCodeLines - lineCounter.NumberTestCodeLines + " Lines of production code (" + percent_p + ")" }; TestCodeText.Text = lineCounter.NumberTestCodeLines + " Lines of testcode (" + percent_t + ")" + Environment.NewLine + (lineCounter.NumberCodeLines - lineCounter.NumberTestCodeLines) + " Lines of production code (" + percent_p + ")"; string percent_blank = ((double)lineCounter.NumberBlankLines / lineCounter.NumberLines).ToString("P1"); string percent_comments = ((double)lineCounter.NumberCommentsLines / lineCounter.NumberLines).ToString("P1"); string percent_code = ((double)lineCounter.NumberCodeLines / lineCounter.NumberLines).ToString("P1"); string percent_designer = ((double)lineCounter.NumberLinesInDesignerFiles / lineCounter.NumberLines).ToString("P1"); LinesOfCodePie.SetValues(new Decimal[] { lineCounter.NumberBlankLines, lineCounter.NumberCommentsLines, lineCounter.NumberLines, lineCounter.NumberLinesInDesignerFiles }); LinesOfCodePie.ToolTips = new[] { lineCounter.NumberBlankLines + " Blank lines (" + percent_blank + ")", lineCounter.NumberCommentsLines + " Comment lines (" + percent_comments + ")", lineCounter.NumberCodeLines + " Lines of code (" + percent_code + ")", lineCounter.NumberLinesInDesignerFiles + " Lines in designer files (" + percent_designer + ")" }; LinesOfCodePerTypeText.Text = LinesOfCodePie.ToolTips[0] + Environment.NewLine; LinesOfCodePerTypeText.Text += LinesOfCodePie.ToolTips[1] + Environment.NewLine; LinesOfCodePerTypeText.Text += LinesOfCodePie.ToolTips[2] + Environment.NewLine; LinesOfCodePerTypeText.Text += LinesOfCodePie.ToolTips[3] + Environment.NewLine; LinesOfCodePerLanguageText.Text = linesOfCodePerLanguageText; LinesOfCodeExtensionPie.SetValues(extensionValues); LinesOfCodeExtensionPie.ToolTips = extensionLabels; TotalLinesOfCode2.Text = TotalLinesOfCode.Text = lineCounter.NumberCodeLines + " Lines of code"; }, null); }
private void UpdateUI(LineCounter lineCounter, string linesOfCodePerLanguageText, decimal[] extensionValues, string[] extensionLabels) { TotalLinesOfTestCode.Text = lineCounter.NumberTestCodeLines + " Lines of test code"; TestCodePie.SetValues(new Decimal[] { lineCounter.NumberTestCodeLines, lineCounter.NumberCodeLines - lineCounter.NumberTestCodeLines }); string percent_t = ((double)lineCounter.NumberTestCodeLines / lineCounter.NumberCodeLines).ToString("P1"); string percent_p = ((double)(lineCounter.NumberCodeLines - lineCounter.NumberTestCodeLines) / lineCounter.NumberCodeLines).ToString( "P1"); TestCodePie.ToolTips = new[] { lineCounter.NumberTestCodeLines + " Lines of testcode (" + percent_t + ")", lineCounter.NumberCodeLines - lineCounter.NumberTestCodeLines + " Lines of production code (" + percent_p + ")" }; TestCodeText.Text = lineCounter.NumberTestCodeLines + " Lines of testcode (" + percent_t + ")" + Environment.NewLine + (lineCounter.NumberCodeLines - lineCounter.NumberTestCodeLines) + " Lines of production code (" + percent_p + ")"; string percent_blank = ((double)lineCounter.NumberBlankLines / lineCounter.NumberLines).ToString("P1"); string percent_comments = ((double)lineCounter.NumberCommentsLines / lineCounter.NumberLines).ToString("P1"); string percent_code = ((double)lineCounter.NumberCodeLines / lineCounter.NumberLines).ToString("P1"); string percent_designer = ((double)lineCounter.NumberLinesInDesignerFiles / lineCounter.NumberLines).ToString("P1"); LinesOfCodePie.SetValues(new Decimal[] { lineCounter.NumberBlankLines, lineCounter.NumberCommentsLines, lineCounter.NumberLines, lineCounter.NumberLinesInDesignerFiles }); LinesOfCodePie.ToolTips = new[] { lineCounter.NumberBlankLines + " Blank lines (" + percent_blank + ")", lineCounter.NumberCommentsLines + " Comment lines (" + percent_comments + ")", lineCounter.NumberCodeLines + " Lines of code (" + percent_code + ")", lineCounter.NumberLinesInDesignerFiles + " Lines in designer files (" + percent_designer + ")" }; LinesOfCodePerTypeText.Text = LinesOfCodePie.ToolTips[0] + Environment.NewLine; LinesOfCodePerTypeText.Text += LinesOfCodePie.ToolTips[1] + Environment.NewLine; LinesOfCodePerTypeText.Text += LinesOfCodePie.ToolTips[2] + Environment.NewLine; LinesOfCodePerTypeText.Text += LinesOfCodePie.ToolTips[3] + Environment.NewLine; LinesOfCodePerLanguageText.Text = linesOfCodePerLanguageText; LinesOfCodeExtensionPie.SetValues(extensionValues); LinesOfCodeExtensionPie.ToolTips = extensionLabels; TotalLinesOfCode2.Text = TotalLinesOfCode.Text = lineCounter.NumberCodeLines + " Lines of code"; }