Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10006


Ignore:
Timestamp:
09/25/13 13:55:12 (11 years ago)
Author:
abeham
Message:

#2107: merged r9946 and r10002 into stable

Location:
stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Visualization.ChartControlsExtensions/3.3/ImageExportDialog.cs

    r9532 r10006  
    6868        Width = 305;
    6969        Height = 625;
    70       } finally { SuppressEvents = false; }
     70      }
     71      finally { SuppressEvents = false; }
    7172      #endregion
    7273    }
     
    9394        if (workingChart.Legends.Count == 0) legendFontSizeComboBox.Text = "6";
    9495        else legendFontSizeComboBox.Text = workingChart.Legends[0].Font.SizeInPoints.ToString();
    95       } finally {
     96      }
     97      finally {
    9698        SuppressEvents = false;
    9799      }
     
    209211          }
    210212        }
    211       } finally { SuppressEvents = false; }
     213      }
     214      finally { SuppressEvents = false; }
    212215      base.OnShown(e);
    213216
     
    438441      float height;
    439442      GetImageParameters(out dpi, out width, out height);
    440 
    441443      var image = new Bitmap((int)Math.Round(width), (int)Math.Round(height));
    442444      image.SetResolution(dpi, dpi);
    443       using (var graphics = Graphics.FromImage(image)) {
    444         workingChart.Printing.PrintPaint(graphics, new Rectangle(0, 0, image.Width, image.Height));
    445       }
    446 
    447445      if (titleTextBox.Text.Trim() != String.Empty) saveFileDialog.FileName = titleTextBox.Text.Trim();
    448446      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
    449447        var format = ImageFormat.Bmp;
    450448        var filename = saveFileDialog.FileName.ToLower();
    451         if (filename.EndsWith("jpg")) {
    452           format = ImageFormat.Jpeg;
    453         } else if (filename.EndsWith("emf")) {
    454           format = ImageFormat.Emf;
    455         } else if (filename.EndsWith("gif")) {
    456           format = ImageFormat.Gif;
    457         } else if (filename.EndsWith("png")) {
    458           format = ImageFormat.Png;
    459         } else if (filename.EndsWith("tif")) {
    460           format = ImageFormat.Tiff;
    461         }
    462         image.Save(saveFileDialog.FileName, format);
    463       }
    464 
     449        if (filename.EndsWith("emf")) {
     450          using (var graphics = Graphics.FromImage(image)) {
     451            var rectangle = new Rectangle(0, 0, image.Width, image.Height);
     452            using (var metafile = new Metafile(filename, graphics.GetHdc(), rectangle, MetafileFrameUnit.Pixel, EmfType.EmfPlusDual)) {
     453              graphics.ReleaseHdc();
     454              using (var g = Graphics.FromImage(metafile)) {
     455                workingChart.Printing.PrintPaint(g, rectangle);
     456              }
     457            }
     458          }
     459        } else {
     460          using (var graphics = Graphics.FromImage(image)) {
     461            workingChart.Printing.PrintPaint(graphics, new Rectangle(0, 0, image.Width, image.Height));
     462          }
     463          if (filename.EndsWith("jpg")) {
     464            format = ImageFormat.Jpeg;
     465          } else if (filename.EndsWith("gif")) {
     466            format = ImageFormat.Gif;
     467          } else if (filename.EndsWith("png")) {
     468            format = ImageFormat.Png;
     469          } else if (filename.EndsWith("tif")) {
     470            format = ImageFormat.Tiff;
     471          }
     472          image.Save(saveFileDialog.FileName, format);
     473        }
     474      }
    465475      image.Dispose();
    466 
    467476      Cleanup();
    468477    }
Note: See TracChangeset for help on using the changeset viewer.