예제 #1
0
        protected void OnExportWithDirect2DMenuItemClick(NEventArgs args)
        {
#if SUPPORT_DIRECT2D && DEBUG
            string fileName = "d:\\D2D_output.png";
            NSize  imgSize  = new NSize(this.Width, this.Height);

            try
            {
                Nevron.Windows.DirectX.ND2DGraphicsHelper gh = new Nevron.Windows.DirectX.ND2DGraphicsHelper();
                INGraphics2D pdfG = gh.CreateGraphics((int)imgSize.Width, (int)imgSize.Height);

                NRegion clip = NRegion.FromRectangle(new NRectangle(0, 0, imgSize.Width, imgSize.Height));

                NMatrix canvasTransform = NMatrix.Identity;
                NMatrix invertedCT      = canvasTransform;
                invertedCT.Invert();

                NPaintVisitor visitor = new NPaintVisitor(pdfG, 96, invertedCT, clip);
                // assign media

                // forward traverse the display tree
                visitor.BeginPainting();
                VisitDisplaySubtree(visitor);
                visitor.EndPainting();

                gh.SaveToFileAndDispose(fileName);

                System.Diagnostics.Process.Start(fileName);
            }
            catch (Exception x)
            {
                NMessageBox.Show(null, x.Message, "Exception", ENMessageBoxButtons.OK);
            }
#endif
        }