コード例 #1
0
ファイル: MapPresenter.cs プロジェクト: pre078/ApsimX
        /// <summary>Export the map to PDF</summary>
        /// <param name="workingDirectory"></param>
        /// <returns></returns>
        internal string ExportToPDF(string folder)
        {
            string path     = Apsim.FullPath(map).Replace(".Simulations.", "");
            string fileName = Path.Combine(folder, path + ".png");

            Image rawImage = view.Export();

            rawImage.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);


            // The numbers below are optimised for generation of PDF document
            // on a computer that has its display settings at 100%.
            //double targetWidth = 650;
            //double targetHeight = 450;

            //// Determine scaling.
            //double scale = Math.Min(targetWidth / rawImage.Width, targetHeight / rawImage.Height);
            //var scaleWidth = (int)(rawImage.Width * scale);
            //var scaleHeight = (int)(rawImage.Height * scale);
            //var scaleRectangle = new Rectangle(((int)targetWidth - scaleWidth) / 2, ((int)targetHeight - scaleHeight) / 2, scaleWidth, scaleHeight);

            //// Create a scaled image.
            //Bitmap scaledImage = new Bitmap((int) targetWidth, (int) targetHeight);
            //using (var graph = Graphics.FromImage(scaledImage))
            //{
            //    graph.DrawImage(rawImage, scaleRectangle);

            //    scaledImage.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);

            return(fileName);
            //}
        }
コード例 #2
0
        /// <summary>Export the map to PDF</summary>
        /// <param name="workingDirectory"></param>
        /// <returns></returns>
        internal string ExportToPDF(string folder)
        {
            string path     = Apsim.FullPath(map).Replace(".Simulations.", "");
            string fileName = Path.Combine(folder, path + ".png");

            Image rawImage = view.Export();

            rawImage.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);

            return(fileName);
        }