Esempio n. 1
0
 public static void PrintAllQuantitiesToImage(
     this StatisticsCollection statisticalQuantities, string filePath,
     ChartType chartType = ChartType.Line, ChartImageFormat imageFormat = ChartImageFormat.Png,
     int width           = 1024, int height = 768)
 {
     CreateAndPrintChart(statisticalQuantities, filePath, "Chart", chartType, width, height, imageFormat);
 }
Esempio n. 2
0
        private void exportGraphDialog_FileOk(object sender, CancelEventArgs e)
        {
            string           a           = Path.GetExtension(exportGraphDialog.FileName);
            ChartImageFormat ImageFormat = ChartImageFormat.Png;

            switch (Path.GetExtension(exportGraphDialog.FileName))
            {
            case ".png":
                ImageFormat = ChartImageFormat.Png;
                break;

            case ".jpg":
                ImageFormat = ChartImageFormat.Jpeg;
                break;

            case ".bmp":
                ImageFormat = ChartImageFormat.Bmp;
                break;

            case ".gif":
                ImageFormat = ChartImageFormat.Gif;
                break;
            }
            measureChart.SaveImage(exportGraphDialog.FileName, ImageFormat);
        }
/*
 *      private void ExportToExcel()
 *      {
 *          saveExportFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
 *          DialogResult ret = saveExportFileDialog.ShowDialog();
 *
 *          if (ret == DialogResult.OK)
 *          {
 *              string fileSaveName = saveExportFileDialog.FileName;
 *
 *              if (File.Exists(fileSaveName))
 *                  File.Delete(fileSaveName);
 *
 *
 *              if (Path.GetExtension(fileSaveName).Contains("xlsx")) // 2010
 *              {
 *
 *                  FileInfo newFile = new FileInfo(fileSaveName);
 *                  ExcelPackage pck = new ExcelPackage(newFile);
 *                  {
 *                      //Create the worksheet
 *                      ExcelWorksheet ws1 = pck.Workbook.Worksheets.Add("Fridge Temperature " + _selectedDevice.DeviceName);
 *
 *                      ws1.Cells.Style.Font.Size = 12;
 *                      ws1.Cells.Style.Font.Name = "Verdana";
 *
 *                      //Load the datatable into the sheet, starting from cell A1. Print the column names on row 1
 *                      ws1.Cells["A1"].LoadFromDataTable(_dtTemp, true);
 *
 *                      ws1.Cells[1, 1, 1, _dtTemp.Columns.Count].Style.Font.Bold = true;
 *                      ws1.Cells[1, 1, 1, _dtTemp.Columns.Count].Style.Fill.PatternType = ExcelFillStyle.Solid;
 *                      ws1.Cells[1, 1, 1, _dtTemp.Columns.Count].Style.Fill.BackgroundColor.SetColor(Color.AliceBlue);
 *                      for (int loop = 1; loop <= _dtTemp.Columns.Count; loop++)
 *                          ws1.Column(loop).AutoFit(25);
 *
 *                      pck.Save();
 *                  }
 *              }
 *              else
 *              {
 *
 *                  DBClassSQLite.Export(_dtTemp, fileSaveName, "Fridge Temperature " + _selectedDevice.DeviceName);
 *
 *              }
 *          }
 *      }
 */

        private void toolStripButtonExport_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveGraphAsPictureDialog = new SaveFileDialog();

            saveGraphAsPictureDialog.Filter           = "PNG image (*.png)|*.png|Bitmap image (*.bmp)|*.bmp|JPEG image (*.jpg)|*.jpg";
            saveGraphAsPictureDialog.RestoreDirectory = true;

            if (saveGraphAsPictureDialog.ShowDialog() == DialogResult.OK)
            {
                Stream fileStream;

                if ((fileStream = saveGraphAsPictureDialog.OpenFile()) != null)
                {
                    ChartImageFormat format = ChartImageFormat.Png;

                    switch (saveGraphAsPictureDialog.FilterIndex)
                    {
                    case 1:
                        format = ChartImageFormat.Png;
                        break;

                    case 2:
                        format = ChartImageFormat.Bmp;
                        break;

                    case 3:
                        format = ChartImageFormat.Jpeg;
                        break;
                    }

                    _chartTemp.SaveImage(fileStream, format);
                    fileStream.Close();
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Saves the chart to a memory stream using the given image
 /// <paramref name="format"/> and returns the stream, ready for reading.
 /// </summary>
 /// <param name="chart">The chart to be saved to the stream.</param>
 /// <param name="format">The format to used to save the image.</param>
 /// <returns>The stream containing the chart as an image.</returns>
 public static Stream ConvertToImageStream(this Chart chart, ChartImageFormat format = ChartImageFormat.Png)
 {
     MemoryStream stream = new MemoryStream();
     chart.SaveImage(stream, format);
     stream.Position = 0;
     return stream;
 }
        private void button12_Click(object sender, EventArgs e)
        {
            saveFileDialog1.FileName = DateTime.Now.ToString("dd_MM_yyyy_hhmmss");
            if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                ChartImageFormat cif = ChartImageFormat.Png;
                switch (saveFileDialog1.FilterIndex)
                {
                case 1:
                    cif = ChartImageFormat.Png;
                    break;

                case 2:
                    cif = ChartImageFormat.Jpeg;
                    break;

                case 3:
                    cif = ChartImageFormat.Bmp;
                    break;

                case 4:
                    cif = ChartImageFormat.Gif;
                    break;

                case 5:
                    cif = ChartImageFormat.Tiff;
                    break;
                }
                chart.SaveImage(saveFileDialog1.FileName, cif);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// save chart image to file
        /// </summary>
        /// <param name="fileName">the file name with path and the format.</param>
        public void SaveAsImage(string fileName)
        {
            ChartImageFormat format = ChartImageFormat.Bmp;

            if (fileName.EndsWith("bmp"))
            {
                format = ChartImageFormat.Bmp;
            }
            else if (fileName.EndsWith("jpg"))
            {
                format = ChartImageFormat.Jpeg;
            }
            else if (fileName.EndsWith("emf"))
            {
                format = ChartImageFormat.Emf;
            }
            else if (fileName.EndsWith("gif"))
            {
                format = ChartImageFormat.Gif;
            }
            else if (fileName.EndsWith("png"))
            {
                format = ChartImageFormat.Png;
            }
            else if (fileName.EndsWith("tif"))
            {
                format = ChartImageFormat.Tiff;
            }

            // Save image
            chartMain.SaveImage(fileName, format);
        }
Esempio n. 7
0
        public ChartActionResult(Chart chart, ChartImageFormat imageFormat = ChartImageFormat.Png)
        {
            if (chart == null) { throw new ArgumentNullException("chart"); }

            _chart = chart;
            _imageFormat = imageFormat;
        }
Esempio n. 8
0
 private string AsBase64String(ChartImageFormat chartImageFormat)
 {
     Requires.NotNull(_chart, nameof(_chart));
     using var ms = new MemoryStream();
     _chart.SaveImage(ms, chartImageFormat);
     return(Convert.ToBase64String(ms.ToArray()));
 }
Esempio n. 9
0
        public static void ExportChartToImage(
            string filePath, int width, int height, PlotModel chartModel, ChartImageFormat imageFormat)
        {
            using (var stream = File.Create(filePath))
            {
                switch (imageFormat)
                {
                case ChartImageFormat.Svg:
                    new SvgExporter {
                        Width = width, Height = height
                    }.Export(chartModel, stream);
                    break;

                case ChartImageFormat.Pdf:
                    new PdfExporter {
                        Width = width, Height = height
                    }.Export(chartModel, stream);
                    break;

                default:
                    new PngExporter {
                        Width = width, Height = height
                    }.Export(chartModel, stream);
                    break;
                }
            }
        }
Esempio n. 10
0
        public void SaveChart()
        {
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter = "png|*.png|jpg|*.jpg|tiff|*.tiff";
            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            string           ext    = Path.GetExtension(dlg.FileName);
            ChartImageFormat format = ChartImageFormat.Jpeg;

            switch (ext.ToLower())
            {
            case ".jpg":
                format = ChartImageFormat.Jpeg;
                break;

            case ".png":
                format = ChartImageFormat.Png;
                break;

            case ".tiff":
                format = ChartImageFormat.Tiff;
                break;
            }
            mainChart.SaveImage(dlg.FileName, format);
        }
Esempio n. 11
0
        /// <summary>
        /// Saves the chart to a memory stream using the given image
        /// <paramref name="format"/> and returns the stream, ready for reading.
        /// </summary>
        /// <param name="chart">The chart to be saved to the stream.</param>
        /// <param name="format">The format to used to save the image.</param>
        /// <returns>The stream containing the chart as an image.</returns>
        public static Stream ConvertToImageStream(this Chart chart, ChartImageFormat format = ChartImageFormat.Png)
        {
            MemoryStream stream = new MemoryStream();

            chart.SaveImage(stream, format);
            stream.Position = 0;
            return(stream);
        }
Esempio n. 12
0
        private static Stream ConvertToImage(Chart chart, ChartImageFormat format)
        {
            MemoryStream stream = new MemoryStream();

            chart.SaveImage(stream, format);
            stream.Position = 0;
            return(stream);
        }
Esempio n. 13
0
 private void buttonSavePie_Click(object sender, EventArgs e)
 {
     saveFileDialog1.Filter   = "PNG files (*.png)|*.png";
     saveFileDialog1.FileName = "PieChart";
     if (saveFileDialog1.ShowDialog() != DialogResult.Cancel)
     {
         ChartImageFormat format = ChartImageFormat.Png;
         chartPieNew.SaveImage(saveFileDialog1.FileName, format);
     }
 }
Esempio n. 14
0
        public ChartActionResult(Chart chart, ChartImageFormat imageFormat = ChartImageFormat.Png)
        {
            if (chart == null)
            {
                throw new ArgumentNullException("chart");
            }

            _chart       = chart;
            _imageFormat = imageFormat;
        }
        public void ExportToImage(Chart chart)
        {
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.Filter           = "Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|PNG (*.png)|*.png|GIF (*.gif)|*.gif|TIFF (*.tif)|*.tif|EMF (*.emf)|*.emf|EMF-Plus (*.emf)|*.emf|EMF-Dual (*.emf)|*.emf";
            dialog.RestoreDirectory = true;
            dialog.FileName         = DateTime.Now.ToString("yyyyMMdd_hhmmss");

            if (DialogResult.OK == dialog.ShowDialog())
            {
                string           fileName    = dialog.FileName;
                ChartImageFormat imageFormat = ChartImageFormat.Bmp;

                switch (dialog.FilterIndex)
                {
                case 0:
                    imageFormat = ChartImageFormat.Bmp;
                    break;

                case 1:
                    imageFormat = ChartImageFormat.Jpeg;
                    break;

                case 2:
                    imageFormat = ChartImageFormat.Png;
                    break;

                case 3:
                    imageFormat = ChartImageFormat.Gif;
                    break;

                case 4:
                    imageFormat = ChartImageFormat.Tiff;
                    break;

                case 5:
                    imageFormat = ChartImageFormat.Emf;
                    break;

                case 6:
                    imageFormat = ChartImageFormat.EmfPlus;
                    break;

                case 7:
                    imageFormat = ChartImageFormat.EmfDual;
                    break;

                default:
                    imageFormat = ChartImageFormat.Bmp;
                    break;
                }

                chart.SaveImage(fileName, imageFormat);
            }
        }
Esempio n. 16
0
 private void buttonSavePlot_Click(object sender, EventArgs e)
 {
     saveFileDialog1.Filter   = "PNG files (*.png)|*.png";
     saveFileDialog1.FileName = "Chart";
     if (saveFileDialog1.ShowDialog() != DialogResult.Cancel)
     {
         ChartImageFormat format = ChartImageFormat.Png;
         chartAnova.SaveImage(saveFileDialog1.FileName, format);
         MessageBox.Show("Chart saved");
     }
 }
        private void Save_Click(object sender, System.EventArgs e)
        {
            // Create a new save file dialog
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            // Sets the current file name filter string, which determines
            // the choices that appear in the "Save as file type" or
            // "Files of type" box in the dialog box.
            saveFileDialog1.Filter           = "Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|EMF-Plus (*.emf)|*.emf|EMF-Dual (*.emf)|*.emf|EMF (*.emf)|*.emf|PNG (*.png)|*.png|GIF (*.gif)|*.gif|TIFF (*.tif)|*.tif";
            saveFileDialog1.FilterIndex      = 2;
            saveFileDialog1.RestoreDirectory = true;

            // Set image file format
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                ChartImageFormat format = ChartImageFormat.Bmp;

                if (saveFileDialog1.FileName.EndsWith("bmp"))
                {
                    format = ChartImageFormat.Bmp;
                }
                else if (saveFileDialog1.FileName.EndsWith("jpg"))
                {
                    format = ChartImageFormat.Jpeg;
                }
                else if (saveFileDialog1.FileName.EndsWith("emf") && saveFileDialog1.FilterIndex == 3)
                {
                    format = ChartImageFormat.EmfDual;
                }
                else if (saveFileDialog1.FileName.EndsWith("emf") && saveFileDialog1.FilterIndex == 4)
                {
                    format = ChartImageFormat.EmfPlus;
                }
                else if (saveFileDialog1.FileName.EndsWith("emf"))
                {
                    format = ChartImageFormat.Emf;
                }
                else if (saveFileDialog1.FileName.EndsWith("gif"))
                {
                    format = ChartImageFormat.Gif;
                }
                else if (saveFileDialog1.FileName.EndsWith("png"))
                {
                    format = ChartImageFormat.Png;
                }
                else if (saveFileDialog1.FileName.EndsWith("tif"))
                {
                    format = ChartImageFormat.Tiff;
                }

                // Save image
                Chart1.SaveImage(saveFileDialog1.FileName, format);
            }
        }
Esempio n. 18
0
        private void tbSaveReport_Click(object sender, EventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter = ApplicationStrings.ReportSavingFilter;
            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                ChartImageFormat format = getChartImageFormat(dlg.FileName);
                chart1.SaveImage(dlg.OpenFile(), format);
                dlg.Dispose();
            }
        }
Esempio n. 19
0
        private void button2_Click(object sender, EventArgs e)
        {
            // Create a new save file dialog
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            // Sets the current file name filter string, which determines
            // the choices that appear in the "Save as file type" or
            // "Files of type" box in the dialog box.
            saveFileDialog1.Filter           = "Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|EMF (*.emf)|*.emf|PNG (*.png)|*.png|SVG (*.svg)|*.svg|GIF (*.gif)|*.gif|TIFF (*.tif)|*.tif";
            saveFileDialog1.FilterIndex      = 2;
            saveFileDialog1.RestoreDirectory = true;

            // Set image file format
            ChartImageFormat format = ChartImageFormat.Bmp;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if (saveFileDialog1.FileName.EndsWith("bmp"))
                {
                    format = ChartImageFormat.Bmp;
                }
                else if (saveFileDialog1.FileName.EndsWith("jpg"))
                {
                    format = ChartImageFormat.Jpeg;
                }
                else if (saveFileDialog1.FileName.EndsWith("emf"))
                {
                    format = ChartImageFormat.Emf;
                }
                else if (saveFileDialog1.FileName.EndsWith("gif"))
                {
                    format = ChartImageFormat.Gif;
                }
                else if (saveFileDialog1.FileName.EndsWith("png"))
                {
                    format = ChartImageFormat.Png;
                }
                else if (saveFileDialog1.FileName.EndsWith("tif"))
                {
                    format = ChartImageFormat.Tiff;
                }
                else if (saveFileDialog1.FileName.EndsWith("svg"))
                {
                    format = ChartImageFormat.Bmp;
                }
                string s2 = null;
                //s2 = saveFileDialog1.FileName.ToString();
                // Save image
                this.chart2.SaveImage(saveFileDialog1.FileName, format);//
            }
        }
