Esempio n. 1
0
 /// <summary>
 /// Exports the specified model.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="fileName">The file name.</param>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="background">The background.</param>
 public static void Export(IPlotModel model, string fileName, int width, int height, Brush background = null)
 {
     var exporter = new PngExporter { Width = width, Height = height, Background = background.ToOxyColor() };
     using (var stream = File.Create(fileName))
     {
         exporter.Export(model, stream);
     }
 }
 /// <summary>
 /// Exports the specified model.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="fileName">The file name.</param>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="background">The background.</param>
 public static void Export(IPlotModel model, string fileName, int width, int height, Brush background = null)
 {
     var exporter = new PngExporter { Width = width, Height = height, Background = background.ToOxyColor() };
     using (var stream = File.Create(fileName))
     {
         exporter.Export(model, stream);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Exports the specified model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="fileName">The file name.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="resolution">The resolution.</param>
        public static void Export(IPlotModel model, string fileName, int width, int height, double resolution = 96)
        {
            var exporter = new PngExporter {
                Width = width, Height = height, Resolution = resolution
            };

            using (var stream = File.Create(fileName))
            {
                exporter.Export(model, stream);
            }
        }
Esempio n. 4
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);
     }
 }
Esempio n. 5
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);
                    }
                }
            }
        }