画一个Polygong,并将这个Polygon创建为Featureclass 10
在ArcEngine中利用C#怎么实现画一个Polygong,并将这个Polygon创建为Featureclass。...
在ArcEngine中利用C#怎么实现画一个Polygong,并将这个Polygon创建为Featureclass。
展开
展开全部
/// <summary>
/// 划多边形
/// </summary>
/// <param name="pPolygonElement">多边形</param>
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
{
IFillShapeElement pPolygonElement;
ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();
IPolygon pPolygon = new PolygonClass();
IRubberBand pRubberBand = new RubberPolygonClass();
ISimpleLineSymbol pSimpleLineSymbol=new SimpleLineSymbolClass();
pPolygonElement = new PolygonElementClass();
if (e.button == 1)
{
pPolygon=(IPolygon) pRubberBand.TrackNew(axMapControl1.ActiveView.ScreenDisplay, null);
}
pSimpleLineSymbol.Width=2;
pSimpleLineSymbol.Style=esriSimpleLineStyle.esriSLSSolid;
pSimpleLineSymbol.Color=GetRGBColor(46,24,63);
pSimpleFillSymbol.Color = GetRGBColor(11, 200, 145);
pSimpleFillSymbol.Outline = pSimpleLineSymbol;
IElement pElement = (IElement)pPolygonElement;
pElement.Geometry = pPolygon;
pPolygonElement.Symbol = pSimpleFillSymbol;
IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)axMapControl1.Map;
pGraphicsContainer.AddElement((IElement)pPolygonElement,0);
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null,null);
}
private IRgbColor GetRGBColor(int red, int green, int blue)
{
IRgbColor rGBColor = new RgbColorClass();
rGBColor.Red = red;
rGBColor.Green = green;
rGBColor.Blue = blue;
return rGBColor;
}
/// <summary>
/// 向多边形shp中添加要素
/// </summary>
/// <param name="pPolygonElement">多边形</param>
/// <param name="pFeatureClass">多边形shp</param>
public static void AddFeatureToFeatureClass(IPolygon pPolygonElement, IFeatureClass pFeatureClass)
{
IFeature pFeature = pFeatureClass.CreateFeature();
pFeature.Shape = pPolygon;
pFeature.Store();
}
/// 划多边形
/// </summary>
/// <param name="pPolygonElement">多边形</param>
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
{
IFillShapeElement pPolygonElement;
ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();
IPolygon pPolygon = new PolygonClass();
IRubberBand pRubberBand = new RubberPolygonClass();
ISimpleLineSymbol pSimpleLineSymbol=new SimpleLineSymbolClass();
pPolygonElement = new PolygonElementClass();
if (e.button == 1)
{
pPolygon=(IPolygon) pRubberBand.TrackNew(axMapControl1.ActiveView.ScreenDisplay, null);
}
pSimpleLineSymbol.Width=2;
pSimpleLineSymbol.Style=esriSimpleLineStyle.esriSLSSolid;
pSimpleLineSymbol.Color=GetRGBColor(46,24,63);
pSimpleFillSymbol.Color = GetRGBColor(11, 200, 145);
pSimpleFillSymbol.Outline = pSimpleLineSymbol;
IElement pElement = (IElement)pPolygonElement;
pElement.Geometry = pPolygon;
pPolygonElement.Symbol = pSimpleFillSymbol;
IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)axMapControl1.Map;
pGraphicsContainer.AddElement((IElement)pPolygonElement,0);
axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null,null);
}
private IRgbColor GetRGBColor(int red, int green, int blue)
{
IRgbColor rGBColor = new RgbColorClass();
rGBColor.Red = red;
rGBColor.Green = green;
rGBColor.Blue = blue;
return rGBColor;
}
/// <summary>
/// 向多边形shp中添加要素
/// </summary>
/// <param name="pPolygonElement">多边形</param>
/// <param name="pFeatureClass">多边形shp</param>
public static void AddFeatureToFeatureClass(IPolygon pPolygonElement, IFeatureClass pFeatureClass)
{
IFeature pFeature = pFeatureClass.CreateFeature();
pFeature.Shape = pPolygon;
pFeature.Store();
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询