Esempio n. 20
0
 private bool copyToClipboard(ChartImageFormat chartImgFormat)
 {
     using (MemoryStream stream = new MemoryStream())
     {
         if (chartImgFormat == ChartImageFormat.Emf)
         {
             specGraph.SaveImage(stream, ChartImageFormat.EmfPlus);
             return(HandleMetafiles.CopyEmfToClipboard(this.Handle, stream));
         }
         specGraph.SaveImage(stream, chartImgFormat);
         Clipboard.SetImage(Image.FromStream(stream));
         return(true);
     }
 }
Esempio n. 21
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem menuItem  = (ToolStripMenuItem)sender;
            ContextMenuStrip  menuStrip = (ContextMenuStrip)menuItem.GetCurrentParent();
            Chart             cht       = (Chart)(menuStrip.SourceControl);

            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            // Sets the current file name filter string, which determines
            // the choices that appear in the "Save as file type" or
            // "Files of type" box in the dialog box.
            saveFileDialog1.Filter           = "Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|EMF (*.emf)|*.emf|PNG (*.png)|*.png|GIF (*.gif)|*.gif|TIFF (*.tif)|*.tif";
            saveFileDialog1.FilterIndex      = 2;
            saveFileDialog1.RestoreDirectory = true;

            // Set image file format
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                ChartImageFormat format = ChartImageFormat.Bmp;

                if (saveFileDialog1.FileName.EndsWith("bmp"))
                {
                    format = ChartImageFormat.Bmp;
                }
                else if (saveFileDialog1.FileName.EndsWith("jpg"))
                {
                    format = ChartImageFormat.Jpeg;
                }
                else if (saveFileDialog1.FileName.EndsWith("emf"))
                {
                    format = ChartImageFormat.Emf;
                }
                else if (saveFileDialog1.FileName.EndsWith("gif"))
                {
                    format = ChartImageFormat.Gif;
                }
                else if (saveFileDialog1.FileName.EndsWith("png"))
                {
                    format = ChartImageFormat.Png;
                }
                else if (saveFileDialog1.FileName.EndsWith("tif"))
                {
                    format = ChartImageFormat.Tiff;
                }

                // Save image
                cht.SaveImage(saveFileDialog1.FileName, format);
            }
        }
        public static void PrintStatisticsToCSV(
            this StatisticalQuantity quantity, string filePath, bool printValuesOnly = false,
            bool printImage = true, ChartType chartType       = ChartType.Line,
            int width       = DEFAULT_IMAGE_WIDTH, int height = DEFAULT_IMAGE_HEIGHT,
            ChartImageFormat imageFormat = ChartImageFormat.Pdf)
        {
            quantity.PrintStatisticsToCSV(filePath, printValuesOnly);

            if (printImage)
            {
                quantity.PrintStatisticsToImage(
                    PathUtil.ReplaceExtension(filePath, imageFormat.ToString().ToLower()),
                    chartType, width, height, imageFormat);
            }
        }
        public static void PrintStatisticsToImage(
            this StatisticalQuantity quantity, string filePath, ChartType chartType,
            int width = DEFAULT_IMAGE_WIDTH, int height = DEFAULT_IMAGE_HEIGHT,
            ChartImageFormat imageFormat = ChartImageFormat.Pdf)
        {
            if ((quantity.Samples == null) || (quantity.Samples.Length == 0))
            {
                return;
            }

            //creates chart
            var title = Path.GetFileNameWithoutExtension(filePath);

            new StatisticsCollection {
                { title, quantity }
            }.CreateAndPrintChart(
                filePath, title, chartType, width, height, imageFormat);
        }
