当前位置: 首页>>代码示例>>C#>>正文


C# Envelope.PutCoords方法代码示例

本文整理汇总了C#中Envelope.PutCoords方法的典型用法代码示例。如果您正苦于以下问题:C# Envelope.PutCoords方法的具体用法?C# Envelope.PutCoords怎么用?C# Envelope.PutCoords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Envelope的用法示例。


在下文中一共展示了Envelope.PutCoords方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExportActiveViewParameterized


//.........这里部分代码省略.........

            if (docExport is IExportImage)
            {
                SetOutputQuality(docActiveView, 1);
            }
            else
            {
                SetOutputQuality(docActiveView, lResampleRatio);
            }

            docExport.ExportFileName = sOutputFileName + "." + docExport.Filter.Split('.')[1].Split('|')[0].Split(')')[0];

            tmpDC = GetDC(0);
            iScreenResolution = GetDeviceCaps((int)tmpDC, 88); //88 is the win32 const for Logical pixels/inch in X)
            ReleaseDC(0, (int)tmpDC);
            frmSetResolution mSetResolution = new frmSetResolution(iOutputResolution);
            mSetResolution.ShowDialog();
            iOutputResolution = mSetResolution.m_Resolution ;
            docExport.Resolution = iOutputResolution;

            if (docActiveView is IPageLayout)
            {
                DisplayBounds = docActiveView.ExportFrame;
                docGraphicsExtentEnv = GetGraphicsExtent(docActiveView);
            }
            else
            {
                docDisplayTransformation = docActiveView.ScreenDisplay.DisplayTransformation;
                DisplayBounds = docDisplayTransformation.get_DeviceFrame();
            }

            PixelBoundsEnv = new Envelope() as IEnvelope;

            if (bClipToGraphicsExtent && (docActiveView is IPageLayout))
            {
                docGraphicsExtentEnv = GetGraphicsExtent(docActiveView);
                docPageLayout = docActiveView as PageLayout;
                pUnitConvertor = new UnitConverter();

                PixelBoundsEnv.XMin = 0;
                PixelBoundsEnv.YMin = 0;
                PixelBoundsEnv.XMax = pUnitConvertor.ConvertUnits(docGraphicsExtentEnv.XMax, docPageLayout.Page.Units, esriUnits.esriInches) * docExport.Resolution - pUnitConvertor.ConvertUnits(docGraphicsExtentEnv.XMin, docPageLayout.Page.Units, esriUnits.esriInches) * docExport.Resolution;
                PixelBoundsEnv.YMax = pUnitConvertor.ConvertUnits(docGraphicsExtentEnv.YMax, docPageLayout.Page.Units, esriUnits.esriInches) * docExport.Resolution - pUnitConvertor.ConvertUnits(docGraphicsExtentEnv.YMin, docPageLayout.Page.Units, esriUnits.esriInches) * docExport.Resolution;

                exportRECT.bottom = (int)(PixelBoundsEnv.YMax) + 1;
                exportRECT.left = (int)(PixelBoundsEnv.XMin);
                exportRECT.top = (int)(PixelBoundsEnv.YMin);
                exportRECT.right = (int)(PixelBoundsEnv.XMax) + 1;

                docMapExtEnv = docGraphicsExtentEnv;
            }
            else
            {
                double tempratio = iOutputResolution / iScreenResolution;
                double tempbottom = DisplayBounds.bottom * tempratio;
                double tempright = DisplayBounds.right * tempratio;
                exportRECT.bottom = (int)Math.Truncate(tempbottom);
                exportRECT.left = 0;
                exportRECT.top = 0;
                exportRECT.right = (int)Math.Truncate(tempright);

                PixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);

                docMapExtEnv = null;
            }
            docExport.PixelBounds = PixelBoundsEnv;

            try
            {
                hdc = docExport.StartExporting();
                docActiveView.Output((int)hdc, (int)docExport.Resolution, ref exportRECT, docMapExtEnv, null);

                docExport.FinishExporting();
                docExport.Cleanup();

                MessageBox.Show("�ɹ����� " + sOutputDir + sOutputFileName + "." + docExport.Filter.Split('.')[1].Split('|')[0].Split(')')[0] + ".", "�����ͼͼƬ", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
            catch
            {
                MessageBox.Show("�����ͼͼƬ�����г������⣡", "�����ͼͼƬ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            finally
            {
                SetOutputQuality(docActiveView, iPrevOutputImageQuality);
                if (bReenable)
                {
                    EnableFontSmoothing();
                    bReenable = false;
                    if (!GetFontSmoothing())
                    {
                        MessageBox.Show("Unable to reenable Font Smoothing", "Font Smoothing error");
                    }
                }

                docMapExtEnv = null;
                PixelBoundsEnv = null;
            }
        }
开发者ID:chinasio,项目名称:minegis,代码行数:101,代码来源:CmdExoprtMapAsPicture.cs

示例2: ExportActiveView


//.........这里部分代码省略.........
            {
                // for vector formats, assign the desired ResampleRatio to control drawing of raster layers at export time
                SetOutputQuality(docActiveView, lResampleRatio);
            }
            //set the name root for the export
            // sNameRoot = "ExportActiveViewSampleOutput";
            //set the export filename (which is the nameroot + the appropriate file extension)
            docExport.ExportFileName = sOutputDir + "\\" + sOutputName + "." + docExport.Filter.Split('.')[1].Split('|')[0].Split(')')[0];

            tmpDC = GetDC(0);

            iScreenResolution = GetDeviceCaps((int)tmpDC, 88); //88 is the win32 const for Logical pixels/inch in X)

            ReleaseDC(0, (int)tmpDC);
            docExport.Resolution = iOutputResolution;

            if (docActiveView is IPageLayout)
            {
                //get the bounds of the "exportframe" of the active view.
                DisplayBounds = docActiveView.ExportFrame;
                //set up pGraphicsExtent, used if clipping to graphics extent.
                docGraphicsExtentEnv = pEnvelope;
            }
            else
            {
                //Get the bounds of the deviceframe for the screen.
                docDisplayTransformation = docActiveView.ScreenDisplay.DisplayTransformation;
                DisplayBounds = docDisplayTransformation.get_DeviceFrame();
            }
            PixelBoundsEnv = new Envelope() as IEnvelope;
            if (bClipToGraphicsExtent && (docActiveView is IPageLayout))
            {
                docGraphicsExtentEnv = pEnvelope;
                docPageLayout = docActiveView as PageLayout;
                pUnitConvertor = new UnitConverter();
                //assign the x and y values representing the clipped area to the PixelBounds envelope
                PixelBoundsEnv.XMin = 0;
                PixelBoundsEnv.YMin = 0;
                PixelBoundsEnv.XMax = pUnitConvertor.ConvertUnits(docGraphicsExtentEnv.XMax, docPageLayout.Page.Units, esriUnits.esriInches) * docExport.Resolution - pUnitConvertor.ConvertUnits(docGraphicsExtentEnv.XMin, docPageLayout.Page.Units, esriUnits.esriInches) * docExport.Resolution;
                PixelBoundsEnv.YMax = pUnitConvertor.ConvertUnits(docGraphicsExtentEnv.YMax, docPageLayout.Page.Units, esriUnits.esriInches) * docExport.Resolution - pUnitConvertor.ConvertUnits(docGraphicsExtentEnv.YMin, docPageLayout.Page.Units, esriUnits.esriInches) * docExport.Resolution;
                //'assign the x and y values representing the clipped export extent to the exportRECT
                exportRECT.bottom = (int)(PixelBoundsEnv.YMax) + 1;
                exportRECT.left = (int)(PixelBoundsEnv.XMin);
                exportRECT.top = (int)(PixelBoundsEnv.YMin);
                exportRECT.right = (int)(PixelBoundsEnv.XMax) + 1;
                //since we're clipping to graphics extent, set the visible bounds.
                docMapExtEnv = docGraphicsExtentEnv;
            }
            else
            {
                double tempratio = iOutputResolution / iScreenResolution;
                double tempbottom = DisplayBounds.bottom * tempratio;
                double tempright = DisplayBounds.right * tempratio;
                //'The values in the exportRECT tagRECT correspond to the width
                //and height to export, measured in pixels with an origin in the top left corner.
                exportRECT.bottom = (int)Math.Truncate(tempbottom);
                exportRECT.left = 0;
                exportRECT.top = 0;
                exportRECT.right = (int)Math.Truncate(tempright);

                //populate the PixelBounds envelope with the values from exportRECT.
                // We need to do this because the exporter object requires an envelope object
                // instead of a tagRECT structure.
                PixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
                //since it's a page layout or an unclipped page layout we don't need docMapExtEnv.
                docMapExtEnv = null;
            }
            // Assign the envelope object to the exporter object's PixelBounds property.  The exporter object
            // will use these dimensions when allocating memory for the export file.
            docExport.PixelBounds = PixelBoundsEnv;
            // call the StartExporting method to tell docExport you're ready to start outputting.
            hdc = docExport.StartExporting();
            // Redraw the active view, rendering it to the exporter object device context instead of the app display.
            // We pass the following values:
            //  * hDC is the device context of the exporter object.
            //  * exportRECT is the tagRECT structure that describes the dimensions of the view that will be rendered.
            // The values in exportRECT should match those held in the exporter object's PixelBounds property.
            //  * docMapExtEnv is an envelope defining the section of the original image to draw into the export object.
            docActiveView.Output((int)hdc, (int)docExport.Resolution, ref exportRECT, docMapExtEnv, null);
            //finishexporting, then cleanup.
            docExport.FinishExporting();
            docExport.Cleanup();
            MessageBox.Show("成功导出地图: " + docExport.ExportFileName, "提示");
            //set the output quality back to the previous value
            SetOutputQuality(docActiveView, iPrevOutputImageQuality);

            if (bReenable)
            {
                EnableFontSmoothing();
                bReenable = false;
                if (!GetFontSmoothing())
                {
                    //error: cannot reenable font smoothing.
                    MessageBox.Show("Unable to reenable Font Smoothing", "Font Smoothing error");
                }
            }

            docMapExtEnv = null;
            PixelBoundsEnv = null;
        }
开发者ID:niwho,项目名称:ArcGISFundation,代码行数:101,代码来源:PrintHelper.cs

示例3: ExportPicPdf

        /// <summary>
        /// 导出为图片或PDF
        /// </summary>
        public static void ExportPicPdf(IMapControl3 m_MapControl)
        {
            SaveFileDialog savePrinterFileDialog = new SaveFileDialog();
            savePrinterFileDialog.Title = "打印成图片";
            savePrinterFileDialog.Filter = "BMP图片(*.bmp)|*.bmp|JPG图片(*.jpg)|*.jpg|PDF 文件(*.pdf)|*.pdf|PNG 图片(*.png)|*.png";
            if (savePrinterFileDialog.ShowDialog() == DialogResult.OK)
            {
                IActiveView activeView = m_MapControl.ActiveView;
                if (activeView == null)
                {
                    return;
                }

                IExport export = null;

                switch (savePrinterFileDialog.FilterIndex)
                {
                    case 1://bmp
                        export = new ExportBMP() as IExport;//输出BMP格式图片
                        export.ExportFileName = savePrinterFileDialog.FileName;
                        break;
                    case 2://jpg
                        export = new ExportJPEG() as IExport;//输出JPG格式图片
                        export.ExportFileName = savePrinterFileDialog.FileName;
                        break;
                    case 3://pdf
                        export = new ExportPDF() as IExport;//输出PDF格式文件
                        ((IExportPDF2)export).ExportMeasureInfo = true;
                        ((IExportPDF2)export).ExportPDFLayersAndFeatureAttributes = esriExportPDFLayerOptions.esriExportPDFLayerOptionsLayersAndFeatureAttributes;
                        export.ExportFileName = savePrinterFileDialog.FileName;
                        break;
                    case 4://png
                        export = new ExportPNG() as IExport;//输出PNG格式图片
                        export.ExportFileName = savePrinterFileDialog.FileName;
                        break;
                }

                if (export == null)
                {
                    MessageBox.Show(@"请选择输出路径。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                int ScreenResolution = 96;
                int OutputResolution = 300;
                export.Resolution = OutputResolution;

                tagRECT exportRECT;
                exportRECT.left = 0;
                exportRECT.top = 0;
                exportRECT.right = activeView.ExportFrame.right * (OutputResolution / ScreenResolution);
                exportRECT.bottom = activeView.ExportFrame.bottom * (OutputResolution / ScreenResolution);

                IEnvelope pixelBoundsEnv = new Envelope() as IEnvelope;
                pixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
                export.PixelBounds = pixelBoundsEnv;
                int hDC = export.StartExporting();
                activeView.Output(hDC, (int)export.Resolution, ref exportRECT, null, null);
                export.FinishExporting();
                export.Cleanup();
            }
        }
开发者ID:ismethr,项目名称:gas-geological-map,代码行数:65,代码来源:MyMapHelp.cs

示例4: ShowResult

		// Outputs result, zoom to route, fill directions
		private void ShowResult(ISMDirections objDirections)
		{
			// Fill directions
			m_dlgDirections.Init(objDirections);
			m_btnShowDirections.Enabled = true;

			try
			{
                // Zoom to extent
				Envelope objEnv = null;
				objEnv = new Envelope();

				objEnv.PutCoords(objDirections.BoundBox.Left, objDirections.BoundBox.Bottom, objDirections.BoundBox.Right, objDirections.BoundBox.Top);
				objEnv.Expand(1.1, 1.1, true);

				// set spatial reference
				IGeometry objGeo = objEnv as IGeometry;
				objGeo.SpatialReference = m_objSpatialReference;

				ZoomToExtent(objEnv);

				// Create polyline
				CreatePolyline(objDirections);
			}
			catch (Exception ex)
			{
				MessageBox.Show(this, "Cannot show result.", "Routing Sample", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
			}
			finally
			{
				// Refresh map
				RefreshMap();
			}
		}
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:35,代码来源:RoutingForm.cs


注:本文中的Envelope.PutCoords方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。