Ejemplo n.º 1
0
        private static async Task Export(PlotModel model, string name)
        {
            var fileName  = Path.Combine(OutputDirectory, name + ".png");
            var directory = Path.GetDirectoryName(fileName) ?? ".";

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

            if (ExportPng)
            {
                Console.WriteLine(fileName);
                using (var stream = File.Create(fileName))
                {
                    var exporter = new PngExporter {
                        Width = 600, Height = 400
                    };
                    exporter.Export(model, stream);
                }

                await OptimizePng(fileName);
            }

            if (ExportPdf)
            {
                fileName = Path.ChangeExtension(fileName, ".pdf");
                Console.WriteLine(fileName);
                using (var stream = File.Create(fileName))
                {
                    var exporter = new PdfExporter {
                        Width = 600d * 72 / 96, Height = 400d * 72 / 96
                    };
                    exporter.Export(model, stream);
                }
            }

            if (ExportSvg)
            {
                fileName = Path.ChangeExtension(fileName, ".svg");
                Console.WriteLine(fileName);

                using (var stream = File.Create(fileName))
                {
                    using (var exporter = new OxyPlot.WindowsForms.SvgExporter {
                        Width = 600, Height = 400, IsDocument = true
                    })
                    {
                        exporter.Export(model, stream);
                    }
                }
            }
        }
        private static void Export(PlotModel model, string name)
        {
            var fileName = Path.Combine(OutputDirectory, name + ".png");

            Console.WriteLine(fileName);
            using (var stream = File.Create(fileName))
            {
                var exporter = new PngExporter {
                    Width = 600, Height = 400
                };
                exporter.Export(model, stream);
            }

            fileName = Path.ChangeExtension(fileName, ".pdf");
            Console.WriteLine(fileName);
            using (var stream = File.Create(fileName))
            {
                var exporter = new PdfExporter {
                    Width = 600d * 72 / 96, Height = 400d * 72 / 96
                };
                exporter.Export(model, stream);
            }

            fileName = Path.ChangeExtension(fileName, ".svg");
            Console.WriteLine(fileName);

            using (var stream = File.Create(fileName))
            {
                using (var exporter = new OxyPlot.WindowsForms.SvgExporter
                {
                    Width = 600,
                    Height = 400,
                    IsDocument = true
                })
                {
                    exporter.Export(model, stream);
                }
            }
        }
Ejemplo n.º 3
0
 public void Save(string path, int width, int height, int dpi = 96)
 {
     using (var stream = File.Create(path + ".png"))
     {
         var pngexporter = new OxyPlot.WindowsForms.PngExporter
         {
             Width      = width,
             Height     = height,
             Resolution = dpi
         };
         pngexporter.Export(Model, stream);
     }
     using (var stream = File.Create(path + ".svg"))
     {
         var svgexporter = new OxyPlot.WindowsForms.SvgExporter
         {
             Width      = width,
             Height     = height,
             IsDocument = true
         };
         svgexporter.Export(Model, stream);
     }
 }
Ejemplo n.º 4
0
        private static void Export(PlotModel model, string name)
        {
            var fileName = Path.Combine(OutputDirectory, name + ".png");
            var directory = Path.GetDirectoryName(fileName) ?? ".";
            
            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            if (ExportPng)
            {
                Console.WriteLine(fileName);
                using (var stream = File.Create(fileName))
                {
                    var exporter = new PngExporter { Width = 600, Height = 400 };
                    exporter.Export(model, stream);
                }

                OptimizePng(fileName);
            }

            if (ExportPdf)
            {
                fileName = Path.ChangeExtension(fileName, ".pdf");
                Console.WriteLine(fileName);
                using (var stream = File.Create(fileName))
                {
                    var exporter = new PdfExporter { Width = 600d * 72 / 96, Height = 400d * 72 / 96 };
                    exporter.Export(model, stream);
                }
            }

            if (ExportSvg)
            {
                fileName = Path.ChangeExtension(fileName, ".svg");
                Console.WriteLine(fileName);

                using (var stream = File.Create(fileName))
                {
                    using (var exporter = new OxyPlot.WindowsForms.SvgExporter { Width = 600, Height = 400, IsDocument = true })
                    {
                        exporter.Export(model, stream);
                    }
                }
            }
        }