Example #1
0
        public void screenShot(IEnvelope IN_Envelope, string IN_SaveFile, AxMapControl IN_Axmapcontrols, double ratio)
        {
            /*
             * IN_Envelope为输出范围,单位为米
             * IN_SaveFile为输出文件名
             * IN_Axmapcontrols map控件
             * ratio 影像空间分辨率的倒数
             *
             */
            if (IN_Envelope == null)
            {
                IN_Envelope = IN_Axmapcontrols.ActiveView.Extent;
            }

            IExport     Temp_Exporter          = new ExportJPEGClass(); //定义输出设备 Temp_Exporter
            IActiveView Temp_CurrentActiveView = IN_Axmapcontrols.ActiveView;

            tagRECT Temp_TtagRECT; //定义的是输出设备的像素大小

            Temp_TtagRECT.left   = 0;
            Temp_TtagRECT.top    = 0;
            Temp_TtagRECT.right  = (int)(IN_Envelope.Width * ratio);
            Temp_TtagRECT.bottom = (int)(IN_Envelope.Height * ratio);

            int Temp_DPI = 300;                            //DPI 设置

            IEnvelope Temp_Envelope = new EnvelopeClass(); //定义一个Envelope来确定设备单元中输出的图片大小

            Temp_Envelope.PutCoords(Temp_TtagRECT.left, Temp_TtagRECT.top, Temp_TtagRECT.right, Temp_TtagRECT.bottom);
            //Temp_Envelope.PutCoords(0, 0, 500, 500); 此参数只会显示图片左上角500*500区域

            Temp_Exporter.Resolution     = Temp_DPI;
            Temp_Exporter.ExportFileName = IN_SaveFile;
            Temp_Exporter.PixelBounds    = Temp_Envelope;

            //IOutputRasterSettings pOutputRasterS = (IOutputRasterSettings)IN_Axmapcontrols.ActiveView.ScreenDisplay.DisplayTransformation;
            IOutputRasterSettings pOutputRasterS = (IOutputRasterSettings)Temp_CurrentActiveView.ScreenDisplay.DisplayTransformation;

            pOutputRasterS.ResampleRatio = 1;   //设置了这个采样比例后,输出图片的像素和原始影像的像素一样!

            Temp_CurrentActiveView.Output(Temp_Exporter.StartExporting(), (int)Temp_DPI, ref Temp_TtagRECT, IN_Envelope, null);

            Temp_Exporter.FinishExporting();
            Temp_Exporter.Cleanup();

            System.Runtime.InteropServices.Marshal.ReleaseComObject(Temp_Exporter);
        }
        private void btnPrint_Click(object sender, EventArgs e)
        {
            this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
            if (export is IOutputRasterSettings)
            {
                //矢量格式输出
                rasterSettings = (IOutputRasterSettings)export;
                rasterSettings.ResampleRatio = 1;
            }
            if (Information.IsNumeric(txtResolution.Text))
            {
                iOutputResolution = Convert.ToInt32(txtResolution.Text);
            }
            else
            {
                iOutputResolution = 300;
            }

            IActiveView pActiveView       = axPageLayoutControl1.ActiveView;
            double      iScreenResolution = pActiveView.ScreenDisplay.DisplayTransformation.Resolution;
            tagRECT     exportRECT;

            exportRECT.left   = 0;
            exportRECT.top    = 0;
            exportRECT.right  = Convert.ToInt32(Math.Ceiling(pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution)));
            exportRECT.bottom = Convert.ToInt32(Math.Round(pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution)));
            IEnvelope pPixelBoundsEnv = new EnvelopeClass();

            pPixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
            export.Resolution     = iOutputResolution;
            export.PixelBounds    = pPixelBoundsEnv;
            export.ExportFileName = exportFileName;
            int hDC = export.StartExporting();

            pActiveView.Output(hDC, (int)export.Resolution, ref exportRECT, null, null);
            export.FinishExporting();
            export.Cleanup();
            this.Close();
            this.Cursor = Cursors.Default;
            MessageBox.Show("输出成功!", "消息提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Example #3
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (export is IOutputRasterSettings)
            {
                rasterSettings = export as IOutputRasterSettings;
                rasterSettings.ResampleRatio = 1;
            }
            if (Information.IsNumeric(txtResolution.Text))
            {
                iOutputResolution = Convert.ToInt32(txtResolution.Text);
            }
            else
            {
                iOutputResolution = 300;
            }
            IActiveView pActiveView       = axPageLayoutControl1.ActiveView;
            double      iScreenResolution = pActiveView.ScreenDisplay.
                                            DisplayTransformation.Resolution;
            tagRECT exportRECT; exportRECT.left = 0; exportRECT.top = 0;

            exportRECT.right = Convert.ToInt32(Math.Ceiling(pActiveView.ExportFrame.
                                                            right * (iOutputResolution / iScreenResolution)));
            exportRECT.bottom = Convert.ToInt32(Math.Round(pActiveView.ExportFrame.
                                                           bottom * (iOutputResolution / iScreenResolution)));
            IEnvelope pPixelBoundsEnv = new Envelope() as IEnvelope;

            pPixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right
                                      , exportRECT.bottom);
            export.Resolution     = iOutputResolution;
            export.PixelBounds    = pPixelBoundsEnv;
            export.ExportFileName = exportFileName;
            int hDC = export.StartExporting();

            pActiveView.Output(hDC, (int)export.Resolution, ref exportRECT,
                               null, null);
            export.FinishExporting();
            export.Cleanup();
            MessageBox.Show("Export Success");
        }
