/// <summary> /// Pops up the Save Image dialog /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveImageButton_Click(object sender, EventArgs e) { SaveImage dlg = new SaveImage(); if (dlg.ShowDialog() == DialogResult.OK) { MainChart.SaveImage(dlg.ImageSize, dlg.FileName, dlg.ImageFormat); } MainChart.Focus(); dlg.Dispose(); }
//-------------------------------------------------------------------------------------------------------------------------------------------------------- private void SaveImageButton_Click(object sender, EventArgs e) { var saveFileDialog = new SaveFileDialog(); saveFileDialog.Title = "Wählen Sie ein Speicherort aus"; saveFileDialog.Filter = "PNG File|*.png"; saveFileDialog.InitialDirectory = LastFileDir; var objResult = saveFileDialog.ShowDialog(this); if (objResult == DialogResult.OK) { var DataFileIsALog = ((DataFile)FileSelectionBox.Tag).IsALog; if (DataFileIsALog || !FirstDataTypeSelectionBox.SelectedItem.ToString().Equals(SecondDataTypeSelectionBox.SelectedItem.ToString(), StringComparison.InvariantCultureIgnoreCase)) { if ((((int)ChartImageWidthControl.Value) != MainChart.Size.Width) || (((int)ChartImageHeightControl.Value) != MainChart.Size.Height)) { var VirtualChart = new Chart(); VirtualChart.Visible = false; VirtualChart.Width = (int)ChartImageWidthControl.Value; VirtualChart.Height = (int)ChartImageHeightControl.Value; VirtualChart.Palette = ChartColorPalette.Bright; VirtualChart.ChartAreas.Add(new ChartArea()); VirtualChart.Titles.Add("Performance"); VirtualChart.AntiAliasing = AntiAliasingStyles.Text; VirtualChart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Arial", VirtualChart.Width / 150, FontStyle.Regular); VirtualChart.ChartAreas[0].AxisX.LabelStyle.Font = new Font("Arial", VirtualChart.Width / 150, FontStyle.Regular); VirtualChart.Titles[0].Font = new Font("Arial", VirtualChart.Width / 150, FontStyle.Regular); var FirstData = ((DataFile)FileSelectionBox.Tag).GetDataSet(FirstDataTypeSelectionBox.SelectedItem.ToString()); DataSet SecondData = null; if (!DataFileIsALog) { SecondData = ((DataFile)FileSelectionBox.Tag).GetDataSet(SecondDataTypeSelectionBox.SelectedItem.ToString()); } if (DataFileIsALog || (FirstData.AVGValue > SecondData.AVGValue)) { if (DataFileIsALog) { VirtualChart.ChartAreas[0].AxisY.Maximum = FirstData.AVGValue * 2; } else { VirtualChart.ChartAreas[0].AxisY.Maximum = FirstData.MaxValue; } } else { if (DataFileIsALog) { VirtualChart.ChartAreas[0].AxisY.Maximum = SecondData.AVGValue * 2; } else { VirtualChart.ChartAreas[0].AxisY.Maximum = SecondData.MaxValue; } } VirtualChart.ChartAreas[0].AxisY.Minimum = 0; VirtualChart.Series.Clear(); VirtualChart.Legends.Clear(); var CurSeries = VirtualChart.Series.Add(FirstDataTypeSelectionBox.SelectedItem.ToString() + ": AVG~" + FirstData.AVGValue.ToString()); VirtualChart.Legends.Add(new Legend("Legend1")); VirtualChart.Legends["Legend1"].Font = new Font("Arial", VirtualChart.Width / 150, FontStyle.Regular); CurSeries.Legend = "Legend1"; CurSeries.IsVisibleInLegend = true; for (int i2 = 0; i2 < FirstData.DataValues.Count; i2++) { CurSeries.Points.Add(FirstData.DataValues[i2]); } if (!DataFileIsALog) { CurSeries = VirtualChart.Series.Add(SecondDataTypeSelectionBox.SelectedItem.ToString() + ": AVG~" + SecondData.AVGValue.ToString()); for (int i2 = 0; i2 < SecondData.DataValues.Count; i2++) { CurSeries.Points.Add(SecondData.DataValues[i2]); } } VirtualChart.SaveImage(saveFileDialog.FileName, ChartImageFormat.Png); } else { MainChart.SaveImage(saveFileDialog.FileName, ChartImageFormat.Png); } MessageBox.Show("Bild wurde gespeichert"); } } }