Esempio n. 24
0
        private void  SaveChartToDisk(Object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter          = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif|Tab-Del|*.txt";
            sfd.Title           = "Save chart as Image File";
            sfd.DefaultExt      = "jpg";
            sfd.AddExtension    = true;
            sfd.OverwritePrompt = true;
            //sfd.CheckFileExists = true;
            DialogResult dr = sfd.ShowDialog(this);

            if (dr == DialogResult.OK)
            {
                String             fn  = sfd.FileName;
                System.IO.FileInfo fi  = new System.IO.FileInfo(fn);
                String             ext = fi.Extension.ToLower();

                ChartImageFormat cif = ChartImageFormat.Jpeg;
                if (ext == ".jpg")
                {
                    cif = ChartImageFormat.Jpeg;
                }

                else if (ext == ".bmp")
                {
                    cif = ChartImageFormat.Bmp;
                }

                else if (ext == ".gif")
                {
                    cif = ChartImageFormat.Gif;
                }

                else if (ext == ".txt")
                {
                    SaveTabDelToDisk(fn);
                    return;
                }

                ProfileChart.SaveImage(fn, cif);
            }
        }
Esempio n. 25
0
        public static PlotModel CreateAndPrintChart(
            this StatisticsCollection statisticalQuantities,
            string filePath, string chartName, ChartType chartType = ChartType.Line,
            int width = 640, int height = 480, ChartImageFormat imageFormat = ChartImageFormat.Png)
        {
            var dataCollection = CreateDataPointCollection(statisticalQuantities);

            //ignore if no data
            if (dataCollection.Count == 0)
            {
                return(null);
            }

            //creates chart
            var chartModel = PlottingUtil.CreateAndPrintChart(
                dataCollection, filePath, chartName, chartType, width, height, imageFormat);

            return(chartModel);
        }
