PutEnhMetafileOnClipboard() static public method

static public PutEnhMetafileOnClipboard ( IntPtr hWnd, Metafile mf ) : bool
hWnd IntPtr
mf Metafile
return bool
        /// <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));
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        /// <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();
            }
        }
Exemplo n.º 4
0
        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>
        /// 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();
            }
        }