/// <summary> /// Implementation for <see cref="SaveCommand" />. /// Creates the project. /// </summary> private void SaveImpl() { // Path verification var file = new FileInfo(Path); if (!Directory.Exists(file.DirectoryName)) { Directory.CreateDirectory(file.DirectoryName); } // TODO: Save plot, according to settings - QuadTree stuff... //if (this.ShowAllData) var encoder = new PngPlotModelEncoder(); var size = new Size(Width, Height); if (DPI.Equals(96)) { encoder.SaveImage(this.plot, Path, size); } else { encoder.SaveImageHighRes(this.plot, Path, size, dpi); } if (this.Complete != null) { this.Complete(this, EventArgs.Empty); } }
/// <summary> /// Save the plots to the specified path, with a specified width, height, and dpi /// </summary> /// <remarks>If the DPI is not 96, the width and height will be scaled so that the image /// provides the needed pixel size for the specified size and DPI</remarks> /// <param name="pathAndPrefix">Path to save the images to, with a trailing '\' or name prefix</param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="dpi"></param> public void SavePlots(string pathAndPrefix, double width, double height, double dpi) { var encoder = new PngPlotModelEncoder(); var size = new Size(width, height); if (dpi.Equals(96)) { encoder.SaveImage(this.Heatmap.Model, pathAndPrefix + "Heatmap.png", size); encoder.SaveImage(this.NetResidual.Model, pathAndPrefix + "NetScan.png", size); encoder.SaveImage(this.MassHistogram.Model, pathAndPrefix + "MassHistogram.png", size); encoder.SaveImage(this.NetHistogram.Model, pathAndPrefix + "NetHistogram.png", size); encoder.SaveImage(this.MassMzResidual.Model, pathAndPrefix + "MassMz.png", size); encoder.SaveImage(this.MassScanResidual.Model, pathAndPrefix + "MassScan.png", size); } else { encoder.SaveImageHighRes(this.Heatmap.Model, pathAndPrefix + "Heatmap.png", size, dpi); encoder.SaveImageHighRes(this.NetResidual.Model, pathAndPrefix + "NetScan.png", size, dpi); encoder.SaveImageHighRes(this.MassHistogram.Model, pathAndPrefix + "MassHistogram.png", size, dpi); encoder.SaveImageHighRes(this.NetHistogram.Model, pathAndPrefix + "NetHistogram.png", size, dpi); encoder.SaveImageHighRes(this.MassMzResidual.Model, pathAndPrefix + "MassMz.png", size, dpi); encoder.SaveImageHighRes(this.MassScanResidual.Model, pathAndPrefix + "MassScan.png", size, dpi); } }