本文整理汇总了C#中EnvelopeClass.PutCoords方法的典型用法代码示例。如果您正苦于以下问题:C# EnvelopeClass.PutCoords方法的具体用法?C# EnvelopeClass.PutCoords怎么用?C# EnvelopeClass.PutCoords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EnvelopeClass
的用法示例。
在下文中一共展示了EnvelopeClass.PutCoords方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddLegend
/// <summary>
/// 图例
/// </summary>
/// <returns></returns>
public bool AddLegend()
{
IGraphicsContainer pGraphicsContainer;
pGraphicsContainer = mainPage.PageLayout as IGraphicsContainer;
IMapFrame pFocusMapFrame;
pFocusMapFrame = pGraphicsContainer.FindFrame(mainPage.ActiveView.FocusMap) as IMapFrame;
UID u = new UIDClass();
u.Value = "esriCarto.Legend";
IMapSurroundFrame pLegendFrame;
pLegendFrame = pFocusMapFrame.CreateSurroundFrame(u, null);
IEnvelope pEnvelope;
pEnvelope = new EnvelopeClass();
pEnvelope.PutCoords(3, 3, 6, 8);
IElement pElement;
pElement = pLegendFrame as IElement;
pElement.Geometry = pEnvelope;
ILegendWizard pLegendWizard;
pLegendWizard = new LegendWizard();
pLegendWizard.PageLayout = mainPage.PageLayout;
pLegendWizard.InitialLegendFrame = pLegendFrame;
bool bOk = pLegendWizard.DoModal(mainPage.hWnd);
if (bOk == true)
{
IElement ele = pLegendWizard.LegendFrame as IElement;
pGraphicsContainer.AddElement(ele, 0);
mainPage.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
return true;
}
示例2: ExportPictureMyself
/// <summary>
/// 导出图片
/// </summary>
public void ExportPictureMyself(string fileName)
{
IActiveView pActiveView = pagelayout.ActiveView;
IEnvelope pEnv;
int iOutputResolution = 600;
int iScreenResolution = 96;
int hDC;
tagRECT exportRECT;
exportRECT.left = 0;
exportRECT.top = 0;
exportRECT.right = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution);
exportRECT.bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution);
pEnv = new EnvelopeClass();
pEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
IExportFileDialog pExportFileDialog = new ExportFileDialogClass();
string filename = fileName;
IExport pExport = new ExportJPEGClass();
pExport.ExportFileName = filename;
pExport.Resolution = iOutputResolution;
pExport.PixelBounds = pEnv;
hDC = pExport.StartExporting();
pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null);
pExport.FinishExporting();
pExport.Cleanup();
}
示例3: AddImgScaleBar
/// <summary>
/// 图形比例尺
/// </summary>
/// <returns></returns>
public bool AddImgScaleBar()
{
IStyleSelector pStyleSelector = new ScaleBarSelectorClass();
bool m_bOK = pStyleSelector.DoModal(0);
if (m_bOK == true)
{
IScaleBar pScaleBar = pStyleSelector.GetStyle(0) as IScaleBar;
IEnvelope envelope = new EnvelopeClass();
envelope.PutCoords(0.2, 0.2, 5, 1);
ESRI.ArcGIS.esriSystem.IUID uid = new ESRI.ArcGIS.esriSystem.UIDClass();
uid.Value = "esriCarto.Scalebar";
IMap pMap = mainPage.ActiveView.FocusMap;
IGraphicsContainer graphicsContainer = mainPage.ActiveView as IGraphicsContainer;
IActiveView activeView = mainPage.ActiveView as IActiveView;
IFrameElement frameElement = graphicsContainer.FindFrame(pMap);
IMapFrame mapFrame = frameElement as IMapFrame;
IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uid as ESRI.ArcGIS.esriSystem.UID, null);
IMapSurround mapsurround = pScaleBar as IMapSurround;
mapSurroundFrame.MapSurround = mapsurround;
IElement element = mapSurroundFrame as IElement;
element.Geometry = envelope;
element.Activate(activeView.ScreenDisplay);
graphicsContainer.AddElement(element, 0);
IMapSurround mapSurround = mapSurroundFrame.MapSurround;
}
return true;
}
示例4: get_extent
public static ESRI.ArcGIS.Geometry.IEnvelope get_extent(OSGeo.OGR.Envelope ogr_envelope, ISpatialReference sr)
{
IEnvelope env = new EnvelopeClass();
env.PutCoords(ogr_envelope.MinX, ogr_envelope.MinY, ogr_envelope.MaxX, ogr_envelope.MaxY);
env.SpatialReference = sr;
return env;
}
示例5: ExportMap
/// <summary>
/// 保存当前ActiveView为图片
/// </summary>
/// <param name="SaveFilePath">图片路径</param>
/// <param name="ActiveView">Map ActiveView</param>
public static void ExportMap(string SaveFilePath,IActiveView ActiveView)
{
IExport export = ExportBase(SaveFilePath);
double IScreenResolution = ActiveView.ScreenDisplay.DisplayTransformation.Resolution;
export.ExportFileName = SaveFilePath;
export.Resolution = IScreenResolution;
ESRI.ArcGIS.esriSystem.tagRECT deviceRECT = ActiveView.ExportFrame;
IEnvelope envelope = new EnvelopeClass();
deviceRECT.right = deviceRECT.right * 10;
deviceRECT.bottom = deviceRECT.bottom * 10;
envelope.PutCoords(deviceRECT.left, deviceRECT.top, deviceRECT.right, deviceRECT.bottom);
export.PixelBounds = envelope;
ITrackCancel Cancel=new ESRI.ArcGIS.Display.CancelTrackerClass();
ActiveView.Output(export.StartExporting(), (int)IScreenResolution*10, ref deviceRECT, ActiveView.Extent, Cancel);
export.FinishExporting();
export.Cleanup();
//MessageBox.Show("OK");
}
示例6: BoundsFromMetadata
private IEnvelope BoundsFromMetadata(XElement boundsElement)
{
double? xmin = GetSafeDoubleAttribute(boundsElement, "minlon");
double? xmax = GetSafeDoubleAttribute(boundsElement, "maxlon");
double? ymin = GetSafeDoubleAttribute(boundsElement, "minlat");
double? ymax = GetSafeDoubleAttribute(boundsElement, "maxlat");
if (!xmin.HasValue || !xmax.HasValue || !ymin.HasValue || !ymax.HasValue)
return null;
if (xmin < -180 || ymin < -90 || xmax > 180 || ymax > 90 || xmin > xmax || ymin > ymax)
return null;
IEnvelope bounds = new EnvelopeClass { SpatialReference = SpatialReference };
bounds.PutCoords((double)xmin, (double)ymin, (double)xmax, (double)ymax);
return bounds;
}
示例7: ExportPicture
/// <summary>
/// 导出图片
/// </summary>
public void ExportPicture(string strdefaultfilename)
{
if (strdefaultfilename.Contains("制"))
{
strdefaultfilename = strdefaultfilename.Replace("制","");
}
try
{
IActiveView pActiveView =axPageLayoutControl1.ActiveView;
IEnvelope pEnv;
int iOutputResolution = 600;
int iScreenResolution = 96;
int hDC;
tagRECT exportRECT;
exportRECT.left = 0;
exportRECT.top = 0;
//exportRECT.right = pActiveView.ExportFrame.right;
//exportRECT.bottom = pActiveView.ExportFrame.bottom;
exportRECT.right = pActiveView.ExportFrame.right * (iOutputResolution / iScreenResolution);
exportRECT.bottom = pActiveView.ExportFrame.bottom * (iOutputResolution / iScreenResolution);
pEnv = new EnvelopeClass();
pEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
IExportFileDialog pExportFileDialog = new ExportFileDialogClass();
pExportFileDialog.DocumentName = strdefaultfilename;
//bool bl;
//bl = pExportFileDialog.DoModal(pEnv, pActiveView.Extent, pActiveView.Extent, 900);
//if (!bl) return;
//IExport pExport = pExportFileDialog.Export;
//pExport.Resolution = iOutputResolution;
//pExport.PixelBounds = pEnv;
string filename = Application.StartupPath + @"\Image\1.jpg";
if (File.Exists(filename))
{
File.Delete(filename);
}
IExport pExport = new ExportJPEGClass();
pExport.ExportFileName = filename;
pExport.Resolution = iOutputResolution;
pExport.PixelBounds = pEnv;
hDC = pExport.StartExporting();
pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null);
pExport.FinishExporting();
pExport.Cleanup();
hDC = pExport.StartExporting();
pActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, null, null);
pExport.FinishExporting();
pExport.Cleanup();
// MessageBox.Show("保存成功", "提示");
}
catch (Exception ax)
{
MessageBox.Show(ax.ToString());
}
//try
//{
// System.Windows.Forms.SaveFileDialog sfd = new SaveFileDialog();
// sfd.Filter = "*.jpeg|*.jpeg|*.pdf|*.pdf|*.bmp|*.bmp";
// if (sfd.ShowDialog() == DialogResult.OK)
// {
// IExport pExport = null;
// if (1 == sfd.FilterIndex)
// {
// pExport = new ExportJPEGClass();
// }
// else if (2 == sfd.FilterIndex)
// {
// pExport = new ExportPDFClass();
// }
// else if (3 == sfd.FilterIndex)
// {
// pExport = new ExportBMPClass();
// }
// pExport.ExportFileName = sfd.FileName;
// //设置参数
// //默认精度
// int reslution = 300;
// pExport.Resolution = reslution;
// //获取导出范围
// tagRECT exportRECT = axPageLayoutControl1.ActiveView.ExportFrame;
// //tagRECT exportRECT = axMapMain.ActiveView.ExportFrame;
// IEnvelope pPixelBoundsEnv = new EnvelopeClass();
// pPixelBoundsEnv.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
// pExport.PixelBounds = pPixelBoundsEnv;
// //开始导出,获取DC
// int hDC = pExport.StartExporting();
// IEnvelope pVisbounds = null;
// ITrackCancel ptrac = null;
// //导出
// axPageLayoutControl1.ActiveView.Output(hDC, (int)pExport.Resolution, ref exportRECT, pVisbounds, ptrac);
// //结束导出
// pExport.FinishExporting();
// //清理导出类
// pExport.Cleanup();
// MessageBox.Show("导出成功","提示");
//.........这里部分代码省略.........
示例8: CreateTransFromDC
private ITransformation CreateTransFromDC(int hDC, int lWidth, int lHeight)
{
// Calculate the parameters for the new transformation, based on the dimensions passed to this function.
IEnvelope pBoundsEnvelope = new EnvelopeClass();
pBoundsEnvelope.PutCoords(0, 0, lWidth, lHeight);
tagRECT deviceRect;
deviceRect.left = 0;
deviceRect.top = 0;
deviceRect.right = lWidth;
deviceRect.bottom = lHeight;
//int dpi;
//dpi = GetDeviceCaps(hDC, LOGPIXELSY);
//if (dpi == 0) return null;
// Create a new display transformation and set its properties.
IDisplayTransformation pDisplayTransformation = new DisplayTransformationClass();
pDisplayTransformation.VisibleBounds = pBoundsEnvelope;
pDisplayTransformation.Bounds = pBoundsEnvelope;
pDisplayTransformation.set_DeviceFrame(ref deviceRect);
pDisplayTransformation.Resolution = 300;
return pDisplayTransformation;
}
示例9: BoundsFromFileScan
private IEnvelope BoundsFromFileScan()
{
double xmin = double.MaxValue,
ymin = double.MaxValue,
xmax = double.MinValue,
ymax = double.MinValue;
var ptNodes = Root.Descendants().Where(e => e.Name == _xmlNamespace + "wpt" || e.Name == _xmlNamespace + "trkpt" || e.Name == _xmlNamespace + "rtept");
var coords = from e in ptNodes
select new { X = GetSafeDoubleAttribute(e, "lon"), Y = GetSafeDoubleAttribute(e, "lat") };
foreach (var coord in coords.Where(coord => coord.X.HasValue && coord.Y.HasValue))
{
if (coord.X < xmin) xmin = coord.X.Value;
if (coord.X > xmax) xmax = coord.X.Value;
if (coord.Y < ymin) ymin = coord.Y.Value;
if (coord.Y > ymax) ymax = coord.Y.Value;
}
if (xmin < -180 || ymin < -90 || xmax > 180 || ymax > 90 || xmin > xmax || ymin > ymax)
return null;
IEnvelope bounds = new EnvelopeClass { SpatialReference = SpatialReference };
bounds.PutCoords(xmin, ymin, xmax, ymax);
return bounds;
}
示例10: FullExtend
/// <summary>
/// 全屏显示
/// </summary>
public static void FullExtend(AxMapControl axMapControl)
{
if (axMapControl == null)
{
return;
}
IEnvelope env = new EnvelopeClass() as IEnvelope;
env.PutCoords(21256119.5385824, 4381043.1259153, 21812540.059758, 4846733.37736962);
axMapControl.ActiveView.Extent = env;
axMapControl.Refresh();
//ICommand pCommand;
//pCommand = new ESRI.ArcGIS.Controls.ControlsMapFullExtentCommand();
//pCommand.OnCreate(axMapControl.Object);
//pCommand.OnClick();
}
示例11: DoClassifyHandler
/*
*该方法通过纯粹的Arcobject的方式实现最大似然分类 *
*
* *
*/
private byte[] DoClassifyHandler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties)
{
_logger.LogMessage(ServerLogger.msgType.infoDetailed, _soename + ".GetRasterStatistics", 8000, "request received");
if (!_supportRasterItemAccess)
throw new ArgumentException("The image service does not have a catalog and does not support this operation");
responseProperties = null;
long? objectID;
long? classCount;
//case insensitive
bool found = operationInput.TryGetAsLong("objectID", out objectID);
if (!found || (objectID == null))
throw new ArgumentNullException("ObjectID");
found = operationInput.TryGetAsLong("classnumber", out classCount);
if (!found || (objectID == null))
throw new ArgumentNullException("classnumber");
IRasterCatalogItem rasterCatlogItem = null;
try
{
rasterCatlogItem = _mosaicCatalog.GetFeature((int)objectID) as IRasterCatalogItem;
if (rasterCatlogItem == null)
{
_logger.LogMessage(ServerLogger.msgType.infoDetailed, _soename + ".GetRasterStatistics", 8000, "request finished with exception");
throw new ArgumentException("The input ObjectID does not exist");
}
}
catch
{
_logger.LogMessage(ServerLogger.msgType.infoDetailed, _soename + ".GetRasterStatistics", 8000, "request finished with exception");
throw new ArgumentException("The input ObjectID does not exist");
}
JsonObject result = new JsonObject();
string outputurl = "";
try
{
IRasterDataset pRasterDataSet = rasterCatlogItem.RasterDataset;
IGeoDataset pGeo = pRasterDataSet as IGeoDataset;
string inPath = @"D:\arcgisserver\directories\arcgisoutput\imageserver\test2_ImageServer";
string gsgname = System.DateTime.Now.ToString().Replace("/", "").Replace(":", "").Replace(" ", "") + ".gsg";
string gsgPath = System.IO.Path.Combine(inPath, gsgname);
bool bcreatesignaturefile = Classify.CreateSignaturefile(pRasterDataSet, Convert.ToInt32(classCount), gsgPath);
if (bcreatesignaturefile)
{
IMultivariateOp pMultivarateOp = new RasterMultivariateOpClass();
IGeoDataset pGeoDatasetResult = pMultivarateOp.MLClassify(pGeo, gsgPath, false, esriGeoAnalysisAPrioriEnum.esriGeoAnalysisAPrioriEqual, Type.Missing, Type.Missing);
IEnvelope pEnvelp = new EnvelopeClass();
string outurl = "http://localhost:6080/arcgis/rest/directories/arcgisoutput/imageserver/test2_ImageServer/";
pEnvelp.PutCoords(116.56075474, 40.29407147, 116.63105347, 40.34514666);
// string dd = ExportImage.ExportLayerImage((IRaster)pGeoDatasetResult, bbox, new string[] { "400", "400" }, outurl, fileDir);
outputurl = ExportImage.CreateJPEGFromActiveView((IRaster)pGeoDatasetResult, pEnvelp, outurl, inPath);
}
}
catch
{
}
result.AddString("url", outputurl);
return Encoding.UTF8.GetBytes(result.ToJson());
}
示例12: AddLegend
public static void AddLegend(AxPageLayoutControl pageLayoutControl)
{
try
{
IEnvelope pEnvelope = new EnvelopeClass();
pEnvelope.PutCoords(0.2,0.2,5,5);
IActiveView pActiveView = pageLayoutControl as IActiveView;
IMap pMap = pActiveView.FocusMap;
IGraphicsContainer pGraphicsContainer = pActiveView as IGraphicsContainer;
IMapFrame pMapFram = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
IElement mapElement = pMapFram as IElement;
IEnvelope mapEnv = mapElement.Geometry.Envelope;
pEnvelope.PutCoords(mapEnv.XMin, mapEnv.YMin, mapEnv.XMin + 6.5, mapEnv.YMin + 0.8);
UID pUID = new UID();
pUID.Value = "{7A3F91E4-B9E3-11d1-8756-0000F8751720}";
ISymbolBackground pSymbolBackground = new SymbolBackgroundClass();
IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
pFillSymbol.Color = GetRgbColor(255, 255, 255);
pLineSymbol.Color = GetRgbColor(255, 255, 255);
pFillSymbol.Outline = pLineSymbol;
pSymbolBackground.FillSymbol = pFillSymbol;
IMapSurroundFrame pMapSurroundFrame = pMapFram.CreateSurroundFrame(pUID, null);
pMapSurroundFrame.Background = pSymbolBackground;
IElement pElement = pMapSurroundFrame as IElement;
pElement.Geometry = pEnvelope;
IMapSurround pMapSurround = pMapSurroundFrame.MapSurround;
ILegend pLegend = pMapSurround as ILegend;
pLegend.ClearItems();
pLegend.Title = "图例";
ITextSymbol pTextSymbol = new TextSymbolClass();
pTextSymbol.Size = 10;
pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
ILegendItem pLegendItem = null;
for (int i = 0; i < pActiveView.FocusMap.LayerCount; i++)
{
ILayer pLayer = pActiveView.FocusMap.get_Layer(i);
if (pLayer is IFeatureLayer)
{
IFeatureLayer pFLayer = pLayer as IFeatureLayer;
IFeatureClass pFeatureClass = pFLayer.FeatureClass;
if (pFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)
{
continue;
}
else
{
pLegendItem = new HorizontalLegendItemClass();
pLegendItem.Layer = pLayer;
pLegendItem.Columns = 1;
pLegendItem.ShowDescriptions = false;
pLegendItem.ShowHeading = false;
pLegendItem.ShowLabels = true;
pLegendItem.LayerNameSymbol = pTextSymbol;
pLegend.AddItem(pLegendItem);
}
}
}
}
catch(Exception Err)
{ }
}
示例13: CreateBitmap
/// <summary>
/// Create Bitmap From ESRI Dataset
/// </summary>
/// <param name="dataset">Dataset to generate an image from</param>
/// <param name="imageFormat">Output image format</param>
/// <param name="size">Size of output image</param>
/// <param name="resolution">Resolution of output image (dpi)</param>
/// <param name="background">Background color</param>
/// <param name="filename">Ouput filename</param>
public static void CreateBitmap(IDataset dataset, esriImageFormat imageFormat, Size size, ushort resolution, Color background, string filename) {
ILayer layer = null;
switch (dataset.Type) {
case esriDatasetType.esriDTFeatureClass:
IFeatureClass featureClass = (IFeatureClass)dataset;
switch (featureClass.FeatureType) {
case esriFeatureType.esriFTDimension:
layer = new DimensionLayerClass();
break;
case esriFeatureType.esriFTAnnotation:
layer = new FeatureLayerClass();
IGeoFeatureLayer geoFeaureLayer = (IGeoFeatureLayer)layer;
geoFeaureLayer.DisplayAnnotation = true;
break;
case esriFeatureType.esriFTComplexEdge:
case esriFeatureType.esriFTComplexJunction:
case esriFeatureType.esriFTSimple:
case esriFeatureType.esriFTSimpleEdge:
case esriFeatureType.esriFTSimpleJunction:
layer = new FeatureLayerClass();
break;
}
if (layer == null) { return; }
IFeatureLayer featureLayer = (IFeatureLayer)layer;
featureLayer.FeatureClass = featureClass;
break;
case esriDatasetType.esriDTRasterDataset:
layer = new RasterLayerClass();
IRasterLayer rasterLayer = (IRasterLayer)layer;
rasterLayer.CreateFromDataset((IRasterDataset)dataset);
break;
default:
string message = string.Format("[{0}] is not supported", dataset.Type.ToString());
throw new Exception(message);
}
if (layer == null) { return; }
// Create In-memory Map
IMap map = new MapClass();
map.AddLayer(layer);
IActiveView activeView = (IActiveView)map;
IExport export = null;
tagRECT rect = new tagRECT();
// Set Format Specific Properties
switch (imageFormat) {
case esriImageFormat.esriImageJPG:
export = new ExportJPEGClass();
IExportJPEG exportJpeg = (IExportJPEG)export;
exportJpeg.ProgressiveMode = false;
exportJpeg.Quality = 100;
break;
default:
throw new Exception("[" + imageFormat.ToString() + "] is not supported");
}
if (export == null) {
throw new Exception("Failed to Created Exporter");
}
// Set Background
if ((export is IExportBMP) ||
(export is IExportGIF) ||
(export is IExportJPEG) ||
(export is IExportPNG) ||
(export is IExportTIFF)) {
IExportImage exportImage = (IExportImage)export;
exportImage.ImageType = esriExportImageType.esriExportImageTypeTrueColor;
exportImage.BackgroundColor = GeodatabaseUtility.ToESRIColor(background);
}
// Set Export Frame
rect = activeView.ExportFrame;
rect.left = 0;
rect.top = 0;
rect.right = size.Width;
rect.bottom = size.Height;
// Set Output Extent
IEnvelope envelope = new EnvelopeClass();
envelope.PutCoords(rect.left, rect.top, rect.right, rect.bottom);
export.PixelBounds = envelope;
export.Resolution = resolution;
export.ExportFileName = filename;
// Export map to image
int intHdc = export.StartExporting();
activeView.Output(intHdc, resolution, ref rect, null, null);
//.........这里部分代码省略.........
示例14: getTransformation
private ITransformation getTransformation(PictureBox picTarget)
{
RECT boundsRect;
GetWindowRect(picTarget.Handle.ToInt32(), out boundsRect);
int lWidth = boundsRect.Right - boundsRect.Left;
int lHeight = boundsRect.Bottom - boundsRect.Top;
IDisplayTransformation pDispTrans = new DisplayTransformationClass();
IEnvelope pBounds = new EnvelopeClass();
pBounds.PutCoords(picTarget.Left, picTarget.Top, picTarget.Right, picTarget.Bottom);
//pBounds.PutCoords(0, 0, lHeight, lWidth);
pDispTrans.VisibleBounds = pBounds;
pDispTrans.Bounds = pBounds;
tagRECT deviceRect;
deviceRect.left = 0;
deviceRect.top = 0;
deviceRect.right = lWidth;
deviceRect.bottom = lHeight;
pDispTrans.set_DeviceFrame(ref deviceRect);
IntPtr lHDC = picTarget.Handle;
int lDpi = GetDeviceCaps(lHDC, LOGPIXELSY);
if (lDpi == 0) lDpi = 300;
pDispTrans.Resolution = lDpi;
return pDispTrans;
}
示例15: OnClick
/// <summary>
/// Occurs when this command is clicked
/// </summary>
public override void OnClick()
{
// TODO: Add ControlsExportMapCommandClass.OnClick implementation
if (m_hookHelper == null) return;
try
{
SaveFileDialog saveFileDlg = new SaveFileDialog();
saveFileDlg.Filter = "(*jpeg)|*jpeg|(*.tif)|*tif|(*.pdf)|*.pdf|(*.bmp)|*.bmp|(*.gif)|*.gif|(*.png)|*.png";
if (saveFileDlg.ShowDialog() == DialogResult.OK)
{
IExport export = null;
if (1 == saveFileDlg.FilterIndex)
{ export = new ExportJPEGClass(); export.ExportFileName = saveFileDlg.FileName + ".jpeg"; }
else if (2 == saveFileDlg.FilterIndex)
{ export = new ExportTIFFClass(); export.ExportFileName = saveFileDlg.FileName + ".tif"; }
else if (3 == saveFileDlg.FilterIndex)
{ export = new ExportPDFClass(); export.ExportFileName = saveFileDlg.FileName/* + ".pdf"*/; }
else if (4 == saveFileDlg.FilterIndex)
{ export = new ExportBMPClass(); export.ExportFileName = saveFileDlg.FileName/* + ".bmp"*/; }
else if (5 == saveFileDlg.FilterIndex)
{ export = new ExportGIFClass(); export.ExportFileName = saveFileDlg.FileName/* + ".gif"*/; }
else if (6 == saveFileDlg.FilterIndex)
{ export = new ExportPNGClass(); export.ExportFileName = saveFileDlg.FileName/* + ".png"*/; }
int res = 96;
export.Resolution = res;
tagRECT exportRECT = (m_hookHelper.Hook as IMapControl3).ActiveView.ExportFrame;
IEnvelope pENV = new EnvelopeClass();
pENV.PutCoords(exportRECT.left, exportRECT.top, exportRECT.right, exportRECT.bottom);
export.PixelBounds = pENV;
int Hdc = export.StartExporting();
IEnvelope pVisibleBounds = null;
ITrackCancel pTrack = null;
(m_hookHelper.Hook as IMapControl3).ActiveView.Output(Hdc, (int)export.Resolution, ref exportRECT, pVisibleBounds, pTrack);
Application.DoEvents();
export.FinishExporting();
export.Cleanup();
}
}
catch
{
}
}