Exemple #1
0
        private void WriteImage(string fileName, ImmutableDictionary <Point, int> points)
        {
            var file = CreateOutputFile(fileName);

            var minX = points.Min(p => p.Key.X);
            var maxX = points.Max(p => p.Key.X);
            var minY = points.Min(p => p.Key.Y);
            var maxY = points.Max(p => p.Key.Y);

            var xOffset = Math.Abs(minX);
            var yOffset = Math.Abs(minY);

            using (var image = new Image <Rgba32>(maxX + xOffset + 1, maxY + yOffset + 1))
            {
                foreach (var(point, colour) in points)
                {
                    var(x, y) = (point.X + xOffset, point.Y + yOffset);

                    image[x, y] = colour == 0
                        ? Rgba32.Black
                        : Rgba32.White;
                }

                image.Mutate(x => x.Resize(image.Width * 10, image.Height * 10).Pixelate(10));
                image.SaveAsJpeg(file);
            }
        }
Exemple #2
0
        internal static void WriteLinesOfCode(Solution solution, ImmutableDictionary <ProjectId, CodeMetricsInfo> projectsMetrics)
        {
            int maxDigits     = projectsMetrics.Max(f => f.Value.CodeLineCount).ToString("n0").Length;
            int maxNameLength = projectsMetrics.Max(f => solution.GetProject(f.Key).Name.Length);

            foreach (KeyValuePair <ProjectId, CodeMetricsInfo> kvp in projectsMetrics
                     .OrderByDescending(f => f.Value.CodeLineCount)
                     .ThenBy(f => solution.GetProject(f.Key).Name))
            {
                Project         project     = solution.GetProject(kvp.Key);
                CodeMetricsInfo codeMetrics = kvp.Value;

                string count = (codeMetrics.CodeLineCount >= 0)
                    ? codeMetrics.CodeLineCount.ToString("n0").PadLeft(maxDigits)
                    : "-";

                WriteLine($"{count} {project.Name.PadRight(maxNameLength)} {project.Language}", Verbosity.Normal);
            }
        }