Index: branches/HiveStatistics/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/ImageExportDialog.cs
===================================================================
--- branches/HiveStatistics/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/ImageExportDialog.cs	(revision 11202)
+++ branches/HiveStatistics/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/ImageExportDialog.cs	(revision 11203)
@@ -1,5 +1,5 @@
 ﻿#region License Information
 /* HeuristicLab
- * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
  *
  * This file is part of HeuristicLab.
@@ -25,5 +25,4 @@
 using System.Drawing.Imaging;
 using System.IO;
-using System.Linq;
 using System.Windows.Forms;
 using System.Windows.Forms.DataVisualization.Charting;
@@ -59,25 +58,24 @@
         else lengthUnitComboBox.SelectedIndex = 0;
 
-        titleFontSizeComboBox.Text = "10";
+        titleFontSizeComboBox.Text = "12";
         axisFontSizeComboBox.Text = "8";
         scalesFontSizeComboBox.Text = "6";
         legendFontSizeComboBox.Text = "6";
-        resolutionComboBox.Text = "150";
+        resolutionComboBox.Text = "300";
         SuppressEvents = false;
         splitContainer.Panel2Collapsed = true;
         Width = 305;
-        Height = 625;
-      }
-      finally { SuppressEvents = false; }
+        Height = 550;
+      } finally { SuppressEvents = false; }
       #endregion
     }
 
     private void UpdateFields() {
-      var area = GetCurrentChartArea();
+      ChartArea area = GetCurrentChartArea();
 
       try {
         SuppressEvents = true;
 
-        if (workingChart.Titles.Count == 0) titleFontSizeComboBox.Text = "10";
+        if (workingChart.Titles.Count == 0) titleFontSizeComboBox.Text = "12";
         else {
           titleTextBox.Text = workingChart.Titles[0].Text;
@@ -92,8 +90,7 @@
         axisFontSizeComboBox.Text = area.AxisX.TitleFont.SizeInPoints.ToString();
         scalesFontSizeComboBox.Text = area.AxisX.LabelStyle.Font.SizeInPoints.ToString();
-        if (workingChart.Legends.Count == 0) legendFontSizeComboBox.Text = "6";
+        if (workingChart.Legends.Count == 0) legendFontSizeComboBox.Text = "8";
         else legendFontSizeComboBox.Text = workingChart.Legends[0].Font.SizeInPoints.ToString();
-      }
-      finally {
+      } finally {
         SuppressEvents = false;
       }
@@ -124,5 +121,5 @@
       }
 
-      var scaleFactor = (float)Math.Min(previewWidth / width, previewHeight / height);
+      float scaleFactor = (float)Math.Min(previewWidth / width, previewHeight / height);
       if (scaleFactor >= 1) {
         previewZoomLabel.Text = "100%";
@@ -132,5 +129,5 @@
       rawImageSizeLabel.Text = GetRawImageSizeInMegabytes(width, height).ToString("0.00") + "M   " + "(" + Math.Round(width).ToString("0") + " x " + Math.Round(height).ToString("0") + ") pixels";
 
-      var image = new Bitmap(previewWidth, previewHeight);
+      Bitmap image = new Bitmap(previewWidth, previewHeight);
       image.SetResolution(dpi, dpi);
       using (Graphics graphics = Graphics.FromImage(image)) {
@@ -158,15 +155,12 @@
       originalChart.Serializer.Content = SerializationContents.Default;
       originalChart.Serializer.Format = SerializationFormat.Binary;
-      using (var ms = new MemoryStream()) {
-        originalChart.Serializer.Save(ms);
-
-        ms.Seek(0, SeekOrigin.Begin);
-        workingChart = new EnhancedChart();
-        workingChart.Serializer.Format = originalChart.Serializer.Format;
-        workingChart.Serializer.Load(ms);
-      }
-
-      foreach (var s in workingChart.Series.Where(x => !x.Points.Any()).ToArray())
-        s.IsVisibleInLegend = false;
+      MemoryStream ms = new MemoryStream();
+      originalChart.Serializer.Save(ms);
+
+      ms.Seek(0, SeekOrigin.Begin);
+      workingChart = new EnhancedChart();
+      workingChart.Serializer.Format = originalChart.Serializer.Format;
+      workingChart.Serializer.Load(ms);
+      ms.Close();
 
       originalChart.Serializer.Content = prevContent;
@@ -175,42 +169,8 @@
 
       chartAreaComboBox.Items.Clear();
-      foreach (var area in originalChart.ChartAreas) {
+      foreach (ChartArea area in originalChart.ChartAreas) {
         chartAreaComboBox.Items.Add(area.Name);
       }
       chartAreaComboBox.SelectedIndex = 0;
-      SuppressEvents = true;
-      try {
-        showPrimaryXAxisCheckBox.Checked = originalChart.Series.Any(x => x.XAxisType == AxisType.Primary);
-        showPrimaryYAxisCheckBox.Checked = originalChart.Series.Any(x => x.YAxisType == AxisType.Primary);
-        showSecondaryXAxisCheckBox.Checked = originalChart.Series.Any(x => x.XAxisType == AxisType.Secondary);
-        showSecondaryYAxisCheckBox.Checked = originalChart.Series.Any(x => x.YAxisType == AxisType.Secondary);
-
-        if (!workingChart.Legends.Any()) {
-          legendPositionComboBox.Enabled = false;
-          legendFontSizeComboBox.Enabled = false;
-        } else {
-          legendPositionComboBox.Enabled = true;
-          legendFontSizeComboBox.Enabled = true;
-          if (workingChart.Legends[0].Enabled) {
-            switch (workingChart.Legends[0].Docking) {
-              case Docking.Top:
-                legendPositionComboBox.SelectedItem = "Top";
-                break;
-              case Docking.Right:
-                legendPositionComboBox.SelectedItem = "Right";
-                break;
-              case Docking.Bottom:
-                legendPositionComboBox.SelectedItem = "Bottom";
-                break;
-              case Docking.Left:
-                legendPositionComboBox.SelectedItem = "Left";
-                break;
-            }
-          } else {
-            legendPositionComboBox.SelectedItem = "Hidden";
-          }
-        }
-      }
-      finally { SuppressEvents = false; }
       base.OnShown(e);
 
@@ -233,45 +193,12 @@
     }
 
-    private void legendPositionComboBox_SelectedIndexChanged(object sender, EventArgs e) {
-      if (!SuppressEvents) {
-        if (legendPositionComboBox.SelectedIndex >= 0) {
-          var legend = workingChart.Legends[0];
-          var legendPosition = legendPositionComboBox.Items[legendPositionComboBox.SelectedIndex].ToString();
-          if (legendPosition != "Hidden" && !legend.Enabled)
-            legend.Enabled = true;
-          switch (legendPosition) {
-            case "Top":
-              legend.Docking = Docking.Top;
-              break;
-            case "Right":
-              legend.Docking = Docking.Right;
-              break;
-            case "Bottom":
-              legend.Docking = Docking.Bottom;
-              break;
-            case "Left":
-              legend.Docking = Docking.Left;
-              break;
-            case "Hidden":
-              legend.Enabled = false;
-              break;
-          }
-        }
-        UpdatePreview();
-      }
-    }
-
     private void titleTextBox_TextChanged(object sender, EventArgs e) {
       if (!SuppressEvents) {
-        if (string.IsNullOrEmpty(titleTextBox.Text))
-          workingChart.Titles.Clear();
-        else {
-          if (workingChart.Titles.Count > 0) {
-            workingChart.Titles[0].Text = titleTextBox.Text;
-          } else {
-            var t = new Title(titleTextBox.Text);
-            t.Font = ChangeFontSizePt(t.Font, float.Parse(titleFontSizeComboBox.Text));
-            workingChart.Titles.Add(t);
-          }
+        if (workingChart.Titles.Count > 0) {
+          workingChart.Titles[0].Text = titleTextBox.Text;
+        } else {
+          Title t = new Title(titleTextBox.Text);
+          t.Font = ChangeFontSizePt(t.Font, float.Parse(titleFontSizeComboBox.Text));
+          workingChart.Titles.Add(t);
         }
         if (togglePreviewCheckBox.Checked) UpdatePreview();
@@ -281,5 +208,5 @@
     private void primaryXTextBox_TextChanged(object sender, EventArgs e) {
       if (!SuppressEvents) {
-        var area = GetCurrentChartArea();
+        ChartArea area = GetCurrentChartArea();
         area.AxisX.Title = primaryXTextBox.Text;
         if (togglePreviewCheckBox.Checked) UpdatePreview();
@@ -289,5 +216,5 @@
     private void primaryYTextBox_TextChanged(object sender, EventArgs e) {
       if (!SuppressEvents) {
-        var area = GetCurrentChartArea();
+        ChartArea area = GetCurrentChartArea();
         area.AxisY.Title = primaryYTextBox.Text;
         if (togglePreviewCheckBox.Checked) UpdatePreview();
@@ -297,5 +224,5 @@
     private void secondaryXTextBox_TextChanged(object sender, EventArgs e) {
       if (!SuppressEvents) {
-        var area = GetCurrentChartArea();
+        ChartArea area = GetCurrentChartArea();
         area.AxisX2.Title = secondaryXTextBox.Text;
         if (togglePreviewCheckBox.Checked) UpdatePreview();
@@ -305,42 +232,6 @@
     private void secondaryYTextBox_TextChanged(object sender, EventArgs e) {
       if (!SuppressEvents) {
-        var area = GetCurrentChartArea();
+        ChartArea area = GetCurrentChartArea();
         area.AxisY2.Title = secondaryYTextBox.Text;
-        if (togglePreviewCheckBox.Checked) UpdatePreview();
-      }
-    }
-
-    private void showPrimaryXAxisCheckBox_CheckedChanged(object sender, EventArgs e) {
-      if (!SuppressEvents) {
-        var area = GetCurrentChartArea();
-        var isChecked = ((CheckBox)sender).Checked;
-        area.AxisX.Enabled = isChecked ? AxisEnabled.True : AxisEnabled.False;
-        if (togglePreviewCheckBox.Checked) UpdatePreview();
-      }
-    }
-
-    private void showPrimaryYAxisCheckBox_CheckedChanged(object sender, EventArgs e) {
-      if (!SuppressEvents) {
-        var area = GetCurrentChartArea();
-        var isChecked = ((CheckBox)sender).Checked;
-        area.AxisY.Enabled = isChecked ? AxisEnabled.True : AxisEnabled.False;
-        if (togglePreviewCheckBox.Checked) UpdatePreview();
-      }
-    }
-
-    private void showSecondaryXAxisCheckBox_CheckedChanged(object sender, EventArgs e) {
-      if (!SuppressEvents) {
-        var area = GetCurrentChartArea();
-        var isChecked = ((CheckBox)sender).Checked;
-        area.AxisX2.Enabled = isChecked ? AxisEnabled.True : AxisEnabled.False;
-        if (togglePreviewCheckBox.Checked) UpdatePreview();
-      }
-    }
-
-    private void showSecondaryYAxisCheckBox_CheckedChanged(object sender, EventArgs e) {
-      if (!SuppressEvents) {
-        var area = GetCurrentChartArea();
-        var isChecked = ((CheckBox)sender).Checked;
-        area.AxisY2.Enabled = isChecked ? AxisEnabled.True : AxisEnabled.False;
         if (togglePreviewCheckBox.Checked) UpdatePreview();
       }
@@ -379,7 +270,8 @@
         float fontSize;
         if (float.TryParse(axisFontSizeComboBox.Text, out fontSize)) {
-          var area = GetCurrentChartArea();
-          foreach (Axis a in area.Axes)
+          ChartArea area = GetCurrentChartArea();
+          foreach (Axis a in area.Axes) {
             a.TitleFont = ChangeFontSizePt(a.TitleFont, fontSize);
+          }
         }
         if (togglePreviewCheckBox.Checked) UpdatePreview();
@@ -391,7 +283,8 @@
         float fontSize;
         if (float.TryParse(scalesFontSizeComboBox.Text, out fontSize)) {
-          var area = GetCurrentChartArea();
-          foreach (var a in area.Axes)
+          ChartArea area = GetCurrentChartArea();
+          foreach (Axis a in area.Axes) {
             a.LabelStyle.Font = ChangeFontSizePt(a.LabelStyle.Font, fontSize);
+          }
         }
         if (togglePreviewCheckBox.Checked) UpdatePreview();
@@ -403,6 +296,7 @@
         float fontSize;
         if (float.TryParse(legendFontSizeComboBox.Text, out fontSize)) {
-          foreach (var l in workingChart.Legends)
+          foreach (Legend l in workingChart.Legends) {
             l.Font = ChangeFontSizePt(l.Font, fontSize);
+          }
         }
         if (togglePreviewCheckBox.Checked) UpdatePreview();
@@ -441,37 +335,31 @@
       float height;
       GetImageParameters(out dpi, out width, out height);
-      var image = new Bitmap((int)Math.Round(width), (int)Math.Round(height));
+
+      Bitmap image = new Bitmap((int)Math.Round(width), (int)Math.Round(height));
       image.SetResolution(dpi, dpi);
+      using (Graphics graphics = Graphics.FromImage(image)) {
+        workingChart.Printing.PrintPaint(graphics, new Rectangle(0, 0, image.Width, image.Height));
+      }
+
       if (titleTextBox.Text.Trim() != String.Empty) saveFileDialog.FileName = titleTextBox.Text.Trim();
       if (saveFileDialog.ShowDialog() == DialogResult.OK) {
-        var format = ImageFormat.Bmp;
-        var filename = saveFileDialog.FileName.ToLower();
-        if (filename.EndsWith("emf")) {
-          using (var graphics = Graphics.FromImage(image)) {
-            var rectangle = new Rectangle(0, 0, image.Width, image.Height);
-            using (var metafile = new Metafile(filename, graphics.GetHdc(), rectangle, MetafileFrameUnit.Pixel, EmfType.EmfPlusDual)) {
-              graphics.ReleaseHdc();
-              using (var g = Graphics.FromImage(metafile)) {
-                workingChart.Printing.PrintPaint(g, rectangle);
-              }
-            }
-          }
-        } else {
-          using (var graphics = Graphics.FromImage(image)) {
-            workingChart.Printing.PrintPaint(graphics, new Rectangle(0, 0, image.Width, image.Height));
-          }
-          if (filename.EndsWith("jpg")) {
-            format = ImageFormat.Jpeg;
-          } else if (filename.EndsWith("gif")) {
-            format = ImageFormat.Gif;
-          } else if (filename.EndsWith("png")) {
-            format = ImageFormat.Png;
-          } else if (filename.EndsWith("tif")) {
-            format = ImageFormat.Tiff;
-          }
-          image.Save(saveFileDialog.FileName, format);
-        }
-      }
+        ImageFormat format = ImageFormat.Bmp;
+        string filename = saveFileDialog.FileName.ToLower();
+        if (filename.EndsWith("jpg")) {
+          format = ImageFormat.Jpeg;
+        } else if (filename.EndsWith("emf")) {
+          format = ImageFormat.Emf;
+        } else if (filename.EndsWith("gif")) {
+          format = ImageFormat.Gif;
+        } else if (filename.EndsWith("png")) {
+          format = ImageFormat.Png;
+        } else if (filename.EndsWith("tif")) {
+          format = ImageFormat.Tiff;
+        }
+        image.Save(saveFileDialog.FileName, format);
+      }
+
       image.Dispose();
+
       Cleanup();
     }
