public override void OnMouseDown(int button, int Shift, int x, int y) { if (button != 2) { _pointnum++; this.CalculateArea(x, y, 1); } else { graphicsContainer.DeleteAllElements(); ((IActiveView)this._context.FocusMap).PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } }
private void ClearNet_Click(object sender, EventArgs e) { axMapControl1.CurrentTool = null; try { //string name =path + "\\WHU_StudentQuery.mdb"; //string name = NetWorkAnalysClass.getPath(path) + "\\ArcEngineDemo\\WHU_StudentQuery.mdb"; string name = NetWorkAnalysClass.getPath(path) + "\\Data\\TestNet.gdb"; //打开工作空间 pFWorkspace = NetWorkAnalysClass.OpenWorkspace(name) as IFeatureWorkspace; IGraphicsContainer pGrap = this.axMapControl1.ActiveView as IGraphicsContainer; pGrap.DeleteAllElements();//删除所添加的图片要素 IFeatureClass inputFClass = pFWorkspace.OpenFeatureClass("Stops"); //删除站点要素 if (inputFClass.FeatureCount(null) > 0) { ITable pTable = inputFClass as ITable; pTable.DeleteSearchedRows(null); } for (int i = 0; i < axMapControl1.LayerCount; i++)//删除分析结果 { ILayer pLayer = axMapControl1.get_Layer(i); if (pLayer.Name == ShortPathSolveCommand.m_NAContext.Solver.DisplayName) { axMapControl1.DeleteLayer(i); break; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } this.axMapControl1.Refresh(); }
private void ClearElements(IActiveView pActiveView) { IGraphicsContainer graphicsContainer = pActiveView.GraphicsContainer; IMapFrame mapFrame = graphicsContainer.FindFrame(pActiveView.FocusMap) as IMapFrame; (mapFrame as IMapGrids).ClearMapGrids(); graphicsContainer.Reset(); IElement element = graphicsContainer.Next(); List <IElement> list = new List <IElement>(); while (element != null) { if (element != mapFrame) { list.Add(element); } element = graphicsContainer.Next(); } try { graphicsContainer.DeleteAllElements(); graphicsContainer.Reset(); element = graphicsContainer.Next(); if (element != null) { graphicsContainer.DeleteElement(element); } graphicsContainer.AddElement(mapFrame as IElement, -1); pActiveView.FocusMap = mapFrame.Map; } catch (Exception) { } }
public override void timerReduce_Tick(object sender, EventArgs e) { _dblProp = _dblProp - 0.001; IMapControl4 m_mapControl = _DataRecords.ParameterInitialize.m_mapControl; IGraphicsContainer pGra = m_mapControl.Map as IGraphicsContainer; pGra.DeleteAllElements(); if (_dblProp < 0) { timerReduce.Enabled = false; _dblProp = 0; pbScale.Value = Convert.ToInt16(100 * _dblProp); CPolyline cpl0 = GetTargetcpl(_dblProp); CHelpFunc.ViewPolyline(_DataRecords.ParameterInitialize.m_mapControl, cpl0); return; } CPolyline cpl1 = GetTargetcpl(_dblProp); pbScale.Value = Convert.ToInt16(100 * _dblProp); CHelpFunc.ViewPolyline(m_mapControl, cpl1); }
public static void ZoomToCurrentError(IMxDocument pMxDoc, double zoomingAdjust, IPoint pPoint) { IMap pMap = pMxDoc.FocusMap as IMap; IGraphicsContainer pGraphicsContainer = pMap as IGraphicsContainer; //ILayer pLayer = null; //pLayer.Visible = false; ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbol(); IRgbColor pLightGreen = (IRgbColor) new RgbColor(); pLightGreen.Red = 181; pLightGreen.Green = 230; pLightGreen.Blue = 96; pSimpleMarkerSymbol.Color = pLightGreen; pSimpleMarkerSymbol.Outline = true; pSimpleMarkerSymbol.OutlineColor = pLightGreen; pSimpleMarkerSymbol.OutlineSize = 2; pSimpleMarkerSymbol.Size = 25; pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCross; IMarkerElement pMarkerElement = (IMarkerElement) new MarkerElement(); pMarkerElement.Symbol = pSimpleMarkerSymbol; IElement pElement = pMarkerElement as IElement; pElement.Geometry = pPoint as IGeometry; pGraphicsContainer.DeleteAllElements(); pGraphicsContainer.AddElement(pElement, 0); // IEnvelope pExtent = Data.ErrorTable[Data.CurrentErrorIndex].Penvelope; // pExtent.Expand(zoomingAdjust, zoomingAdjust, true); IEnvelope pExtent = (IEnvelope) new Envelope(); pExtent.PutCoords(pPoint.X - zoomingAdjust, pPoint.Y - zoomingAdjust, pPoint.X + zoomingAdjust, pPoint.Y + zoomingAdjust); pMxDoc.ActiveView.Extent = pExtent; pMxDoc.ActiveView.Refresh(); }
/// <summary> /// 主地图OnExtentUpdated事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e) { //刷新axMapControl2 axMapControl2.Refresh(); //以主地图的Extent作为鹰眼红线框的大小范围 IEnvelope pEnvelope = axMapControl1.Extent; //鹰眼强制转换为IGraphicsContainer //IGraphicsContainer是绘图容器接口, 主要功能是在MapControl控件类上添加绘图要素。 IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer; //鹰眼强制转换为pActiveView IActiveView pActiveView = pGraphicsContainer as IActiveView; //删除鹰眼原有要素 pGraphicsContainer.DeleteAllElements(); //实例化矩形框要素 IRectangleElement pRectangleElement = new RectangleElementClass(); //强转矩形要素框为要素 IElement pElement = pRectangleElement as IElement; //赋值几何实体的最小外接矩形, 即包络线 pElement.Geometry = pEnvelope; //使用面要素刷新(存在覆盖注释问题) //DrawPolyline2(pGraphicsContainer, pActiveView, pElement); //使用线要素刷新(已解决重叠问题)(推荐使用) //使用IScreenDisplay的DrawPolyline方法,在鹰眼视图画出红线框 DrawPolyline(axMapControl2.ActiveView, pEnvelope); }
//主地图:地图范围(Extent)变化 private void axMapControlMainMap_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e) { #region 主地图地图范围Extent变化时,鹰眼中的地图范围Extent也跟随着变化 IEnvelope envelope = (IEnvelope)e.newEnvelope; //得到主地图的新范围 IGraphicsContainer graphicsContainer = axMapControlEagleMap.Map as IGraphicsContainer; IActiveView activeView = graphicsContainer as IActiveView; graphicsContainer.DeleteAllElements(); //在绘制前,清除axMapControlEagleMap中的任何图形元素 IRectangleElement rectangleElement = new RectangleElement() as IRectangleElement; IElement element = rectangleElement as IElement; element.Geometry = envelope; //产生一个线符号对象,设置鹰眼中的红线框 ILineSymbol lineSymbol = new SimpleLineSymbol(); lineSymbol.Width = 1.6; lineSymbol.Color = RenderOpt.GetIColor(255, 0, 0); //设置填充符号的属性 IFillSymbol fillSymbol = new SimpleFillSymbol(); fillSymbol.Color = RenderOpt.GetIColor(255, 0, 0, 0); fillSymbol.Outline = lineSymbol; IFillShapeElement fillShapeElement = element as IFillShapeElement; fillShapeElement.Symbol = fillSymbol; graphicsContainer.AddElement((IElement)fillShapeElement, 0); //刷新 envelope.Expand(2, 2, true); activeView.Extent = envelope; activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); #endregion }
private void DeleteGraphics() { IGraphicsContainer graphicsContainer = m_map as IGraphicsContainer; graphicsContainer.DeleteAllElements(); m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
/// <summary> /// 清除所有图元素 /// </summary> public void ClearAllElement() { IActiveView pActiveView = mapControl.ActiveView; IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer; pGraphicsContainer.DeleteAllElements(); }
public bool Buffer(string layerName, string sWhere, int iSize, IMap iMap) { IFeatureClass featClass; IFeature feature; IGeometry iGeom; DataOperator dataOperator = new DataOperator(iMap); IFeatureLayer featLayer = (IFeatureLayer)dataOperator.GetLayerByName(layerName); IGraphicsContainer graphicsContainer = (IGraphicsContainer)iMap; graphicsContainer.DeleteAllElements(); featClass = featLayer.FeatureClass; IQueryFilter queryFilter = new QueryFilter(); queryFilter.WhereClause = sWhere; IFeatureCursor featCursor; featCursor = (IFeatureCursor)featClass.Search(queryFilter, false); int count = featClass.FeatureCount(queryFilter); feature = featCursor.NextFeature(); iGeom = feature.Shape; IElement element = new PolygonElementClass(); ITopologicalOperator ipTO = (ITopologicalOperator)iGeom; element.Geometry = ipTO.Buffer(iSize); graphicsContainer.AddElement(element, 0); return(true); }
public void LabelQueryInfo(string name, string strContent, IPoint pt, IMap pMap, bool isRemoveLast) { //获取并激活Graphic标注图层 if (pt == null) { return; } IActiveView pActiveView = pMap as IActiveView; ICompositeGraphicsLayer pCompositeGraphicsLayer = pMap.BasicGraphicsLayer as ICompositeGraphicsLayer; //WeatherLabel标记组,通过ArcMap的Layers Properties的Annotation group可以看到 IGraphicsLayer pGraphicsLayer = pCompositeGraphicsLayer.FindLayer("WeatherLabel"); pMap.ActiveGraphicsLayer = pGraphicsLayer as ILayer; pGraphicsLayer.Activate(pActiveView.ScreenDisplay); IGraphicsContainer pGraphicsContainer = pGraphicsLayer as IGraphicsContainer;//转换到图形容器接口 IElementCollection pElementCollection = new ElementCollectionClass(); AddBalloonCalloutLabel(name, strContent, pt, pElementCollection);//我们需要一个新的私有函数来实现设置标签元素背景,BalloonCallout对象 //添加标注 if (isRemoveLast == true) { pGraphicsContainer.DeleteAllElements(); } pGraphicsContainer.AddElements(pElementCollection, 1000); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, pActiveView.ScreenDisplay.DisplayTransformation.VisibleBounds); }
/// <summary> /// 通过添加Element方式高亮显示错误要素(解决点在特定比例尺中未显示问题) /// </summary> /// <param name="pGra"></param> /// <param name="in_fea"></param> private void MakeSymbol(IGraphicsContainer pGra, IFeature in_fea) { if (in_fea == null) { return; } pGra.DeleteAllElements(); IActiveView pAcitveView = pGra as IActiveView; IElement pEle; IRgbColor pColor = new RgbColorClass(); pColor.Blue = 255; pColor.Green = 200; pColor.Red = 0; if (in_fea.Shape.GeometryType == esriGeometryType.esriGeometryPoint) { IMarkerElement pMakEle = new MarkerElementClass(); pEle = pMakEle as IElement; IMarkerSymbol pMakSym = new SimpleMarkerSymbolClass(); pMakSym.Color = pColor; pMakEle.Symbol = pMakSym; pEle.Geometry = in_fea.Shape as ESRI.ArcGIS.Geometry.IGeometry; pGra.AddElement(pEle, 0); pAcitveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } }
/// <summary> /// 清除所有图元素 /// </summary> public static void ClearAllElement() { IActiveView pActiveView = Main.Program.myMap.ActiveView; IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer; pGraphicsContainer.DeleteAllElements(); }
private void OnOnDoubleClick(int button, int shift, int i, int i1, double mapX, double mapY) { if (button == 2) { return; } if (_polygonFeedback == null) { return; } IPoint point = new PointClass(); point.PutCoords(mapX, mapY); _polygonFeedback.AddPoint(point); _polygon = _polygonFeedback.Stop(); IRgbColor rgbColorClass = new RgbColor(); rgbColorClass.Red = (0); rgbColorClass.Green = (255); rgbColorClass.Blue = (255); ISimpleFillSymbol simpleFillSymbolClass = new SimpleFillSymbol(); ((ISymbol)simpleFillSymbolClass).ROP2 = (esriRasterOpCode)(10); simpleFillSymbolClass.Color = (rgbColorClass); IElement element = new PolygonElement(); element.Geometry = _polygon; ((IFillShapeElement)element).Symbol = simpleFillSymbolClass; _graphicsContainer.DeleteAllElements(); _graphicsContainer.AddElement(element, 100); _context.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); OnDrawCompleteEvent(); //_polygon = null; _polygonFeedback = null; }
//在鹰眼地图上面画矩形框 public static void DrawRectangle(IEnvelope pIEnvelope) { //在绘制前,清除鹰眼中之前绘制的矩形框 IGraphicsContainer pGraphicsContainer = Variable.pEagleEyeMapFrm.EagelEyeMapControl.Map as IGraphicsContainer; IActiveView pActiveView = pGraphicsContainer as IActiveView; pGraphicsContainer.DeleteAllElements(); //得到当前视图范围 IRectangleElement pRectangleElement = new RectangleElementClass(); IElement pElement = pRectangleElement as IElement; pElement.Geometry = pIEnvelope; //设置矩阵框(实质为中间透明度面) IRgbColor pRgbColor = new RgbColorClass(); pRgbColor = GetRgbColor(255, 0, 0); pRgbColor.Transparency = 255; ILineSymbol pOutLine = new SimpleLineSymbolClass(); pOutLine.Width = 2; pOutLine.Color = pRgbColor; IFillSymbol pFillSymbol = new SimpleFillSymbolClass(); pRgbColor = new RgbColorClass(); pRgbColor.Transparency = 0; pFillSymbol.Color = pRgbColor; pFillSymbol.Outline = pOutLine; //向鹰眼中添加矩形框 IFillShapeElement pFillShapeElement = pElement as IFillShapeElement; pFillShapeElement.Symbol = pFillSymbol; pGraphicsContainer.AddElement((IElement)pFillShapeElement, 0); //刷新 pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
private void 给出可测区域ToolStripMenuItem_Click(object sender, EventArgs e) { IGeometry buffer; ISelection pSeletion = axMapControl1.Map.FeatureSelection; IEnumFeature pEnumFeature = (IEnumFeature)pSeletion; IGraphicsContainer graphicsContainer = axMapControl1.ActiveView.GraphicsContainer; graphicsContainer.DeleteAllElements(); IFeature pFeature = pEnumFeature.Next(); double bufferDistance = GlobalData.dist; if (bufferDistance <= 0.0) { MessageBox.Show("距离设置错误"); return; } while (pFeature != null) { ITopologicalOperator topoOperator = pFeature.Shape as ITopologicalOperator; buffer = topoOperator.Buffer(bufferDistance); IElement element = new PolygonElementClass(); element.Geometry = buffer; graphicsContainer.AddElement(element, 0); pFeature = pEnumFeature.Next(); } axMapControl1.Refresh(); }
private void button2_Click(object sender, EventArgs e) { IActiveView pIActiveView = pmapcontrol.Map as IActiveView; IGraphicsContainer pIGraphicsContainer = pIActiveView.GraphicsContainer; pIGraphicsContainer.DeleteAllElements(); IFeatureLayer pIFeatureLayer = pmapcontrol.get_Layer(0) as IFeatureLayer; IFeatureCursor pIFeatureCursor = pIFeatureLayer.FeatureClass.Search(null, false); IFeature pfeature = pIFeatureCursor.NextFeature(); while (pfeature != null) { ITopologicalOperator pITopologicalOperator = pfeature.Shape as ITopologicalOperator; IPolygon pPolygon = pITopologicalOperator.Buffer(double.Parse(textBox1.Text)) as IPolygon; IElement pIElement = new PolygonElement(); pIElement.Geometry = pPolygon; pIGraphicsContainer.AddElement(pIElement, 0); pfeature = pIFeatureCursor.NextFeature(); } pmapcontrol.Refresh(); this.Close(); }
/// <summary> /// 主窗体视图范围变化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e) { //获得当前地图视图的外包矩形 IEnvelope pEnvelope = (IEnvelope)e.newEnvelope; //获得GraphicsContainer对象用来管理元素对象 IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer; //清除对象中的所有图形元素 pGraphicsContainer.DeleteAllElements(); //获得矩形图形元素 IRectangleElement pRectangleEle = new RectangleElementClass(); IElement pElement = pRectangleEle as IElement; pElement.Geometry = pEnvelope; //设置FillShapeElement对象的symbol IFillShapeElement pFillShapeEle = pElement as IFillShapeElement; pFillShapeEle.Symbol = this.Presenter.getFillSymbol(); //进行填充 pGraphicsContainer.AddElement((IElement)pFillShapeEle, 0); //刷新视图 IActiveView pActiveView = pGraphicsContainer as IActiveView; pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
/// <summary> /// 显示并返回多个插值线段 /// </summary> /// <param name="pDataRecords">数据记录</param> /// <param name="dblProp">差值参数</param> /// <returns>插值线段</returns> public static List <CPolyline> DisplayInterpolations(CDataRecords pDataRecords, double dblProp) { if (dblProp < 0 || dblProp > 1) { MessageBox.Show("请输入正确参数!"); return(null); } List <List <CPoint> > CResultPtLtLt = pDataRecords.ParameterResult.CResultPtLtLt; List <CPolyline> cpllt = new List <CPolyline>(); for (int i = 0; i < CResultPtLtLt.Count; i++) { CPolyline cpl = CGeoFunc.GetTargetcpl(CResultPtLtLt[i], dblProp); cpllt.Add(cpl); } // 清除绘画痕迹 IMapControl4 m_mapControl = pDataRecords.ParameterInitialize.m_mapControl; IGraphicsContainer pGra = m_mapControl.Map as IGraphicsContainer; pGra.DeleteAllElements(); //m_mapControl.ActiveView.Refresh(); //由于在下一步“ViewPolyline”中有刷新的命令,此语句可省略 ViewPolylines(m_mapControl, cpllt); //显示生成的线段 return(cpllt); }
public void SyncMapObject(IMap pSourceMap, ref IMap pTargetMap, bool bClearElements) { try { if ((pSourceMap != null) && (pTargetMap != null)) { IObjectCopy copy = null; copy = new ObjectCopyClass(); object pInObject = null; pInObject = pSourceMap; object obj3 = null; obj3 = copy.Copy(pInObject); object pOverwriteObject = null; pOverwriteObject = pTargetMap; copy.Overwrite(obj3, ref pOverwriteObject); IActiveView view = pTargetMap as IActiveView; IGraphicsContainer graphicsContainer = view.GraphicsContainer; if (graphicsContainer != null) { IViewManager manager = view as IViewManager; ISelection elementSelection = manager.ElementSelection; view.Selection = elementSelection; } if (bClearElements) { graphicsContainer.DeleteAllElements(); } } } catch (Exception exception) { this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.CoreFun", "SyncMapObject", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); } }
public override void RestoreEnv() { if (this._uc != null) { this._uc.RestoreEnv(); this._uc.Dispose(); this._uc = null; } if (this._uPanel != null) { this._uPanel.GetControlContainer().Controls.Clear(); this._uPanel.Close(); this._uPanel = null; } IMap2DView mapView = UCService.GetContent(typeof(Map2DView)) as Map2DView; if (mapView == null) { return; } DF2DApplication app = DF2DApplication.Application; if (app == null || app.Current2DMapControl == null || app.Workbench == null) { return; } //app.Workbench.SetMenuEnable(true); IGraphicsContainer gc = app.Current2DMapControl.Map as IGraphicsContainer; gc.DeleteAllElements(); app.Current2DMapControl.ActiveView.Refresh(); mapView.UnBind(this); WaitForm.Stop(); Map2DCommandManager.Pop(); }
private void ptsTpMapBtn_Click(object sender, EventArgs e) { //在绘制前,清除mainkMapControl中的任何图形元素 IGraphicsContainer pGra = this.axMapControl.Map as IGraphicsContainer; IActiveView pAcitveView = pGra as IActiveView; pGra.DeleteAllElements(); for (int i = 0; i < this.dataGridView.Rows.Count; i++) { string lgstr = string.Empty, lastr = string.Empty; if (this.dataGridView.Rows[i].Cells["lg"].Value != null) { lgstr = this.dataGridView.Rows[i].Cells["lg"].Value.ToString(); } if (this.dataGridView.Rows[i].Cells["la"].Value != null) { lastr = this.dataGridView.Rows[i].Cells["la"].Value.ToString(); } DrawPointOrLine(lgstr, lastr, pGra, false); } pAcitveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
private void mainMapControl_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e) { IEnvelope pEnvelope = e.newEnvelope as IEnvelope; ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass(); pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDash; pSimpleLineSymbol.Width = 2; pSimpleLineSymbol.Color = this.getRGBColor(0, 0, 0); ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass(); pSimpleFillSymbol.Color = this.getRGBColor(255, 0, 0); pSimpleFillSymbol.Outline = pSimpleLineSymbol as ILineSymbol; pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSHollow; IRectangleElement pRectangleElement = new RectangleElementClass(); IElement pElement = pRectangleElement as IElement; pElement.Geometry = pEnvelope as IGeometry; IFillShapeElement pFillShapeElement = pRectangleElement as IFillShapeElement; pFillShapeElement.Symbol = pSimpleFillSymbol as IFillSymbol; IGraphicsContainer pGraphicsContainer = this.EagleaxMapControl.Map as IGraphicsContainer; pGraphicsContainer.DeleteAllElements(); pGraphicsContainer.AddElement(pElement, 0); this.EagleaxMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { try { Form.ribbonBar1.Text = ""; Form.Set_Pointclicked = null; RemoveGraphics(); IActiveView pACView = (IActiveView)m_Map; bool ShowGraphics = (Form.rbtClickedPoint.CheckState == CheckState.Checked); if (ShowGraphics) { IPoint pPointclicked = pACView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); IRgbColor pRGB_Point = CreateRGBColor(255, 0, 0); AddGraphicToMap(m_Map, pPointclicked, pRGB_Point, pRGB_Point); Form.Set_Pointclicked = pPointclicked; pACView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } } catch { IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)m_Map; IActiveView pACView = (IActiveView)m_Map; pGraphicsContainer.DeleteAllElements(); Form.ribbonBar1.Text = ""; Form.Set_Pointclicked = null; pACView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } }
private void DrawRectangle(IEnvelope pEnvelope) { IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer; IActiveView pActiveView = pGraphicsContainer as IActiveView; pGraphicsContainer.DeleteAllElements(); IRectangleElement pRectangleElement = new RectangleElementClass(); IElement pElement = pRectangleElement as IElement; pElement.Geometry = pEnvelope; IRgbColor pRgbColor = new RgbColorClass(); pRgbColor.Red = 255; pRgbColor.Blue = 0; pRgbColor.Green = 0; pRgbColor.Transparency = 255; ILineSymbol pLineSymbol = new SimpleLineSymbolClass(); pLineSymbol.Width = 3; pLineSymbol.Color = pRgbColor; pRgbColor.Red = 255; pRgbColor.Blue = 0; pRgbColor.Green = 0; pRgbColor.Transparency = 0; IFillSymbol pFillSymbol = new SimpleFillSymbolClass(); pFillSymbol.Outline = pLineSymbol; pFillSymbol.Color = pRgbColor; IFillShapeElement pFillShapeElement = pElement as IFillShapeElement; pFillShapeElement.Symbol = pFillSymbol; pGraphicsContainer.AddElement((IElement)pFillShapeElement, 0); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
public bool DeleteAllElements(IGraphicsLayer pGraphicsLayer) { try { if ((pGraphicsLayer != null) && (pGraphicsLayer is IGraphicsContainer)) { IGraphicsContainer container = pGraphicsLayer as IGraphicsContainer; try { container.DeleteAllElements(); } catch (Exception) { } } else { return(false); } return(true); } catch (Exception exception) { this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.ElementFun", "DeleteAllElements", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); return(false); } }
///////////////////////////////////////// private void axMapControl_sub_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e) { //实现鹰眼的方框的 symbol 部分 ILineSymbol outLineSymbol = new SimpleLineSymbol(); //设置鹰眼图中的红线! outLineSymbol.Width = 2; outLineSymbol.Color = GetColor(255, 0, 0, 255); IFillSymbol fillSymbol = new SimpleFillSymbol(); //设置填充符号的属性! fillSymbol.Color = GetColor(255, 0, 0, 0); //设置完全透明色 fillSymbol.Outline = outLineSymbol; //实现信息传递 IEnvelope envlope2 = e.newEnvelope as IEnvelope; IElement element2 = new RectangleElement(); element2.Geometry = envlope2; IFillShapeElement fillShapeElement2 = element2 as IFillShapeElement; fillShapeElement2.Symbol = fillSymbol; IGraphicsContainer graphicsContainer2 = axMapControl_sub.Map as IGraphicsContainer; graphicsContainer2.DeleteAllElements(); IElement pElement = fillShapeElement2 as IElement; graphicsContainer2.AddElement(pElement, 0); axMapControl_sub.Refresh(esriViewDrawPhase.esriViewGeography, null, null); }
private void clearResultMenuItem_Click(object sender, EventArgs e) { axMapControl1.CurrentTool = null;//将地图空间的当前工具注销 try { string name = NetWorkAnalysClass.getPath(path) + "\\data\\HuanbaoGeodatabase.gdb"; //打开工作空间 IFeatureWorkspace pFWorkspace = NetWorkAnalysClass.OpenWorkspace(name) as IFeatureWorkspace; IGraphicsContainer pGrap = this.axMapControl1.ActiveView as IGraphicsContainer; pGrap.DeleteAllElements(); //删除所添加的图片要素 IFeatureClass inputFClass = pFWorkspace.OpenFeatureClass("Stops"); //站点要素 IFeatureClass barriesFClass = pFWorkspace.OpenFeatureClass("barries"); //障碍点要素 if (inputFClass.FeatureCount(null) > 0) { ITable pTable = barriesFClass as ITable; pTable.DeleteSearchedRows(null); } for (int i = 0; i < axMapControl1.LayerCount; i++) //删除分析结果 { ILayer pLayer = axMapControl1.get_Layer(i); if (pLayer.Name == ShortPathSolveCommand.m_NAContext.Solver.DisplayName) { axMapControl1.DeleteLayer(i); break; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } this.axMapControl1.Refresh(); }
/// <summary> /// 当主图视野发生变化时,重新绘制鸟瞰图中的红色矩形框 /// </summary> private void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e) { // 得到新范围 IEnvelope pEnvelope = (IEnvelope)e.newEnvelope; IGraphicsContainer pGraphicsContainer = axMapControl2.Map as IGraphicsContainer; IActiveView pActiveView = pGraphicsContainer as IActiveView; //在绘制前,清除axMapControl2中的任何图形元素 pGraphicsContainer.DeleteAllElements(); IRectangleElement pRectangleEle = new RectangleElementClass(); IElement pElement = pRectangleEle as IElement; pElement.Geometry = pEnvelope; //设置鹰眼图中的红线框 IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; pColor.Transparency = 255; //产生一个线符号对象 ILineSymbol pOutline = new SimpleLineSymbolClass(); pOutline.Width = 3; pOutline.Color = pColor; //设置颜色属性 pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; pColor.Transparency = 0; //设置填充符号的属性 IFillSymbol pFillSymbol = new SimpleFillSymbolClass(); pFillSymbol.Color = pColor; pFillSymbol.Outline = pOutline; IFillShapeElement pFillShapeEle = pElement as IFillShapeElement; pFillShapeEle.Symbol = pFillSymbol; pGraphicsContainer.AddElement((IElement)pFillShapeEle, 0); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);//部分刷新 }
private CPolyline DisplayInterpolation(double dblProp, IMapControl4 m_mapControl) { List <CCorrCpts> pCorrCptsLt = _DataRecords.ParameterResult.CCorrCptsLt; int intPtNum = pCorrCptsLt.Count; List <CPoint> newcptlt = new List <CPoint>(); //先确定最后两个点 double dblLastX = (1 - dblProp) * pCorrCptsLt[intPtNum - 1].FrCpt.X + dblProp * pCorrCptsLt[intPtNum - 1].ToCpt.X; double dblLastY = (1 - dblProp) * pCorrCptsLt[intPtNum - 1].FrCpt.Y + dblProp * pCorrCptsLt[intPtNum - 1].ToCpt.Y; CPoint newlastcpt = new CPoint(intPtNum - 1, dblLastX, dblLastY); double dblLast1X = (1 - dblProp) * pCorrCptsLt[intPtNum - 2].FrCpt.X + dblProp * pCorrCptsLt[intPtNum - 2].ToCpt.X; double dblLast1Y = (1 - dblProp) * pCorrCptsLt[intPtNum - 2].FrCpt.Y + dblProp * pCorrCptsLt[intPtNum - 2].ToCpt.Y; CPoint newlast1cpt = new CPoint(intPtNum - 2, dblLast1X, dblLast1Y); newcptlt.Insert(0, newlastcpt); newcptlt.Insert(0, newlast1cpt); double dblPreAxisAngle = CGeoFunc.CalAxisAngle(newlast1cpt, newlastcpt); //前一个线段的绝对角 for (int i = pCorrCptsLt.Count - 3; i >= 0; i--) { //目标夹角大小 double dblAngle = (1 - dblProp) * _adblFrAngle[i] + dblProp * _adblToAngle[i]; //绝对角 double dblCurAxisAngle = dblPreAxisAngle - dblAngle; //当前线段的绝对角(0到2*PI) if (dblCurAxisAngle >= 2 * Math.PI) { dblCurAxisAngle = dblCurAxisAngle - 2 * Math.PI; } else if (dblCurAxisAngle < 0) { dblCurAxisAngle = dblCurAxisAngle + 2 * Math.PI; } //目标长度 double dblLength = (1 - dblProp) * _adblFrLength[i] + dblProp * _adblToLength[i]; //新坐标 double dblNewX = newcptlt[0].X + dblLength * Math.Cos(dblCurAxisAngle); double dblNewY = newcptlt[0].Y + dblLength * Math.Sin(dblCurAxisAngle); CPoint newcpt = new CPoint(i, dblNewX, dblNewY); newcptlt.Insert(0, newcpt); //更新dblPreAxisAngle(将向量旋转180°) if (dblCurAxisAngle >= Math.PI) { dblPreAxisAngle = dblCurAxisAngle - Math.PI; } else { dblPreAxisAngle = dblCurAxisAngle + Math.PI; } } CPolyline newcpl = new CPolyline(0, newcptlt); IGraphicsContainer pGra = m_mapControl.Map as IGraphicsContainer; pGra.DeleteAllElements(); CHelpFunc.ViewPolyline(m_mapControl, newcpl); return(newcpl); }