/// <summary> ///创建图元 /// </summary> /// <param name="kml"></param> /// <param name="layer"></param> /// <returns></returns> public Core.Interface.IMFElement CreateElement(Core.Model.Kml kml, ILayer layer) { KmlText kmlText = kml.Placemark.Graph as KmlText; if (kmlText == null) { return(null); } if (kmlText.Position == null) { return(null); } CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(null); } Text_ArcMap textElement = new Text_ArcMap(mapControl, kmlText, mapFactory); textElement.ElementType = ElementTypeEnum.Text; graphicLayer.AddElement(textElement, 0); return(textElement); }
/// <summary> /// 显示隐藏 /// </summary> /// <param name="isVisible"></param> public void SetVisible(bool isVisible) { if (this.isVisible == isVisible) { return; } ILayer layer = factoryArcMap.GetLayerByName(belongLayer.LayerName); CompositeGraphicsLayerClass graphLayer = layer as CompositeGraphicsLayerClass; this.isVisible = isVisible; if (isVisible)//显示 { this.Dosomething((Action) delegate() { graphLayer.AddElement(this, 1); }, true); } else { this.Dosomething((Action) delegate() { graphLayer.DeleteElement(this); }, true); } Update(); this.isVisible = isVisible; }
/// <summary> /// 创建线图元 /// </summary> /// <param name="kml">线的kml</param> /// <param name="layer">图层</param> /// <returns></returns> public Core.Interface.IMFElement CreateElement(Core.Model.Kml kml, ILayer layer) { KmlLineString line = kml.Placemark.Graph as KmlLineString; if (line == null) { return(null); } if (line.PositionList == null || line.PositionList.Count < 1) { return(null); } CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(null); } Line_ArcMap lineElement = new Line_ArcMap(mapControl, line, mapFactory); lineElement.Opacity = 50; lineElement.ElementType = ElementTypeEnum.Line; graphicLayer.AddElement(lineElement, 0); return(lineElement); }
/// <summary> /// 创建图元 /// </summary> /// <param name="kml">图标的kml</param> /// <param name="layer">图元所在的图层</param> /// <returns></returns> public Core.Interface.IElement CreateElement(Core.Model.Kml kml, ESRI.ArcGIS.Carto.ILayer layer) { KmlPicture pictureKml = kml.Placemark.Graph as KmlPicture; if (pictureKml == null) { return(null); } if (pictureKml.Position == null) { return(null); } CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(null); } Picture_ArcMap pictureElement = new Picture_ArcMap(graphicLayer, pictureKml); pictureElement.ElementType = ElementTypeEnum.Picture; graphicLayer.AddElement(pictureElement, 0); return(pictureElement); }
/// <summary> /// 创建图元 /// </summary> /// <param name="kml">面的kml</param> /// <param name="layer">图元所在的图层</param> /// <returns></returns> public Core.Interface.IMFElement CreateElement(Core.Model.Kml kml, ILayer layer) { KmlPolygon kmlPolygon = kml.Placemark.Graph as KmlPolygon; if (kmlPolygon == null) { return(null); } if (kmlPolygon.PositionList == null || kmlPolygon.PositionList.Count == 0) { return(null); } CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(null); } Polygon_ArcMap polygonElement = new Polygon_ArcMap(mapControl, kmlPolygon, mapFoctory); polygonElement.Opacity = 30; graphicLayer.AddElement(polygonElement, 0); polygonElement.ElementType = ElementTypeEnum.Polygon; return(polygonElement); }
/// <summary> /// 隐藏 /// </summary> /// <param name="isVisible"></param> public void SetVisible(bool isVisible) { if (this.isVisible == isVisible) { return; } ILayer layer = mapFactory.GetLayerByName(this.BelongLayer.LayerName); CompositeGraphicsLayerClass graphLayer = layer as CompositeGraphicsLayerClass; if (graphLayer == null) { return; } Dosomething((Action)(delegate { if (isVisible)//显示 { graphLayer.AddElement(this, 1); } else { graphLayer.DeleteElement(this); } Update(); }), true); this.isVisible = isVisible; }
/// <summary> /// 创建图元 /// </summary> /// <param name="kml">图元的kml</param> /// <param name="layer">图元所在的图层</param> /// <returns></returns> public Core.Interface.IMFElement CreateElement(Core.Model.Kml kml, ILayer layer) { Core.Model.KmlCircle kmlCircle = kml.Placemark.Graph as Core.Model.KmlCircle; if (kmlCircle == null) { return(null); } if (kmlCircle.Position == null || kmlCircle.Radius <= 0) { return(null); } CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(null); } Circle_ArcMap circleElement = new Circle_ArcMap(mapControl, kmlCircle, factoryArcMap); circleElement.Opacity = 30; circleElement.ElementType = Core.Model.ElementTypeEnum.Circle; graphicLayer.AddElement(circleElement, 0); return(circleElement); }
/// <summary> /// 创建图元 /// </summary> /// <param name="kml">图标的kml</param> /// <param name="layer">图元所在的图层</param> /// <returns></returns> public Core.Interface.IMFElement CreateElement(Core.Model.Kml kml, ESRI.ArcGIS.Carto.ILayer layer) { KmlPoint pointKml = kml.Placemark.Graph as KmlPoint; if (pointKml == null) { return(null); } if (pointKml.Position == null) { return(null); } CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(null); } PointIco_ArcMap pictureElement = new PointIco_ArcMap(mapControl, pointKml, mapFactory); pictureElement.ElementType = ElementTypeEnum.Picture; graphicLayer.AddElement(pictureElement, 0); return(pictureElement); }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { //get the map IMap map = m_hookHelper.FocusMap; //count the graphics layers (will be used in order to name the new layer) int graphicsLayerCoount = 0; for (int i = 0; i < map.LayerCount; i++) { if (map.get_Layer(i) is IGraphicsLayer) { graphicsLayerCoount++; } } //create a new graphics layer IGraphicsLayer graphicsLayer = new CompositeGraphicsLayerClass(); //name the new layer ((ILayer)graphicsLayer).Name = "Graphics Layer " + graphicsLayerCoount.ToString(); //make the new graphics layer the active graphics layer map.ActiveGraphicsLayer = (ILayer)graphicsLayer; //add the new layer to the map map.AddLayer((ILayer)graphicsLayer); }
/// <summary> /// 释放该类 /// </summary> public void Dispose() { ReleaseCommond(); CommondExecutedEvent = null; currTool = null; mapControl = null; textCtr = null; editElement = null; editElement = null; graphicsContainer = null; }
/// <summary> /// 构造函数 /// </summary> /// <param name="_mapControl">arcgis地图控件</param> /// <param name="_element">要编辑的文字图元</param> public EditText(AxMapControl _mapControl, IMFElement _element) { mapControl = _mapControl; currTool = _mapControl.CurrentTool; editElement = _element as Text_ArcMap; if (editElement != null) { graphicsContainer = GetLayerByName(editElement.BelongLayer.LayerName) as CompositeGraphicsLayerClass; } }
/// <summary> /// 清除当前图层 /// </summary> /// <param name="layerName">图层名称</param> public void ClearLayer(string layerName) { if (!layerDic.ContainsKey(layerName)) { return; } CompositeGraphicsLayerClass graLayer = layerDic[layerName]; if (graLayer != null) { graLayer.DeleteAllElements(); } }
/// <summary> /// 添加图层 /// </summary> /// <param name="layerName">图层名称</param> /// <returns></returns> public bool AddLayer(string layerName) { if (layerDic.ContainsKey(layerName)) { return(true); } CompositeGraphicsLayerClass layer = new CompositeGraphicsLayerClass(); layer.Name = layerName; layer.Visible = true; axMapControl.Map.AddLayer(layer); layerDic.Add(layerName, layer); return(true); }
/// <summary> /// 鼠标弹起结束绘制 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void mapControl_OnMouseUp(object sender, IMapControlEvents2_OnMouseUpEvent e) { IPoint point = new PointClass() { X = e.mapX, Y = e.mapY }; envelope = rectangleFeedback.Stop() as IEnvelope; int layerCount = mapControl.LayerCount; for (int i = 0; i < layerCount; i++) { ILayer layer = mapControl.get_Layer(i); CompositeGraphicsLayerClass comp = layer as CompositeGraphicsLayerClass; if (comp == null) { continue; } if (envelope.IsEmpty == true) { elementEnums = comp.LocateElements(point, 0); } else { elementEnums = comp.LocateElementsByEnvelope(envelope); } List <IElement> list = new List <IElement>(); if (elementEnums == null) { return; } IElement el = null; do { el = elementEnums.Next(); if (el != null) { var element = el as IMFElement; listElements.Add(element); } }while (el != null); } ReleaseCommond(); }
/// <summary> /// 移除图元 /// </summary> /// <param name="element">要移除的圆图元</param> /// <param name="layer">图元的所在图层</param> /// <returns></returns> public bool RemoveElement(Core.Interface.IMFElement element, ILayer layer) { if (element == null) { return(true); } CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(true); } CircleElementClass circleElement = element as CircleElementClass; graphicLayer.DeleteElement(circleElement); return(true); }
/// <summary> /// 移除图元 /// </summary> /// <param name="element">要移除的图元</param> /// <param name="layer">图元所在的图层</param> /// <returns></returns> public bool RemoveElement(Core.Interface.IElement element, ESRI.ArcGIS.Carto.ILayer layer) { if (element == null) { return(true); } CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(true); } PictureElementClass pictureElement = element as PictureElementClass; graphicLayer.DeleteElement(pictureElement); return(true); }
public bool AddGraphicsLayer(IBasicMap pBasicMap, IGroupLayer pParentLayer, string sLayerName) { try { if (sLayerName == null) { sLayerName = ""; } if (pBasicMap == null) { return(false); } if (string.IsNullOrEmpty(sLayerName)) { sLayerName = "<新建图像图层>"; } IGraphicsLayer layer = null; if (this.FindGraphicsLayer(pBasicMap, sLayerName) == null) { layer = new CompositeGraphicsLayerClass(); ILayer layer2 = null; layer2 = layer as ILayer; layer2.Name = sLayerName; pBasicMap.AddLayer(layer as ILayer); IMapLayers layers = pBasicMap as IMapLayers; if (pParentLayer == null) { layers.MoveLayer(layer2, 0); } else if (pBasicMap is IMap) { layers.MoveLayerEx(pParentLayer, pParentLayer, layer2, 0); } } return(true); } catch (Exception exception) { this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.LayerFun", "AddGraphicsLayer", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); return(false); } }
/// <summary> /// 显示隐藏 /// </summary> /// <param name="isVisible"></param> public void SetVisible(bool isVisible) { if (this.isVisible == isVisible) { return; } ILayer layer = mapFactory.GetLayerByName(belongLayer.LayerName); CompositeGraphicsLayerClass graphLayer = layer as CompositeGraphicsLayerClass; this.isVisible = isVisible; if (isVisible)//显示 { graphLayer.AddElement(this, 1); } else { graphLayer.DeleteElement(this); } Update(); }
/// <summary> /// 删除图元 /// </summary> /// <param name="element">要移除的线图元</param> /// <param name="layer">图元所在的图层</param> /// <returns></returns> public bool RemoveElement(Core.Interface.IMFElement element, ILayer layer) { CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(false); } Line_ArcMap line = element as Line_ArcMap; if (line == null) { return(false); } graphicLayer.DeleteElement(line);//删除线图元 return(true); }
//上朔追踪查找管线涉及的地块 public static void UpStreamFindParcels(MainFrm pMainFrm, IEnumNetEID pEnumResultEdges, IGeometricNetwork pGeoNetwork) { try { AxMapControl axMap = pMainFrm.getMapControl(); IFeatureLayer pFeatLayerSewerLines = FindFeatLayer("Sewer Lines", pMainFrm); IFeatureLayer pFeatLayerParcels = FindFeatLayer("Parcels", pMainFrm); //从所选择的Sewer线特征中创建几何包 IGeometryCollection pGeomBag = new GeometryBagClass(); object missing = Type.Missing; int lEID; int iUserClassID; int iUserID; int iUserSubID; INetElements pNetElements = pGeoNetwork.Network as INetElements; pEnumResultEdges.Reset(); IFeature pFeature; for (int j = 0; j <= pEnumResultEdges.Count - 1; j++) { lEID = pEnumResultEdges.Next(); pNetElements.QueryIDs(lEID, esriElementType.esriETEdge, out iUserClassID, out iUserID, out iUserSubID); pFeature = pFeatLayerSewerLines.FeatureClass.GetFeature(iUserID); pGeomBag.AddGeometry(pFeature.Shape, ref missing, ref missing); // MessageBox.Show(iUserClassID.ToString()+","+iUserID.ToString()+","+iUserSubID.ToString()); } //进行空间拓扑叠加操作以用于查找地块信息 ISpatialFilter pSpatialFilter = new SpatialFilterClass(); pSpatialFilter.Geometry = pGeomBag as IGeometry ; pSpatialFilter.GeometryField = "Shape"; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; pSpatialFilter.SearchOrder = esriSearchOrder.esriSearchOrderSpatial; //获得交叉到的地块信息 IFeatureCursor pFeatCursor=pFeatLayerParcels.FeatureClass.Search(pSpatialFilter, false); //增加被选择的地块数据到地图的图形图层数据中 ICompositeGraphicsLayer pComGraphicLayer = new CompositeGraphicsLayerClass(); ILayer pLayer = pComGraphicLayer as ILayer ; pLayer.Name = "受影响的地块"; IGraphicsContainer pGraphicContainer = pComGraphicLayer as IGraphicsContainer; //增加所选择的地块到图形容器中 ISimpleFillSymbol pSymFill=new SimpleFillSymbolClass(); IFillSymbol pFillSymbol=pSymFill as IFillSymbol; IRgbColor pRgbColor=new RgbColorClass(); pRgbColor.Red=0; pRgbColor.Green=200; pRgbColor.Blue=100; pFillSymbol.Color=pRgbColor as IColor; ICartographicLineSymbol pCartoLine=new CartographicLineSymbolClass(); IRgbColor pRgbColor2=new RgbColorClass(); pRgbColor2.Red=100; pRgbColor2.Green=200; pRgbColor2.Blue=100; pCartoLine.Width=2; pCartoLine.Color =pRgbColor2 as IColor; pFillSymbol.Outline=pCartoLine; //创建存放所有地块特征的数组 IArray pFeatArray = new ArrayClass(); pFeature=pFeatCursor.NextFeature(); while (pFeature != null) { IElement pPolyElement = new PolygonElementClass(); IFillShapeElement pFillShapeElement = pPolyElement as IFillShapeElement; pPolyElement.Geometry = pFeature.Shape; pFillShapeElement.Symbol = pFillSymbol; pGraphicContainer.AddElement(pPolyElement, 0); pFeatArray.Add(pFeature); pFeature = pFeatCursor.NextFeature(); } axMap.AddLayer(pGraphicContainer as ILayer); axMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null,null); frmUpstreamCreateOwnerList frmUpstreamCreateOwnerList1 = new frmUpstreamCreateOwnerList(pMainFrm,pFeatLayerParcels, pFeatArray); frmUpstreamCreateOwnerList1.Show(); } catch (Exception eX) { MessageBox.Show(eX.Message); } }
//��˷�ٲ��ҹ����漰�ĵؿ� public static void UpStreamFindParcels(AxMapControl ppAxMapControl, IEnumNetEID pEnumResultEdges, IGeometricNetwork pGeoNetwork) { try { IFeatureLayer pFeatLayerSewerLines = FindFeatLayer("Sewer Lines", ppAxMapControl); IFeatureLayer pFeatLayerParcels = FindFeatLayer("Parcels", ppAxMapControl); //����ѡ���Sewer�������д������ΰ� IGeometryCollection pGeomBag = new GeometryBagClass(); object missing = Type.Missing; int lEID; int iUserClassID; int iUserID; int iUserSubID; INetElements pNetElements = pGeoNetwork.Network as INetElements; pEnumResultEdges.Reset(); IFeature pFeature; for (int j = 0; j <= pEnumResultEdges.Count - 1; j++) { lEID = pEnumResultEdges.Next(); pNetElements.QueryIDs(lEID, esriElementType.esriETEdge, out iUserClassID, out iUserID, out iUserSubID); pFeature = pFeatLayerSewerLines.FeatureClass.GetFeature(iUserID); pGeomBag.AddGeometry(pFeature.Shape, ref missing, ref missing); // MessageBox.Show(iUserClassID.ToString()+","+iUserID.ToString()+","+iUserSubID.ToString()); } //���пռ����˵��Ӳ��������ڲ��ҵؿ���Ϣ ISpatialFilter pSpatialFilter = new SpatialFilterClass(); pSpatialFilter.Geometry = pGeomBag as IGeometry; pSpatialFilter.GeometryField = "Shape"; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; pSpatialFilter.SearchOrder = esriSearchOrder.esriSearchOrderSpatial; //��ý��浽�ĵؿ���Ϣ IFeatureCursor pFeatCursor = pFeatLayerParcels.FeatureClass.Search(pSpatialFilter, false); //���ӱ�ѡ��ĵؿ����ݵ���ͼ��ͼ��ͼ�������� ICompositeGraphicsLayer pComGraphicLayer = new CompositeGraphicsLayerClass(); ILayer pLayer = pComGraphicLayer as ILayer; pLayer.Name = "��Ӱ��ĵؿ�"; IGraphicsContainer pGraphicContainer = pComGraphicLayer as IGraphicsContainer; //������ѡ��ĵؿ鵽ͼ�������� ISimpleFillSymbol pSymFill = new SimpleFillSymbolClass(); IFillSymbol pFillSymbol = pSymFill as IFillSymbol; IRgbColor pRgbColor = new RgbColorClass(); pRgbColor.Red = 0; pRgbColor.Green = 200; pRgbColor.Blue = 100; pFillSymbol.Color = pRgbColor as IColor; ICartographicLineSymbol pCartoLine = new CartographicLineSymbolClass(); IRgbColor pRgbColor2 = new RgbColorClass(); pRgbColor2.Red = 100; pRgbColor2.Green = 200; pRgbColor2.Blue = 100; pCartoLine.Width = 2; pCartoLine.Color = pRgbColor2 as IColor; pFillSymbol.Outline = pCartoLine; //����������еؿ����������� IArray pFeatArray = new ArrayClass(); pFeature = pFeatCursor.NextFeature(); while (pFeature != null) { IElement pPolyElement = new PolygonElementClass(); IFillShapeElement pFillShapeElement = pPolyElement as IFillShapeElement; pPolyElement.Geometry = pFeature.Shape; pFillShapeElement.Symbol = pFillSymbol; pGraphicContainer.AddElement(pPolyElement, 0); pFeatArray.Add(pFeature); pFeature = pFeatCursor.NextFeature(); } ppAxMapControl.AddLayer(pGraphicContainer as ILayer); ppAxMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); //ma //frmUpstreamCreateOwnerList frmUpstreamCreateOwnerList1 = new frmUpstreamCreateOwnerList(ppAxMapControl,pFeatLayerParcels, pFeatArray); //frmUpstreamCreateOwnerList1.Show(); } catch (Exception eX) { MessageBox.Show(eX.Message); } }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { //get the map IMap map = m_hookHelper.FocusMap; //count the graphics layers (will be used in order to name the new layer) int graphicsLayerCoount = 0; for (int i = 0; i < map.LayerCount; i++) { if (map.get_Layer(i) is IGraphicsLayer) graphicsLayerCoount++; } //create a new graphics layer IGraphicsLayer graphicsLayer = new CompositeGraphicsLayerClass(); //name the new layer ((ILayer)graphicsLayer).Name = "Graphics Layer " + graphicsLayerCoount.ToString(); //make the new graphics layer the active graphics layer map.ActiveGraphicsLayer = (ILayer)graphicsLayer; //add the new layer to the map map.AddLayer((ILayer)graphicsLayer); }