Пример #1
0
        public void Export_AllExamplesInExampleLibrary_CheckThatAllFilesExist()
        {
            var destinationDirectory = Path.Combine(TestContext.CurrentContext.WorkDirectory, "PdfExporterTests_ExampleLibrary");

            if (!Directory.Exists(destinationDirectory))
            {
                Directory.CreateDirectory(destinationDirectory);
            }

            // A4
            const double Width  = 297 / 25.4 * 72;
            const double Height = 210 / 25.4 * 72;

            foreach (var example in Examples.GetList())
            {
                void ExportModelAndCheckFileExists(PlotModel model, string fileName)
                {
                    if (model == null)
                    {
                        return;
                    }

                    var path = Path.Combine(destinationDirectory, FileNameUtilities.CreateValidFileName(fileName, ".pdf"));

                    using (var s = File.Create(path))
                    {
                        PdfExporter.Export(model, s, Width, Height);
                    }

                    Assert.IsTrue(File.Exists(path));
                }

                ExportModelAndCheckFileExists(example.PlotModel, $"{example.Category} - {example.Title}");
            }
        }
Пример #2
0
        public void Export_AllExamplesInExampleLibrary_CheckThatAllFilesExist()
        {
            const string DestinationDirectory = "SvgExporterTests_ExampleLibrary";

            if (!Directory.Exists(DestinationDirectory))
            {
                Directory.CreateDirectory(DestinationDirectory);
            }

            foreach (var example in Examples.GetList())
            {
                void ExportModelAndCheckFileExists(PlotModel model, string fileName)
                {
                    if (model == null)
                    {
                        return;
                    }

                    var path = Path.Combine(DestinationDirectory, FileNameUtilities.CreateValidFileName(fileName, ".svg"));

                    using (var s = File.Create(path))
                    {
                        SvgExporter.Export(model, s, 800, 500, true);
                    }

                    Assert.IsTrue(File.Exists(path));
                }

                ExportModelAndCheckFileExists(example.PlotModel, $"{example.Category} - {example.Title}");
                ExportModelAndCheckFileExists(example.TransposedPlotModel, $"{example.Category} - {example.Title} - Transposed");
            }
        }
Пример #3
0
        public void Export_AllExamplesInExampleLibrary_CheckThatAllFilesExist()
        {
            const string DestinationDirectory = "SvgExporterTests_ExampleLibrary";

            if (!Directory.Exists(DestinationDirectory))
            {
                Directory.CreateDirectory(DestinationDirectory);
            }

            foreach (var example in Examples.GetList())
            {
                if (example.PlotModel == null)
                {
                    continue;
                }

                var path = Path.Combine(DestinationDirectory, FileNameUtilities.CreateValidFileName(example.Category + " - " + example.Title, ".svg"));
                using (var s = File.Create(path))
                {
                    SvgExporter.Export(example.PlotModel, s, 800, 500, true);
                }

                Assert.IsTrue(File.Exists(path));
            }
        }
Пример #4
0
        public void Export_BoundedTest()
        {
            const string DestinationDirectory = "SvgExporterTests_Meh";

            if (!Directory.Exists(DestinationDirectory))
            {
                Directory.CreateDirectory(DestinationDirectory);
            }

            var fileName = "BoundedTest";
            var path     = Path.Combine(DestinationDirectory, FileNameUtilities.CreateValidFileName(fileName, ".svg"));

            var width  = 550;
            var height = 550;
            var whole  = new OxyRect(0, 0, width, height);

            var rect = new OxyRect(50, 50, 400, 400);
            //var model = ExampleLibrary.PolarPlotExamples.ArchimedeanSpiral();
            var model = ExampleLibrary.AxisExamples.PositionTier();

            model.Title                   = "Title";
            model.Subtitle                = "SubTitle";
            model.PlotAreaBorderColor     = OxyColors.Black;
            model.PlotAreaBorderThickness = new OxyThickness(1.0);
            var textMeasurer = new PdfRenderContext(width, height, model.Background);

            using (var stream = new FileStream(path, FileMode.Create))
                using (var rc = new SvgRenderContext(stream, width, height, false, textMeasurer, model.Background, true))
                {
                    ((IPlotModel)model).Update(true);
                    ((IPlotModel)model).Render(rc, rect);
                    rc.DrawClippedRectangle(whole, rect.Inflate(2.0, 2.0), OxyColors.Transparent, OxyColors.Blue, 1.0, EdgeRenderingMode.Adaptive);
                    rc.DrawClippedRectangle(whole, model.PlotBounds, OxyColors.Transparent, OxyColors.Black, 1.0, EdgeRenderingMode.Adaptive);
                    rc.DrawClippedRectangle(whole, whole, OxyColors.Transparent, OxyColors.Black, 1.0, EdgeRenderingMode.Adaptive);
                    rc.Complete();
                    rc.Flush();
                }
        }
Пример #5
0
        public void Export_AllExamplesInExampleLibrary_CheckThatAllFilesExist()
        {
            const string DestinationDirectory = "PdfExporterTests_ExampleLibrary";

            if (!Directory.Exists(DestinationDirectory))
            {
                Directory.CreateDirectory(DestinationDirectory);
            }

            // A4
            const double Width  = 297 / 25.4 * 72;
            const double Height = 210 / 25.4 * 72;

            foreach (var example in Examples.GetList())
            {
                if (example.PlotModel == null)
                {
                    continue;
                }

                var path = Path.Combine(DestinationDirectory, FileNameUtilities.CreateValidFileName(example.Category + " - " + example.Title, ".pdf"));
                using (var s = File.Create(path))
                {
                    try
                    {
                        PdfExporter.Export(example.PlotModel, s, Width, Height);
                    }
                    catch (Exception ex)
                    {
                        Assert.Fail("Exception in " + example.Title + ":" + ex.Message);
                    }
                }

                Assert.IsTrue(File.Exists(path));
            }
        }