private void axSceneControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ISceneControlEvents_OnMouseDownEvent e) { IPoint pPoint = null; object objOwner = null; object objObject = null; axSceneControl1.SceneGraph.Locate(axSceneControl1.SceneViewer, e.x, e.y, esriScenePickMode.esriScenePickGeography, true, out pPoint, out objOwner, out objObject); ITextElement pTextElement = new TextElementClass(); pTextElement.Text = "dddddd"; IGraphicsContainer3D pGCon3D = axSceneControl1.Scene.BasicGraphicsLayer as IGraphicsContainer3D; IElement pElement = new MarkerElementClass(); IMarkerElement pPointElement = pElement as MarkerElementClass; ILineElement pLineElement = pElement as ILineElement; ISimpleLineSymbol pLSymbol = new SimpleLineSymbolClass(); ISimpleMarkerSymbol pMSym = new SimpleMarkerSymbolClass(); IColor pFromColor = new RgbColorClass(); IRgbColor pRgbColor = pFromColor as IRgbColor; pRgbColor.Red = 255; pRgbColor.Green = 0; pRgbColor.Blue = 0; pMSym.Size = 10; pMSym.Color = pFromColor; pMSym.Style = esriSimpleMarkerStyle.esriSMSDiamond; pPointElement.Symbol = pMSym; pLSymbol.Style = esriSimpleLineStyle.esriSLSSolid; pElement.Geometry = pPoint; pGCon3D.AddElement(pElement as IElement ); axSceneControl1.Scene.SceneGraph.RefreshViewers(); IDisplay3D pIDisplay3D = axSceneControl1.Scene.SceneGraph as IDisplay3D ; pIDisplay3D.FlashLocation(pPoint); }
private void 添加点型图层ToolStripMenuItem_Click(object sender, EventArgs e) { //创建要素类 #region 创建新的内存工作空间 IWorkspaceFactory pWSF = new InMemoryWorkspaceFactoryClass(); IWorkspaceName pWSName = pWSF.Create("", "Temp", null, 0); IName pName = (IName)pWSName; IWorkspace pMemoryWS = (IWorkspace)pName.Open(); #endregion IField oField = new FieldClass(); IFields oFields = new FieldsClass(); IFieldsEdit oFieldsEdit = null; IFieldEdit oFieldEdit = null; IFeatureClass oFeatureClass = null; IFeatureLayer oFeatureLayer = null; oFieldsEdit = oFields as IFieldsEdit; oFieldEdit = oField as IFieldEdit; oFieldEdit.Name_2 = "OBJECTID"; oFieldEdit.Type_2 = esriFieldType.esriFieldTypeOID; oFieldEdit.IsNullable_2 = false; oFieldEdit.Required_2 = false; oFieldsEdit.AddField(oField); oField = new FieldClass(); oFieldEdit = oField as IFieldEdit; IGeometryDef pGeoDef = new GeometryDefClass(); IGeometryDefEdit pGeoDefEdit = (IGeometryDefEdit)pGeoDef; pGeoDefEdit.AvgNumPoints_2 = 5; pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint; pGeoDefEdit.GridCount_2 = 1; pGeoDefEdit.HasM_2 = false; pGeoDefEdit.HasZ_2 = false; pGeoDefEdit.SpatialReference_2 = axMapControl1.SpatialReference; oFieldEdit.Name_2 = "SHAPE"; oFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry; oFieldEdit.GeometryDef_2 = pGeoDef; oFieldEdit.IsNullable_2 = true; oFieldEdit.Required_2 = true; oFieldsEdit.AddField(oField); oField = new FieldClass(); oFieldEdit = oField as IFieldEdit; oFieldEdit.Name_2 = "Code"; oFieldEdit.Type_2 = esriFieldType.esriFieldTypeSmallInteger; //oFieldEdit.Length = 10; oFieldEdit.IsNullable_2 = true; oFieldsEdit.AddField(oField); //创建要素类 oFeatureClass = (pMemoryWS as IFeatureWorkspace).CreateFeatureClass("Temp", oFields, null, null, esriFeatureType.esriFTSimple, "SHAPE", ""); oFeatureLayer = new FeatureLayerClass(); oFeatureLayer.Name = "PointLayer"; oFeatureLayer.FeatureClass = oFeatureClass; //创建唯一值符号化对象 IUniqueValueRenderer pURender = new UniqueValueRendererClass(); pURender.FieldCount = 1; pURender.set_Field(0, "Code"); pURender.UseDefaultSymbol = false; //创建SimpleMarkerSymbolClass对象 ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass(); //创建RgbColorClass对象为pSimpleMarkerSymbol设置颜色 IRgbColor pRgbColor = new RgbColorClass(); pRgbColor.Red = 255; pSimpleMarkerSymbol.Color = pRgbColor as IColor; //设置pSimpleMarkerSymbol对象的符号类型,选择钻石 pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond; //设置pSimpleMarkerSymbol对象大小,设置为5 pSimpleMarkerSymbol.Size = 5; //显示外框线 pSimpleMarkerSymbol.Outline = true; //为外框线设置颜色 IRgbColor pLineRgbColor = new RgbColorClass(); pLineRgbColor.Green = 255; pSimpleMarkerSymbol.OutlineColor = pLineRgbColor as IColor; //设置外框线的宽度 pSimpleMarkerSymbol.OutlineSize = 1; //半透明颜色 pURender.AddValue("1", "", pSimpleMarkerSymbol as ISymbol); //唯一值符号化内存图层 (oFeatureLayer as IGeoFeatureLayer).Renderer = pURender as IFeatureRenderer; ILayerEffects pLyrEffect = oFeatureLayer as ILayerEffects; //透明度 pLyrEffect.Transparency = 0; oFeatureLayer.Visible = true; this.axMapControl1.AddLayer(oFeatureLayer,axMapControl1.LayerCount); insertpoint = true; }
/*创建各种符号的公共函数 * */ /// <summary> /// 创建一个简单符号 /// </summary> /// <param name="color">色彩</param> /// <param name="size">大小</param> /// <param name="bOutLine">是否外线</param> /// <param name="OutColor">外线色彩</param> /// <param name="OutLineSize">外线大小</param> /// <param name="style">样式</param> /// <returns>正常:返回符号;异常:null</returns> public ISimpleMarkerSymbol CreateSimpleMarkerSymbol(IRgbColor color = null, double size = 7, bool bOutLine = true, IRgbColor OutColor = null, double OutLineSize = 2, esriSimpleMarkerStyle style = esriSimpleMarkerStyle.esriSMSCircle) { try { if (color == null) { color = getRGB(156, 200, 180) as IRgbColor; } if (OutColor == null) { OutColor = getRGB(70, 90, 160) as IRgbColor; } ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass(); //创建SimpleMarkerSymbolClass对象 pSimpleMarkerSymbol.Color = color as IColor; pSimpleMarkerSymbol.Style = style; //设置pSimpleMarkerSymbol对象的符号类型,选择钻石 pSimpleMarkerSymbol.Size = size; //设置pSimpleMarkerSymbol对象大小,设置为5 pSimpleMarkerSymbol.Outline = bOutLine; //显示外框线 pSimpleMarkerSymbol.OutlineColor = OutColor as IColor; //为外框线设置颜色 pSimpleMarkerSymbol.OutlineSize = OutLineSize; //设置外框线的宽度 return(pSimpleMarkerSymbol); } catch (Exception) { return(null); } }
public static ISimpleMarkerSymbol SetMeasureSnapSymbol() { ISimpleMarkerSymbol pMarkerSymbol; ISymbol pSymbol; IRgbColor pRgbColor; pRgbColor = new RgbColorClass(); pRgbColor.Transparency = 0; pMarkerSymbol = new SimpleMarkerSymbolClass(); pSymbol = (ISymbol)pMarkerSymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPMaskNotPen; pMarkerSymbol.Color = pRgbColor; pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pRgbColor.Red = 255; pRgbColor.Blue = 0; pRgbColor.Green = 0; pRgbColor.Transparency = 255; pMarkerSymbol.Outline = true; pMarkerSymbol.OutlineColor = pRgbColor; return(pMarkerSymbol); }
//设置画捕捉时候的符号 private static ISimpleMarkerSymbol SetSnapSymbol(esriSimpleMarkerStyle pStyle) { ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass(); ISymbol pSymbol = pMarkerSymbol as ISymbol; IRgbColor pRgbColor = new RgbColorClass(); pRgbColor.Transparency = 0; //采用异或方式绘制,擦除以前画的符号 pSymbol.ROP2 = esriRasterOpCode.esriROPXOrPen; pMarkerSymbol.Color = pRgbColor; pMarkerSymbol.Style = pStyle; //设置轮廓线样式 pRgbColor.Red = 255; pRgbColor.Blue = 0; pRgbColor.Green = 0; pRgbColor.Transparency = 230; pMarkerSymbol.Outline = true; pMarkerSymbol.OutlineColor = pRgbColor; pMarkerSymbol.OutlineSize = 1; pMarkerSymbol.Size = 12; return(pMarkerSymbol); }
//更新车辆的位置 private void MovePointUpdateElement(IPoint point) { try { IGraphicsContainer pGraphicsContainer = Variable.pMapFrm.mainMapControl.ActiveView as IGraphicsContainer; //pGraphicsContainer.DeleteAllElements(); IMarkerElement pMarkerElement = new MarkerElementClass(); //ISimpleMarkerSymbol来设置点的属性 ISimpleMarkerSymbol pSymbol = new SimpleMarkerSymbolClass(); IRgbColor pRGBcolor = new RgbColorClass(); pRGBcolor.Red = 255; pRGBcolor.Green = 0; pRGBcolor.Blue = 0; IPictureMarkerSymbol pms = new PictureMarkerSymbolClass(); pms.BitmapTransparencyColor = pRGBcolor; pms.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, @"C:\Users\Administrator\Desktop\突发环境事件应急资源调度系统\DynamicSchedulingofEmergencyResourceSystem\DynamicSchedulingofEmergencyResourceSystem\Resources\vehicle.png"); pms.Size = 6; pMarkerElement.Symbol = pms as IMarkerSymbol; //pSymbol.Color = pRGBcolor; //pMarkerElement.Symbol = pSymbol; Variable.PElement = pMarkerElement as IElement; Variable.PElement.Geometry = point; pGraphicsContainer.AddElement(Variable.PElement, 0); //pGraphicsContainer.UpdateElement(Variable.PElement); //Variable.pMapFrm.mainMapControl.CenterAt(point); Variable.pMapFrm.mainMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); //Variable.pMapFrm.mainMapControl.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常"); } }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { // TODO: Add DotDensityRender.OnClick implementation string strPopField = "value"; IActiveView pActiveView = m_HookHelper.ActiveView; IMap pMap = m_HookHelper.FocusMap; IGeoFeatureLayer pGeoFeatureLayer = pMap.get_Layer(0) as IGeoFeatureLayer; IDotDensityRenderer pDotDensityRenderer = new DotDensityRendererClass(); IRendererFields pRendererFields = (IRendererFields)pDotDensityRenderer; pRendererFields.AddField(strPopField, strPopField); IDotDensityFillSymbol pDotDensityFillSymbol = new DotDensityFillSymbolClass(); pDotDensityFillSymbol.DotSize = 5; pDotDensityFillSymbol.Color = GetRGB(0, 0, 0); pDotDensityFillSymbol.BackgroundColor = GetRGB(239, 228, 190); ISymbolArray pSymbolArray = (ISymbolArray)pDotDensityFillSymbol; ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass(); pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pSimpleMarkerSymbol.Size = 5; pSimpleMarkerSymbol.Color = GetRGB(128, 128, 255); pSymbolArray.AddSymbol((ISymbol)pSimpleMarkerSymbol); pDotDensityRenderer.DotDensitySymbol = pDotDensityFillSymbol; pDotDensityRenderer.DotValue = 0.5; pDotDensityRenderer.CreateLegend(); pGeoFeatureLayer.Renderer = (IFeatureRenderer)pDotDensityRenderer; pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); }
private void 更换控制点符号ToolStripMenuItem_Click(object sender, EventArgs e) { //layer = (IFeatureLayer)axMapControl1.get_Layer(0); int iIndex; for (iIndex = 0; iIndex < axMapControl1.LayerCount; iIndex++) { ILayer pLayer = axMapControl1.get_Layer(iIndex); IFeatureLayer pFLayer = pLayer as IFeatureLayer; IFeatureClass pFClass = pFLayer.FeatureClass; if (pFClass.ShapeType == esriGeometryType.esriGeometryPoint) { IGeoFeatureLayer geoFeatureLayer = pLayer as IGeoFeatureLayer; SimpleRenderer simpleRender = new SimpleRendererClass(); ISimpleMarkerSymbol pMarkerSymbol; Random rd = new Random(); Color mycolor = Color.FromArgb(0, rd.Next(0, 256), rd.Next(0, 256), rd.Next(0, 256)); IColor color = Color2IColor(mycolor); pMarkerSymbol = new SimpleMarkerSymbolClass(); pMarkerSymbol.Style = (esriSimpleMarkerStyle)rd.Next(0, 5); pMarkerSymbol.Color = color; pMarkerSymbol.Angle = 60; pMarkerSymbol.Size = 6; simpleRender.Symbol = pMarkerSymbol as ISymbol; geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer; axMapControl1.Refresh(); } } }
/// <summary> /// 通过符号选择器选择符号样式 /// </summary> /// <param name="geometryType">要素类型</param> /// <returns>返回 ISymbol 对象</returns> public static ISymbol GetSymbolBySymbolSelector(esriGeometryType geometryType) { ISymbol symbol = null; switch (geometryType) { case esriGeometryType.esriGeometryPoint: symbol = new SimpleMarkerSymbolClass(); break; case esriGeometryType.esriGeometryPolyline: symbol = new SimpleLineSymbolClass(); break; case esriGeometryType.esriGeometryPolygon: symbol = new SimpleFillSymbolClass(); break; } ESRI.ArcGIS.DisplayUI.ISymbolSelector pSymbolSelector = new ESRI.ArcGIS.DisplayUI.SymbolSelectorClass(); pSymbolSelector.AddSymbol(symbol); bool response = pSymbolSelector.SelectSymbol(0); if (response) { symbol = pSymbolSelector.GetSymbolAt(0); return(symbol); } return(null); }
/// <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> /// <param name="geometry"></param> /// <returns></returns> private static IElement CreateHightLightElement(IGeometry geometry) { IElement element = null; IColor redcolor = ColorCreate.GetIColor(255, 0, 0, 50); IColor bluecolor = ColorCreate.GetIColor(0, 0, 255); switch (geometry.GeometryType) { case esriGeometryType.esriGeometryLine: case esriGeometryType.esriGeometryPolyline: element = new LineElementClass(); element.Geometry = geometry; ((ILineElement)element).Symbol = SymbolCreate.GetSimpleLineSymbol(redcolor); break; case esriGeometryType.esriGeometryPolygon: element = new PolygonElementClass(); element.Geometry = geometry; ((PolygonElementClass)element).Symbol = SymbolCreate.GetSimpleFillSymbol(redcolor, bluecolor); break; case esriGeometryType.esriGeometryPoint: element = new MarkerElementClass(); element.Geometry = geometry; IMarkerSymbol pisymbol = new SimpleMarkerSymbolClass(); pisymbol.Color = (IColor)redcolor; pisymbol.Size = 6; ((MarkerElementClass)element).Symbol = pisymbol; break; } return(element); }
private ISymbol GetSymbolBySymbolSelector(esriGeometryType geometryType) { ISymbolSelector pSymbolSelector = new SymbolSelectorClass(); ISymbol symbol = null; switch (geometryType) { case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint: symbol = new SimpleMarkerSymbolClass(); break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline: symbol = new SimpleLineSymbolClass(); break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon: symbol = new SimpleFillSymbolClass(); break; default: break; } pSymbolSelector.AddSymbol(symbol); bool response = pSymbolSelector.SelectSymbol(0); if (response) { symbol = pSymbolSelector.GetSymbolAt(0); return(symbol); } return(null); }
///<summary> ///设置要素图层唯一值符号化 ///</summary> ///<param name="pFeatureLayer"></param> private void UniqueValueRenderFlyr(AxMapControl axMapControl1, IFeatureLayer pFeatureLayer) { try { //创建UniqueValueRendererClass对象 IUniqueValueRenderer pUVRender = new UniqueValueRendererClass(); List <string> pFieldValues = new List <string>(); pFieldValues.Add("Hospital 2"); pFieldValues.Add("School 1"); pFieldValues.Add("Airport"); for (int i = 0; i < pFieldValues.Count; i++) { ISymbol pSymbol = new SimpleMarkerSymbolClass(); pSymbol = GetSymbol(@"D:\Program Files\ArcGIS\Styles\ESRI.ServerStyle", "Marker Symbols", pFieldValues[i]); //添加唯一值符号化字段值和相对应的符号 pUVRender.AddValue(pFieldValues[i], pFieldValues[i], pSymbol); } //设置唯一值符号化的字段个数和字段名 pUVRender.FieldCount = 1; pUVRender.set_Field(0, "类别"); IGeoFeatureLayer pGFeatureLyr = pFeatureLayer as IGeoFeatureLayer; //设置IGeofeatureLayer的Renderer属性 pGFeatureLyr.Renderer = pUVRender as IFeatureRenderer; } catch (Exception Err) { MessageBox.Show(Err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private ISymbol method_6(esriGeometryType esriGeometryType_0) { switch (esriGeometryType_0) { case esriGeometryType.esriGeometryPoint: case esriGeometryType.esriGeometryMultipoint: { IMarkerSymbol symbol = new SimpleMarkerSymbolClass { Size = 3.0 }; return(symbol as ISymbol); } case esriGeometryType.esriGeometryPolyline: { ILineSymbol symbol2 = new SimpleLineSymbolClass { Width = 0.2 }; return(symbol2 as ISymbol); } case esriGeometryType.esriGeometryPolygon: return(new SimpleFillSymbolClass()); } return(null); }
//简单符号化 private void MarkerSymbolToolStripMenuItem_Click(object sender, EventArgs e) { try { //获得点图层,要求当前地图文档第一个图层为点图层 IFeatureLayer layer; layer = mainMapControl.get_Layer(0) as IFeatureLayer; //QI到IGeoFeatureLayer IGeoFeatureLayer geoFeatureLayer = layer as IGeoFeatureLayer; //新建SimpleRendererClass对象 SimpleRenderer simpleRender = new SimpleRendererClass(); ISimpleMarkerSymbol pMarkerSymbol; IColor pColor = new RgbColorClass(); pColor.RGB = 2256; pMarkerSymbol = new SimpleMarkerSymbolClass(); pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pMarkerSymbol.Color = pColor; pMarkerSymbol.Angle = 60; pMarkerSymbol.Size = 6; simpleRender.Symbol = pMarkerSymbol as ISymbol; geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer; mainMapControl.Refresh(); axTOCControl1.Update(); } catch { MessageBox.Show("没有可以实例化的图层"); } }
private void button1_Click(object sender, EventArgs e) { switch (m_pTarFeatureLayer.FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: { ISimpleMarkerSymbol sms = new SimpleMarkerSymbolClass(); sms.Color = m_pFillColor; sms.Style = esriSimpleMarkerStyle.esriSMSCircle; sms.Size = trackBar1.Value; (m_pTarGeoFeatureLayer.Renderer as ISimpleRenderer).Symbol = sms as ISymbol; frmMainOper(OperationType.RefreshMapCtrl); frmMainOper(OperationType.UpdateTOCCtrl); break; } case esriGeometryType.esriGeometryPolygon: { ISimpleFillSymbol sfs = new SimpleFillSymbolClass(); sfs.Style = esriSimpleFillStyle.esriSFSSolid; sfs.Color = m_pFillColor; ISimpleLineSymbol sls = new SimpleLineSymbolClass(); sls.Style = esriSimpleLineStyle.esriSLSSolid; sls.Color = m_pOutlineColor; sls.Width = trackBar1.Value; sfs.Outline = sls as ILineSymbol; (m_pTarGeoFeatureLayer.Renderer as ISimpleRenderer).Symbol = sfs as ISymbol; frmMainOper(OperationType.RefreshMapCtrl); frmMainOper(OperationType.UpdateTOCCtrl); break; } } }
/// <summary> /// 设置要素高亮显示的符号 /// </summary> /// <param name="pFeatureLayer"></param> /// <returns></returns> private ISymbol GetSymbolByShapeType(IFeatureLayer pFeatureLayer) { ISymbol symbol = null; switch (pFeatureLayer.FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: symbol = new SimpleMarkerSymbolClass(); SetPointMarkerSymbol(symbol); break; case esriGeometryType.esriGeometryPolyline: symbol = new SimpleLineSymbolClass(); SetPolylineMarkerSymbol(symbol); break; case esriGeometryType.esriGeometryPolygon: symbol = new SimpleFillSymbolClass(); SetPolygonMarkerSymbol(symbol); break; default: break; } return(symbol); }
private void FlashPoint(IScreenDisplay pScreenDisplay, IGeometry pGeometry, bool bFlashFlag, long lFlashRate, bool bDoubleFlag) { try { ISimpleMarkerSymbol symbol = new SimpleMarkerSymbolClass { Style = esriSimpleMarkerStyle.esriSMSCircle }; ISymbol symbol2 = symbol as ISymbol; symbol2.ROP2 = esriRasterOpCode.esriROPNotXOrPen; pScreenDisplay.SetSymbol(symbol as ISymbol); pScreenDisplay.DrawPoint(pGeometry); if (bFlashFlag) { Thread.Sleep((int)lFlashRate); pScreenDisplay.DrawPoint(pGeometry); } if (bDoubleFlag) { Thread.Sleep((int)(((int)lFlashRate) / 2)); pScreenDisplay.DrawPoint(pGeometry); Thread.Sleep((int)(((int)lFlashRate) / 2)); pScreenDisplay.DrawPoint(pGeometry); } } catch (Exception exception) { this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.FlashFun", "FlashPoint", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); } }
public static void FlashPoint(IScreenDisplay pDisplay, IGeometry pGeometry) { try { ISimpleMarkerSymbol pMarkerSymbol; ISymbol pSymbol; IRgbColor pRGBColor; pRGBColor = new RgbColorClass(); pRGBColor.Red = 255; pRGBColor.Green = 150; pRGBColor.Blue = 150; pMarkerSymbol = new SimpleMarkerSymbolClass(); pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pMarkerSymbol.Color = pRGBColor; pSymbol = (ISymbol)pMarkerSymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; pDisplay.SetSymbol(pSymbol); pDisplay.DrawPoint(pGeometry); System.Threading.Thread.Sleep(300); pDisplay.DrawPoint(pGeometry); } catch (Exception) { throw; } }
private void DotDensity(IFeatureLayer pFeatLyr, string sFieldName, int intRendererDensity) { IGeoFeatureLayer pGeoFeatureLayer = pFeatLyr as IGeoFeatureLayer; IDotDensityRenderer pDotDensityRenderer = new DotDensityRendererClass(); IRendererFields pRendererFields = pDotDensityRenderer as IRendererFields; //设置渲染字段 pRendererFields.AddField(sFieldName); //设置填充背景色 IDotDensityFillSymbol pDotDensityFillSymbol = new DotDensityFillSymbolClass(); pDotDensityFillSymbol.DotSize = 3; pDotDensityFillSymbol.BackgroundColor = GetRgbColor(0, 255, 0); //设置渲染符号 ISymbolArray pSymbolArray = pDotDensityFillSymbol as ISymbolArray; ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass(); pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pSimpleMarkerSymbol.Color = GetRgbColor(0, 0, 255); pSymbolArray.AddSymbol(pSimpleMarkerSymbol as ISymbol); pDotDensityRenderer.DotDensitySymbol = pDotDensityFillSymbol; //设置渲染密度,即每个点符号所代表的数值大小 pDotDensityRenderer.DotValue = intRendererDensity; //创建图例 pDotDensityRenderer.CreateLegend(); pGeoFeatureLayer.Renderer = pDotDensityRenderer as IFeatureRenderer; axMapControl1.Refresh(); axMapControl1.Update(); Close(); }
private void btnMarkSymbol_Click(object sender, EventArgs e) { try { frmSymbolSelector selector = new frmSymbolSelector(); ISymbol pSym = null; if (this.m_pMarkerLineSymbol.MarkerSymbol != null) { pSym = (ISymbol)((IClone)this.m_pMarkerLineSymbol.MarkerSymbol).Clone(); } else { pSym = new SimpleMarkerSymbolClass(); } selector.SetSymbol(pSym); selector.SetStyleGallery(this.m_pSG); if (selector.ShowDialog() == DialogResult.OK) { this.m_pMarkerLineSymbol.MarkerSymbol = (IMarkerSymbol)selector.GetSymbol(); this.btnMarkSymbol.Style = this.m_pMarkerLineSymbol.MarkerSymbol; this.btnMarkSymbol.Invalidate(); this.refresh(e); } } catch { } }
/// <summary> /// 获取颜色符号 /// </summary> /// <param name="geometryType"></param> /// <param name="pColor"></param> /// <returns></returns> public static ISymbol GetColorSymbol(esriGeometryType geometryType, IColor pColor) { switch (geometryType) { case esriGeometryType.esriGeometryLine: case esriGeometryType.esriGeometryPolyline: ISimpleLineSymbol pLineSymbol = new SimpleLineSymbolClass(); pLineSymbol.Color = pColor; pLineSymbol.Width = 2; pLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; return((ISymbol)pLineSymbol); case esriGeometryType.esriGeometryPoint: ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass(); pMarkerSymbol.Color = pColor; pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; return((ISymbol)pMarkerSymbol); case esriGeometryType.esriGeometryPolygon: ISimpleFillSymbol pFillSymbol = new SimpleFillSymbolClass(); pFillSymbol.Color = pColor; pFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid; return((ISymbol)pFillSymbol); } return(null); }
public FlowSymbol() { ISimpleMarkerSymbol symbol = new SimpleMarkerSymbolClass(); IRgbColor color = new RgbColorClass { Green = 0, Blue = 0, Red = 0 }; symbol.Color = color; symbol.Style = esriSimpleMarkerStyle.esriSMSCircle; symbol.Size = 6.0; this.m_UninitializedFolwArrow = symbol as ISymbol; this.m_IndeterminateFolwArrow = (symbol as IClone).Clone() as ISymbol; IArrowMarkerSymbol symbol2 = new ArrowMarkerSymbolClass(); IRgbColor color2 = new RgbColorClass { Green = 0, Blue = 0, Red = 0 }; symbol2.Color = color2; symbol2.Style = esriArrowMarkerStyle.esriAMSPlain; symbol2.Size = 9.0; this.m_DeterminateFolwArrow = symbol2 as ISymbol; }
private void FlashFeature(IGeometry pGeometry)//目标闪烁 { esriGeometryType pGeometryType = pGeometry.GeometryType; ISymbol pSymbol = null; IColor pColor = new RgbColorClass(); pColor.RGB = 255; if (pGeometryType == esriGeometryType.esriGeometryPolygon) { ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass(); pSimpleFillSymbol.Color = pColor; pSymbol = pSimpleFillSymbol as ISymbol; } else if (pGeometryType == esriGeometryType.esriGeometryPolyline || pGeometryType == esriGeometryType.esriGeometryLine) { ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass(); pSimpleLineSymbol.Color = pColor; pSimpleLineSymbol.Width = 2; pSymbol = pSimpleLineSymbol as ISymbol; } else if (pGeometryType == esriGeometryType.esriGeometryPoint || pGeometryType == esriGeometryType.esriGeometryMultipoint) { ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass(); pSimpleMarkerSymbol.OutlineColor = pColor; pSimpleMarkerSymbol.OutlineSize = 2; pSymbol = pSimpleMarkerSymbol as ISymbol; } mMapControl.FlashShape(pGeometry, 4, 200, pSymbol); }
private ISymbol CreateSimpleSsymbol(esriGeometryType geometryType) { ISymbol symbol = null; switch (geometryType) { case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint: ISimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbolClass(); markerSymbol.Color = getRGB(255, 0, 0); markerSymbol.Size = 8; symbol = markerSymbol as ISymbol; break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline: ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass(); lineSymbol.Color = getRGB(255, 0, 0); lineSymbol.Width = 4; symbol = lineSymbol as ISymbol; break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon: ISimpleFillSymbol fillSymbol = new SimpleFillSymbolClass(); fillSymbol.Color = getRGB(255, 0, 0); symbol = fillSymbol as ISymbol; break; default: break; } symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; return(symbol); }
/// <summary> /// Draw a specified graphic on the map using the supplied colors. /// </summary> /// <param name="map"> /// An IMap interface. /// </param> /// <param name="geometry"> /// An IGeometry interface. It can be of the geometry type: esriGeometryPoint, esriGeometryPolyline, or esriGeometryPolygon. /// </param> /// <param name="rgbColor"> /// An IRgbColor interface. The color to draw the geometry. /// </param> /// <param name="outlineRgbColor"> /// An IRgbColor interface. For those geometry's with an outline it will be this color. /// </param> /// <remarks> /// Calling this function will not automatically make the graphics appear in the map area. Refresh the map area after after calling this function with Methods like IActiveView.Refresh or IActiveView.PartialRefresh. /// </remarks> /// <returns> /// The <see cref="IElement"/>. /// </returns> private static IElement AddGraphicToMap( IMap map, IGeometry geometry, IRgbColor rgbColor, IRgbColor outlineRgbColor) { var graphicsContainer = (IGraphicsContainer)map; // Explicit Cast IElement element = null; if (geometry.GeometryType == esriGeometryType.esriGeometryPoint) { // Marker symbols ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Color = rgbColor; simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineColor = outlineRgbColor; simpleMarkerSymbol.Size = 15; simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; IMarkerElement markerElement = new MarkerElementClass(); markerElement.Symbol = simpleMarkerSymbol; element = (IElement)markerElement; // Explicit Cast } else if (geometry.GeometryType == esriGeometryType.esriGeometryPolyline) { // Line elements ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Color = rgbColor; simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = 5; ILineElement lineElement = new LineElementClass(); lineElement.Symbol = simpleLineSymbol; element = (IElement)lineElement; // Explicit Cast } else if (geometry.GeometryType == esriGeometryType.esriGeometryPolygon) { // Polygon elements ILineSymbol lineSymbol = new SimpleLineSymbolClass(); lineSymbol.Color = rgbColor; lineSymbol.Width = 2.0; ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Color = rgbColor; simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSNull; simpleFillSymbol.Outline = lineSymbol; IFillShapeElement fillShapeElement = new PolygonElementClass(); fillShapeElement.Symbol = simpleFillSymbol; element = (IElement)fillShapeElement; // Explicit Cast } if (element != null) { element.Geometry = geometry; graphicsContainer.AddElement(element, 0); } return(element); }
public OtherGridPropertyPage() { this.InitializeComponent(); SimpleMarkerSymbolClass class2 = new SimpleMarkerSymbolClass { Style = esriSimpleMarkerStyle.esriSMSCross, Size = 28.0 }; this.imarkerSymbol_0 = class2; CartographicLineSymbolClass class3 = new CartographicLineSymbolClass { Cap = esriLineCapStyle.esriLCSSquare }; RgbColorClass class4 = new RgbColorClass { Red = 0, Blue = 0, Green = 0 }; class3.Color = class4; class3.Join = esriLineJoinStyle.esriLJSMitre; class3.Width = 1.0; this.ilineSymbol_0 = class3; this.cboFontName.Items.Clear(); InstalledFontCollection fonts = new InstalledFontCollection(); for (int i = 0; i < fonts.Families.Length; i++) { this.cboFontName.Items.Add(fonts.Families[i].Name); } }
public void SelectPoint(string X, string Y, int CheckIfMapLoaded) { if (CheckIfMapLoaded == 0) { toolStripStatusLabel1.Text = "Map X Y"; } else { toolStripStatusLabel1.Text = "X=" + X + "," + "Y=" + Y; int ConstantNum = 255; IMarkerElement MyIMarkerElement = new MarkerElementClass(); ISimpleMarkerSymbol MyISimpleMarkerSymbol = new SimpleMarkerSymbolClass(); IRgbColor MyIRGBColor = new RgbColorClass(); MyIRGBColor.Blue = ConstantNum; MyISimpleMarkerSymbol.Color = MyIRGBColor; MyISimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCross; MyIMarkerElement.Symbol = MyISimpleMarkerSymbol; IPoint MyIPoint = new PointClass(); MyIPoint.X = double.Parse(X); MyIPoint.Y = double.Parse(Y); IElement MyIElement = MyIMarkerElement as IElement; MyIElement.Geometry = MyIPoint; axMapControl1.ActiveView.GraphicsContainer.AddElement(MyIElement, 0); axMapControl1.ActiveView.Refresh(); ISpatialFilter MyISpatialFilter = new SpatialFilterClass(); MyISpatialFilter.Geometry = MyIPoint; MyISpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelWithin; IFeatureLayer SelectedLayer = axMapControl1.ActiveView.FocusMap.get_Layer(comboBox13.SelectedIndex) as IFeatureLayer; IFeatureSelection MyIFeatureSelection = SelectedLayer as IFeatureSelection; MyIFeatureSelection.SelectFeatures(MyISpatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false); axMapControl1.ActiveView.Refresh(); } }
private void btnOK_Click(object sender, EventArgs e) { IGeoFeatureLayer geoFeatureLayer = m_featureLayer as IGeoFeatureLayer; //Create a new simple marker symbol ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; simpleMarkerSymbol.Size = int.Parse(tbSize.Text); //Change symbol's color IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = int.Parse(tbRed.Text); rgbColor.Blue = int.Parse(tbBlue.Text); rgbColor.Green = int.Parse(tbGreen.Text); simpleMarkerSymbol.Color = rgbColor; //Change properties of points ISimpleRenderer simpleRenderer = new SimpleRendererClass(); simpleRenderer.Symbol = simpleMarkerSymbol as ISymbol; geoFeatureLayer.Renderer = simpleRenderer as IFeatureRenderer; m_fraMain.RefreshMap(); m_fraMain.RefreshTOCControl(); this.Close(); }
private static ISymbol GetSymbol(esriGeometryType featureGeometryType, RgbColor color) { if (featureGeometryType == esriGeometryType.esriGeometryPolygon) { ISimpleFillSymbol simplePolygonSymbol = new SimpleFillSymbolClass(); simplePolygonSymbol.Color = color; ISimpleLineSymbol outlineSymbol = new SimpleLineSymbolClass(); var outLine = color; color.Transparency = 255; outlineSymbol.Color = outLine; outlineSymbol.Width = 1; simplePolygonSymbol.Outline = outlineSymbol; return(simplePolygonSymbol as ISymbol); } else if (featureGeometryType == esriGeometryType.esriGeometryPolyline) { ISimpleLineSymbol simplePolylineSymbol = new SimpleLineSymbolClass(); simplePolylineSymbol.Color = color; simplePolylineSymbol.Width = 4; return(simplePolylineSymbol as ISymbol); } ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Color = color; return(simpleMarkerSymbol as ISymbol); }
/// <summary> /// Dot Density Render /// </summary> /// <param name="currentLayer"></param> /// <param name="breakCount"></param> /// <author>Shen Yongyuan</author> /// <date>20091114</date> public static void DotDensityRender(ILayer currentLayer, string fieldName) { IGeoFeatureLayer pGeoFeatureL = currentLayer as IGeoFeatureLayer; pGeoFeatureL.ScaleSymbols = true; //Dot Density Render IDotDensityRenderer pDotDensityRenderer = new DotDensityRendererClass(); IRendererFields pRendererFields = (IRendererFields)pDotDensityRenderer; pRendererFields.AddField(fieldName, "生态"); //Dot Style IDotDensityFillSymbol pDotDensityFillS = new DotDensityFillSymbolClass(); pDotDensityFillS.DotSize = 4; pDotDensityFillS.Color = ArcGIS.Color.ToEsriColor(System.Drawing.Color.FromArgb(0, 0, 0)); pDotDensityFillS.BackgroundColor = ArcGIS.Color.ToEsriColor(System.Drawing.Color.FromArgb(239, 228, 190)); //Symbol Array ISymbolArray pSymbolArray = (ISymbolArray)pDotDensityFillS; ISimpleMarkerSymbol pSimpleMarkerS = new SimpleMarkerSymbolClass(); pSimpleMarkerS.Style = esriSimpleMarkerStyle.esriSMSCircle; pSimpleMarkerS.Size = 4; pSimpleMarkerS.Color = ArcGIS.Color.ToEsriColor(System.Drawing.Color.FromArgb(128, 128, 255)); pSymbolArray.AddSymbol((ISymbol)pSimpleMarkerS); pDotDensityRenderer.DotDensitySymbol = pDotDensityFillS; pDotDensityRenderer.DotValue = 0.05; pDotDensityRenderer.CreateLegend(); pGeoFeatureL.Renderer = (IFeatureRenderer)pDotDensityRenderer; }
public static void AddPointElement(IGraphicsContainer pGraphicsContainer, int intRed = 0, int intGreen = 0, int intBlue = 0) { IPoint ipt = new PointClass(); ipt.PutCoords(10, 10); ISimpleMarkerSymbol pSimpleSym = new SimpleMarkerSymbolClass(); pSimpleSym.Style = esriSimpleMarkerStyle.esriSMSCross; pSimpleSym.Size = 10; pSimpleSym.Color = CHelpFunc.GenerateIRgbColor(intRed, intGreen, intBlue) as IColor; IMarkerElement pMarkerElem = null; IElement pElem; pElem = new MarkerElementClass(); pElem.Geometry = ipt; pMarkerElem = pElem as IMarkerElement; pMarkerElem.Symbol = pSimpleSym; pGraphicsContainer.AddElement(pElem, 0); //pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
public static ISimpleMarkerSymbol get_SimplePointSymbol(IColor color, double size, esriSimpleMarkerStyle style) { ISimpleMarkerSymbol theReturn = new SimpleMarkerSymbolClass(); theReturn.Color = color; theReturn.Style = style; theReturn.Size = size; return theReturn; }
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(); } }
public static ISimpleMarkerSymbol CreateSimpleMarkerSymbol(IRgbColor rgbColor, esriSimpleMarkerStyle inputStyle) { if (rgbColor == null || inputStyle == null) { return null; } ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Color = rgbColor; simpleMarkerSymbol.Style = inputStyle; return simpleMarkerSymbol; }
public ProPortialRender(AxMapControl pMapcontrol, IFeatureLayer pFtLayer, string pFieldName) { IGeoFeatureLayer pGeo = pFtLayer as IGeoFeatureLayer; IProportionalSymbolRenderer pProRender = new ProportionalSymbolRendererClass(); pProRender.Field = pFieldName; pProRender.ValueUnit = esriUnits.esriUnknownUnits; ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass(); pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pMarkerSymbol.Size = 2; pMarkerSymbol.Color = GetRGBColor(255, 0, 0); pProRender.MinSymbol = pMarkerSymbol as ISymbol; IDataStatistics pDataStat = new DataStatisticsClass(); IFeatureCursor pFtCursor = pFtLayer.FeatureClass.Search(null, false); pDataStat.Cursor = pFtCursor as ICursor; pDataStat.Field = pFieldName; pProRender.MinDataValue = pDataStat.Statistics.Minimum; pProRender.MaxDataValue = pDataStat.Statistics.Maximum; IFillSymbol pFillS = new SimpleFillSymbolClass(); pFillS.Color = GetRGBColor(239, 228, 190); ILineSymbol pLineS = new SimpleLineSymbolClass(); pLineS.Width = 2; pFillS.Outline = pLineS; ISimpleFillSymbol pSFillS = pFillS as ISimpleFillSymbol; pSFillS.Color = GetRGBColor(100, 100, 253); pProRender.BackgroundSymbol = pFillS; pGeo.Renderer = pProRender as IFeatureRenderer; pMapcontrol.ActiveView.Refresh(); }
public ClickSearchTool(string LayerName, string WhereClause, AxMapControl axMapControl,MainForm Father,bool Bus=false) { this.LayerName = LayerName; this.WhererClause = WhereClause; this.axMapControl = axMapControl; this.Father = Father; this.BusFlag = Bus; simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Width = 4; simpleLineSymbol.Color = DisplayHelper.GetRGBColor(255, 0, 99); simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; simpleMarkerSymbol.Size = 8; simpleMarkerSymbol.Color = DisplayHelper.GetRGBColor(255, 0, 0); }
///<summary>Draw a specified graphic on the map using the supplied colors.</summary> /// ///<param name="map">An IMap interface.</param> ///<param name="geometry">An IGeometry interface. It can be of the geometry type: esriGeometryPoint, esriGeometryPolyline, or esriGeometryPolygon.</param> ///<param name="rgbColor">An IRgbColor interface. The color to draw the geometry.</param> ///<param name="outlineRgbColor">An IRgbColor interface. For those geometry's with an outline it will be this color.</param> /// ///<remarks>Calling this function will not automatically make the graphics appear in the map area. Refresh the map area after after calling this function with Methods like IActiveView.Refresh or IActiveView.PartialRefresh.</remarks> public void AddGraphicToMap(IMap map, IGeometry geometry, IRgbColor rgbColor, IRgbColor outlineRgbColor) { IGraphicsContainer graphicsContainer = (IGraphicsContainer)map; // Explicit Cast IElement element = null; if ((geometry.GeometryType) == esriGeometryType.esriGeometryPoint) { // Marker symbols ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Color = rgbColor; simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineColor = outlineRgbColor; simpleMarkerSymbol.Size = 15; simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; IMarkerElement markerElement = new MarkerElementClass(); markerElement.Symbol = simpleMarkerSymbol; element = (IElement)markerElement; // Explicit Cast } else if ((geometry.GeometryType) == esriGeometryType.esriGeometryPolyline) { // Line elements ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Color = rgbColor; simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = 5; ILineElement lineElement = new LineElementClass(); lineElement.Symbol = simpleLineSymbol; element = (IElement)lineElement; // Explicit Cast } else if ((geometry.GeometryType) == esriGeometryType.esriGeometryPolygon) { // Polygon elements ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Color = rgbColor; simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSForwardDiagonal; IFillShapeElement fillShapeElement = new PolygonElementClass(); fillShapeElement.Symbol = simpleFillSymbol; element = (IElement)fillShapeElement; // Explicit Cast } if (!(element == null)) { element.Geometry = geometry; graphicsContainer.AddElement(element, 0); } }
private IElement GetElement(IGeometry geometry, double size, esriSimpleMarkerStyle simpleMarkerStyle) { IElement element; IMarkerElement markerElement = new MarkerElementClass(); element = markerElement as IElement; ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Style = simpleMarkerStyle; simpleMarkerSymbol.Color = ColorSelection.GetColor(); simpleMarkerSymbol.Size = size; element.Geometry = geometry; markerElement.Symbol = simpleMarkerSymbol; return element; }
public Form1() { InitializeComponent(); MXDPath = System.Configuration.ConfigurationManager.AppSettings["MXD"]; RoadName = System.Configuration.ConfigurationManager.AppSettings["ROAD"]; BusLineName = System.Configuration.ConfigurationManager.AppSettings["BUSLINE"]; BusStopName = System.Configuration.ConfigurationManager.AppSettings["BUSSTOP"]; ParkingName = System.Configuration.ConfigurationManager.AppSettings["PARKING"]; BikeName = System.Configuration.ConfigurationManager.AppSettings["BIKE"]; FlowName = System.Configuration.ConfigurationManager.AppSettings["FLOW"]; simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Width = 4; simpleLineSymbol.Color = DisplayHelper.GetRGBColor(255, 0, 99); simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; simpleMarkerSymbol.Size = 8; simpleMarkerSymbol.Color = DisplayHelper.GetRGBColor(255, 0, 0); }
public MainForm() { InitializeComponent(); MapControl = RendererHelper.GetMapControl(); MXDPath = ConfigurationManager.AppSettings["MXD"]; RoadName = ConfigurationManager.AppSettings["ROAD"]; RoadHistoryName = ConfigurationManager.AppSettings["ROADHISTORY"]; RoadNodeName = ConfigurationManager.AppSettings["ROADNODE"]; BusLineName = ConfigurationManager.AppSettings["BUSLINE"]; BusStopName = ConfigurationManager.AppSettings["BUSSTOP"]; ParkingName = ConfigurationManager.AppSettings["PARKING"]; BikeName = ConfigurationManager.AppSettings["BIKE"]; FlowName = ConfigurationManager.AppSettings["FLOW"]; StartEndName = ConfigurationManager.AppSettings["BUSSTOPNAME"]; XZQName = ConfigurationManager.AppSettings["XZQ"]; MapType = ConfigurationManager.AppSettings["MAPTYPE"]; simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Width = 4; simpleLineSymbol.Color = DisplayHelper.GetRGBColor(255, 0, 99); simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; simpleMarkerSymbol.Size = 8; simpleMarkerSymbol.Color = DisplayHelper.GetRGBColor(255, 0, 0); m_CrossroadSymbol = new SimpleMarkerSymbolClass() { Style = esriSimpleMarkerStyle.esriSMSCircle, Size = 8, Color = DisplayHelper.GetRGBColor(255, 0, 0, 0), OutlineColor = DisplayHelper.GetRGBColor(255, 0, 0), OutlineSize = 3, Outline = true }; m_ImportRoadSymbol = new SimpleLineSymbolClass() { Style = esriSimpleLineStyle.esriSLSSolid, Width = 3, Color = DisplayHelper.GetRGBColor(0, 0, 0, 200) }; axMapControl1.OnAfterDraw += this.axMapControl1_OnAfterDraw; }
/// <summary> /// 点图层的简单渲染 /// </summary> /// <param name="pGeoFeatureLayer"></param> public void DefinePointSimpleValueRenderer(IGeoFeatureLayer pGeoFeatureLayer) { ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass(); pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pSimpleMarkerSymbol.Size = 5; pSimpleMarkerSymbol.Outline = true; IRgbColor pLineRgbColor = new RgbColorClass(); pLineRgbColor.RGB = 0; // pLineRgbColor.Red = 0; // pLineRgbColor.Green = 0; // pLineRgbColor.Blue = 0; pSimpleMarkerSymbol.OutlineColor = pLineRgbColor as IColor; pLineRgbColor.Red = 34; pLineRgbColor.Green = 139; pLineRgbColor.Blue = 34; pSimpleMarkerSymbol.Color = pLineRgbColor as IColor; ISimpleRenderer simpleRender = new SimpleRendererClass(); simpleRender.Symbol = pSimpleMarkerSymbol as ISymbol; pGeoFeatureLayer.Renderer = (IFeatureRenderer)simpleRender; }
//���ҷ��� private void BurstFindValves(IFlagDisplay pFlagDisplay) { try { INetwork pNetwork = pGeoNetwork.Network; IFeatureLayer pValveFeatLayer = Utility.FindFeatLayer("Water Fixtures", this); IFeatureLayer pWaterLineFeatLyr = Utility.FindFeatLayer("Water Lines", this); //�õ�EdgeFlag IEdgeFlag pEdgeFlag = new EdgeFlagClass(); INetFlag pNetFlag = pEdgeFlag as INetFlag; pNetFlag.UserClassID = pFlagDisplay.FeatureClassID; pNetFlag.UserID = pFlagDisplay.FID; //��÷��ŵĹ�� IQueryFilter pQueryFilter = new QueryFilterClass(); pQueryFilter.WhereClause = "PWF_TYPE_CODE = 1"; IFeatureSelection pValveFeatSelection = pValveFeatLayer as IFeatureSelection; pValveFeatSelection.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, false); //������ѡ��ķ���ΪSelectionSetBarriers ISelectionSetBarriers pSelSetBarriers = new SelectionSetBarriersClass(); int FeatClassID = pValveFeatLayer.FeatureClass.FeatureClassID; IEnumIDs pEnumIDs = pValveFeatSelection.SelectionSet.IDs; pEnumIDs.Reset(); int FeatID = pEnumIDs.Next(); while (FeatID > 0) { pSelSetBarriers.Add(FeatClassID, FeatID); FeatID = pEnumIDs.Next(); } //����TraceFlowSolver ITraceFlowSolver pTraceFlowSolver = new TraceFlowSolverClass() as ITraceFlowSolver; INetSolver pNetSolver = pTraceFlowSolver as INetSolver; pNetSolver.SourceNetwork = pNetwork; pNetSolver.SelectionSetBarriers = pSelSetBarriers; pTraceFlowSolver.PutEdgeOrigins(1, ref pEdgeFlag); //�Ӹ��ٹ����л�ý�� IEnumNetEID pResultJenction; IEnumNetEID pResultsEdges; IEnumNetEID ptmpEnumNetEID = null; pTraceFlowSolver.FindFlowEndElements(esriFlowMethod.esriFMConnected, esriFlowElements.esriFEJunctions, out pResultJenction, out ptmpEnumNetEID); pTraceFlowSolver.FindFlowElements(esriFlowMethod.esriFMConnected, esriFlowElements.esriFEEdges, out ptmpEnumNetEID, out pResultsEdges); int lEID; int iUserClassID; int iUserID; int iUserSubID; INetElements pNetElements = pGeoNetwork.Network as INetElements; pResultJenction.Reset(); IFeature pFeature; pValveFeatSelection.Clear(); for (int j = 0; j <= pResultJenction.Count - 1; j++) { lEID = pResultJenction.Next(); pNetElements.QueryIDs(lEID, esriElementType.esriETJunction, out iUserClassID, out iUserID, out iUserSubID); pFeature = pValveFeatLayer.FeatureClass.GetFeature(iUserID); pValveFeatSelection.Add(pFeature); // MessageBox.Show(iUserClassID.ToString()+","+iUserID.ToString()+","+iUserSubID.ToString()); } IFeatureSelection pLinesFeatSelection = pWaterLineFeatLyr as IFeatureSelection; pLinesFeatSelection.Clear(); for (int i = 0; i <= pResultsEdges.Count - 1; i++) { lEID = pResultsEdges.Next(); pNetElements.QueryIDs(lEID, esriElementType.esriETEdge, out iUserClassID, out iUserID, out iUserSubID); pFeature = pWaterLineFeatLyr.FeatureClass.GetFeature(iUserID); pLinesFeatSelection.Add(pFeature); } //�����µķ���������Ⱦѡȡ�Ľ�� IMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass(); IRgbColor pRGBColor = new RgbColorClass(); pRGBColor.Red = 12; pRGBColor.Green = 250; pRGBColor.Blue = 233; pMarkerSymbol.Size = 14; pMarkerSymbol.Color = pRGBColor; pValveFeatSelection.SelectionSymbol = pMarkerSymbol as ISymbol; pValveFeatSelection.SelectionColor = pRGBColor as IColor; pValveFeatSelection.SelectionChanged(); IRgbColor pRGBColor2 = new RgbColorClass(); pRGBColor2.Red = 230; pRGBColor2.Green = 230; pRGBColor2.Blue = 0; pLinesFeatSelection.SelectionColor = pRGBColor2; pLinesFeatSelection.SelectionChanged(); axMapControl1.ActiveView.Refresh(); ICursor pCursor = null; pValveFeatSelection.SelectionSet.Search(null, false, out pCursor); IFeatureCursor pFeatCursor = pCursor as IFeatureCursor; IArray pArray = new ArrayClass(); pFeature = pFeatCursor.NextFeature(); while (pFeature != null) { pArray.Add(pFeature); pFeature = pFeatCursor.NextFeature(); } pFeature = pWaterLineFeatLyr.FeatureClass.GetFeature(pFlagDisplay.FID); frmBurstReport frmBurstReport1 = new frmBurstReport(this, pValveFeatLayer, pWaterLineFeatLyr, pArray, pFeature); frmBurstReport1.Show(); } catch (Exception eX) { MessageBox.Show(eX.Message); } }
//Ϊ�����������ñߵ�Flag private void BurstSetEdgeFlag(IPoint pPoint) { // try { INetElements pNetElements = pGeoNetwork.Network as INetElements; IPointToEID pPtToEID = new PointToEIDClass(); IPoint pNewPt; int iUserClassID; int iUserID; int iUserSubID; double dPercent; int eid; pPtToEID.SourceMap = axMapControl1.ActiveView.FocusMap; pPtToEID.GeometricNetwork = pGeoNetwork; pPtToEID.SnapTolerance = axMapControl1.ActiveView.Extent.Envelope.Width / 100; pPtToEID.GetNearestEdge(pPoint, out eid, out pNewPt, out dPercent); if (pNewPt == null) { MessageBox.Show("û�в������ٽ��ı�"); } else { pNetElements.QueryIDs(eid, esriElementType.esriETEdge, out iUserClassID, out iUserID, out iUserSubID); IMarkerSymbol pMarkerSym = new SimpleMarkerSymbolClass(); IRgbColor pRGBColor = new RgbColorClass(); pRGBColor.Red = 255; pRGBColor.Green = 0; pRGBColor.Blue = 0; pMarkerSym.Color = pRGBColor; pMarkerSym.Size = 20; //�����µ�Flag IEdgeFlagDisplay pEdgeFlagDisplay = new EdgeFlagDisplayClass(); IFlagDisplay pFlagDisplay = pEdgeFlagDisplay as IFlagDisplay; pFlagDisplay.Symbol = pMarkerSym as ISymbol; pFlagDisplay.Geometry = pNewPt; pFlagDisplay.FeatureClassID = iUserClassID; pFlagDisplay.FID = iUserID; pFlagDisplay.SubID = iUserSubID; //���Ƹõ� IScreenDisplay pScreenDisplay = axMapControl1.ActiveView.ScreenDisplay; pScreenDisplay.StartDrawing(pScreenDisplay.hDC, 0); pScreenDisplay.SetSymbol(pMarkerSym as ISymbol); pScreenDisplay.DrawPoint(pNewPt as IGeometry); pScreenDisplay.FinishDrawing(); BurstFindValves(pFlagDisplay); } } catch (Exception eX) { MessageBox.Show(eX.Message); } }
private IUniqueValueRenderer CreateRenderer(IFeatureClass featureClass) { int uniqueValuesCount = GetUniqueValuesCount(featureClass, strRendererField); System.Collections.IEnumerator enumerator = GetUniqueValues(featureClass, strRendererField); if (uniqueValuesCount == 0) return null; IEnumColors pEnumRamp = GetEnumColorsByRandomColorRamp(uniqueValuesCount); //IEnumColors pEnumRamp = GetEnumColorsBySelectColorRamp(uniqueValuesCount); pEnumRamp.Reset(); IUniqueValueRenderer pUniqueValueR = new UniqueValueRendererClass(); //只用一个字段进行单值着色 pUniqueValueR.FieldCount = 1; //用于区分着色的字段 pUniqueValueR.set_Field(0, strRendererField); IColor pColor = null; ISymbol symbol = null; enumerator.Reset(); while (enumerator.MoveNext()) { object codeValue = enumerator.Current; pColor = pEnumRamp.Next(); switch (featureClass.ShapeType) { case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint: ISimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbolClass() as ISimpleMarkerSymbol; markerSymbol.Color = pColor; symbol = markerSymbol as ISymbol; break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline: ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass() as ISimpleLineSymbol; lineSymbol.Color = pColor; symbol = lineSymbol as ISymbol; break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon: ISimpleFillSymbol fillSymbol = new SimpleFillSymbolClass() as ISimpleFillSymbol; fillSymbol.Color = pColor; symbol = fillSymbol as ISymbol; break; default: break; } //将每次得到的要素字段值和修饰它的符号放入着色对象中 pUniqueValueR.AddValue(codeValue.ToString(), strRendererField, symbol); } return pUniqueValueR; }
public DotRender(AxMapControl pMapControl, IFeatureLayer pFtLayer, double pValue,string pFieldName) { //IActiveView pActiveView; //this.pGeoLayer = pFtLayer as IGeoFeatureLayer; //pActiveView = pMapControl.ActiveView; //pDotDensityRenderer = new DotDensityRendererClass(); //pRendFields = pDotDensityRenderer as IRendererFields; //pRendFields.AddField(pFieldName, pFieldName); //ͬһ������Ľӿڵ��л����ܷ���ġ� //this.pDotDensityFill = new DotDensityFillSymbolClass(); //pDotDensityFill.DotSize = 8; //pDotDensityFill.Color = GetRGBColor(10, 20, 0); //pDotDensityFill.BackgroundColor = GetRGBColor(100, 108, 190); //pSymbolArry = pDotDensityFill as ISymbolArray;//�ѵ����ܶȡ� //ISimpleMarkerSymbol pSimpleMark; //pSimpleMark = new SimpleMarkerSymbolClass(); //pSimpleMark.Style = esriSimpleMarkerStyle.esriSMSDiamond; //pSimpleMark.Size = 8; //pSimpleMark.Color = GetRGBColor(128, 128, 255); //pSymbolArry.AddSymbol(pSimpleMark as ISymbol); //pDotDensityRenderer.DotDensitySymbol = pDotDensityFill; //pDotDensityRenderer.DotValue = pValue; //pDotDensityRenderer.CreateLegend(); //pGeoLayer.Renderer = (IFeatureRenderer)pDotDensityRenderer; //pActiveView.Refresh(); //��ȡ��ǰͼ�� �����������ó�IGeoFeatureLayer��ʵ�� IMap pMap = pMapControl.Map; // ILayer pFtLayer = pMap.get_Layer(0) as IFeatureLayer; IFeatureLayer pFeatureLayer = pFtLayer as IFeatureLayer; IGeoFeatureLayer pGeoFeatureLayer = pFtLayer as IGeoFeatureLayer; //��ȡͼ���ϵ�feature IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false); IFeature pFeature = pFeatureCursor.NextFeature(); /////////////////////// /////////////////////////////////////////////////////////////////// //������ܶ�ͼ��Ⱦ��� IDotDensityRenderer DotDensityRenderer = new DotDensityRendererClass(); //������ܶ�ͼ��Ⱦ����������Ⱦ�ֶζ��� IRendererFields flds = (IRendererFields)DotDensityRenderer; flds.AddField(pFieldName, pFieldName); //flds.AddField("Shape", "Shape"); //������ܶ�ͼ��Ⱦ�÷��Ŷ��� IDotDensityFillSymbol ddSym = new DotDensityFillSymbolClass(); IRgbColor BackColor = new RgbColorClass(); BackColor.Red = 234; BackColor.Blue = 128; BackColor.Green = 220; IRgbColor SymbolColor = new RgbColorClass(); SymbolColor.Red = 234; SymbolColor.Blue = 128; SymbolColor.Green = 220; ////���ܶ�ͼ��Ⱦ������ɫ //ddSym.BackgroundColor = BackColor; ddSym.DotSize = 8; ddSym.FixedPlacement = true; //ddSym.Color = SymbolColor; ILineSymbol pLineSymbol = new CartographicLineSymbolClass(); ddSym.Outline = pLineSymbol; //����������� ISymbolArray symArray = (ISymbolArray)ddSym; //��ӵ��ܶ�ͼ��Ⱦ�ĵ���ŵ�����������ȥ ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass(); pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pMarkerSymbol.Size = 0.2; pMarkerSymbol.Color = SymbolColor; ; symArray.AddSymbol(pMarkerSymbol as ISymbol); //���õ��ܶ�ͼ��Ⱦ�ĵ���� //DotDensityRenderer.DotDensitySymbol =symArray; DotDensityRenderer.DotDensitySymbol = ddSym; //ȷ��һ����������ֵ DotDensityRenderer.DotValue = pValue; //���ܶ���Ⱦ���õ���ɫģʽ DotDensityRenderer.ColorScheme = "Custom"; //�������ܶ�ͼ��Ⱦͼ�� DotDensityRenderer.CreateLegend(); //���÷��Ŵ�С�Ƿ�̶� DotDensityRenderer.MaintainSize = true; //�����ܶ�ͼ��Ⱦ��������Ⱦͼ��ҹ� pGeoFeatureLayer.Renderer = (IFeatureRenderer)DotDensityRenderer; //ˢ�µ�ͼ��TOOCotrol IActiveView pActiveView = pMap as IActiveView; pActiveView.Refresh(); }
private void SearchFeature(ISpatialFilter pSpatialFilter, IFeatureLayer pFeatureLyr) { ISpatialFilter pFilter; pFilter = pSpatialFilter; IFeatureLayer pFeatureLayer; pFeatureLayer = pFeatureLyr; IFeatureClass pFC = pFeatureLayer.FeatureClass; IFeatureCursor pFeatureCursor; pFeatureCursor = pFeatureLayer.Search(pFilter, true); IFeature pFeature; pFeature = pFeatureCursor.NextFeature(); IGeometry pShape; switch (pFC.ShapeType) { case esriGeometryType.esriGeometryPolyline: while (pFeature != null) { ISimpleLineSymbol pFillsyl; pFillsyl = new SimpleLineSymbolClass(); pFillsyl.Color = getRGB(220, 100, 50); object oFillsyl; oFillsyl = pFillsyl; pShape = pFeature.Shape as IPolyline; m_mapControl.FlashShape(pShape, 15, 20, pFillsyl); m_mapControl.DrawShape(pShape, ref oFillsyl); pFeature = pFeatureCursor.NextFeature(); } break; case esriGeometryType.esriGeometryPolygon: while (pFeature != null) { ISimpleFillSymbol pFillsyl; pFillsyl = new SimpleFillSymbolClass(); pFillsyl.Color = getRGB(220, 100, 50); object oFillsyl; oFillsyl = pFillsyl; pShape = pFeature.Shape as IPolygon; m_mapControl.FlashShape(pShape, 15, 20, pFillsyl); m_mapControl.DrawShape(pShape, ref oFillsyl); pFeature = pFeatureCursor.NextFeature(); } break; case esriGeometryType.esriGeometryPoint: while (pFeature != null) { ISimpleMarkerSymbol pFillsyl; pFillsyl = new SimpleMarkerSymbolClass(); pFillsyl.Color = getRGB(220, 100, 50); object oFillsyl; oFillsyl = pFillsyl; pShape = pFeature.Shape as IPoint; m_mapControl.FlashShape(pShape, 15, 20, pFillsyl); m_mapControl.DrawShape(pShape, ref oFillsyl); pFeature = pFeatureCursor.NextFeature(); } break; } }
//////////////////////////////////�����������ǰ���ý����С�� public static void ProfileSetJunctionFlag(AxMapControl ppAxMapControl, ref IArray pNetFlagArray, IPoint pPoint, IGeometricNetwork pGeoNetwork) { try { //�����ͼ��ѡ�� ppAxMapControl.ActiveView.FocusMap.ClearSelection(); INetElements pNetElements = pGeoNetwork.Network as INetElements; IPointToEID pPtToEID = new PointToEIDClass(); int pJunctionID = 0; int iUserClassID; int iUserID; int iUserSubID; IPoint pLocation; pPtToEID.SourceMap = ppAxMapControl.ActiveView.FocusMap; pPtToEID.GeometricNetwork = pGeoNetwork; pPtToEID.SnapTolerance = ppAxMapControl.ActiveView.Extent.Envelope.Width / 100; pPtToEID.GetNearestJunction(pPoint, out pJunctionID, out pLocation); if (pJunctionID == 0) { MessageBox.Show("û�в������ٽ��ĵ�"); } else { pNetElements.QueryIDs(pJunctionID, esriElementType.esriETJunction, out iUserClassID, out iUserID, out iUserSubID); INetFlag ipNetFlag = new JunctionFlagClass(); ipNetFlag.UserClassID = iUserClassID; ipNetFlag.UserID = iUserID; ipNetFlag.UserSubID = iUserSubID; IMarkerSymbol pMarkerSym = new SimpleMarkerSymbolClass(); IRgbColor pRGBColor = new RgbColorClass(); pRGBColor.Red = 255; pRGBColor.Green = 0; pRGBColor.Blue = 0; pMarkerSym.Color = pRGBColor; pMarkerSym.Size = 20; //���Ƹõ� IScreenDisplay pScreenDisplay = ppAxMapControl.ActiveView.ScreenDisplay; pScreenDisplay.StartDrawing(pScreenDisplay.hDC, 0); pScreenDisplay.SetSymbol(pMarkerSym as ISymbol); pScreenDisplay.DrawPoint(pLocation); pScreenDisplay.FinishDrawing(); if (pLocation != null) { pNetFlagArray.Add(ipNetFlag); } if (pNetFlagArray.Count == 2) { //�����ٽ�� ProfileFindPath(ppAxMapControl, pNetFlagArray, pGeoNetwork); } } } catch (Exception eX) { MessageBox.Show(eX.Message); } }
private ISymbol GetSymbolBySymbolSelector(esriGeometryType geometryType) { try { ISymbolSelector pSymbolSelector = new SymbolSelectorClass(); ISymbol symbol = null; switch (geometryType) { case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint: symbol = new SimpleMarkerSymbolClass(); break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline: symbol = new SimpleLineSymbolClass(); break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon: symbol = new SimpleFillSymbolClass(); break; default: break; } pSymbolSelector.AddSymbol(symbol); bool response = pSymbolSelector.SelectSymbol(0); if (response) { symbol = pSymbolSelector.GetSymbolAt(0); return symbol; } return null; } catch (Exception ex) { MessageBox.Show(ex.Message); ISymbol symbol = null; switch (geometryType) { case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint: symbol = new SimpleMarkerSymbolClass(); break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline: symbol = new SimpleLineSymbolClass(); break; case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon: symbol = new SimpleFillSymbolClass(); break; default: break; } return symbol; } }
//坐标画点 public static void CreatPoint(AxMapControl axMapControl,double x,double y,int m) { //首先要实现容器接口 IGraphicsContainer pGraphicsContainer = axMapControl.ActiveView as IGraphicsContainer; //pGraphicsContainer.DeleteAllElements();//清空容器里面所有的元素 //设置点的坐标 IPoint pPoint = new PointClass(); pPoint.PutCoords(x, y); //IMarkerElement用来获得symbol属性 IMarkerElement pMarkerElement = new MarkerElementClass(); //用ISimpleMarkerSymbol来设置点的属性 ISimpleMarkerSymbol pSymbol = new SimpleMarkerSymbolClass(); IRgbColor pRGBcolor = new RgbColorClass(); pRGBcolor.Red = 0; pRGBcolor.Green =220; pRGBcolor.Blue = 0; // pSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pSymbol.Size = 5; pSymbol.Color = pRGBcolor;//绿色 pSymbol.Style = esriSimpleMarkerStyle.esriSMSCross; pSymbol.Outline = false; pMarkerElement.Symbol = pSymbol; //IEnvelope envelop=new EnvelopeClass(); pPoint.Envelope.SetEmpty(); //IElement用来获得Geometry属性 IElement pElement = pMarkerElement as IElement; //把IPoint转换为为IGeoMetry也能实现 //IGeometry pGeometry = pPoint as IGeometry; //pElement.Geometry = pGeometry; //设置点的标签; ITextSymbol pTextSymbol = new TextSymbolClass(); pTextSymbol.Size = 10; pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; ITextElement texElement = new TextElementClass(); texElement.Symbol = pTextSymbol; texElement.Text = m.ToString(); IElement tElement = texElement as IElement; texElement.ScaleText = true; pElement.Geometry = pPoint; tElement.Geometry = pPoint; //在容器里添加元素 pGraphicsContainer.AddElement(pElement, 0); pGraphicsContainer.AddElement(tElement, 0); pElement.Activate(axMapControl.ActiveView.ScreenDisplay); //tElement.Activate(axMapControl.ActiveView.ScreenDisplay); axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pElement, null); // axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, tElement, null); }
public static IMarkerSymbol DefaultUninitializedSymbol() { ISimpleMarkerSymbol uninitializedSymbol = new SimpleMarkerSymbolClass(); uninitializedSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; return uninitializedSymbol; }
public static IMarkerSymbol DefaultIndeterminateSymbol() { ISimpleMarkerSymbol indeterminateSymbol = new SimpleMarkerSymbolClass(); indeterminateSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; return indeterminateSymbol; }
/// <summary> /// Draws the input geometry using the specified colors. /// </summary> /// <param name="geometry">The input IGeometry to draw. Supported geometry types are GeometryBag, Polygon, Polyline, Point and Multipoint.</param> /// <param name="fillColor">An IRgbColor reference for the fill color</param> /// <param name="lineColor">An IRgbColor reference for the line or outline color</param> /// <param name="display">An IDisplay reference</param> /// <param name="cancelTracker">An ITrackCancel reference</param> private static void DrawGeometry(IGeometry geometry, IRgbColor fillColor, IRgbColor lineColor, IDisplay display, ITrackCancel cancelTracker) { bool continueDrawing = true; switch (geometry.GeometryType) { case esriGeometryType.esriGeometryBag: { IEnumGeometry enumGeometry = (IEnumGeometry)geometry; IGeometry innerGeometry = enumGeometry.Next(); while (innerGeometry != null && continueDrawing == true) { DrawGeometry(innerGeometry, fillColor, lineColor, display, cancelTracker); // Recursive method call innerGeometry = enumGeometry.Next(); if (cancelTracker != null) { continueDrawing = cancelTracker.Continue(); } } break; } case esriGeometryType.esriGeometryPolygon: { // Set the input polygon geometry's symbol. ISimpleFillSymbol fillSymbol = new SimpleFillSymbolClass(); fillSymbol.Color = (IColor)fillColor; ILineSymbol lineSymbol = new SimpleLineSymbolClass(); lineSymbol.Color = lineColor; fillSymbol.Outline = lineSymbol; // Draw the input polygon geometry. display.SetSymbol((ISymbol)fillSymbol); display.DrawPolygon(geometry); break; } case esriGeometryType.esriGeometryPolyline: { // Set the input polyline geometry's symbol. IMultiLayerLineSymbol multiLineSymbol = new MultiLayerLineSymbolClass(); ISimpleLineSymbol simpleLineSymbol1 = new SimpleLineSymbolClass(); ISimpleLineSymbol simpleLineSymbol2 = new SimpleLineSymbolClass(); simpleLineSymbol1.Width = 3; simpleLineSymbol1.Color = fillColor; simpleLineSymbol2.Width = 5; simpleLineSymbol2.Color = lineColor; multiLineSymbol.AddLayer((ILineSymbol)simpleLineSymbol2); multiLineSymbol.AddLayer((ILineSymbol)simpleLineSymbol1); // Draw the input polyline geometry. display.SetSymbol((ISymbol)multiLineSymbol); display.DrawPolyline(geometry); break; } case esriGeometryType.esriGeometryPoint: { // Set the input point geometry's symbol. ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; simpleMarkerSymbol.Size = 12; simpleMarkerSymbol.Color = fillColor; simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineColor = lineColor; // Draw the input point geometry. display.SetSymbol((ISymbol)simpleMarkerSymbol); display.DrawPoint(geometry); break; } case esriGeometryType.esriGeometryMultipoint: { // Set the input multipoint geometry's symbol. ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; simpleMarkerSymbol.Size = 8; simpleMarkerSymbol.Color = fillColor; simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineColor = lineColor; // Draw the input multipoint geometry. display.SetSymbol((ISymbol)simpleMarkerSymbol); display.DrawMultipoint(geometry); break; } } }
/// <summary> /// The add XY event layer. /// </summary> /// <param name="table"> /// The table. /// </param> /// <param name="query"> /// The query. /// </param> /// <param name="tweetShow"> /// The tweet show. /// </param> public static void AddXyEventLayer(ITable table, string query, bool tweetShow = true) { var mxdoc = ArcMap.Application.Document as IMxDocument; if (mxdoc != null) { var map = mxdoc.FocusMap; // Get the table named XYSample.txt var stTableCollection = map as IStandaloneTableCollection; // Get the table name object var dataset = table as IDataset; var tableName = dataset.FullName; // Specify the X and Y fields var xyEvent2FieldsProperties = new XYEvent2FieldsProperties() as IXYEvent2FieldsProperties; if (xyEvent2FieldsProperties != null) { xyEvent2FieldsProperties.XFieldName = "x"; xyEvent2FieldsProperties.YFieldName = "y"; xyEvent2FieldsProperties.ZFieldName = string.Empty; // Specify the projection var spatialReferenceFactory = new SpatialReferenceEnvironment() as ISpatialReferenceFactory; var projectedCoordinateSystem = spatialReferenceFactory.CreateGeographicCoordinateSystem( (int) esriSRGeoCSType.esriSRGeoCS_WGS1984); // Create the XY name object as set it's properties var xyEventSourceName = new XYEventSourceName() as IXYEventSourceName; xyEventSourceName.EventProperties = xyEvent2FieldsProperties; xyEventSourceName.SpatialReference = projectedCoordinateSystem; xyEventSourceName.EventTableName = tableName; IName xyName = xyEventSourceName as IName; IXYEventSource xyEventSource = xyName.Open() as IXYEventSource; // Create a new Map Layer IFeatureLayer featureLayer = new FeatureLayer() as IFeatureLayer; featureLayer.FeatureClass = xyEventSource as IFeatureClass; featureLayer.Name = query; // Add the layer extension (this is done so that when you edit // the layer's Source properties and click the Set Data Source // button, the Add XY Events Dialog appears) ILayerExtensions layerExtensions = featureLayer as ILayerExtensions; XYDataSourcePageExtension resPageExtension = new XYDataSourcePageExtension(); layerExtensions.AddExtension(resPageExtension); IGeoFeatureLayer geoLayer = (IGeoFeatureLayer) featureLayer; ISimpleRenderer simpleRenderer = (ISimpleRenderer) geoLayer.Renderer; var randomNumber = NumberRandom.Next(0, Colors.Count - 1); var color = Colors[randomNumber]; IRgbColor rgbColor = new RgbColorClass(); rgbColor.Blue = color.B; rgbColor.Red = color.R; rgbColor.Green = color.G; IMarkerSymbol markerSymbol = new SimpleMarkerSymbolClass(); markerSymbol.Color = rgbColor; markerSymbol.Size = 5; simpleRenderer.Symbol = (ISymbol) markerSymbol; try { map.AddLayer(featureLayer); } catch (Exception error) { Console.WriteLine(error.Message); } } } }
/// <summary> /// 简单点 /// </summary> /// <param name="size"></param> /// <param name="color"></param> /// <param name="style"></param> /// <param name="outLineSymbol"></param> /// <returns></returns> private IMarkerSymbol DefinePointSymbol(double size, IColor color, esriSimpleMarkerStyle style, ILineSymbol outLineSymbol) { ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); IMarkerSymbol markerSymbol = (IMarkerSymbol)simpleMarkerSymbol; simpleMarkerSymbol.Size = size; //定义点符号大小 simpleMarkerSymbol.Color = color; //定义点符号颜色 simpleMarkerSymbol.Style = style; //定义点符号样式 if (outLineSymbol == null) { simpleMarkerSymbol.Outline = false; } else { simpleMarkerSymbol.Outline = true; //定义点符号边线 simpleMarkerSymbol.OutlineColor = outLineSymbol.Color; simpleMarkerSymbol.OutlineSize = outLineSymbol.Width; } return markerSymbol; }
public static void UpStreamTrace(AxMapControl ppAxMapControl, IPoint pPoint, IGeometricNetwork pGeoNetwork) { try { //�����ͼ��ѡ�� ppAxMapControl.ActiveView.FocusMap.ClearSelection(); INetElements pNetElements = pGeoNetwork.Network as INetElements; IPointToEID pPtToEID = new PointToEIDClass(); int pJunctionID = 0; int iUserClassID; int iUserID; int iUserSubID; IPoint pLocation; pPtToEID.SourceMap = ppAxMapControl.ActiveView.FocusMap; pPtToEID.GeometricNetwork = pGeoNetwork; pPtToEID.SnapTolerance = ppAxMapControl.ActiveView.Extent.Envelope.Width / 100; pPtToEID.GetNearestJunction(pPoint, out pJunctionID, out pLocation); if (pJunctionID == 0) { MessageBox.Show("û�в������ٽ��ĵ�"); } else { pNetElements.QueryIDs(pJunctionID, esriElementType.esriETJunction, out iUserClassID, out iUserID, out iUserSubID); INetFlag ipNetFlag = new JunctionFlagClass(); ipNetFlag.UserClassID = iUserClassID; ipNetFlag.UserID = iUserID; ipNetFlag.UserSubID = iUserSubID; IMarkerSymbol pMarkerSym = new SimpleMarkerSymbolClass(); IRgbColor pRGBColor = new RgbColorClass(); pRGBColor.Red = 255; pRGBColor.Green = 0; pRGBColor.Blue = 0; pMarkerSym.Color = pRGBColor; pMarkerSym.Size = 20; //�����µ�Flag IEdgeFlagDisplay pEdgeFlagDisplay = new EdgeFlagDisplayClass(); IFlagDisplay pFlagDisplay = pEdgeFlagDisplay as IFlagDisplay; pFlagDisplay.Symbol = pMarkerSym as ISymbol; pFlagDisplay.Geometry = pLocation; pFlagDisplay.FeatureClassID = iUserClassID; pFlagDisplay.FID = iUserID; pFlagDisplay.SubID = iUserSubID; //���Ƹõ� IScreenDisplay pScreenDisplay = ppAxMapControl.ActiveView.ScreenDisplay; pScreenDisplay.StartDrawing(pScreenDisplay.hDC, 0); pScreenDisplay.SetSymbol(pMarkerSym as ISymbol); pScreenDisplay.DrawPoint(pLocation as IGeometry); pScreenDisplay.FinishDrawing(); //�����ٽ�� FindStreamTraceResult(ppAxMapControl, ipNetFlag, pGeoNetwork); } } catch (Exception eX) { MessageBox.Show(eX.Message); } }
//��˸�������� public static void FlashPoint(IScreenDisplay pDisplay, IGeometry pGeometry) { ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass(); pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; IRgbColor pRgbColor = new RgbColorClass(); pRgbColor.Red = 150; pRgbColor.Green = 100; pRgbColor.Blue = 100; pMarkerSymbol.Color = pRgbColor as IColor; pMarkerSymbol.Outline = true; ISymbol pSymbol = pMarkerSymbol as ISymbol; pSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; pDisplay.SetSymbol(pSymbol); pDisplay.DrawPoint(pGeometry); Thread.Sleep(300); pDisplay.DrawPoint(pGeometry); }
public static IElement DrawPointMarker(IMap map, IPoint point) { IMarkerElement markerElement = new MarkerElementClass(); ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); IRgbColor color = new RgbColorClass(); color.Red = 200; color.Green = 100; color.Blue = 100; simpleMarkerSymbol.Color = color as IColor; simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare; markerElement.Symbol = simpleMarkerSymbol; IElement element = markerElement as IElement; element.Geometry = point; IGraphicsContainer graphicsContainer = map as IGraphicsContainer; graphicsContainer.AddElement(element, 0); IActiveView activeView = map as IActiveView; activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); return element; }
private void drawpoints(IPointCollection ippoints) { IGraphicsContainer pgraghicscontainer = axMapControl1.Map as IGraphicsContainer; IActiveView pactiveview = pgraghicscontainer as ESRI.ArcGIS.Carto.IActiveView; //设定路径颜色 IRgbColor pcolor = new RgbColorClass(); pcolor.Red = 255; pcolor.Green = 0; pcolor.Blue = 0; pcolor.Transparency = 100; //设置线格式 ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Color = pcolor; simpleMarkerSymbol.Size = 4; //绘出路径线 IScreenDisplay screenDisplay = pactiveview.ScreenDisplay; ISymbol symbol = (ISymbol)simpleMarkerSymbol; screenDisplay.StartDrawing(screenDisplay.hDC, System.Convert.ToInt16(esriScreenCache.esriNoScreenCache)); screenDisplay.SetSymbol(symbol); int i; for (i = 0; i < ippoints.PointCount; i++) { screenDisplay.DrawPoint(ippoints.get_Point(i)); } screenDisplay.FinishDrawing(); }
/// <summary> /// ���Ƽ���ͼ�� /// </summary> /// <params name="geoType"></params> /// <params name="geometry"></params> /// <returns></returns> ESRI.ArcGIS.Carto.IElement createElement_x(ESRI.ArcGIS.Geometry.IGeometry geometry) { IElement element = null; try { switch (geometry.GeometryType) { case esriGeometryType.esriGeometryPolygon: 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 = TransColorToAEColor(Color.Blue); //pSimpleFillSymbol.Color = GetRGBColor(11, 200, 145); pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSNull; pSimpleFillSymbol.Outline = pSimpleLineSymbol; IElement pElement = (IElement)pPolygonElement; pElement.Geometry = geometry; pPolygonElement.Symbol = pSimpleFillSymbol; element = (IElement)pPolygonElement; break; case esriGeometryType.esriGeometryPolyline://Polyline�� ISimpleLineSymbol simpleLineSymbol = m_NewPolygonFeedback.Symbol as ISimpleLineSymbol; ILineElement lineElement = new LineElementClass(); lineElement.Symbol = simpleLineSymbol as ILineSymbol; element = lineElement as IElement; element.Geometry = geometry; break; case esriGeometryType.esriGeometryPoint: //���ý����� IRgbColor pRGB = new RgbColorClass(); pRGB.Red = 255; pRGB.Green = 0; pRGB.Blue = 0; ISimpleMarkerSymbol pSimpleMarkSymbol = new SimpleMarkerSymbolClass(); pSimpleMarkSymbol.Color = pRGB as IColor; pSimpleMarkSymbol.Size = 2; pSimpleMarkSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare; IMarkerElement pMarkerElement = new MarkerElementClass(); pMarkerElement.Symbol = pSimpleMarkSymbol as IMarkerSymbol; element = pMarkerElement as IElement; element.Geometry = geometry as IGeometry; break; } } catch { } return element; }