Example #4
0
        public void PrintActiveViewParameterized(long long_0)
        {
            short                 num6;
            tagRECT               grect;
            IActiveView           view                  = this.iactiveView_0;
            IEnvelope             deviceBounds          = new EnvelopeClass();
            IEnvelope             pageBounds            = new EnvelopeClass();
            IOutputRasterSettings displayTransformation =
                view.ScreenDisplay.DisplayTransformation as IOutputRasterSettings;
            long resampleRatio = displayTransformation.ResampleRatio;

            this.method_4(view, long_0);
            this.iprinter_0.SpoolFileName = "打印地图";
            int num2 = CreateDC(this.iprinter_0.DriverName, this.iprinter_0.Paper.PrinterName, "", IntPtr.Zero);

            if (this.iactiveView_0 is IPageLayout)
            {
                double overlap   = 0.0;
                short  num4      = 1;
                short  pageCount = 1;
                if (this.rdoTitle.Checked)
                {
                    overlap = double.Parse(this.txbOverlap.Text);
                    (this.iactiveView_0 as IPageLayout).Page.PrinterPageCount(this.iprinter_0, 0.0, out num6);
                    if (this.rdoAll.Checked)
                    {
                        (this.iactiveView_0 as IPageLayout2).Page.PrinterPageCount(this.iprinter_0,
                                                                                   Convert.ToDouble(this.txbOverlap.Text), out pageCount);
                    }
                    else
                    {
                        num4      = (short)this.txbStartPage.Value;
                        pageCount = (short)this.txbEndPage.Value;
                    }
                }
                num4 = (short)(num4 - 1);
                int hDC = 0;
                for (short i = num4; i < pageCount; i = (short)(i + 1))
                {
                    (this.iactiveView_0 as IPageLayout).Page.GetDeviceBounds(this.iprinter_0, i, overlap,
                                                                             this.iprinter_0.Resolution, deviceBounds);
                    grect.bottom = ((int)deviceBounds.YMax) - GetDeviceCaps(num2, 113);
                    grect.left   = ((int)deviceBounds.XMin) - GetDeviceCaps(num2, 112);
                    grect.right  = ((int)deviceBounds.XMax) - GetDeviceCaps(num2, 112);
                    grect.top    = ((int)deviceBounds.YMin) - GetDeviceCaps(num2, 113);
                    deviceBounds.PutCoords(0.0, 0.0, (double)(grect.right - grect.left),
                                           (double)(grect.bottom - grect.top));
                    (this.iactiveView_0 as IPageLayout).Page.GetPageBounds(this.iprinter_0, i, overlap, pageBounds);
                    hDC = this.iprinter_0.StartPrinting(deviceBounds, 0);
                    this.iactiveView_0.Output(hDC, this.iprinter_0.Resolution, ref grect, pageBounds, null);
                    this.iprinter_0.FinishPrinting();
                }
            }
            else
            {
                num6       = 1;
                pageBounds = null;
                if (this.ipageLayoutControl_0 != null)
                {
                    this.ipageLayoutControl_0.Page.GetDeviceBounds(this.iprinter_0, 0, 0.0, this.iprinter_0.Resolution,
                                                                   deviceBounds);
                    grect.bottom = ((int)deviceBounds.YMax) - GetDeviceCaps(num2, 113);
                    grect.left   = ((int)deviceBounds.XMin) - GetDeviceCaps(num2, 112);
                    grect.right  = ((int)deviceBounds.XMax) - GetDeviceCaps(num2, 112);
                    grect.top    = ((int)deviceBounds.YMin) - GetDeviceCaps(num2, 113);
                }
                else
                {
                    WKSEnvelope envelope3;
                    this.iprinter_0.PrintableBounds.QueryWKSCoords(out envelope3);
                    double a     = envelope3.XMin * this.iprinter_0.Resolution;
                    double num10 = envelope3.XMax * this.iprinter_0.Resolution;
                    double num11 = envelope3.YMin * this.iprinter_0.Resolution;
                    double num12 = envelope3.YMax * this.iprinter_0.Resolution;
                    grect.left   = (int)Math.Round(a);
                    grect.top    = (int)Math.Round(num11);
                    grect.right  = (int)Math.Round(num10);
                    grect.bottom = (int)Math.Round(num12);
                }
                this.iactiveView_0.Output(this.iprinter_0.StartPrinting(deviceBounds, 0), this.iprinter_0.Resolution,
                                          ref grect, pageBounds, null);
                this.iprinter_0.FinishPrinting();
            }
            this.method_4(view, resampleRatio);
            ReleaseDC(0, num2);
        }
        /// <summary>
        /// Called when a step of this type is executed in the workflow.
        /// </summary>
        /// <param name="JobID">ID of the job being executed</param>
        /// <param name="StepID">ID of the step being executed</param>
        /// <param name="argv">Array of arguments passed into the step's execution</param>
        /// <param name="ipFeedback">Feedback object to return status messages and files</param>
        /// <returns>Return code of execution for workflow path traversal</returns>
        public int Execute(int JobID, int stepID, ref object[] argv, ref IJTXCustomStepFeedback ipFeedback)
        {
            if (JobID <= 0)
            {
                throw new ArgumentOutOfRangeException("JobID", JobID, "Job ID must be a positive value");
            }

            try
            {
                string strTemp = "";
                bool   bAttach = false;
                if (StepUtilities.GetArgument(ref argv, m_expectedArgs[1], false, out strTemp))
                {
                    bAttach = true;
                }

                string strResolution;
                if (!StepUtilities.GetArgument(ref argv, m_expectedArgs[2], false, out strResolution))
                {
                    strResolution = "1200";
                }

                int iResolution = 1200;
                if (!Int32.TryParse(strResolution, out iResolution))
                {
                    iResolution = 1200;
                }

                string outputPath = "";
                if (!bAttach)
                {
                    SaveFileDialog pSaveFileDialog = new SaveFileDialog();
                    pSaveFileDialog.Filter = "PDF files (*.pdf)|*.pdf";
                    pSaveFileDialog.Title  = "Choose output location...";

                    string strInitDir = "";
                    if (StepUtilities.GetArgument(ref argv, m_expectedArgs[0], true, out strInitDir))
                    {
                        if (System.IO.Directory.Exists(strInitDir))
                        {
                            pSaveFileDialog.InitialDirectory = strInitDir;
                        }
                    }

                    if (pSaveFileDialog.ShowDialog() != DialogResult.OK)
                    {
                        return(-1);
                    }

                    outputPath = pSaveFileDialog.FileName;
                }

                string inputPath = JTXUtilities.SaveJobMXD(JobID);

                if (bAttach)
                {
                    outputPath = SystemUtilities.GetTemporaryFileLocation(inputPath, "pdf");
                }

                // delete output file if it already exists
                System.IO.FileInfo fi = new System.IO.FileInfo(outputPath);
                if (fi.Exists)
                {
                    fi.Delete();
                }

                MapDocumentClass map = new MapDocumentClass();

                if (!map.get_IsMapDocument(inputPath))
                {
                    throw new ApplicationException("Invalid map or specified map not found.");
                }

                map.Open(inputPath, null);

                IActiveView pActiveView = (IActiveView)map.PageLayout;
                IExport     pExport     = new ExportPDFClass();

                pExport.ExportFileName = outputPath;

                tagRECT deviceFrameRect;
                deviceFrameRect.left   = 0;
                deviceFrameRect.right  = 800;
                deviceFrameRect.top    = 0;
                deviceFrameRect.bottom = 600;

                pActiveView.ScreenDisplay.DisplayTransformation.set_DeviceFrame(ref deviceFrameRect);

                int iOutputResolution = iResolution;
                int iScreenResolution = 96;
                pExport.Resolution = iOutputResolution;
                IOutputRasterSettings pOutputRasterSettings = (IOutputRasterSettings)pExport;
                pOutputRasterSettings.ResampleRatio = 1;

                tagRECT exportRect;

                exportRect.left   = pActiveView.ExportFrame.left * (iOutputResolution / iScreenResolution);
                exportRect.top    = pActiveView.ExportFrame.top * (iOutputResolution / iScreenResolution);
                exportRect.right  = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution);
                exportRect.bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution);

                IEnvelope pPixelBoundsEnv = new EnvelopeClass();

                pPixelBoundsEnv.PutCoords(exportRect.left, exportRect.top, exportRect.right, exportRect.bottom);
                pExport.PixelBounds = pPixelBoundsEnv;

                int hdc = pExport.StartExporting();
                pActiveView.Output(hdc, iOutputResolution, ref exportRect, null, null);
                pExport.FinishExporting();
                pExport.Cleanup();

                if (bAttach)
                {
                    JTXUtilities.AddAttachmentToJob(JobID, outputPath, jtxFileStorageType.jtxStoreInDB);
                }

                return(0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }