/// <summary>
        /// Initializes a new plot settings.
        /// </summary>
        public PlotSettings()
        {
            this.pageSetupName     = string.Empty;
            this.plotterName       = "none_device";
            this.paperSizeName     = "ISO_A4_(210.00_x_297.00_MM)";
            this.viewName          = string.Empty;
            this.currentStyleSheet = string.Empty;

            this.left   = 7.5;
            this.bottom = 20.0;
            this.right  = 7.5;
            this.top    = 20.0;

            this.paperSize        = new Vector2(210.0, 297.0);
            this.origin           = Vector2.Zero;
            this.windowUpRight    = Vector2.Zero;
            this.windowBottomLeft = Vector2.Zero;

            this.numeratorScale   = 1.0;
            this.denominatorScale = 1.0;
            this.flags            = PlotFlags.DrawViewportsFirst | PlotFlags.PrintLineweights | PlotFlags.PlotPlotStyles | PlotFlags.UseStandardScale;

            this.paperUnits = PlotPaperUnits.Milimeters;
            this.rotation   = PlotRotation.Degrees90;
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of <c>PlotSettings</c>.
        /// </summary>
        public PlotSettings()
        {
            pageSetupName     = string.Empty;
            plotterName       = "none_device";
            paperSizeName     = "ISO_A4_(210.00_x_297.00_MM)";
            viewName          = string.Empty;
            currentStyleSheet = string.Empty;

            paperMargin = new PaperMargin(7.5, 20.0, 7.5, 20.0);

            paperSize        = new Vector2(210.0, 297.0);
            origin           = Vector2.Zero;
            windowUpRight    = Vector2.Zero;
            windowBottomLeft = Vector2.Zero;

            scaleToFit       = true;
            numeratorScale   = 1.0;
            denominatorScale = 1.0;
            flags            = PlotFlags.DrawViewportsFirst | PlotFlags.PrintLineweights | PlotFlags.PlotPlotStyles | PlotFlags.UseStandardScale;
            plotType         = PlotType.DrawingExtents;

            paperUnits = PlotPaperUnits.Milimeters;
            rotation   = PlotRotation.Degrees90;

            shadePlotMode           = ShadePlotMode.AsDisplayed;
            shadePlotResolutionMode = ShadePlotResolutionMode.Normal;
            shadePlotDPI            = 300;
            paperImageOrigin        = Vector2.Zero;
        }
Example #3
0
        /// <summary>
        /// Initializes a new plot settings.
        /// </summary>
        public PlotSettings()
        {
            this.pageSetupName = string.Empty;
            this.plotterName = "none_device";
            this.paperSizeName = "ISO_A4_(210.00_x_297.00_MM)";
            this.viewName = string.Empty;
            this.currentStyleSheet = string.Empty;

            this.left = 7.5;
            this.bottom = 20.0;
            this.right = 7.5;
            this.top = 20.0;

            this.paperSize = new Vector2(210.0, 297.0);
            this.origin = Vector2.Zero;
            this.windowUpRight = Vector2.Zero;
            this.windowBottomLeft = Vector2.Zero;

            this.numeratorScale = 1.0;
            this.denominatorScale = 1.0;
            this.flags = PlotFlags.DrawViewportsFirst | PlotFlags.PrintLineweights | PlotFlags.PlotPlotStyles | PlotFlags.UseStandardScale;

            this.paperUnits = PlotPaperUnits.Milimeters;
            this.rotation = PlotRotation.Degrees90;
        }
Example #4
0
        public override void CopyFrom(DxfHandledObject from, CloneContext cloneContext)
        {
            base.CopyFrom(from, cloneContext);
            DxfPlotSettings dxfPlotSettings = (DxfPlotSettings)from;

            this.string_0              = dxfPlotSettings.string_0;
            this.string_1              = dxfPlotSettings.string_1;
            this.string_2              = dxfPlotSettings.string_2;
            this.string_3              = dxfPlotSettings.string_3;
            this.double_0              = dxfPlotSettings.double_0;
            this.double_1              = dxfPlotSettings.double_1;
            this.double_2              = dxfPlotSettings.double_2;
            this.double_3              = dxfPlotSettings.double_3;
            this.size2D_0              = dxfPlotSettings.size2D_0;
            this.point2D_0             = dxfPlotSettings.point2D_0;
            this.rectangle2D_0         = dxfPlotSettings.rectangle2D_0;
            this.double_4              = dxfPlotSettings.double_4;
            this.double_5              = dxfPlotSettings.double_5;
            this.plotLayoutFlags_0     = dxfPlotSettings.plotLayoutFlags_0;
            this.plotPaperUnits_0      = dxfPlotSettings.plotPaperUnits_0;
            this.plotRotation_0        = dxfPlotSettings.plotRotation_0;
            this.plotArea_0            = dxfPlotSettings.plotArea_0;
            this.string_4              = dxfPlotSettings.string_4;
            this.short_0               = dxfPlotSettings.short_0;
            this.shadePlotMode_0       = dxfPlotSettings.shadePlotMode_0;
            this.shadePlotResolution_0 = dxfPlotSettings.shadePlotResolution_0;
            this.short_1               = dxfPlotSettings.short_1;
            this.double_6              = dxfPlotSettings.double_6;
            this.point2D_1             = dxfPlotSettings.point2D_1;
        }
Example #5
0
        //if the media size doesn't exist, this will search media list for best match
        // 8.5 x 11 should be there
        private static string setClosestMediaName(PlotSettingsValidator psv, PlotSettings ps,
                                                  double pageWidth, double pageHeight, bool matchPrintableArea)
        {
            //get all of the media listed for plotter
            StringCollection mediaList      = psv.GetCanonicalMediaNameList(ps);
            double           smallestOffest = 0.0;
            string           selectedMedia  = string.Empty;
            PlotRotation     selectedRot    = PlotRotation.Degrees000;

            foreach (string media in mediaList)
            {
                psv.SetCanonicalMediaName(ps, media);

                double mediaWidth  = ps.PlotPaperSize.X;
                double mediaHeight = ps.PlotPaperSize.Y;

                if (matchPrintableArea)
                {
                    mediaWidth  -= (ps.PlotPaperMargins.MinPoint.X + ps.PlotPaperMargins.MaxPoint.X);
                    mediaHeight -= (ps.PlotPaperMargins.MinPoint.Y + ps.PlotPaperMargins.MaxPoint.Y);
                }

                PlotRotation rot = PlotRotation.Degrees090;

                //check that we are not outside the media print area
                if (mediaWidth < pageWidth || mediaHeight < pageHeight)
                {
                    //Check if turning paper will work
                    if (mediaHeight < pageWidth || mediaWidth >= pageHeight)
                    {
                        //still too small
                        continue;
                    }
                    rot = PlotRotation.Degrees090;
                }

                double offset = Math.Abs(mediaWidth * mediaHeight - pageWidth * pageHeight);

                if (selectedMedia == string.Empty || offset < smallestOffest)
                {
                    selectedMedia  = media;
                    smallestOffest = offset;
                    selectedRot    = rot;

                    if (smallestOffest == 0)
                    {
                        break;
                    }
                }
            }
            psv.SetCanonicalMediaName(ps, selectedMedia);
            psv.SetPlotRotation(ps, selectedRot);
            return(selectedMedia);
        }
Example #6
0
        void FillPaperOrientation()
        {
            PlotRotation pr = m_plotStg.PlotRotation;

            checkBoxPlotUpsideDown.Checked = Convert.ToBoolean((int)pr & 1);
            if (!isPaperWidthLessHeight())
            {
                radioButtonLandscape.Checked = !radioButtonLandscape.Checked;
            }
            checkBoxPlotUpsideDown.Checked = Convert.ToBoolean(((int)pr & 2) / 2);
        }
Example #7
0
        //determine if the plot is landscape or portrait based on which side is longer
        static public PlotRotation orientation(Extents2d ext)
        {
            PlotRotation portrait  = PlotRotation.Degrees180;
            PlotRotation landscape = PlotRotation.Degrees270;
            double       width     = ext.MinPoint.X - ext.MaxPoint.X;
            double       height    = ext.MinPoint.Y - ext.MaxPoint.Y;

            if (Math.Abs(width) > Math.Abs(height))
            {
                return(landscape);
            }
            else
            {
                return(portrait);
            }
        }
Example #8
0
        public void QueryPaperSize()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;

            LayoutManager         layMgr   = LayoutManager.Current;
            PlotSettingsValidator plSetVdr = PlotSettingsValidator.Current;

            Dictionary <string, Point2d> customPaperSize = new Dictionary <string, Point2d>(StringComparer.CurrentCultureIgnoreCase);

            customPaperSize.Add("A4", new Point2d(210.0, 297.0));
            customPaperSize.Add("A3", new Point2d(297.0, 420.0));
            customPaperSize.Add("A2", new Point2d(420.0, 594.0));
            customPaperSize.Add("A1", new Point2d(594.0, 841.0));
            customPaperSize.Add("A0", new Point2d(841.0, 1189.0));
            customPaperSize.Add("A0Plus", new Point2d(841.0, 1480.0));
            customPaperSize.Add("A0+", new Point2d(841.0, 1470.0));
            customPaperSize.Add("GBKN", new Point2d(594.0, 1051.0));

            customPaperSize.Add("4Z", new Point2d(297.0, 750.0));
            customPaperSize.Add("5Z", new Point2d(297.0, 930.0));
            customPaperSize.Add("6Z", new Point2d(297.0, 1110.0));
            customPaperSize.Add("7Z", new Point2d(297.0, 1290.0));

            customPaperSize.Add("Z3", new Point2d(297.0, 594.0));
            customPaperSize.Add("Z4", new Point2d(297.0, 841.0));
            customPaperSize.Add("Z6", new Point2d(297.0, 1189.0));

            customPaperSize.Add("3A4", new Point2d(297.0, 630.0));
            customPaperSize.Add("4A4", new Point2d(297.0, 841.0));
            customPaperSize.Add("5A4", new Point2d(297.0, 1050.0));
            customPaperSize.Add("6A4", new Point2d(297.0, 1260.0));
            customPaperSize.Add("7A4", new Point2d(297.0, 1470.0));



            db.TileMode = false;        //goto Paperspace if not already
            ed.SwitchToPaperSpace();    //turn PVP off

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                Layout theLayout = (Layout)tr.GetObject(layMgr.GetLayoutId(layMgr.CurrentLayout), OpenMode.ForWrite);

                // Get the PlotInfo from the layout
                PlotInfo plInfo = new PlotInfo();
                plInfo.Layout = theLayout.ObjectId;

                PlotSettings np = new PlotSettings(theLayout.ModelType);
                np.CopyFrom(theLayout);

                string devName = "DWG To PDF.pc3";  //OceTds600.pc3
                plSetVdr.SetPlotConfigurationName(np, devName, null);
                plSetVdr.RefreshLists(np);

                StringCollection canMedNames = plSetVdr.GetCanonicalMediaNameList(np);
                for (int i = 0; i < canMedNames.Count; i++)
                {
                    plSetVdr.SetCanonicalMediaName(np, canMedNames[i]);
                    plSetVdr.RefreshLists(np);
                    string medName = plSetVdr.GetLocaleMediaName(np, i);
                    //ed.WriteMessage("\n{0}: Can. MediaName={1}/{2}", i, np.CanonicalMediaName, medName);
                    if (medName.Equals("ISO A1 (841.00 x 594.00 MM)"))
                    {
                        ed.WriteMessage("\n{0}: Can. MediaName={1}/{2}", i, np.CanonicalMediaName, medName);
                        Point2d pSize = np.PlotPaperSize;
                        ed.WriteMessage("\n\tPaperSize={0}", pSize.ToString());
                        PlotRotation pRot = np.PlotRotation;
                        ed.WriteMessage("\n\tPlot Rotation={0}", pRot.ToString());
                        Extents2d pM = np.PlotPaperMargins;
                        ed.WriteMessage("\n\tPaper Margins={0}, {1}", pM.MinPoint.ToString(), pM.MaxPoint.ToString());
                    }
                }
            }
        }
Example #9
0
        void PrintPage(object sender, PrintPageEventArgs ev)
        {
            if (m_pPrinterDevice != null)
            {
                using (DBObject pVpObj = Aux.active_viewport_id(database).GetObject(OpenMode.ForWrite))
                {
                    using (AbstractViewportData pAV = new AbstractViewportData(pVpObj))
                    {
                        Teigha.GraphicsSystem.View pGSView = pAV.GsView;

                        PrintDocument prDoc = (PrintDocument)sender;

                        // Get printer paper info
                        Double dPrinterWidth  = ev.PageBounds.Width;
                        Double dPrinterHeight = ev.PageBounds.Height;
                        Double dLogPixelX     = ev.PageSettings.PrinterResolution.X; //dot per inch
                        Double dLogPixelY     = ev.PageSettings.PrinterResolution.Y; //dot per inch
                        Double kMmPerInch     = 25.4;
                        Double kMmPerHInch    = 0.254;
                        Double koeffX         = dLogPixelX / kMmPerInch;
                        Double koeffY         = dLogPixelY / kMmPerInch;

                        Layout  pLayout      = (Layout)m_pPrinterDevice.LayoutId.GetObject(OpenMode.ForRead);
                        Boolean bScaledToFit = pLayout.UseStandardScale && (StdScaleType.ScaleToFit == pLayout.StdScaleType);
                        Boolean bCentered    = pLayout.PlotCentered;
                        Boolean bMetric      = (pLayout.PlotPaperUnits != PlotPaperUnit.Inches);
                        Boolean bPrintLW     = pLayout.PrintLineweights || pLayout.ShowPlotStyles;

                        Point2d offsets = pLayout.PlotOrigin; // in mm

                        Extents2d ex2d          = pLayout.PlotPaperMargins;
                        Double    dLeftMargin   = ex2d.MinPoint.X; // in mm
                        Double    dRightMargin  = ex2d.MaxPoint.X; // in mm
                        Double    dTopMargin    = ex2d.MinPoint.Y; // in mm
                        Double    dBottomMargin = ex2d.MaxPoint.Y; // in mm
                        PlotType  plotType      = pLayout.PlotType;

                        PlotRotation plotRotation = pLayout.PlotRotation;
                        if (plotRotation == PlotRotation.Degrees090 || plotRotation == PlotRotation.Degrees270)
                        {
                            plotRotation = (plotRotation == PlotRotation.Degrees090) ? PlotRotation.Degrees270 : PlotRotation.Degrees090;
                        }

                        switch (plotRotation)
                        {
                        case PlotRotation.Degrees090:
                            Swap <Double>(dTopMargin, dRightMargin);
                            Swap <Double>(dBottomMargin, dLeftMargin);
                            Swap <Double>(dBottomMargin, dTopMargin);
                            Swap <Double>(dTopMargin, dRightMargin);
                            offsets = new Point2d(-offsets.X, -offsets.Y);
                            break;

                        case PlotRotation.Degrees180:
                            Swap <Double>(dRightMargin, dLeftMargin);
                            offsets = new Point2d(-offsets.X, -offsets.Y);
                            break;

                        case PlotRotation.Degrees270:
                            Swap <Double>(dTopMargin, dRightMargin);
                            Swap <Double>(dBottomMargin, dLeftMargin);
                            Swap <Double>(dBottomMargin, dTopMargin);
                            offsets = new Point2d(offsets.X, offsets.Y);
                            break;
                        }

                        // Get scale factor
                        double factor;
                        if (pLayout.UseStandardScale)
                        {
                            factor = pLayout.StdScale;
                        }
                        else
                        {
                            CustomScale scale = pLayout.CustomPrintScale;
                            factor = scale.Numerator / scale.Denominator;
                        }

                        // Calculate paper drawable area using margins from layout (in mm).
                        Double drx1 = (ev.MarginBounds.Left * kMmPerHInch + dLeftMargin);                  // in mm
                        Double drx2 = (ev.MarginBounds.Width * kMmPerHInch - dLeftMargin - dRightMargin);  // in mm
                        Double dry1 = (ev.MarginBounds.Top * kMmPerHInch + dTopMargin);                    // in mm
                        Double dry2 = (ev.MarginBounds.Height * kMmPerHInch - dTopMargin - dBottomMargin); // in mm

                        Boolean        bType           = (plotType == PlotType.Display || plotType == PlotType.Layout);
                        AbstractViewPE pAbstractViewPE = new AbstractViewPE(bType ? pViewDr : pGSView);

                        // set LineWeight scale factor for model space
                        if (bPrintLW && database.TileMode)
                        {
                            Teigha.GraphicsSystem.View pTo = m_pPrinterDevice.ViewAt(0);
                            pTo.LineweightToDcScale = Math.Max(dLogPixelX, dLogPixelY) / kMmPerInch * 0.01;
                        }

                        Point3d  viewTarget     = pAbstractViewPE.Target;
                        Point3d  viewportCenter = pAbstractViewPE.Target;      // in plotPaperUnits
                        Boolean  isPerspective  = pAbstractViewPE.IsPerspective;
                        Double   viewportH      = pAbstractViewPE.FieldHeight; // in plotPaperUnits
                        Double   viewportW      = pAbstractViewPE.FieldWidth;  // in plotPaperUnits
                        Vector3d viewDir        = pAbstractViewPE.Direction;   // in plotPaperUnits
                        Vector3d upV            = pAbstractViewPE.UpVector;    // in plotPaperUnits
                        Matrix3d eyeToWorld     = pAbstractViewPE.EyeToWorld;
                        Matrix3d WorldToeye     = pAbstractViewPE.WorldToEye;

                        Boolean isPlanView = viewDir.GetNormal().Equals(Vector3d.ZAxis);
                        Point3d oldTarget  = viewTarget;

                        Double fieldWidth = viewportW, fieldHeight = viewportH;

                        if (plotType == PlotType.Display)
                        {
                            viewTarget  = viewportCenter;
                            fieldWidth  = viewportW;
                            fieldHeight = viewportH;
                        }
                        else if (plotType == PlotType.Extents || (plotType == PlotType.Limits && !isPlanView))
                        {
                            BoundBlock3d extents = new BoundBlock3d();
                            if (pAbstractViewPE.GetViewExtents(extents)) // pIter also skip 'off layers'
                            {
                                extents.TransformBy(eyeToWorld);
                                viewTarget = (extents.GetMinimumPoint() + extents.GetMaximumPoint().GetAsVector()) / 2.0;
                                extents.TransformBy(WorldToeye);

                                fieldWidth  = Math.Abs(extents.GetMaximumPoint().X - extents.GetMinimumPoint().X);
                                fieldHeight = Math.Abs(extents.GetMaximumPoint().Y - extents.GetMinimumPoint().Y);
                            }
                        }
                        else if (plotType == PlotType.View)
                        {
                            viewTarget  = viewportCenter;
                            fieldWidth  = viewportW;
                            fieldHeight = viewportH;
                        }
                        else if (plotType == PlotType.Limits)
                        {
                            fieldWidth  = (drx2 - drx1) / factor; // drx in mm -> fieldWidth in mm
                            fieldHeight = (dry2 - dry1) / factor;

                            viewTarget = new Point3d(fieldWidth / 2.0 - offsets.X / factor, fieldHeight / 2.0 - offsets.Y / factor, 0); // in mm
                            if (!bMetric)
                            {
                                viewTarget  /= kMmPerInch; // must be in plotpaper units
                                fieldWidth  /= kMmPerInch;
                                fieldHeight /= kMmPerInch;
                            }

                            bCentered = bScaledToFit = false; // kLayout doesn't support pIter.
                        }

                        if (plotType != PlotType.View)
                        {
                            viewTarget = viewTarget.OrthoProject(new Plane(oldTarget, viewDir));
                        }

                        pGSView.SetView(viewTarget + viewDir, viewTarget, upV, fieldWidth, fieldHeight, isPerspective ? Teigha.GraphicsSystem.Projection.Perspective : Teigha.GraphicsSystem.Projection.Parallel);

                        if (!bMetric)
                        {
                            fieldWidth  *= kMmPerInch;
                            fieldHeight *= kMmPerInch;
                        }

                        if (bScaledToFit)
                        {
                            factor = Math.Min((drx2 - drx1) / fieldWidth, (dry2 - dry1) / fieldHeight);
                        }

                        if (bCentered) // Offset also can be incorectly saved.
                        {
                            offsets = new Point2d(((drx2 - drx1) - fieldWidth * factor) / 2.0,
                                                  ((dry2 - dry1) - fieldHeight * factor) / 2.0);

                            if (plotRotation == PlotRotation.Degrees090 || plotRotation == PlotRotation.Degrees180)
                            {
                                offsets = new Point2d(-offsets.X, -offsets.Y);
                            }
                        }

                        pGSView.Viewport = new Extents2d(0, 0, 1, 1);

                        // Calculate viewport rect in printer units
                        //int x1 = (int)((offsets.X + drx1) * koeffX);
                        //int x2 = (int)((offsets.X + drx2) * koeffX);
                        //int y1 = (int)((-offsets.Y + dry1) * koeffY);
                        //int y2 = (int)((-offsets.Y + dry2) * koeffY);
                        int x1 = (int)(drx1 * koeffX);
                        int x2 = (int)(drx2 * koeffX);
                        int y1 = (int)(dry1 * koeffY);
                        int y2 = (int)(dry2 * koeffY);

                        Rectangle viewportRect = new Rectangle(x1, y1, x2, y2);
                        m_pPrinterDevice.OnSize(viewportRect);
                        if (m_pPrinterDevice.UnderlyingDevice.Properties.Contains("WindowHDC"))
                        {
                            m_pPrinterDevice.UnderlyingDevice.Properties.AtPut("WindowHDC", new RxVariant((Int32)ev.Graphics.GetHdc()));
                        }
                        m_pPrinterDevice.Update();

                        pAbstractViewPE.Dispose();
                        pLayout.Dispose();
                    }
                }
            }
        }
