本文整理汇总了C#中EnvelopeClass类的典型用法代码示例。如果您正苦于以下问题:C# EnvelopeClass类的具体用法?C# EnvelopeClass怎么用?C# EnvelopeClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnvelopeClass类属于命名空间,在下文中一共展示了EnvelopeClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例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: 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;
}
示例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: ccc
private void ccc(IPoint p)
{
IEnvelope pEnvelope = new EnvelopeClass();
pEnvelope.SetEmpty();
pEnvelope = pAxMapControl.Extent;
pEnvelope.CenterAt(p);
pAxMapControl.Extent = pEnvelope.Envelope;
pAxMapControl.Refresh();
}
示例6: ClampExtent
private static IEnvelope ClampExtent(IEnvelope extent)
{
EnvelopeClass result = new EnvelopeClass();
double origin = Math.PI * 6378137;
result.XMin = Math.Max(extent.XMin, -origin);
result.YMin = Math.Max(extent.YMin, -origin);
result.XMax = Math.Min(extent.XMax, origin - 1);
result.YMax = Math.Min(extent.YMax, origin - 1);
return result;
}
示例7: AddPPGeocodedPoint
internal void AddPPGeocodedPoint(double lat, double lng)
{
// Set the coordinate system of the data frame.
ArcMap.Document.ActiveView.FocusMap.SpatialReference = DefineGCS();
ArcMap.Document.ActiveView.Refresh();
IPoint iPoint = new PointClass();
// Set the coordinate system of your point to match your data frame
iPoint.SpatialReference = DefineGCS();
iPoint.X = lng;
iPoint.Y = lat;
IMap map = ArcMap.Document.ActiveView as IMap;
IGraphicsContainer graphicsContainer = (IGraphicsContainer)map; // Explicit Cast
IElement element = null;
// set the point color
IColor pointColor = new RgbColor();
//pointColor.RGB = 255255255;
pointColor.RGB = 255000000;
// Marker symbols
ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();
simpleMarkerSymbol.Color = pointColor;
simpleMarkerSymbol.Outline = true;
simpleMarkerSymbol.OutlineColor = pointColor;
simpleMarkerSymbol.Size = 10;
simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
// Marker element
IMarkerElement markerElement = new MarkerElementClass();
markerElement.Symbol = simpleMarkerSymbol;
markerElement.Symbol.Color = pointColor;
element = (IElement)markerElement; // Explicit Cast
// set the element name
IElementProperties3 elemProperties = element as IElementProperties3;
elemProperties.Name = string.Concat(lng, " ,", lat);
elemProperties.AnchorPoint = esriAnchorPointEnum.esriCenterPoint;
// Add the element to a graphics container and refresh the ActiveView
if (!(element == null))
{
element.Geometry = iPoint;
graphicsContainer.AddElement(element, 0);
IEnvelope envelope = new EnvelopeClass();
envelope = ArcMap.Document.ActiveView.Extent;
envelope.CenterAt(iPoint);
//ArcMap.Document.ActiveView.Extent = envelope;
//map.MapScale = 2400;
map.MapScale = 5000;
ArcMap.Document.ActiveView.Refresh();
}
}
示例8: toolStripButton1_Click
private void toolStripButton1_Click(object sender, EventArgs e)
{
IEnvelope pEnvelope = new EnvelopeClass();
IPoint pPoint = new PointClass();
pPoint.PutCoords(Convert.ToDouble(txtlong.Text), Convert.ToDouble(txtlat.Text));
pEnvelope = pAxMapControl.Extent;
pEnvelope.CenterAt(pPoint);
pAxMapControl.Extent = pEnvelope.Envelope;
pAxMapControl.FlashShape(pPoint as IGeometry);
//ccc(pPoint);
//ddd(pPoint);
}
示例9: 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");
}
示例10: SelectFeatureByPoint
public static void SelectFeatureByPoint(IMap map,System.Drawing.Point screenPoint,int pixelTol )
{
// Construct select envelope
tagRECT r;
r.left = screenPoint.X - pixelTol;
r.right = screenPoint.X + pixelTol;
r.top = screenPoint.Y - pixelTol;
r.bottom = screenPoint.Y + pixelTol;
IEnvelope hotEnvelope=new EnvelopeClass();
// Transform for screen to map
IActiveView activeView=map as IActiveView;
IDisplayTransformation dispTransf = activeView.ScreenDisplay.DisplayTransformation;
dispTransf.TransformRect(hotEnvelope, ref r, 5);
// Create select environment
hotEnvelope.SpatialReference = map.SpatialReference;
ISelectionEnvironment selectEnviroment = new SelectionEnvironmentClass();
selectEnviroment.CombinationMethod = esriSelectionResultEnum.esriSelectionResultNew;
// Select by shape
map.SelectByShape(hotEnvelope, selectEnviroment, false);
}
示例11: GetEnvelopeFromZoomRowCol
public static IEnvelope GetEnvelopeFromZoomRowCol(int zoom, int row, int col)
{
IEnvelope e = new EnvelopeClass();
e.SpatialReference = GetSpatialReference(102100);
IPoint llupperLeftPoint = TileToGeographic(col, row, zoom);
IPoint lllowerRightPoint = TileToGeographic(col + 1, row + 1, zoom);
var upperLeftPtWm = WebMercatorUtil.GeographicToWebMercator(llupperLeftPoint.Y, llupperLeftPoint.X);
IPoint wmUpperLeftPoint = new PointClass();
wmUpperLeftPoint.X = upperLeftPtWm.X;
wmUpperLeftPoint.Y = upperLeftPtWm.Y;
var lowerRightPtWm = WebMercatorUtil.GeographicToWebMercator(lllowerRightPoint.Y, lllowerRightPoint.X);
IPoint wmLowerRightPoint = new PointClass();
wmLowerRightPoint.X = lowerRightPtWm.X;
wmLowerRightPoint.Y = lowerRightPtWm.Y;
e.UpperLeft = wmUpperLeftPoint;
e.LowerRight = wmLowerRightPoint;
return e;
}
示例12: SelectFeaturesScreenPoint
static void SelectFeaturesScreenPoint(IMap pMap, int x, int y, int pixelTol)
{
tagRECT r;
//Construct a small rectangle out of the x,y coordinates' pixel tolerance.
r.left = x - pixelTol; //Upper left x, top left is 0,0.
r.top = y - pixelTol; //Upper left y, top left is 0,0.
r.right = x + pixelTol; //Lower right x, top left is 0,0.
r.bottom = y + pixelTol; //Lower right y, top left is 0,0.
//Transform the device rectangle into a geographic rectangle via the display transformation.
IEnvelope pEnvelope = new EnvelopeClass();
IActiveView pActiveView = pMap as IActiveView;
IDisplayTransformation pDisplayTrans = pActiveView.ScreenDisplay.DisplayTransformation;
pDisplayTrans.TransformRect(pEnvelope, ref r, 5);
//5 = esriTransformPosition + esriTransformToMap.
pEnvelope.SpatialReference = pMap.SpatialReference;
//ISelectionEnvironment pSelectionEnvironment = new SelectionEnvironmentClass();
//pSelectionEnvironment.CombinationMethod =
// esriSelectionResultEnum.esriSelectionResultNew;
//pMap.SelectByShape(pEnvelope, pSelectionEnvironment, false);
}
示例13: GetGraphicsExtent
private IEnvelope GetGraphicsExtent(IActiveView docActiveView)
{
IEnvelope GraphicsBounds;
IEnvelope GraphicsEnvelope;
IGraphicsContainer oiqGraphicsContainer;
IPageLayout docPageLayout;
IDisplay GraphicsDisplay;
IElement oiqElement;
GraphicsBounds = new EnvelopeClass();
GraphicsEnvelope = new EnvelopeClass();
docPageLayout = docActiveView as IPageLayout;
GraphicsDisplay = docActiveView.ScreenDisplay;
oiqGraphicsContainer = docActiveView as IGraphicsContainer;
oiqGraphicsContainer.Reset();
oiqElement = oiqGraphicsContainer.Next();
while (oiqElement != null)
{
oiqElement.QueryBounds(GraphicsDisplay, GraphicsEnvelope);
GraphicsBounds.Union(GraphicsEnvelope);
oiqElement = oiqGraphicsContainer.Next();
}
return GraphicsBounds;
}
示例14: GetLayerExtent
/// <summary>
/// get the overall extent of the items in the layer
/// </summary>
/// <returns></returns>
private IEnvelope GetLayerExtent()
{
//iterate through all the items in the layers DB and get the bounding envelope
IEnvelope env = new EnvelopeClass();
env.SpatialReference = m_spatialRef;
IPoint point = new PointClass();
point.SpatialReference = m_spatialRef;
int symbolCode = 0;
double symbolSize = 0;
foreach(DataRow r in m_table.Rows)
{
if (r[3] is DBNull || r[4] is DBNull)
continue;
point.Y = Convert.ToDouble(r[3]);
point.X = Convert.ToDouble(r[4]);
// need to get the symbol size in meters in order to add it to the total layer extent
if (m_display != null)
{
symbolCode = Convert.ToInt32(r[8]);
symbolSize = Math.Max(GetSymbolSize(m_display, symbolCode), symbolSize);
}
env.Union(point.Envelope);
}
// Expand the envelope in order to include the size of the symbol
env.Expand(symbolSize, symbolSize, false);
//return the layer's extent in the data underlying coordinate system
return env;
}
示例15: ZoomTo
/// <summary>
/// Zoom to weather item according to its zipcode
/// </summary>
/// <param name="zipCode"></param>
public void ZoomTo(long zipCode)
{
if(null == m_table || null == m_symbolTable )
return;
if(null == m_display)
return;
//get the record for the requested zipCode
DataRow r = m_table.Rows.Find(zipCode);
if(null == r)
return;
//get the coordinate of the zipCode
double lat = Convert.ToDouble(r[3]);
double lon = Convert.ToDouble(r[4]);
IPoint point = new PointClass();
point.X = lon;
point.Y = lat;
point.SpatialReference = m_spatialRef;
if (null != m_mapSpatialRef && m_mapSpatialRef.FactoryCode != m_layerSRFactoryCode)
point.Project(m_mapSpatialRef);
int iconCode = Convert.ToInt32(r[8]);
//find the appropriate symbol record
DataRow rec = m_symbolTable.Rows.Find(iconCode);
if(rec == null)
return;
//get the icon's dimensions
int iconWidth = Convert.ToInt32(rec[3]);
int iconHeight = Convert.ToInt32(rec[4]);
IDisplayTransformation displayTransformation = ((IScreenDisplay)m_display).DisplayTransformation;
//Convert the icon coordinate into screen coordinate
int windowX, windowY;
displayTransformation.FromMapPoint(point,out windowX, out windowY);
//get the upper left coord
int ulx, uly;
ulx = windowX - iconWidth/2;
uly = windowY - iconHeight/2;
IPoint ulPnt = displayTransformation.ToMapPoint(ulx, uly);
//get the lower right coord
int lrx,lry;
lrx = windowX + iconWidth/2;
lry = windowY + iconHeight/2;
IPoint lrPnt = displayTransformation.ToMapPoint(lrx, lry);
//construct the new extent
IEnvelope envelope = new EnvelopeClass();
envelope.PutCoords(ulPnt.X, lrPnt.Y, lrPnt.X, ulPnt.Y);
envelope.Expand(2,2,false);
//set the new extent and refresh the display
displayTransformation.VisibleBounds = envelope;
base.m_bIsCompiledDirty = true;
((IScreenDisplay)m_display).Invalidate(null, true, (short)esriScreenCache.esriAllScreenCaches);
((IScreenDisplay)m_display).UpdateWindow();
}