Esempio n. 26
0
        }//需要新建线程保存

        private void InvokeMethod()
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Title = "请选择要保存的文件路径";                      //设置保存文件对话框的标题

            sfd.InitialDirectory = Application.StartupPath; //初始化保存目录,默认exe文件目录
            //设置保存文件的类型
            sfd.Filter           = "Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|EMF (*.emf)|*.emf|PNG (*.png)|*.png|SVG (*.svg)|*.svg|GIF (*.gif)|*.gif|TIFF (*.tif)|*.tif";
            sfd.FilterIndex      = 2;
            sfd.RestoreDirectory = true;
            if (sfd.ShowDialog() == DialogResult.OK)//设置图片文件格式format
            {
                ChartImageFormat format = ChartImageFormat.Bmp;

                if (sfd.FileName.EndsWith("bmp"))
                {
                    format = ChartImageFormat.Bmp;
                }
                else if (sfd.FileName.EndsWith("jpg"))
                {
                    format = ChartImageFormat.Jpeg;
                }
                else if (sfd.FileName.EndsWith("emf"))
                {
                    format = ChartImageFormat.Emf;
                }
                else if (sfd.FileName.EndsWith("gif"))
                {
                    format = ChartImageFormat.Gif;
                }
                else if (sfd.FileName.EndsWith("png"))
                {
                    format = ChartImageFormat.Png;
                }
                else if (sfd.FileName.EndsWith("tif"))
                {
                    format = ChartImageFormat.Tiff;
                }
                string filePath = sfd.FileName;         //获得保存文件的路径
                chart1.SaveImage(sfd.FileName, format); //保存
            }
        }//保存函数
        /// <summary>
        /// Save the specified graph to a determined file type
        /// </summary>
        /// <param name="graphingChart">
        /// Chart used to display the results of packet matching
        /// </param>
        public void SaveGraphResults(Chart graphingChart)
        {
            // Ask the user to select a file for the graph to be save under
            var sfd = new SaveFileDialog()
            {
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
                Filter           = "Bitmap Image (.bmp)|*.bmp|Gif Image (.gif)|*.gif|JPEG Image (.jpeg)|*.jpeg|Png Image (.png)|*.png|Tiff Image (.tiff)|*.tiff",
                FilterIndex      = 0
            };

            // repeat while there are errors
            do
            {
                sfd.ShowDialog();
            } while (sfd.FileName == "" || System.IO.File.Exists(sfd.FileName));

            // initialize the format to bmp
            ChartImageFormat chartImageFormat = ChartImageFormat.Bmp;

            // correct the format if otherwise specified
            switch (sfd.FilterIndex)
            {
            case 2:
                chartImageFormat = ChartImageFormat.Gif;
                break;

            case 3:
                chartImageFormat = ChartImageFormat.Jpeg;
                break;

            case 4:
                chartImageFormat = ChartImageFormat.Png;
                break;

            case 5:
                chartImageFormat = ChartImageFormat.Tiff;
                break;
            }

            // save the image with the entered file name and format
            graphingChart.SaveImage(sfd.FileName, chartImageFormat);
        }
