예제 #1
0
        private void HandlePainterOption(int width, int height, string fileName, string format, KnownColor knownColor, ContainerBuilder builder)
        {
            var resultFormat    = GetImageFormat(format);
            var color           = Color.FromKnownColor(knownColor);
            var painterSettings = new PainterSettings(width, height, fileName, resultFormat, color);

            builder.RegisterInstance(painterSettings).As <PainterSettings>();
        }
예제 #2
0
 /// <summary>
 /// Construct with the provided painter settings.
 /// </summary>
 /// <param name="settings">Painter settings.</param>
 public GraphPainter(PainterSettings settings)
 {
     _settings                = settings;
     _nodeBorderPen           = new Pen(settings.NodeBorderColor, 2f);
     _nodeFillBrush           = new SolidBrush(settings.NodeFillColor);
     _nodeLabelBrush          = new SolidBrush(settings.NodeLabelColor);
     _connectionWeightToWidth = 2f / MathF.Log10(settings.ConnectionWeightRange + 1f);
 }
예제 #3
0
        private void HandlePainterOption(int width, int height, string fileName, string format, int colorNumber, ContainerBuilder builder)
        {
            var size  = GetSize(width, height);
            var font  = GetFont(format);
            var color = GetColor(colorNumber);

            var painterSettings = new PainterSettings(size, fileName, font, color);

            builder.RegisterInstance(painterSettings).As <PainterSettings>();
        }
예제 #4
0
        public WordCloudPainter(IWordCloud wordCloud, PainterSettings settings)
        {
            wordCloud.BuildCloud();
            this.wordCloud = wordCloud;
            this.settings  = settings;

            offsetX = settings.Size.Width / 2;
            offsetY = settings.Size.Height / 2;

            bitmap   = new Bitmap(settings.Size.Width, settings.Size.Height);
            graphics = Graphics.FromImage(bitmap);
        }
예제 #5
0
 public CircularCloudRectanglesPainter(List <Rectangle> rectangles, PainterSettings settings)
 {
     offsetX         = settings.Size.Width / 2;
     offsetY         = settings.Size.Height / 2;
     format          = settings.Format;
     fileName        = settings.FileName;
     this.rectangles = rectangles;
     randomizer      = new Random();
     color           = new Color();
     bitmap          = new Bitmap(settings.Size.Width, settings.Size.Height);
     graphics        = Graphics.FromImage(bitmap);
 }
예제 #6
0
        public void TearDown()
        {
            var testDir  = TestContext.CurrentContext.TestDirectory;
            var testName = TestContext.CurrentContext.Test.Name;

            if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
            {
                foreach (var rectangle in rectanglesInCloud)
                {
                    var distance = GetMaxDistance(rectangle);
                    radius = distance > radius ? distance : radius;
                }

                var cloudDiameter = (int)Math.Ceiling(radius) * 2;
                var indent        = 20;
                var imageSize     = cloudDiameter + indent;
                var format        = ImageFormat.Png;
                var settings      = new PainterSettings(imageSize, imageSize, $"{testName}.{format}", format, Color.Aqua);
                var painter       = new CircularCloudRectanglesPainter(rectanglesInCloud, settings);
                painter.DrawFigures();
                TestContext.Error.WriteLine($"Tag cloud visualization saved to file {testDir}\\{testName}.png");
            }
        }