Ejemplo n.º 1
0
        /// <summary>
        /// Method to invoke when the ExportPngCommand command is executed.
        /// </summary>
        private async Task OnExportPngCommandExecute()
        {
            var saveFileService = ServiceLocator.Default.ResolveType <ISaveFileService>();

            try
            {
                saveFileService.Filter = "Plot Image|*.png";
                if (!string.IsNullOrEmpty(PlotModel.SavePngPath))
                {
                    saveFileService.InitialDirectory = Path.GetDirectoryName(PlotModel.SavePngPath);
                    if (!Directory.Exists(saveFileService.InitialDirectory))
                    {
                        saveFileService.InitialDirectory = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\Data"));
                    }
                    saveFileService.FileName = Path.GetFileNameWithoutExtension(PlotModel.SavePngPath);
                }
                else
                {
                    saveFileService.InitialDirectory = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"..\Data"));
                }
                if (saveFileService.DetermineFile())
                {
                    var pngExporter = new OxyPlot.Wpf.PngExporter {
                        Width = (int)OxyPlotModel.Width, Height = (int)OxyPlotModel.Height, Background = OxyColors.White
                    };
                    pngExporter.ExportToFile(OxyPlotModel, saveFileService.FileName);
                    if (PlotModel.SavePngPath != saveFileService.FileName)
                    {
                        PlotModel.SavePngPath = saveFileService.FileName;
                    }
                    LogTo.Info("Saved Plot image to: {0}", PlotModel.SavePngPath);
                }
            }
            catch (Exception ex)
            {
                string errmsg = string.Format("Error saving Plot image: {0}", ex.Message);
                LogTo.Error(errmsg);
                await Shared.Utility.ShowErrorMsgAsync(this, errmsg);
            }
        }
Ejemplo n.º 2
-1
 public void export(string outputFolder)
 {
     string fileName;
     //as png
     fileName = outputFolder + "/" + name + ".png";
     var pngExporter = new PngExporter { Width = 600, Height = 400, Background = OxyColors.Transparent };
     pngExporter.ExportToFile(m_plot, fileName);
     //as svg
     fileName = outputFolder + "/" + name + ".svg";
     var svgExporter = new OxyPlot.Wpf.SvgExporter { Width = 600, Height = 400 };
     svgExporter.ExportToFile(m_plot, fileName);
 }