Esempio n. 28
0
        public bool SaveGraph()
        {
            SaveFileDialog sfdSave = new SaveFileDialog();

            sfdSave.Filter           = "Bitmap (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg|EMF (*.emf)|*.emf|PNG (*.png)|*.png|GIF (*.gif)|*.gif|TIFF (*.tif)|*.tif";
            sfdSave.FilterIndex      = 2;
            sfdSave.RestoreDirectory = true;
            if (sfdSave.ShowDialog() == DialogResult.OK)
            {
                ChartImageFormat format = ChartImageFormat.Bmp;
                if (sfdSave.FileName.EndsWith("jpg"))
                {
                    format = ChartImageFormat.Jpeg;
                }
                else
                if (sfdSave.FileName.EndsWith("emf"))
                {
                    format = ChartImageFormat.Emf;
                }
                else
                if (sfdSave.FileName.EndsWith("gif"))
                {
                    format = ChartImageFormat.Gif;
                }
                else
                if (sfdSave.FileName.EndsWith("png"))
                {
                    format = ChartImageFormat.Png;
                }
                else
                if (sfdSave.FileName.EndsWith("tif"))
                {
                    format = ChartImageFormat.Tiff;
                }
                this.SaveImage(sfdSave.FileName, format);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 29
0
        private void 绘图另存为SToolStripMenuItem_Click(object sender, EventArgs e)
        {
            saveFileDialog1.FileName = this.Text;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                var extension = Path.GetExtension(saveFileDialog1.FileName).ToLower();
                ChartImageFormat chartImage = ChartImageFormat.Bmp;
                if (extension.Contains("png"))
                {
                    chartImage = ChartImageFormat.Png;
                }
                if (extension.Contains("jpg"))
                {
                    chartImage = ChartImageFormat.Jpeg;
                }
                this.chart1.SaveImage(saveFileDialog1.FileName, chartImage);
                Geo.Utils.FormUtil.ShowOkAndOpenDirectory(Path.GetDirectoryName(saveFileDialog1.FileName));
            }
        }
Esempio n. 30
0
        private ChartImageFormat getChartImageFormat(string filename)
        {
            ChartImageFormat format = ChartImageFormat.Png;

            switch (Path.GetExtension(filename))
            {
            case ".png":
                format = ChartImageFormat.Png;
                break;

            case ".jpg":
                format = ChartImageFormat.Jpeg;
                break;

            case ".bmp":
                format = ChartImageFormat.Bmp;
                break;
            }
            return(format);
        }
Esempio n. 31
0
        /// <summary>
        /// Построить графики с помощью NMathChart.
        /// </summary>
        /// <param name="m">Количество рисунков.</param>
        /// <param name="matrix">Исходная матрица.</param>
        /// <param name="x0">Начальное значение.</param>
        /// <param name="n">Количество точек.</param>
        /// <param name="t0">Начальное время.</param>
        /// <param name="dt">Шаг по времени.</param>
        private static void PlotByNMath(int m, SquareMatrix matrix, ColumnVector x0, int n, double t0, double dt)
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, commandLineOptions.PicsPath);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            const ChartImageFormat format = ChartImageFormat.Png;

            for (var i = 0; i < m; i++)
            {
                Console.Write($"Plotting {i}-th frame . . . ");
                CalculateSupportingFunctionOfReachableSet(matrix, x0, n, t0, t0 + dt * i,
                                                          x => new ColumnVector(Cos(x), Sin(x)), out var psi, out var supportingFunctionOfReachableSet);
                CalculatePointsForPlot(n, psi, supportingFunctionOfReachableSet, out var data);

                var chart = NMathChart.ToChart(new FloatMatrix(data), 0, 1);
                chart.Size = new Size(3840, 2160);
                NMathChart.Save(chart, $@"{path}\{i}.{format}", format);
                Console.WriteLine($"{i}-th frame saved\n");
            }
        }
