private void method_4(ILineSymbol ilineSymbol_0, Rectangle rectangle_0) { if (ilineSymbol_0 is IPictureLineSymbol) { if (((IPictureLineSymbol)ilineSymbol_0).Picture == null) { return; } } else if (ilineSymbol_0 is IMarkerLineSymbol || ilineSymbol_0 is IHashLineSymbol) { ITemplate template = ((ILineProperties)ilineSymbol_0).Template; if (template != null) { bool flag = false; int i = 0; while (i < template.PatternElementCount) { double num; double num2; template.GetPatternElement(i, out num, out num2); if (num + num2 <= 0.0) { i++; } else { flag = true; if (flag) { break; } return; } } } } object value = System.Reflection.Missing.Value; IPointCollection pointCollection = new Polyline(); IPoint point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords((double)(rectangle_0.Left + 3), (double)((rectangle_0.Bottom + rectangle_0.Top) / 2)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)(rectangle_0.Right - 3), (double)((rectangle_0.Bottom + rectangle_0.Top) / 2)); pointCollection.AddPoint(point, ref value, ref value); ((ISymbol)ilineSymbol_0).Draw((IGeometry)pointCollection); }
public override IGeometry HorizontalMirror(IPoint ipoint_0) { IPoint pointClass; IGeometry geometry; if (this.m_pGeometry.GeometryType != esriGeometryType.esriGeometryPoint) { object value = Missing.Value; IPointCollection mPGeometry = this.m_pGeometry as IPointCollection; IPointCollection multipointClass = new Multipoint(); for (int i = 0; i < mPGeometry.PointCount; i++) { IPoint point = mPGeometry.Point[i]; pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(2 * ipoint_0.X - pointClass.X, pointClass.Y); multipointClass.AddPoint(pointClass, ref value, ref value); } geometry = multipointClass as IGeometry; } else { pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(2 * ipoint_0.X - (this.m_pGeometry as IPoint).X, (this.m_pGeometry as IPoint).Y); geometry = pointClass; } return(geometry); }
private IElement CreateLineElement(IPoint pt, ILineSymbol pSymbol, IFillSymbol pBackSymbol, string des) { IGroupElement groupElementClass = new GroupElement() as IGroupElement; IPolyline polylineClass = new Polyline() as IPolyline; object missing = Type.Missing; IPoint pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(pt.X + this.m_itemwidth / 10, pt.Y - this.m_itemheight / 2); (polylineClass as IPointCollection).AddPoint(pointClass, ref missing, ref missing); pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(pt.X + this.m_itemwidth * 0.9, pt.Y - this.m_itemheight / 2); (polylineClass as IPointCollection).AddPoint(pointClass, ref missing, ref missing); IElement lineElementClass = new LineElement() { Geometry = polylineClass }; (lineElementClass as ILineElement).Symbol = pSymbol; if (pBackSymbol != null) { groupElementClass.AddElement(this.CreatePolygonElement(pt, pBackSymbol)); } else if (this.m_ItemHasBorder) { groupElementClass.AddElement(this.CreatePolygonElement(pt)); } groupElementClass.AddElement(lineElementClass); if (des.Length > 0) { groupElementClass.AddElement(this.CreateTextElement(pt, des, 10)); } return(groupElementClass as IElement); }
private IElement CreatePointElement(IPoint pt, IMarkerSymbol pSymbol, IFillSymbol pBackSymbol, string des) { IGroupElement groupElementClass = new GroupElement() as IGroupElement; IPoint pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(pt.X + this.m_itemwidth / 2, pt.Y - this.m_itemheight / 2); IElement markerElementClass = new MarkerElement() { Geometry = pointClass }; (markerElementClass as IMarkerElement).Symbol = pSymbol; if (pBackSymbol != null) { groupElementClass.AddElement(this.CreatePolygonElement(pt, pBackSymbol)); } else if (this.m_ItemHasBorder) { groupElementClass.AddElement(this.CreatePolygonElement(pt)); } groupElementClass.AddElement(markerElementClass); if (des.Length > 0) { groupElementClass.AddElement(this.CreateTextElement(pt, des, 10)); } return(groupElementClass as IElement); }
/// <summary> /// 通过坐标创建点 /// </summary> /// <param name="x">x坐标</param> /// <param name="y">y坐标</param> /// <returns>ESRI点几何形状接口</returns> public static IPoint CreatePointByCoord(double x, double y) { IPoint point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords(x, y); return(point); }
private IElement CreatePolygonElement(IPoint pt, IFillSymbol pFillSymbol) { IPolygon polygonClass = new Polygon() as IPolygon; object missing = Type.Missing; IPoint pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(pt.X, pt.Y); (polygonClass as IPointCollection).AddPoint(pointClass, ref missing, ref missing); pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(pt.X, pt.Y - this.m_itemheight); (polygonClass as IPointCollection).AddPoint(pointClass, ref missing, ref missing); pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(pt.X + this.m_itemwidth, pt.Y - this.m_itemheight); (polygonClass as IPointCollection).AddPoint(pointClass, ref missing, ref missing); pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(pt.X + this.m_itemwidth, pt.Y); (polygonClass as IPointCollection).AddPoint(pointClass, ref missing, ref missing); pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(pt.X, pt.Y); (polygonClass as IPointCollection).AddPoint(pointClass, ref missing, ref missing); IElement rectangleElementClass = new RectangleElement(); rectangleElementClass.Geometry = polygonClass.Envelope; (rectangleElementClass as IFillShapeElement).Symbol = pFillSymbol; return(rectangleElementClass); }
private IElement CreateJionTabTextElement(IActiveView pAV, string text, double x, double y, IEnvelope pNewEnvelope) { ITextElement textElement = new TextElement() as ITextElement; ((ITextElement)textElement).Symbol = this.TextSymbol; textElement.Text = text; ITextElement textElementClass = textElement as ITextElement; IElement element = textElementClass as IElement; IPoint pointClass = new ESRI.ArcGIS.Geometry.Point(); IEnvelope envelopeClass = new Envelope() as IEnvelope; pointClass.PutCoords(x, y); element.Geometry = pointClass; this.TextSymbol.Text = text; IPolygon polygonClass = new Polygon() as IPolygon; element.QueryOutline(pAV.ScreenDisplay, polygonClass); element.QueryBounds(pAV.ScreenDisplay, envelopeClass); if (!envelopeClass.IsEmpty) { if (envelopeClass.Width > pNewEnvelope.Width) { double width = pNewEnvelope.Width / envelopeClass.Width; double height = pNewEnvelope.Height / envelopeClass.Height; (element as ITransform2D).Scale(pointClass, width, height); } } return(element); }
private void LoadPage(PageInfoWrap infoWrap) { if (isRunning) { return; } propertyPage.SelectedObject = infoWrap.PrintPageInfo; IActiveView pActiveView = _context.FocusMap as IActiveView; pActiveView.ScreenDisplay.DisplayTransformation.Rotation = btnRotatePage.Checked ? infoWrap.PrintPageInfo.Angle : 0; IPoint centerPoint = new ESRI.ArcGIS.Geometry.Point(); IEnvelope pEnv = infoWrap.PrintPageInfo.Boundary.Envelope; centerPoint.PutCoords(pEnv.XMin + pEnv.Width / 2.0, pEnv.YMin + pEnv.Height / 2.0); IEnvelope pExtentEnv = pActiveView.Extent; pExtentEnv.CenterAt(centerPoint); pActiveView.Extent = pExtentEnv; pActiveView.ScreenDisplay.DisplayTransformation.ScaleRatio = infoWrap.PrintPageInfo.Scale; pActiveView.Refresh(); if (_context.MainView.ControlType != GISControlType.PageLayout) { return; } LoadPrintPage(infoWrap.PrintPageInfo); MessageService.Current.Info("Refresh"); pActiveView.Extent = pExtentEnv; pActiveView.ScreenDisplay.DisplayTransformation.ScaleRatio = infoWrap.PrintPageInfo.Scale; pActiveView.Refresh(); }
private IPolygon CreatePolygon(IPoint pt1, IPoint pt2) { try { //Dim rotation As Double = CountRotationAsRatians(pt1, pt2) ILine line = new Line(); line.FromPoint = pt1; line.ToPoint = pt2; IPoint centerPt = new ESRI.ArcGIS.Geometry.Point(); centerPt.PutCoords((pt1.X + pt2.X) / 2, (pt1.Y + pt2.Y) / 2); ITransform2D trans = line as ITransform2D; trans.Rotate(centerPt, -Rotation); IPolygon poly = BuildRectange(centerPt); ITransform2D transForPoly = poly as ITransform2D; transForPoly.Rotate(centerPt, Rotation * (Math.PI / 180)); poly.SpatialReference = pt1.SpatialReference; return(poly); } catch (Exception ex) { return(null); } }
private IPolygon BuildRectange(IPoint centerPt) { double fwWidth = 0; double fwHeight = 0; fwWidth = CountFilmWindowWidth(); fwHeight = fwWidth / _WidthHeightRatio; IPointCollection ptCol = new Polygon(); IPoint pts_0 = new ESRI.ArcGIS.Geometry.Point(); pts_0.PutCoords(centerPt.X - fwWidth / 2, centerPt.Y - fwHeight / 2); IPoint pts_1 = new ESRI.ArcGIS.Geometry.Point(); pts_1.PutCoords(centerPt.X - fwWidth / 2, centerPt.Y + fwHeight / 2); IPoint pts_2 = new ESRI.ArcGIS.Geometry.Point(); pts_2.PutCoords(centerPt.X + fwWidth / 2, centerPt.Y + fwHeight / 2); IPoint pts_3 = new ESRI.ArcGIS.Geometry.Point(); pts_3.PutCoords(centerPt.X + fwWidth / 2, centerPt.Y - fwHeight / 2); ptCol.AddPoint(pts_0); ptCol.AddPoint(pts_1); ptCol.AddPoint(pts_2); ptCol.AddPoint(pts_3); ptCol.AddPoint(pts_0); return(ptCol as IPolygon); }
private void method_1(string string_0) { IPoint point = new ESRI.ArcGIS.Geometry.Point(); IPoint point2 = new ESRI.ArcGIS.Geometry.Point(); string_0 = string_0.Trim(); int index = string_0.IndexOf(" "); double x = Convert.ToDouble(string_0.Substring(0, index)); string_0 = string_0.Substring(index); string_0 = string_0.Trim(); index = string_0.IndexOf(" "); double y = Convert.ToDouble(string_0.Substring(0, index)); point.PutCoords(x, y); string_0 = string_0.Substring(index); string_0 = string_0.Trim(); index = string_0.IndexOf(" "); x = Convert.ToDouble(string_0.Substring(0, index)); string_0 = string_0.Substring(index); string_0 = string_0.Trim(); string str = string_0; y = Convert.ToDouble(str); point2.PutCoords(x, y); RasterAdjustHelper.RasterAdjust.AddPointPair(point, point2); }
public override void Draw(int int_0, Rectangle rectangle_0, double double_0, double double_1) { if (this.m_pStyle is ISymbol3D) { IDisplayTransformation displayTransformation = new DisplayTransformation() as IDisplayTransformation; IEnvelope envelope = new Envelope() as IEnvelope; envelope.PutCoords((double)rectangle_0.Left, (double)rectangle_0.Top, (double)rectangle_0.Right, (double)rectangle_0.Bottom); tagRECT tagRECT; tagRECT.left = rectangle_0.Left; tagRECT.right = rectangle_0.Right; tagRECT.bottom = rectangle_0.Bottom; tagRECT.top = rectangle_0.Top; displayTransformation.set_DeviceFrame(ref tagRECT); displayTransformation.Bounds = envelope; displayTransformation.Resolution = 48.0; displayTransformation.ReferenceScale = 1.0; displayTransformation.ScaleRatio = double_1; ISymbol symbol = this.m_pStyle as ISymbol; symbol.SetupDC(int_0, displayTransformation); object value = System.Reflection.Missing.Value; IPoint point = new ESRI.ArcGIS.Geometry.Point(); IPointCollection pointCollection = new Polygon(); point.PutCoords((double)(rectangle_0.Left + 3), (double)(rectangle_0.Top + 6)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)(rectangle_0.Right - 3), (double)(rectangle_0.Top + 6)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)(rectangle_0.Right - 3), (double)(rectangle_0.Bottom - 6)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)(rectangle_0.Left + 3), (double)(rectangle_0.Bottom - 6)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)(rectangle_0.Left + 3), (double)(rectangle_0.Top + 6)); pointCollection.AddPoint(point, ref value, ref value); symbol.Draw((IGeometry)pointCollection); symbol.ResetDC(); } else { IStyleGalleryClass styleGalleryClass = new FillSymbolStyleGalleryClass(); tagRECT tagRECT = default(tagRECT); tagRECT.left = rectangle_0.Left; tagRECT.right = rectangle_0.Right; tagRECT.top = rectangle_0.Top; tagRECT.bottom = rectangle_0.Bottom; styleGalleryClass.Preview(this.m_pStyle, int_0, ref tagRECT); } }
public bool HandleCommand(string string_1) { bool flag; if (!this.bool_0) { try { string_1 = string_1.Trim(); if (string_1.Length != 0) { string[] strArrays = string_1.Split(new char[] { ',' }); double num = 0; IPoint pointClass = new ESRI.ArcGIS.Geometry.Point(); if ((int)strArrays.Length < 2) { this._appContext.ShowCommandString("输入不正确", CommandTipsType.CTTLog); flag = true; return(flag); } else { num = Convert.ToDouble(strArrays[0]); pointClass.PutCoords(num, Convert.ToDouble(strArrays[1])); if ((int)strArrays.Length == 3) { pointClass.Z = Convert.ToDouble(strArrays[2]); } if (this.int_0 == 1) { this.bool_0 = true; } SketchShareEx.SketchMouseDown(pointClass, this._appContext.MapControl.Map as IActiveView, Editor.CurrentEditTemplate.FeatureLayer); ThreePointArcCommandFlow int0 = this; int0.int_0 = int0.int_0 + 1; } } else { flag = false; return(flag); } } catch { this._appContext.ShowCommandString("输入不正确", CommandTipsType.CTTLog); flag = true; return(flag); } this.ShowCommandLine(); flag = true; } else { flag = false; } return(flag); }
protected void DrawColorRamp(int int_0, Rectangle rectangle_0, IColorRamp icolorRamp_0) { IDisplayTransformation displayTransformation = new DisplayTransformation() as IDisplayTransformation; IEnvelope envelope = new Envelope() as IEnvelope; envelope.PutCoords((double)rectangle_0.Left, (double)rectangle_0.Top, (double)rectangle_0.Right, (double)rectangle_0.Bottom); tagRECT tagRECT; tagRECT.left = rectangle_0.Left; tagRECT.right = rectangle_0.Right; tagRECT.bottom = rectangle_0.Bottom; tagRECT.top = rectangle_0.Top; displayTransformation.set_DeviceFrame(ref tagRECT); displayTransformation.Bounds = envelope; IGradientFillSymbol gradientFillSymbol = new GradientFillSymbol(); ILineSymbol outline = gradientFillSymbol.Outline; outline.Width = 0.0; gradientFillSymbol.Outline = outline; gradientFillSymbol.ColorRamp = icolorRamp_0; gradientFillSymbol.GradientAngle = 180.0; gradientFillSymbol.GradientPercentage = 1.0; gradientFillSymbol.IntervalCount = 100; gradientFillSymbol.Style = esriGradientFillStyle.esriGFSLinear; ISymbol symbol = (ISymbol)gradientFillSymbol; symbol.SetupDC(int_0, displayTransformation); object value = System.Reflection.Missing.Value; IPoint point = new ESRI.ArcGIS.Geometry.Point(); IPointCollection pointCollection = new Polygon(); point.PutCoords((double)(rectangle_0.Left + 3), (double)(rectangle_0.Top + 3)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)(rectangle_0.Right - 3), (double)(rectangle_0.Top + 3)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)(rectangle_0.Right - 3), (double)(rectangle_0.Bottom - 3)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)(rectangle_0.Left + 3), (double)(rectangle_0.Bottom - 3)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)(rectangle_0.Left + 3), (double)(rectangle_0.Top + 3)); pointCollection.AddPoint(point, ref value, ref value); symbol.Draw((IGeometry)pointCollection); symbol.ResetDC(); }
private void method_2(IFillSymbol ifillSymbol_0, Rectangle rectangle_0) { object value = System.Reflection.Missing.Value; IPoint point = new ESRI.ArcGIS.Geometry.Point(); IPointCollection pointCollection = new Polygon(); point.PutCoords((double)(rectangle_0.Left + 3), (double)(rectangle_0.Top + 3)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)(rectangle_0.Right - 3), (double)(rectangle_0.Top + 3)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)(rectangle_0.Right - 3), (double)(rectangle_0.Bottom - 3)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)(rectangle_0.Left + 3), (double)(rectangle_0.Bottom - 3)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)(rectangle_0.Left + 3), (double)(rectangle_0.Top + 3)); pointCollection.AddPoint(point, ref value, ref value); ((ISymbol)ifillSymbol_0).Draw((IGeometry)pointCollection); }
// MARK: - Zoom view private void axMapControl2_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e) { IPoint point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords(e.mapX, e.mapY); axMapControl1.CenterAt(point); Console.WriteLine(axMapControl2.MapScale.ToString()); }
public static void DrawSymbol(IFillSymbol ifillSymbol_0, Rectangle rectangle_0) { object value = Missing.Value; IPoint pointClass = new ESRI.ArcGIS.Geometry.Point(); IPointCollection polygonClass = new Polygon(); pointClass.PutCoords((double)(rectangle_0.Left + 3), (double)(rectangle_0.Top + 3)); polygonClass.AddPoint(pointClass, ref value, ref value); pointClass.PutCoords((double)(rectangle_0.Right - 3), (double)(rectangle_0.Top + 3)); polygonClass.AddPoint(pointClass, ref value, ref value); pointClass.PutCoords((double)(rectangle_0.Right - 3), (double)(rectangle_0.Bottom - 3)); polygonClass.AddPoint(pointClass, ref value, ref value); pointClass.PutCoords((double)(rectangle_0.Left + 3), (double)(rectangle_0.Bottom - 3)); polygonClass.AddPoint(pointClass, ref value, ref value); pointClass.PutCoords((double)(rectangle_0.Left + 3), (double)(rectangle_0.Top + 3)); polygonClass.AddPoint(pointClass, ref value, ref value); ((ISymbol)ifillSymbol_0).Draw((IGeometry)polygonClass); }
//鹰眼图鼠标下落事件 private void axMapControl_Eagle_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { IPoint Pnt; Pnt = new ESRI.ArcGIS.Geometry.Point(); Pnt.PutCoords(e.mapX, e.mapY); axMapControl_1.CenterAt(Pnt); axMapControl_1.Refresh(); }
private IElement CreatePolygonElement(IPoint pt, IFillSymbol pSymbol, IFillSymbol pBackSymbol, string des) { IGroupElement groupElementClass = new GroupElement() as IGroupElement; IPolygon polygonClass = new Polygon() as IPolygon; object missing = Type.Missing; IPoint pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(pt.X, pt.Y); (polygonClass as IPointCollection).AddPoint(pointClass, ref missing, ref missing); pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(pt.X, pt.Y - this.m_itemheight); (polygonClass as IPointCollection).AddPoint(pointClass, ref missing, ref missing); pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(pt.X + this.m_itemwidth, pt.Y - this.m_itemheight); (polygonClass as IPointCollection).AddPoint(pointClass, ref missing, ref missing); pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(pt.X + this.m_itemwidth, pt.Y); (polygonClass as IPointCollection).AddPoint(pointClass, ref missing, ref missing); pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(pt.X, pt.Y); (polygonClass as IPointCollection).AddPoint(pointClass, ref missing, ref missing); IElement rectangleElementClass = new RectangleElement() { Geometry = polygonClass.Envelope }; (rectangleElementClass as IFillShapeElement).Symbol = pSymbol; if (pBackSymbol != null) { groupElementClass.AddElement(this.CreatePolygonElement(pt, pBackSymbol)); } else if (this.m_ItemHasBorder) { if (pSymbol.Outline != null) { IRgbColor color = pSymbol.Outline.Color as IRgbColor; if (color != null) { if ((color.Red < 212 || color.Green < 208 ? false : color.Blue >= 200)) { groupElementClass.AddElement(this.CreatePolygonElement(pt)); } } } else { groupElementClass.AddElement(this.CreatePolygonElement(pt)); } } groupElementClass.AddElement(rectangleElementClass); if (des.Length > 0) { groupElementClass.AddElement(this.CreateTextElement(pt, des, 10)); } return(groupElementClass as IElement); }
/// <summary> /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="Tolerance"></param> /// <returns></returns> public bool HitTest(double x, double y, double Tolerance) { IPoint pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(x, y); IRelationalOperator polygonClass = new Polygon() as IRelationalOperator; this.QueryOutline(this.m_pCachedDisplay, polygonClass as IPolygon); return(!polygonClass.Disjoint(pointClass)); }
private static IGeometry CreateGeometryFromSymbol(ISymbol sym, IEnvelope env) { IPoint point; if (sym is IMarkerSymbol) { IArea area = (IArea)env; return(area.Centroid); } if ((sym is ILineSymbol) || (sym is ITextSymbol)) { IPolyline polyline = new Polyline() as IPolyline; point = new ESRI.ArcGIS.Geometry.Point() as IPoint; point.PutCoords(env.LowerLeft.X, (env.LowerLeft.Y + env.UpperRight.Y) / 2.0); polyline.FromPoint = point; point = new ESRI.ArcGIS.Geometry.Point() as IPoint; point.PutCoords(env.UpperRight.X, (env.LowerLeft.Y + env.UpperRight.Y) / 2.0); polyline.ToPoint = point; if (sym is ITextSymbol) { (sym as ITextSymbol).Text = "样本字符"; } return(polyline); } if (sym is IFillSymbol) { IPolygon polygon = new Polygon() as IPolygon; IPointCollection points = (IPointCollection)polygon; point = new ESRI.ArcGIS.Geometry.Point() as IPoint; point.PutCoords(env.LowerLeft.X, env.LowerLeft.Y); points.AddPoints(1, ref point); point.PutCoords(env.UpperLeft.X, env.UpperLeft.Y); points.AddPoints(1, ref point); point.PutCoords(env.UpperRight.X, env.UpperRight.Y); points.AddPoints(1, ref point); point.PutCoords(env.LowerRight.X, env.LowerRight.Y); points.AddPoints(1, ref point); point.PutCoords(env.LowerLeft.X, env.LowerLeft.Y); points.AddPoints(1, ref point); return(polygon); } return(null); }
public bool HitTest(double x, double y, double Tolerance) { IPoint other = new ESRI.ArcGIS.Geometry.Point(); other.PutCoords(x, y); IRelationalOperator @operator = new ESRI.ArcGIS.Geometry.Polygon() as IRelationalOperator; this.QueryOutline(this.m_pCachedDisplay, @operator as IPolygon); return([email protected](other)); }
private void ActiveViewEventsOnAfterDraw(IDisplay display, esriViewDrawPhase phase) { if (!_drawFence) { return; } if (_fenceArray == null || _fenceArray.Count == 0) { return; } IScreenDisplay paramScreenDisplay = ((IActiveView)_context.FocusMap).ScreenDisplay; paramScreenDisplay.StartDrawing(paramScreenDisplay.hDC, -2); for (int i = 0; i < _fenceArray.Count; i++) { IGeometry fence = _fenceArray.Element[i]; if (fence.IsEmpty) { continue; } if (fence is IPolyline) { paramScreenDisplay.SetSymbol(_lineSymbol); paramScreenDisplay.DrawPolyline(fence); } else if (fence is IPolygon) { paramScreenDisplay.SetSymbol(_fillSymbol); paramScreenDisplay.DrawPolygon(fence); } } if (_drawPage && _pageInfos != null && _pageInfos.Count > 0) { IFontDisp disp = new StdFont() as IFontDisp; disp.Name = "Arial"; disp.Size = new decimal(16); foreach (IPrintPageInfo pageInfo in _pageInfos) { IGeometry pageBoundary = pageInfo.Boundary; paramScreenDisplay.SetSymbol(_fillSymbol); paramScreenDisplay.DrawPolygon(pageBoundary); _textSymbol = SymbolHelper.CreateTextSymbol(Color.Red, disp, 16, pageInfo.PageName); paramScreenDisplay.SetSymbol(_textSymbol as ISymbol); if (!string.IsNullOrEmpty(pageInfo.PageName)) { IPoint centerPoint = new ESRI.ArcGIS.Geometry.Point(); IEnvelope pEnv = pageBoundary.Envelope; centerPoint.PutCoords((pEnv.XMin + pEnv.Width / 2.0), pEnv.YMin + pEnv.Height / 2.0); paramScreenDisplay.DrawText(centerPoint, pageInfo.PageName); } } } paramScreenDisplay.FinishDrawing(); }
public void Draw(IDisplay Display, ITrackCancel trackCancel) { int num; int num2; int num3; int num4; IPoint mapPoint = new ESRI.ArcGIS.Geometry.Point(); mapPoint.PutCoords(this.m_pGeometry.XMin, this.m_pGeometry.YMin); Display.DisplayTransformation.FromMapPoint(mapPoint, out num, out num2); mapPoint.PutCoords(this.m_pGeometry.XMax, this.m_pGeometry.YMax); Display.DisplayTransformation.FromMapPoint(mapPoint, out num3, out num4); double num5 = num3 - num; double num6 = num2 - num4; IntPtr hdc = new IntPtr(Display.hDC); Graphics g = Graphics.FromHdc(hdc); Rectangle r = new Rectangle(num, num4, (int)num5, (int)num6); this.m_chart.Draw(g, r); g.Dispose(); }
private static void DrawSymbol(ILineSymbol ilineSymbol_0, Rectangle rectangle_0, bool bool_0) { if (ilineSymbol_0 is IPictureLineSymbol) { if (((IPictureLineSymbol)ilineSymbol_0).Picture == null) { return; } } else if (ilineSymbol_0 is ITemplate) { bool flag = false; int i = 0; while (i < ((ITemplate)ilineSymbol_0).PatternElementCount) { double num; double num2; ((ITemplate)ilineSymbol_0).GetPatternElement(i, out num, out num2); if (num + num2 <= 0.0) { i++; } else { flag = true; IL_75: if (flag) { object value = System.Reflection.Missing.Value; IPointCollection pointCollection = new Polyline(); IPoint point = new ESRI.ArcGIS.Geometry.Point(); if (bool_0) { point.PutCoords((double)(rectangle_0.Left + 2), (double)(rectangle_0.Bottom + 2)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)((rectangle_0.Width - 4) / 3 + rectangle_0.Left + 2), (double)(rectangle_0.Top - 2)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)((rectangle_0.Width - 4) / 3 * 2 + rectangle_0.Left + 2), (double)(rectangle_0.Bottom + 2)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)(rectangle_0.Right - 2), (double)(rectangle_0.Top - 2)); pointCollection.AddPoint(point, ref value, ref value); } else { point.PutCoords((double)(rectangle_0.Left + 3), (double)((rectangle_0.Bottom + rectangle_0.Top) / 2)); pointCollection.AddPoint(point, ref value, ref value); point.PutCoords((double)(rectangle_0.Right - 3), (double)((rectangle_0.Bottom + rectangle_0.Top) / 2)); pointCollection.AddPoint(point, ref value, ref value); } ((ISymbol)ilineSymbol_0).Draw((IGeometry)pointCollection); } return; } } } }
public static void AddAndVisualizeTreelistBackground(TreeList parentTree, IMapControl2 mapControl1) { try { if (mapControl1 == null) { return; } IMapDocument pMapDoc = new MapDocument(); string pFileName = Config.GetConfigValue("2DMxdBackground");//获得背景图文件路径 if (string.IsNullOrEmpty(pFileName) || !File.Exists(pFileName)) { return; } SplashScreenManager.Default.SendCommand(null, "正在加载二维基础数据......"); pMapDoc.Open(pFileName, null); //打开地图 IMap pMap = pMapDoc.get_Map(0); //获得地图 List <ILayer> loadLayer = new List <ILayer>(); //初始化待加载地理信息图层list int layerNum = mapControl1.Map.LayerCount; //获得当前主地图控件的图层数 for (int i = 0; i < pMap.LayerCount; i++) //对地图的图层进行遍历 { ILayer layer = pMap.get_Layer(i); AddComLayerNode(parentTree, rootNode, layer, loadLayer);//为图层树控件加载新图层,并将待加载图层写入loadLayer rootNode.CollapseAll(); } if (loadLayer.Count > 0) { foreach (ILayer layer in loadLayer) { mapControl1.AddLayer(layer, layerNum); layerNum++; //if (layer is IRasterLayer) //{ // mapControl2.AddLayer(layer); //} } IEnvelope pEnv = mapControl1.ActiveView.Extent; IPoint point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords((pEnv.XMax + pEnv.XMin) / 2, (pEnv.YMax + pEnv.YMin) / 2); pEnv.CenterAt(point); mapControl1.ActiveView.Extent = pEnv; mapControl1.MapUnits = pMap.MapUnits; mapControl1.ReferenceScale = pMap.ReferenceScale; mapControl1.ActiveView.Refresh(); } } catch (System.Exception ex) { return; } }
public override void OnClick() { frmInputText frmInputText = new frmInputText(); if (frmInputText.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string text = frmInputText.txtText.Text; IElement element = new TextElement(); ITextElement textElement = element as ITextElement; ITextSymbol textSymbol = new TextSymbol(); textSymbol.Text = text; textSymbol.Size = 48.0; IActiveView activeView = this._context.ActiveView as IActiveView; activeView.ScreenDisplay.StartDrawing(0, 0); double num; double num2; textSymbol.GetTextSize(activeView.ScreenDisplay.WindowDC, activeView.ScreenDisplay.DisplayTransformation, text, out num, out num2); activeView.ScreenDisplay.FinishDrawing(); textSymbol.Text = text; num *= 0.0353; num2 *= 0.0353; IEnvelope extent = (this._context.ActiveView as IActiveView).Extent; double num3; double num4; double num5; double num6; extent.QueryCoords(out num3, out num4, out num5, out num6); num3 = (num3 + num5) / 2.0; num4 = num6 - 3.0; num5 = num3 + 1.2 * num; num6 = num4 + 1.2 * num2; num3 = (double)((int)num3); num4 = (double)((int)num4); num5 = (double)((int)num5); num6 = (double)((int)num6); extent.PutCoords(num3, num4, num5, num6); textElement.Symbol = textSymbol; textElement.Text = text; IPoint point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords(num3, num4); element.Geometry = point; IGraphicsContainer arg_181_0 = activeView.GraphicsContainer; (element as IElementProperties2).AutoTransform = true; INewElementOperation operation = new NewElementOperation { ActiveView = this._context.ActiveView, Element = element }; this._context.OperationStack.Do(operation); } }
private IGeometry method_2(tagRECT tagRECT_0) { IPoint point = new ESRI.ArcGIS.Geometry.Point(); object value = System.Reflection.Missing.Value; IGeometry geometry = new Polyline() as IGeometry; point.PutCoords((double)(tagRECT_0.left + 5), (double)((tagRECT_0.top + tagRECT_0.bottom) / 2)); (geometry as IPointCollection).AddPoint(point, ref value, ref value); point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords((double)(tagRECT_0.left + 5), (double)((tagRECT_0.top + tagRECT_0.bottom) / 2)); (geometry as IPointCollection).AddPoint(point, ref value, ref value); return(geometry); }
private void QueryBoundsFromGeom(int hDC, ref IDisplayTransformation transform, ref IPolygon boundary, ref IPointCollection points) { double map = 0; double num = 0; double map1 = 0; num = this.PointsToMap(transform, this.m_dSize); if (this.m_dXOffset != 0) { map = this.PointsToMap(transform, this.m_dXOffset); } if (this.m_dYOffset != 0) { map1 = this.PointsToMap(transform, this.m_dYOffset); } this.SetupDeviceRatio(hDC, transform); IPointCollection pointCollection = null; ISegmentCollection segmentCollection = null; double num1 = 0; double num2 = 0; pointCollection = (IPointCollection)boundary; segmentCollection = (ISegmentCollection)boundary; num2 = num / 2; num1 = Math.Sqrt(num2 * num2 / 2); object value = Missing.Value; IEnvelope envelope = (points as IGeometry).Envelope; double num3 = 100; double num4 = 200; double num5 = -100; double num6 = 400; this.QueryBound(points, transform, out num3, out num4, out num5, out num6); IPoint pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(num3, num4); pointCollection.AddPoint(pointClass, ref value, ref value); pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(num5, num4); pointCollection.AddPoint(pointClass, ref value, ref value); pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(num5, num6); pointCollection.AddPoint(pointClass, ref value, ref value); pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(num3, num6); pointCollection.AddPoint(pointClass, ref value, ref value); pointClass = new ESRI.ArcGIS.Geometry.Point(); pointClass.PutCoords(num3, num4); pointCollection.AddPoint(pointClass, ref value, ref value); }
//鹰眼地图:左键拖动矩形框、右键绘制矩形框 private void axMapControlEagleMap_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { if (axMapControlEagleMap.Map.LayerCount == 0) { return; } //按下鼠标左键拖动矩形框 if (e.button == 1) { IPoint point = new ESRI.ArcGIS.Geometry.Point(); point.PutCoords(e.mapX, e.mapY); IEnvelope envelope = axMapControlMainMap.Extent; envelope.CenterAt(point); axMapControlMainMap.Extent = envelope; axMapControlMainMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); } //按下鼠标右键绘制矩形框 else if (e.button == 2) { IEnvelope envelope = axMapControlEagleMap.TrackRectangle(); //计算新显示框范围 double newWidth = 0; double newHeight = 0; if (envelope.IsEmpty) { return; } if (envelope.Width / envelope.Height > axMapControlMainMap.ActiveView.Extent.Width / axMapControlMainMap.ActiveView.Extent.Height) {//宽相同 newWidth = envelope.Width; newHeight = envelope.Width * axMapControlMainMap.ActiveView.Extent.Height / axMapControlMainMap.ActiveView.Extent.Width; } else//高相同 { newHeight = envelope.Height; newWidth = envelope.Height * axMapControlMainMap.ActiveView.Extent.Width / axMapControlMainMap.ActiveView.Extent.Height; } double midX = (envelope.XMin + envelope.XMax) / 2; double midY = (envelope.YMin + envelope.YMax) / 2; double xmi = midX - newWidth / 2; double xma = midX + newWidth / 2; double ymi = midY - newHeight / 2; double yma = midY + newHeight / 2; envelope.PutCoords(xmi, ymi, xma, yma); axMapControlMainMap.Extent = envelope; axMapControlMainMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); } }
public static string GetXMQMC(AxMapControl _mapControl, IMapControlEvents2_OnMouseDownEvent e) { string xzqmc = ""; try { if (_mapControl.Map.LayerCount == 0) { return xzqmc; } IIdentify pIdentify = _mapControl.Map.get_Layer(0) as IIdentify; //通过图层获取 IIdentify 实例 IPoint pPoint = new ESRI.ArcGIS.Geometry.Point(); //新建点来选择 IArray pIDArray; IIdentifyObj pIdObj; pPoint.PutCoords(e.mapX, e.mapY); //定义点 int delta = 500; IEnvelope envelope = new EnvelopeClass(); envelope.XMin = e.mapX - delta; envelope.XMax = e.mapX + delta; envelope.YMin = e.mapY - delta; envelope.YMax = e.mapY + delta; IGeometry geo = envelope as IGeometry; IZAware zAware = geo as IZAware; zAware.ZAware = true; pIDArray = pIdentify.Identify(geo); //通过点获取数组,用点一般只能选择一个元素 if (pIDArray != null) { //取得要素 pIdObj = pIDArray.get_Element(0) as IIdentifyObj; //取得要素 pIdObj.Flash(_mapControl.ActiveView.ScreenDisplay); //闪烁效果 IRowIdentifyObject rowIdentify = pIdObj as IRowIdentifyObject; IFeature feature = rowIdentify.Row as IFeature; if (feature != null) { IFields fields = feature.Fields; int xmqmcFieldIndex = fields.FindField("XZQMC"); xzqmc = Convert.ToString(feature.get_Value(xmqmcFieldIndex)); } } else { //MessageBox.Show("Nothing!"); } } catch { } return xzqmc; }
/// <summary> /// Read the GeoJason File and add new Polygongs to the vector layer /// the name of file should be newFile.json /// </summary> /// <param name="featureLayer"></param> /// <param name="featureworkspace"></param> public void AddPolygon(IFeatureLayer featureLayer, IFeatureWorkspace featureworkspace, string dir) { try { //Define vertices GeoJson geoJson = new GeoJson(); _featureInJSON = geoJson.readGeoJsonFile(dir); IMap map = ArcMap.Document.FocusMap; AddGraphicToMap(map); IWorkspaceEdit editWorkspace = featureworkspace as IWorkspaceEdit; editWorkspace.StartEditing(true); editWorkspace.StartEditOperation(); for (int j = 0; j < _featureInJSON.features.Count; j++) { IPoint pPoint1 = new ESRI.ArcGIS.Geometry.Point(); IPoint pPoint2 = new ESRI.ArcGIS.Geometry.Point(); IPoint pPoint3 = new ESRI.ArcGIS.Geometry.Point(); IPoint pPoint4 = new ESRI.ArcGIS.Geometry.Point(); pPoint1.PutCoords(_featureInJSON.features[j].geometry.rings[0, 0, 0], _featureInJSON.features[j].geometry.rings[0, 0, 1]); pPoint2.PutCoords(_featureInJSON.features[j].geometry.rings[0, 1, 0], _featureInJSON.features[j].geometry.rings[0, 1, 1]); pPoint3.PutCoords(_featureInJSON.features[j].geometry.rings[0, 2, 0], _featureInJSON.features[j].geometry.rings[0, 2, 1]); pPoint4.PutCoords(_featureInJSON.features[j].geometry.rings[0, 3, 0], _featureInJSON.features[j].geometry.rings[0, 3, 1]); IPointCollection pPolygon = new Polygon(); IPointCollection pPointCollection = pPolygon as IPointCollection; //Add the vertices of the polygon pPointCollection.AddPoints(1, ref pPoint1); pPointCollection.AddPoints(1, ref pPoint2); pPointCollection.AddPoints(1, ref pPoint3); pPointCollection.AddPoints(1, ref pPoint4); ((IPolygon)pPolygon).Close(); IFeature iFeature = featureLayer.FeatureClass.CreateFeature(); iFeature.Shape = (IPolygon)pPolygon; iFeature.Store(); //Feature cursor used to loop through all features in feature class, optionally a query filter can be used. int num = featureLayer.FeatureClass.FindField(_featureInJSON.fieldAliases.Char_count); iFeature.set_Value(num, _featureInJSON.features[j].attributes.Char_count.ToString()); num = featureLayer.FeatureClass.FindField(_featureInJSON.fieldAliases.Filename); iFeature.set_Value(num, _featureInJSON.features[j].attributes.Filename); //num = featureLayer.FeatureClass.FindField(_featureInJSON.fieldAliases.Mass_centerX); iFeature.set_Value(8, _featureInJSON.features[j].attributes.Mass_centerX.ToString()); //num = featureLayer.FeatureClass.FindField(_featureInJSON.fieldAliases.Mass_centerY); iFeature.set_Value(9, _featureInJSON.features[j].attributes.Mass_centerY.ToString()); //num = featureLayer.FeatureClass.FindField(_featureInJSON.fieldAliases.OBJECTID); //iFeature.set_Value(num, _featureInJSON.features[j].attributes.OBJECTID.ToString()); //num = featureLayer.FeatureClass.FindField(_featureInJSON.fieldAliases.Orientation); iFeature.set_Value(4, _featureInJSON.features[j].attributes.OBJECTID.ToString()); //num = featureLayer.FeatureClass.FindField(_featureInJSON.fieldAliases.Susp_char_count); iFeature.set_Value(7, _featureInJSON.features[j].attributes.Susp_char_count.ToString()); num = featureLayer.FeatureClass.FindField(_featureInJSON.fieldAliases.Susp_text); iFeature.set_Value(num, _featureInJSON.features[j].attributes.Susp_text.ToString()); num = featureLayer.FeatureClass.FindField(_featureInJSON.fieldAliases.Text); iFeature.set_Value(num, _featureInJSON.features[j].attributes.Text); iFeature.Store(); } IFeatureCursor fcCursor = featureLayer.FeatureClass.Update(null, true); //Stop the operation and provide a name to add to the operation stack. editWorkspace.StartEditOperation(); //Stop editing and save the edits. editWorkspace.StopEditing(true); map.AddLayer(featureLayer); } catch (Exception e) { Log.WriteLine("AddPolygon: " + e.Message); } }
private void Create_Click(object sender, EventArgs e) { try { IWorkspaceFactory pShpWksFact = new ShapefileWorkspaceFactory(); IFeatureWorkspace pFeatWks; pFeatWks = (IFeatureWorkspace)pShpWksFact.OpenFromFile(filePath, 0); const string strShapeFieldName = "Shape"; //定义属性字段 IFields pFields = new Fields(); IFieldsEdit pFieldsEdit; pFieldsEdit = pFields as IFieldsEdit; IField pField = new Field(); IFieldEdit pFieldEdit = new Field() as IFieldEdit; pFieldEdit.Name_2 = strShapeFieldName; pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry; pField = pFieldEdit as IField; //定义几何属性 IGeometryDef pGeomDef = new GeometryDef(); IGeometryDefEdit pGeomDefEdit = new GeometryDef() as IGeometryDefEdit; pGeomDefEdit = pGeomDef as IGeometryDefEdit; switch (shpTypeComboBox.Text) { case "Point": pGeomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint; break; case "Polyline": pGeomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolyline; break; case "Polygon": pGeomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon; break; } pGeomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint; pGeomDefEdit.SpatialReference_2 = new UnknownCoordinateSystem() as ISpatialReference; pFieldEdit.GeometryDef_2 = pGeomDef; pFieldsEdit.AddField(pField); pFields = pFieldsEdit as IFields; IFeatureClass pFeatureClass; pFeatureClass = pFeatWks.CreateFeatureClass(fileName, pFields, null, null, esriFeatureType.esriFTSimple, strShapeFieldName, ""); //添加属性字段 for (int i = 0; i < addFieldListBox.Items.Count; i++) { IField pfield = new Field(); IFieldEdit pfieldEdit = new Field() as IFieldEdit; pfieldEdit.Name_2 = addFieldListBox.Items[i].ToString(); pfieldEdit.Type_2 = esriFieldType.esriFieldTypeString; pfield = pfieldEdit as IField; pFeatureClass.AddField(pfield); } //绘制点 for (int i = 0; i < excelDataGridViewX.Rows.Count - 1; i++) { DataGridViewRow dataRow = excelDataGridViewX.Rows[i]; double pointX, pointY; pointX = double.Parse(dataRow.Cells[xComboBoxEx.Text].Value.ToString()); pointY = double.Parse(dataRow.Cells[yComboBoxEx.Text].Value.ToString()); IPoint pPoint = new ESRI.ArcGIS.Geometry.Point() as IPoint; pPoint.PutCoords(pointX, pointY); IFeature pFeature = pFeatureClass.CreateFeature(); pFeature.Shape = pPoint; //为该点添加属性值 for (int j = 0; j < addFieldListBox.Items.Count; j++) { string fieldName = addFieldListBox.Items[j].ToString(); pFeature.set_Value(pFeature.Fields.FindField(fieldName), dataRow.Cells[fieldName].Value.ToString()); } pFeature.Store(); } //添加新建的数据至Map中 axMapControl.AddShapeFile(filePath, fileName); this.Hide(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void addPoligonGeorefrenced(IFeatureLayer featureLayer, IFeatureWorkspace featureworkspace) { try { //Define vertices if (_rasterInfo.rasterType != "Unknown") convertPolygon(); IMap map = ArcMap.Document.FocusMap; AddGraphicToMap(map); IWorkspaceEdit editWorkspace = featureworkspace as IWorkspaceEdit; editWorkspace.StartEditing(true); editWorkspace.StartEditOperation(); int count = 0; if (_rasterInfo.rasterType != "Unknown") count = lngLatSet.Length; else count = pointSet.Length; for (int j = 0; j < count; j++) { IPoint pPoint1 = new ESRI.ArcGIS.Geometry.Point(); IPoint pPoint2 = new ESRI.ArcGIS.Geometry.Point(); IPoint pPoint3 = new ESRI.ArcGIS.Geometry.Point(); IPoint pPoint4 = new ESRI.ArcGIS.Geometry.Point(); if (_rasterInfo.rasterType != "Unknown") { pPoint1.PutCoords(lngLatSet[j].leftTopX, lngLatSet[j].leftTopY); pPoint2.PutCoords(lngLatSet[j].rightTopX, lngLatSet[j].rightTopY); pPoint3.PutCoords(lngLatSet[j].rightDownX, lngLatSet[j].rightDownY); pPoint4.PutCoords(lngLatSet[j].leftDownX, lngLatSet[j].leftDownY); } else { // if (pointSet[j].leftTopY < 0) { pPoint1.PutCoords(pointSet[j].leftTopX, pointSet[j].leftTopY); pPoint2.PutCoords(pointSet[j].rightTopX, pointSet[j].rightTopY); pPoint3.PutCoords(pointSet[j].rightDownX, pointSet[j].rightDownY); pPoint4.PutCoords(pointSet[j].leftDownX, pointSet[j].leftDownY); } //else if (_rasterInfo.ratserNegative<0) //{ // pPoint1.PutCoords(pointSet[j].leftTopX, pointSet[j].leftTopY *-1); // pPoint2.PutCoords(pointSet[j].rightTopX, pointSet[j].rightTopY*-1); // pPoint3.PutCoords(pointSet[j].rightDownX, pointSet[j].rightDownY*-1); // pPoint4.PutCoords(pointSet[j].leftDownX, pointSet[j].leftDownY*-1); //} } IPointCollection pPolygon = new Polygon(); IPointCollection pPointCollection = pPolygon as IPointCollection; //Add the vertices of the polygon pPointCollection.AddPoints(1, ref pPoint1); pPointCollection.AddPoints(1, ref pPoint2); pPointCollection.AddPoints(1, ref pPoint3); pPointCollection.AddPoints(1, ref pPoint4); ((IPolygon)pPolygon).Close(); IFeature iFeature = featureLayer.FeatureClass.CreateFeature(); iFeature.Shape = (IPolygon)pPolygon; iFeature.Store(); //Feature cursor used to loop through all features in feature class, optionally a query filter can be used. if (_rasterInfo.rasterType != "Unknown") { int num = featureLayer.FeatureClass.FindField("URI"); iFeature.set_Value(num, lngLatSet[j].URI.ToString()); } iFeature.Store(); } IFeatureCursor fcCursor = featureLayer.FeatureClass.Update(null, true); //Stop the operation and provide a name to add to the operation stack. editWorkspace.StartEditOperation(); //Stop editing and save the edits. editWorkspace.StopEditing(true); map.AddLayer(featureLayer); } catch (Exception e) { Log.WriteLine("AddPolygon: " + e.Message); } }