private void SavePng_Click(object sender, RoutedEventArgs e)
        {
            var d = new SaveFileDialog {
                Filter = "Png files (*.png)|*.png", DefaultExt = ".png"
            };

            if (true == d.ShowDialog())
            {
                using (var s = d.OpenFile())
                {
                    PngExporter.Export(this.plot1.ActualModel, s, this.plot1.ActualWidth, this.plot1.ActualHeight, OxyColors.Transparent);
                }
            }
        }
Exemple #2
0
        private void SavePng_Click(object sender, RoutedEventArgs e)
        {
            var d = new SaveFileDialog {
                Filter = "Png files (*.png)|*.png", DefaultExt = ".png"
            };

            if (d.ShowDialog().Value)
            {
                using (var s = d.OpenFile())
                {
                    PngExporter.Export(Plot1.ActualModel, s, Plot1.ActualWidth, Plot1.ActualHeight);
                }
            }
        }
        private Report CreateReport(string fileName)
        {
            string ext = Path.GetExtension(fileName);

            ext = ext.ToLower();

            var r = new Report();

            r.Title = "Oxyplot example report";

            var main = new ReportSection();

            r.AddHeader(1, "Example report from OxyPlot");

            // r.AddHeader(2, "Content");
            // r.AddTableOfContents(main);
            r.Add(main);

            main.AddHeader(2, "Introduction");
            main.AddParagraph("The content in this file was generated by OxyPlot.");
            main.AddParagraph("See http://oxyplot.codeplex.com for more information.");

            var dir  = Path.GetDirectoryName(fileName);
            var name = Path.GetFileNameWithoutExtension(fileName);

            string fileNameWithoutExtension = Path.Combine(dir, name);

            main.AddHeader(2, "Plot");
            main.AddParagraph("This plot was rendered to a file and included in the report as a plot.");
            main.AddPlot(this.Model, "Plot", 800, 500);

            main.AddHeader(2, "Drawing");
            main.AddParagraph("Not yet implemented.");

            /*            switch (ext)
             *          {
             *              case ".html":
             *                  {
             *                      main.AddHeader(2, "Plot (svg)");
             *                      main.AddParagraph("This plot was rendered to a .svg file and included in the report.");
             *                      main.AddPlot(Model, "SVG plot", 800, 500);
             *
             *                      //main.AddHeader(2, "Drawing (vector)");
             *                      //main.AddParagraph("This plot was rendered to SVG and included in the report as a drawing.");
             *                      //var svg = Model.ToSvg(800, 500);
             *                      //main.AddDrawing(svg, "SVG plot as a drawing.");
             *                      break;
             *                  }
             *              case ".pdf":
             *              case ".tex":
             *                  {
             *                      main.AddHeader(2, "Plot (vector)");
             *                      main.AddParagraph("This plot was rendered to a .pdf file and included in the report.");
             *                      main.AddPlot(Model, "PDF plot", 800, 500);
             *                      //var pdfPlotFileName = fileNameWithoutExtension + "_plot.pdf";
             *                      //PdfExporter.Export(Model, pdfPlotFileName, 800, 500);
             *                      //main.AddParagraph("This plot was rendered to PDF and embedded in the report.");
             *                      //main.AddImage(pdfPlotFileName, "PDF plot");
             *                      break;
             *                  }
             *              case ".docx":
             *                  {
             *                      main.AddHeader(2, "Plot");
             *                      main.AddParagraph("This plot was rendered to a .png file and included in the report.");
             *                      main.AddPlot(Model, "Plot", 800, 500);
             *                  }
             *                  break;
             *          }*/
            main.AddHeader(2, "Image");
            main.AddParagraph("The plot is rendered to a .png file and included in the report as an image. Zoom in to see the difference.");

            string pngPlotFileName = fileNameWithoutExtension + "_Plot2.png";

            PngExporter.Export(this.Model, pngPlotFileName, 800, 500, OxyColors.Automatic);
            main.AddImage(pngPlotFileName, "Plot as image");

            main.AddHeader(2, "Data");
            int i = 1;

            foreach (OxyPlot.Series.DataPointSeries s in this.Model.Series)
            {
                main.AddHeader(3, "Data series " + (i++));
                var pt = main.AddPropertyTable("Properties of the " + s.GetType().Name, new[] { s });
                pt.Fields[0].Width = 50;
                pt.Fields[1].Width = 100;

                var fields = new List <ItemsTableField>
                {
                    new ItemsTableField("X", "X")
                    {
                        Width = 60, StringFormat = "0.00"
                    },
                    new ItemsTableField("Y", "Y")
                    {
                        Width = 60, StringFormat = "0.00"
                    }
                };
                main.Add(new ItemsTable {
                    Caption = "Data", Fields = fields, Items = s.Points
                });
            }

            // main.AddHeader(3, "Equations");
            // main.AddEquation(@"E = m \cdot c^2");
            // main.AddEquation(@"\oint \vec{B} \cdot d\vec{S} = 0");
            return(r);
        }