Esempio n. 32
0
        private void exportChartToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Set image file format
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                ChartImageFormat format   = ChartImageFormat.Bmp;
                string           filename = saveFileDialog.FileName.ToLower();
                if (filename.EndsWith("bmp"))
                {
                    format = ChartImageFormat.Bmp;
                }
                else if (filename.EndsWith("jpg"))
                {
                    format = ChartImageFormat.Jpeg;
                }
                else if (filename.EndsWith("emf"))
                {
                    format = ChartImageFormat.EmfDual;
                }
                else if (filename.EndsWith("gif"))
                {
                    format = ChartImageFormat.Gif;
                }
                else if (filename.EndsWith("png"))
                {
                    format = ChartImageFormat.Png;
                }
                else if (filename.EndsWith("tif"))
                {
                    format = ChartImageFormat.Tiff;
                }

                // Save image
                SaveImage(saveFileDialog.FileName, format);
            }
        }
Esempio n. 33
0
File: Chart.cs Progetto: GirlD/mono
		public void SaveImage (Stream imageStream, ChartImageFormat format)
		{
			throw new NotImplementedException ();
		}
Esempio n. 34
0
		/// <summary>
		/// Save graph to image file
		/// </summary>
		/// <param name="fileName">Image filename</param>
		/// <param name="format">Image format</param>
		public void SaveImage(string fileName, ChartImageFormat format)
		{
			this.chart.SaveImage(fileName, format);
		}
Esempio n. 35
0
File: Chart.cs Progetto: GirlD/mono
		public void SaveImage (string imageFileName, ChartImageFormat format)
		{
			throw new NotImplementedException ();
		}