Example #10
0
        public void Print(Database db, Teigha.GraphicsSystem.View pView, bool bPreview)
        {
            database = db;
            pViewDr  = pView;
            ObjectId idLayout = database.CurrentSpaceId;

            using (BlockTableRecord btr = (BlockTableRecord)database.CurrentSpaceId.GetObject(OpenMode.ForRead))
            {
                using (Layout pLayout = (Layout)btr.LayoutId.GetObject(OpenMode.ForRead))
                {
                    PrintDocument prDoc = new PrintDocument();
                    prDoc.PrintPage += new PrintPageEventHandler(this.PrintPage);
                    prDoc.PrinterSettings.PrinterName = pLayout.PlotConfigurationName;

                    PageSettings pageSetting = prDoc.DefaultPageSettings;
                    PlotRotation rotation    = pLayout.PlotRotation;
                    if (rotation == PlotRotation.Degrees090 || rotation == PlotRotation.Degrees270)
                    {
                        pageSetting.Landscape = true;
                    }
                    else
                    {
                        pageSetting.Landscape = false;
                    }

                    Double    kMmPerInch  = 10 / 2.54;
                    Point2d   ptPaperSize = pLayout.PlotPaperSize;
                    PaperSize ps          = new PaperSize(pLayout.CanonicalMediaName, (int)(ptPaperSize.X * kMmPerInch), (int)(ptPaperSize.Y * kMmPerInch));
                    pageSetting.PaperSize = ps;

                    //default as OdaMfc
                    pageSetting.Margins.Left   = 0;
                    pageSetting.Margins.Right  = 0;
                    pageSetting.Margins.Top    = 0;
                    pageSetting.Margins.Bottom = 0;

                    prDoc.DefaultPageSettings = pageSetting;
                    if (prDoc.PrinterSettings.IsValid)
                    {
                        try
                        {                                                                 //WinGDI, WinOpenGL
                            using (GsModule gsModule = (GsModule)SystemObjects.DynamicLinker.LoadModule("WinGDI.txv", false, true))
                            {
                                using (Teigha.GraphicsSystem.Device graphichsDevice = gsModule.CreateDevice())
                                {
                                    using (ContextForDbDatabase ctx = new ContextForDbDatabase(database))
                                    {
                                        ctx.SetPlotGeneration(true);
                                        ctx.UseGsModel   = true;
                                        m_pPrinterDevice = LayoutHelperDevice.SetupActiveLayoutViews(graphichsDevice, ctx);
                                        m_pPrinterDevice.BackgroundColor = Color.FromArgb(0, 255, 255, 255);
                                        m_pPrinterDevice.SetLogicalPalette(Device.LightPalette);

                                        Aux.preparePlotstyles(database, ctx);
                                    }
                                }
                            }
                        }
                        catch (System.Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }

                        if (bPreview)
                        {
                            PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
                            printPreviewDialog.Document = prDoc;
                            printPreviewDialog.ShowDialog();
                        }
                        else
                        {
                            prDoc.Print();
                        }

                        m_pPrinterDevice = null;
                        database         = null;
                        pViewDr          = null;
                    }
                }
            }
        }
