コード例 #1
0
ファイル: Form1.cs プロジェクト: mzh3511/OdExamplesMgd
        private void pageSetupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (DBObject pVpObj = Aux.active_viewport_id(database).GetObject(OpenMode.ForWrite))
            {
                AbstractViewportData pAVD = new AbstractViewportData(pVpObj);
                pAVD.SetView(helperDevice.ActiveView);
            }

            TransactionManager tm = database.TransactionManager;

            using (Transaction ta = tm.StartTransaction())
            {
                using (BlockTableRecord blTableRecord = (BlockTableRecord)database.CurrentSpaceId.GetObject(OpenMode.ForRead))
                {
                    using (Layout pLayObj = (Layout)blTableRecord.LayoutId.GetObject(OpenMode.ForWrite))
                    {
                        PlotSettings    ps           = (PlotSettings)pLayObj;
                        Print.PageSetup pageSetupDlg = new Print.PageSetup(ps);
                        if (pageSetupDlg.ShowDialog() == DialogResult.OK)
                        {
                            ta.Commit();
                        }
                        else
                        {
                            ta.Abort();
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: mzh3511/OdExamplesMgd
        void initializeGraphics()
        {
            try
            {
                graphics = Graphics.FromHwnd(panel1.Handle);
                // load some predefined rendering module (may be also "WinDirectX" or "WinOpenGL")
                using (GsModule gsModule = (GsModule)SystemObjects.DynamicLinker.LoadModule("WinGDI.txv", false, true))
                {
                    // create graphics device
                    using (Teigha.GraphicsSystem.Device graphichsDevice = gsModule.CreateDevice())
                    {
                        // setup device properties
                        using (Dictionary props = graphichsDevice.Properties)
                        {
                            if (props.Contains("WindowHWND"))                                   // Check if property is supported
                            {
                                props.AtPut("WindowHWND", new RxVariant((Int32)panel1.Handle)); // hWnd necessary for DirectX device
                            }
                            if (props.Contains("WindowHDC"))                                    // Check if property is supported
                            {
                                props.AtPut("WindowHDC", new RxVariant(graphics.GetHdc()));     // hWindowDC necessary for Bitmap device
                            }
                            if (props.Contains("DoubleBufferEnabled"))                          // Check if property is supported
                            {
                                props.AtPut("DoubleBufferEnabled", new RxVariant(true));
                            }
                            if (props.Contains("EnableSoftwareHLR")) // Check if property is supported
                            {
                                props.AtPut("EnableSoftwareHLR", new RxVariant(true));
                            }
                            if (props.Contains("DiscardBackFaces")) // Check if property is supported
                            {
                                props.AtPut("DiscardBackFaces", new RxVariant(true));
                            }
                        }
                        // setup paperspace viewports or tiles
                        ContextForDbDatabase ctx = new ContextForDbDatabase(database);
                        ctx.UseGsModel = true;

                        helperDevice = LayoutHelperDevice.SetupActiveLayoutViews(graphichsDevice, ctx);
                        Aux.preparePlotstyles(database, ctx);
                        gripManager.init(helperDevice, helperDevice.Model, database);
                        //helperDevice.ActiveView.Mode = Teigha.GraphicsSystem.RenderMode.HiddenLine;
                    }
                }
                // set palette
                helperDevice.SetLogicalPalette(Device.DarkPalette);
                // set output extents
                resize();


                helperDevice.Model.Invalidate(InvalidationHint.kInvalidateAll);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: mzh3511/OdExamplesMgd
        // the same as Editor.ActiveViewportId if ApplicationServices are available

        private void zoom_extents_handler(object sender, EventArgs e)
        {
            using (DBObject pVpObj = Aux.active_viewport_id(database).GetObject(OpenMode.ForWrite))
            {
                // using protocol extensions we handle PS and MS viewports in the same manner
                AbstractViewportData       pAVD  = new AbstractViewportData(pVpObj);
                Teigha.GraphicsSystem.View pView = pAVD.GsView;
                // do actual zooming - change GS view
                zoom_extents(pView, pVpObj);
                // save changes to database
                pAVD.SetView(pView);
                pAVD.Dispose();
                pVpObj.Dispose();
                Invalidate();
            }
        }