/// <summary> /// Save the current Graph to the specified filename in EMF (vector) format. /// See <see cref="SaveAsEmf()" /> for public access. /// </summary> /// <remarks> /// Note that this handler saves as an Emf format only. The default handler is /// <see cref="SaveAs()" />, which allows for Bitmap or EMF formats. /// </remarks> internal void SaveEmfFile(string fileName, PointF?mousepos) { using (Graphics g = this.CreateGraphics()) { Metafile metaFile; IntPtr hdc = g.GetHdc(); if (mousepos == null) { metaFile = new Metafile(hdc, this._masterPane.Rect, MetafileFrameUnit.Pixel, EmfType.EmfPlusOnly); using (Graphics gMeta = Graphics.FromImage(metaFile)) { this._masterPane.Draw(gMeta); } } else { metaFile = new Metafile(hdc, this._masterPane.FindPane((PointF)mousepos).Rect, MetafileFrameUnit.Pixel, EmfType.EmfPlusOnly); using (Graphics gMeta = Graphics.FromImage(metaFile)) { this._masterPane.FindPane((PointF)mousepos).Draw(gMeta); } } ClipboardMetafileHelper.SaveEnhMetafileToFile(metaFile, fileName); g.ReleaseHdc(hdc); //g.Dispose(); } }
/// <summary> /// Save the current Graph to the specified filename in EMF (vector) format. /// See <see cref="SaveAsEmf()" /> for public access. /// </summary> /// <remarks> /// Note that this handler saves as an Emf format only. The default handler is /// <see cref="SaveAs()" />, which allows for Bitmap or EMF formats. /// </remarks> internal void SaveEmfFile(string fileName) { using (Graphics g = this.CreateGraphics()) { IntPtr hdc = g.GetHdc(); Metafile metaFile = new Metafile(hdc, EmfType.EmfPlusOnly); using (Graphics gMeta = Graphics.FromImage(metaFile)) { //PaneBase.SetAntiAliasMode( gMeta, IsAntiAlias ); //gMeta.CompositingMode = CompositingMode.SourceCopy; //gMeta.CompositingQuality = CompositingQuality.HighQuality; //gMeta.InterpolationMode = InterpolationMode.HighQualityBicubic; //gMeta.SmoothingMode = SmoothingMode.AntiAlias; //gMeta.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; this._masterPane.Draw(gMeta); //gMeta.Dispose(); } ClipboardMetafileHelper.SaveEnhMetafileToFile(metaFile, fileName); g.ReleaseHdc(hdc); //g.Dispose(); } }
/// <summary> /// Copy the chart as enhanced metafile into the clipboard /// </summary> public static void CopyToClipboard(Bitmap bitmap, IntPtr controlHandle) { using (var ms = new MemoryStream()) { bitmap.Save(ms, ImageFormat.Emf); ms.Seek(0, SeekOrigin.Begin); ClipboardMetafileHelper.PutEnhMetafileOnClipboard(controlHandle, new Metafile(ms)); } }
/// <summary> /// Save the current Graph to the specified filename in EMF (vector) format. /// See <see cref="SaveAsEmf()" /> for public access. /// </summary> /// <remarks> /// Note that this handler saves as an Emf format only. The default handler is /// <see cref="SaveAs()" />, which allows for Bitmap or EMF formats. /// </remarks> internal void SaveEmfFile(string fileName) { using (Graphics g = this.CreateGraphics()) { IntPtr hdc = g.GetHdc(); Metafile metaFile = this._masterPane.GetMetafile(); ClipboardMetafileHelper.SaveEnhMetafileToFile(metaFile, fileName); g.ReleaseHdc(hdc); //g.Dispose(); } }
private void copyMetafileToClipboardToolStripMenuItem_Click(object sender, EventArgs e) { var grfx = CreateGraphics(); var ipHdc = grfx.GetHdc(); var ms = new MemoryStream(); var mf = new Metafile(ms, ipHdc, EmfType.EmfPlusDual); grfx.ReleaseHdc(ipHdc); grfx.Dispose(); var g = Graphics.FromImage(mf); Draw(g); g.Dispose(); ClipboardMetafileHelper.PutEnhMetafileOnClipboard(this.Handle, mf); }
/// <summary> /// A threaded version of the copy method to avoid crash with MTA /// </summary> void ClipboardCopyThreadEmf() { using (var g = CreateGraphics()) { var hdc = g.GetHdc(); var metaFile = new Metafile(hdc, EmfType.EmfPlusOnly); g.ReleaseHdc(hdc); using (var gMeta = Graphics.FromImage(metaFile)) _masterPane.Draw(gMeta); //IntPtr hMeta = metaFile.GetHenhmetafile(); ClipboardMetafileHelper.PutEnhMetafileOnClipboard(Handle, metaFile); //System.Windows.Forms.Clipboard.SetDataObject(hMeta, true); //g.Dispose(); } }
internal void SaveEmfLegendFile(string fileName) { using (Graphics g = _colorBlendControl.CreateGraphics()) { IntPtr hdc = g.GetHdc(); Metafile metaFile = new Metafile(hdc, EmfType.EmfPlusOnly); using (Graphics gMeta = Graphics.FromImage(metaFile)) { _colorBlendControl.DrawImage(); } ClipboardMetafileHelper.SaveEnhMetafileToFile(metaFile, fileName); g.ReleaseHdc(hdc); } }
private void ClipboardCopyThreadEmf() { using (Graphics g = this.CreateGraphics()) { IntPtr hdc = g.GetHdc(); Metafile metaFile = new Metafile(hdc, EmfType.EmfPlusOnly); g.ReleaseHdc(hdc); using (Graphics gMeta = Graphics.FromImage(metaFile)) { this._masterPane.Draw(gMeta); } ClipboardMetafileHelper.PutEnhMetafileOnClipboard(this.Handle, metaFile); } }
/// <summary> /// Save the current Graph to the specified filename in EMF (vector) format. /// See <see cref="SaveAsEmf()" /> for public access. /// </summary> /// <remarks> /// Note that this handler saves as an Emf format only. The default handler is /// <see cref="SaveAs()" />, which allows for Bitmap or EMF formats. /// </remarks> internal void SaveEmfFile(string fileName) { using (Graphics g = this.CreateGraphics()) { IntPtr hdc = g.GetHdc(); using (Metafile metaFile = new Metafile(hdc, EmfType.EmfPlusOnly)) { using (Graphics gMeta = Graphics.FromImage(metaFile)) { this._masterPane.Draw(gMeta); } ClipboardMetafileHelper.SaveEnhMetafileToFile(metaFile, fileName); } g.ReleaseHdc(hdc); } }
/// <summary> /// A threaded version of the copy method to avoid crash with MTA /// </summary> private void ClipboardCopyThreadEmf() { using (Graphics g = this.CreateGraphics()) { IntPtr hdc = g.GetHdc(); Metafile metaFile = new Metafile(hdc, EmfType.EmfPlusOnly); g.ReleaseHdc(hdc); IGraphics gMeta = new GdiGraphics(Graphics.FromImage(metaFile)); { this._masterPane.Draw(gMeta); } //IntPtr hMeta = metaFile.GetHenhmetafile(); ClipboardMetafileHelper.PutEnhMetafileOnClipboard(this.Handle, metaFile); //System.Windows.Forms.Clipboard.SetDataObject(hMeta, true); //g.Dispose(); } }
/// <summary> /// A threaded version of the copy method to avoid crash with MTA /// </summary> private void ClipboardCopyThreadEmf() { try { using (Graphics g = this.CreateGraphics()) { IntPtr hdc = g.GetHdc(); Metafile metaFile = new Metafile(hdc, EmfType.EmfPlusOnly); g.ReleaseHdc(hdc); using (Graphics gMeta = Graphics.FromImage(metaFile)) { this._masterPane.Draw(gMeta); } //IntPtr hMeta = metaFile.GetHenhmetafile(); ClipboardMetafileHelper.PutEnhMetafileOnClipboard(this.Handle, metaFile); //System.Windows.Forms.Clipboard.SetDataObject(hMeta, true); //g.Dispose(); } } catch (Exception ex) { log.Error("ERROR: Thread had an exception:", ex); } }
/// <summary> /// A threaded version of the copy method to avoid crash with MTA /// </summary> private void ClipboardCopyThreadEmf(PointF?mousepos) { using (Graphics g = this.CreateGraphics()) { IntPtr hdc = g.GetHdc(); Metafile metaFile; if (mousepos == null) { metaFile = new Metafile(hdc, this._masterPane.Rect, MetafileFrameUnit.Pixel, EmfType.EmfPlusOnly); g.ReleaseHdc(hdc); using (Graphics gMeta = Graphics.FromImage(metaFile)) { this._masterPane.Draw(gMeta); } } else { metaFile = new Metafile(hdc, this._masterPane.FindPane((PointF)mousepos).Rect, MetafileFrameUnit.Pixel, EmfType.EmfPlusOnly); g.ReleaseHdc(hdc); using (Graphics gMeta = Graphics.FromImage(metaFile)) { this._masterPane.FindPane((PointF)mousepos).Draw(gMeta); } } //IntPtr hMeta = metaFile.GetHenhmetafile(); ClipboardMetafileHelper.PutEnhMetafileOnClipboard(this.Handle, metaFile); //System.Windows.Forms.Clipboard.SetDataObject(hMeta, true); //g.Dispose(); } }
private void CopyButton_Click(object sender, EventArgs e) { using Metafile metafile = CreateMetafile(); using Bitmap bitmap = CreateBitmap(); ClipboardMetafileHelper.PutOnClipboard(this.Handle, metafile, bitmap); }