Example #11
0
        bool isWHSwap()
        {
            PlotRotation pr = m_plotStg.PlotRotation;

            return(pr == PlotRotation.Degrees090 || pr == PlotRotation.Degrees270);
        }
Example #12
0
        public DxfLayout.PlotInfo GetPlotInfo(
            double paperWidth,
            double paperHeight,
            Rectangle2D printArea,
            bool autoRotate,
            bool invertY)
        {
            DxfLayout.BasicLayoutRenderInfo layoutRenderInfo = this.method_8();
            if (!layoutRenderInfo.LayoutViewport.Initialized)
            {
                return((DxfLayout.PlotInfo)null);
            }
            Bounds2D layoutViewport = layoutRenderInfo.LayoutViewport;
            Matrix4D matrix4D1      = Matrix4D.Identity;
            double   num1           = layoutViewport.Delta.X;
            double   num2           = layoutViewport.Delta.Y;

            if (autoRotate && (printArea.Width > printArea.Height && num1 < num2 || printArea.Width < printArea.Height && num1 > num2))
            {
                PlotRotation plotRotation1 = PlotRotation.None;
                PlotRotation plotRotation2;
                PlotRotation plotRotation3;
                switch (this.PlotRotation)
                {
                case PlotRotation.None:
                    plotRotation2 = PlotRotation.QuarterCounterClockwise;
                    plotRotation3 = PlotRotation.QuarterCounterClockwise;
                    goto label_10;

                case PlotRotation.QuarterCounterClockwise:
                    plotRotation2 = PlotRotation.QuarterClockwise;
                    plotRotation3 = PlotRotation.QuarterClockwise;
                    break;

                case PlotRotation.Half:
                    plotRotation2 = PlotRotation.QuarterClockwise;
                    plotRotation3 = PlotRotation.QuarterClockwise;
                    break;

                case PlotRotation.QuarterClockwise:
                    plotRotation2 = PlotRotation.QuarterCounterClockwise;
                    plotRotation3 = PlotRotation.QuarterCounterClockwise;
                    goto label_10;

                default:
                    switch (plotRotation1)
                    {
                    case PlotRotation.QuarterCounterClockwise:
                        goto label_10;

                    case PlotRotation.QuarterClockwise:
                        break;

                    default:
                        goto label_11;
                    }
                }
                matrix4D1 = Transformation4D.RotateZ(invertY ? System.Math.PI / 2.0 : -1.0 * System.Math.PI / 2.0);
                goto label_11;
label_10:
                matrix4D1 = Transformation4D.RotateZ(invertY ? -1.0 * System.Math.PI / 2.0 : System.Math.PI / 2.0);
label_11:
                num1 = layoutViewport.Delta.Y;
                num2 = layoutViewport.Delta.X;
            }
            double s = System.Math.Min(printArea.Width / num1, printArea.Height / num2);

            if (!DxfUtil.IsSaneNotZero(s))
            {
                return((DxfLayout.PlotInfo)null);
            }
            Matrix4D matrix4D2 = Transformation4D.Translation(printArea.Center.X, printArea.Center.Y, 0.0) * Transformation4D.Scaling(s) * matrix4D1 * Transformation4D.Translation(-layoutViewport.Center.X, -layoutViewport.Center.Y, 0.0);

            WW.Math.Point3D point3D1 = matrix4D2.Transform(new WW.Math.Point3D(layoutViewport.Corner1, 0.0));
            WW.Math.Point3D point3D2 = matrix4D2.Transform(new WW.Math.Point3D(layoutViewport.Corner2, 0.0));
            return(new DxfLayout.PlotInfo(this, new Size2D(paperWidth, paperHeight), new Rectangle2D(System.Math.Min(point3D1.X, point3D2.X), System.Math.Min(point3D1.Y, point3D2.Y), System.Math.Max(point3D1.X, point3D2.X), System.Math.Max(point3D1.Y, point3D2.Y)), matrix4D2 * layoutRenderInfo.ModelToLayoutTransform, s * layoutRenderInfo.ModelToLayoutScaling));
        }