protected override void OnClick() { // Access a feature layer from ArcMap IMap map = ArcMap.Document.FocusMap; IFeatureLayer featureLayer = map.Layer[0] as IFeatureLayer; IFeatureClass featureclass = featureLayer.FeatureClass; IRgbColor lineColor = new RgbColorClass(); lineColor.Red = 255; lineColor.Green = 255; lineColor.Blue = 0; ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass(); lineSymbol.Color = lineColor; lineSymbol.Width = 3.0; ISimpleRenderer simpleRenderer = new SimpleRendererClass(); simpleRenderer.Label = "Taper"; simpleRenderer.Symbol = lineSymbol as ISymbol; IGeoFeatureLayer geoFL = featureLayer as IGeoFeatureLayer; geoFL.Renderer = simpleRenderer as IFeatureRenderer; ArcMap.Document.ActivatedView.Refresh(); ArcMap.Document.ActivatedView.PartialRefresh(esriViewDrawPhase.esriViewGeography, geoFL, ArcMap.Document.ActivatedView.Extent); ArcMap.Document.UpdateContents(); }
/// <summary> /// 为要素图层设置符号 /// </summary> /// <param name="fl">要素图层</param> /// <param name="paras">4参数(颜色和宽度)表示线图层,5参数(颜色、形状、大小)表示点图层</param> public static void SetSymbol(IFeatureLayer fl, object[] paras) { //设置线图层的颜色、线宽 if (paras.Length == 4) { ISimpleLineSymbol ls = new SimpleLineSymbolClass(); IRgbColor color = new RgbColorClass(); color.Red = (int)paras[0]; color.Green = (int)paras[1]; color.Blue = (int)paras[2]; ls.Color = color; ls.Width = (double)paras[3]; ISimpleRenderer render = new SimpleRendererClass(); render.Symbol = ls as ISymbol; (fl as IGeoFeatureLayer).Renderer = render as IFeatureRenderer; } else if (paras.Length == 5)//设置点图层的颜色、大小、形状 { ISimpleMarkerSymbol ms = new SimpleMarkerSymbolClass(); IRgbColor color = new RgbColorClass(); color.Red = (int)paras[0]; color.Green = (int)paras[1]; color.Blue = (int)paras[2]; ms.Color = color; ms.Style = (esriSimpleMarkerStyle)paras[3]; ms.Size = (double)paras[4]; ISimpleRenderer render = new SimpleRendererClass(); render.Symbol = ms as ISymbol; (fl as IGeoFeatureLayer).Renderer = render as IFeatureRenderer; } }
//简单符号化 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 Form1_Load(object sender, System.EventArgs e) { //Find sample data by navigating two folders up string sFilePath = @"..\..\..\Data\World\Continents.lyr"; //Add sample 'country' shapefile data axMapControl1.AddLayerFromFile(sFilePath); //Set the extent axMapControl1.Extent = axMapControl1.get_Layer(0).AreaOfInterest; //Grab hold of the IgeoFeaturelayer interface on the layer //in the map control in order to symbolize the data IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)axMapControl1.get_Layer(0); //Create a simple renderer and grab hold of ISimpleRenderer interface ISimpleRenderer simpleRenderer = new SimpleRendererClass(); //Create a fill symbol and grab hold of the ISimpleFillSymbol interface ISimpleFillSymbol fillSymbol = new SimpleFillSymbolClass(); //Create a line symbol and grab hold of the ISimpleLineSymbol interface ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass(); //Assign line symbol and fill symbol properties lineSymbol.Width = 0.1; lineSymbol.Color = GetRGBColor(255, 0, 0); //Red fillSymbol.Outline = lineSymbol; fillSymbol.Color = GetRGBColor(0, 0, 255); //Blue //Set the symbol property of the renderer simpleRenderer.Symbol = (ISymbol)fillSymbol; //Set the renderer property of the geo feature layer geoFeatureLayer.Renderer = (IFeatureRenderer)simpleRenderer; }
private void btnOK_Click(object sender, EventArgs e) { IGeoFeatureLayer geoFeatureLayer = m_featureLayer as IGeoFeatureLayer; //Create a new simple line symbol ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = int.Parse(tbSize.Text); //Change the color of line IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = int.Parse(tbRed.Text); rgbColor.Blue = int.Parse(tbBlue.Text); rgbColor.Green = int.Parse(tbGreen.Text); simpleLineSymbol.Color = rgbColor; //Change the properties of line ISimpleRenderer simpleRenderer = new SimpleRendererClass(); simpleRenderer.Symbol = simpleLineSymbol as ISymbol; geoFeatureLayer.Renderer = simpleRenderer as IFeatureRenderer; m_fraMain.RefreshMap(); m_fraMain.RefreshTOCControl(); this.Close(); }
protected void simpleRender(IFeatureLayer layer, IColor borderColor, double borderWidth) { ISimpleRenderer simpleRender = null; IFillSymbol fillSymbol = null; ILineSymbol lineSymbol = null; IColor fillColor = null; IGeoFeatureLayer geoLayer = null; if (layer != null && borderColor != null) { fillColor = new RgbColorClass(); fillColor.NullColor = true; fillSymbol = new SimpleFillSymbolClass(); lineSymbol = new SimpleLineSymbolClass(); fillSymbol.Color = fillColor; lineSymbol.Color = borderColor; lineSymbol.Width = borderWidth; fillSymbol.Outline = lineSymbol; geoLayer = layer as IGeoFeatureLayer; if (geoLayer != null) { simpleRender = new SimpleRendererClass(); simpleRender.Symbol = fillSymbol as ISymbol; geoLayer.Renderer = simpleRender as IFeatureRenderer; } } }
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="layer">特征层</param> /// <param name="symbol">渲染符号</param> public void RendLayer(ref ILayer layer, ISymbol symbol) { IGeoFeatureLayer pGeoFeatureL = null; if (layer == null) { return; } else { pGeoFeatureL = layer as IGeoFeatureLayer; } ISimpleRenderer pSimpleRenderer = new SimpleRendererClass(); if (symbol == null) { pSimpleRenderer.Symbol = SymbolWorker.CreateSimpleLineSymbol() as ISymbol; } else { pSimpleRenderer.Symbol = symbol; } pSimpleRenderer.Description = "USA"; pSimpleRenderer.Label = "SimpleRenderer"; ITransparencyRenderer pTransRenderer = pSimpleRenderer as ITransparencyRenderer; pTransRenderer.TransparencyField = "POP1999"; pGeoFeatureL.Renderer = pTransRenderer as IFeatureRenderer; }
//简单渲染专题图 private void button1_Click(object sender, EventArgs e) { //简单填充符号 ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSDiagonalCross; simpleFillSymbol.Color = getRGB(255, 0, 0); //创建边线符号 ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot; simpleLineSymbol.Color = getRGB(0, 255, 0); ISymbol symbol = simpleLineSymbol as ISymbol; symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; simpleFillSymbol.Outline = simpleLineSymbol; ISimpleRenderer simpleRender = new SimpleRendererClass(); simpleRender.Symbol = simpleFillSymbol as ISymbol; simpleRender.Label = "continent"; simpleRender.Description = "简单渲染"; IGeoFeatureLayer geoFeatureLayer; geoFeatureLayer = getGeoLayer("Continents"); if (geoFeatureLayer != null) { geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer; } this.axMapControl1.Refresh(); }
/// <summary> /// 渲染符号的样式为瓦斯压力点 /// </summary> /// <param name="pfeature"></param> /// <param name="ge"></param> private void RenderfeatureLayer(IFeatureLayer featureLayer, ISymbol layerSymbols) { ISimpleRenderer pRenderer = new SimpleRendererClass(); pRenderer.Symbol = layerSymbols; (featureLayer as IGeoFeatureLayer).Renderer = pRenderer as IFeatureRenderer;//渲染图层; }
private void SymbolizeData(ILayer layer, double dWidth, IRgbColor colorLine, IRgbColor colorFill) { //Create a line symbol and get the ILineSymbol interface ILineSymbol lineSymbol = new SimpleLineSymbolClass(); //Set the line symbol properties lineSymbol.Width = dWidth; lineSymbol.Color = colorLine; //Create a fill symbol and get the IFillSymbol interface ISimpleFillSymbol fillSymbol = new SimpleFillSymbolClass(); //Set the fill symbol properties fillSymbol.Outline = lineSymbol; fillSymbol.Color = colorFill; //Create a simple renderer and get the ISimpleRenderer interface ISimpleRenderer simpleRenderer = new SimpleRendererClass(); //Set the simple renderer properties simpleRenderer.Symbol = (ISymbol)fillSymbol; //QI for the IGeoFeatureLayer interface from the ILayer2 interface IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)layer; //Set the GeoFeatureLayer properties geoFeatureLayer.Renderer = (IFeatureRenderer)simpleRenderer; }
public void LoadLayers(List <string> fcnames) { this.axMapControl1.ClearLayers(); IFeatureWorkspace ws = Util.ServerWorkspace as IFeatureWorkspace; foreach (string fcname in fcnames) { IFeatureClass fc = ws.OpenFeatureClass(fcname); IFeatureLayer flyr = new FeatureLayerClass(); flyr.FeatureClass = fc; ILayer lyr = flyr as ILayer; lyr.Name = fcname; IGeoFeatureLayer gflyr = flyr as IGeoFeatureLayer; ISimpleRenderer render = new SimpleRendererClass(); ISymbol sym = null; if (fc.ShapeType == esriGeometryType.esriGeometryPolygon) { sym = new SimpleFillSymbolClass(); } render.Symbol = sym; gflyr.Renderer = render as IFeatureRenderer; this.axMapControl1.AddLayer(lyr); } this.axMapControl1.Extent = this.axMapControl1.FullExtent; }
public static void ApplySimpleRenderer(IGeoFeatureLayer fl) { ISimpleRenderer sr = new SimpleRendererClass(); sr.Symbol = (ISymbol)CreateSimpleFillSymbol(255, 0, 0); fl.Renderer = (IFeatureRenderer)sr; }
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 void InitMapCtr() { IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass(); IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(@"D:\RasterMaSysTemp\hhData", 0); IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace; if (pFeatureWorkspace != null) { IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass("洪湖水域.shp"); IFeatureLayer pFeatureLayer = new FeatureLayerClass(); pFeatureLayer.Name = "洪湖水域"; pFeatureLayer.FeatureClass = pFeatureClass; //设置为湖泊符号渲染 IGeoFeatureLayer pGeoFeatureLayer = (IGeoFeatureLayer)pFeatureLayer; IFillSymbol pFillSymbol = new SimpleFillSymbolClass(); pFillSymbol.Color = DataShowControl.GetColor(151, 219, 242); ILineSymbol pLineSymbol = new SimpleLineSymbolClass(); pLineSymbol.Color = DataShowControl.GetColor(64, 101, 235); pLineSymbol.Width = 0.4; pFillSymbol.Outline = pLineSymbol; ISimpleRenderer pSimpleRenderer = new SimpleRendererClass(); pSimpleRenderer.Symbol = (ISymbol)pFillSymbol; pGeoFeatureLayer.Renderer = pSimpleRenderer as IFeatureRenderer; //添加图层 axMapControl1.Map.AddLayer(pGeoFeatureLayer); axMapControl1.ActiveView.Extent = axMapControl1.ActiveView.FullExtent; } }
/// <summary> /// 刷新Mobike数据 /// </summary> public void RefreshmobikeInfo() { //获取车辆位置信息 var mobikecars = new List <mobikeInfo>(); NetUtils.GetmobikeCars(out mobikecars); if (mobikecars == null) { view.ShowError("数据出现问题,可能是mobike用户认证出错 返回示例数据"); mobikecars = SampleData.mobikeSampleList; } IFeatureClass featureclass = CreateFeatureClass("mobike"); IFeatureCursor featureCursor = featureclass.Insert(true); //遍历照片链表 以创建缓存的形式插入数据 foreach (var c in mobikecars) { IPoint pPoint = new PointClass(); //坐标转换 var t = CoordinateUtils.gcj02_To_Wgs84(c.distY, c.distX); pPoint.PutCoords(t.longtitude, t.latitude); pPoint.SpatialReference = ApplicationV.GlobalMapControl.SpatialReference; pPoint.Project(ApplicationV.GlobalMapControl.SpatialReference); IFeatureBuffer featureBuffer = featureclass.CreateFeatureBuffer(); featureBuffer.Shape = pPoint; featureBuffer.set_Value(featureBuffer.Fields.FindField("Latitude"), t.latitude); featureBuffer.set_Value(featureBuffer.Fields.FindField("Longtitude"), t.longtitude); featureCursor.InsertFeature(featureBuffer); } featureCursor.Flush(); //创建图层 IFeatureLayer pFeaturelayer = new FeatureLayerClass(); pFeaturelayer.FeatureClass = featureclass; pFeaturelayer.Name = "mobike分布"; //修饰该图层 IPictureMarkerSymbol mobikeMarkerSymbol = new PictureMarkerSymbolClass(); mobikeMarkerSymbol.Size = 18; mobikeMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPicturePNG, ApplicationV.Data_ImgPath + "//mobike.png"); // ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbol(); // pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; // var pRgbColor = ColorUtils.GetRgbColor(226, 61, 14); // pMarkerSymbol.Color = pRgbColor; ISimpleRenderer pSimpleRenderer = new SimpleRendererClass(); pSimpleRenderer.Symbol = (ISymbol)mobikeMarkerSymbol; (pFeaturelayer as IGeoFeatureLayer).Renderer = pSimpleRenderer as IFeatureRenderer; //正式归为图层 ofoLayer = pFeaturelayer as ILayer; ApplicationV.GlobalMapControl.AddLayer(ofoLayer); ApplicationV.GlobalMapControl.Refresh(); }
//文字符号化 private void CharacterMarkerSymbolToolStripMenuItem_Click(object sender, EventArgs e) { try { //获得点图层,要求当前地图文档第一个图层为点图层 IFeatureLayer layer; layer = mainMapControl.get_Layer(0) as IFeatureLayer; //QI到IGeoFeatureLayer IGeoFeatureLayer geoFeatureLayer = layer as IGeoFeatureLayer; SimpleRenderer simpleRender = new SimpleRendererClass(); ICharacterMarkerSymbol pCharacterMarkerSymbol = new CharacterMarkerSymbolClass(); IColor pColor = new RgbColorClass(); pColor.RGB = 2256; stdole.IFontDisp font = new stdole.StdFontClass() as stdole.IFontDisp; font.Name = "Arial"; font.Size = 30; font.Bold = true; pCharacterMarkerSymbol.Font = font; pCharacterMarkerSymbol.Color = pColor; pCharacterMarkerSymbol.Size = 20; pCharacterMarkerSymbol.CharacterIndex = 55; //ASCII55对应数字7 simpleRender.Symbol = pCharacterMarkerSymbol as ISymbol; geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer; mainMapControl.Refresh(); axTOCControl1.Update(); } catch { MessageBox.Show("没有可以实例化的图层"); } }
//箭头符号化 private void ArrowMarkerSymbolToolStripMenuItem_Click(object sender, EventArgs e) { try { //获得点图层,要求当前地图文档第一个图层为点图层 IFeatureLayer layer; layer = mainMapControl.get_Layer(0) as IFeatureLayer; //QI到IGeoFeatureLayer IGeoFeatureLayer geoFeatureLayer = layer as IGeoFeatureLayer; SimpleRenderer simpleRender = new SimpleRendererClass(); IArrowMarkerSymbol pMarkerSymbol; IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 0; pColor.Blue = 255; pMarkerSymbol = new ArrowMarkerSymbolClass(); pMarkerSymbol.Length = 20; pMarkerSymbol.Color = pColor; pMarkerSymbol.Width = 10; //箭头底边的宽度 pMarkerSymbol.Angle = 60; 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) { //简单填充符号 ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSDiagonalCross; simpleFillSymbol.Color = getRGB(255, 0, 0); //创建边线符号 ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot; simpleLineSymbol.Color = getRGB(0, 255, 0); ISymbol symbol = simpleLineSymbol as ISymbol; symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; simpleFillSymbol.Outline = simpleLineSymbol; ISimpleRenderer simpleRender = new SimpleRendererClass(); simpleRender.Symbol = simpleFillSymbol as ISymbol; simpleRender.Label = "NAME"; simpleRender.Description = "东丰县行政区域"; IGeoFeatureLayer geoFeatureLayer; geoFeatureLayer = getGeoLayer("东丰县行政区域"); if (geoFeatureLayer != null) { geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer; } this.axMapControl1.Refresh(); }
private void SimpleFillToolStripMenuItem_Click(object sender, EventArgs e) { //获得面图层,要求当前地图文档第三个图层为面图层 IFeatureLayer layer = axMapControl1.get_Layer(2) as IFeatureLayer; IGeoFeatureLayer geoFeatureLayer = layer as IGeoFeatureLayer; ISimpleRenderer simpleRender = new SimpleRendererClass(); IColor pLineColor = new RgbColorClass(); pLineColor.RGB = 2256; IColor pFillColor = new RgbColorClass(); pFillColor.RGB = 255; ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass(); pSimpleLineSymbol.Width = 5; pSimpleLineSymbol.Color = pLineColor; ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass(); pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSCross; pSimpleFillSymbol.Outline = pSimpleLineSymbol; pSimpleFillSymbol.Color = pFillColor; simpleRender.Symbol = pSimpleFillSymbol as ISymbol; geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer; axMapControl1.Refresh(); axTOCControl1.Update(); }
public override void OnClick() { IMapControlDefault pMapControl = m_hookHelper.Hook as IMapControlDefault; IGeoFeatureLayer pGeoFeatLyr = pMapControl.CustomProperty as IGeoFeatureLayer; if (pGeoFeatLyr == null) return; frmSymbology symbolForm = new frmSymbology(); IStyleGalleryItem styleGalleryItem = null; switch (pGeoFeatLyr.FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassMarkerSymbols); break; case esriGeometryType.esriGeometryPolyline: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassLineSymbols); break; case esriGeometryType.esriGeometryPolygon: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassFillSymbols); break; } symbolForm.Dispose(); //mMainPlatfrom.Activate(); if (styleGalleryItem == null) return; ISimpleRenderer simpleRenderer = new SimpleRendererClass(); simpleRenderer.Symbol = (ISymbol)styleGalleryItem.Item; pGeoFeatLyr.Renderer = simpleRenderer as IFeatureRenderer; pMapControl.Refresh(esriViewDrawPhase.esriViewGeography, null, null); }
private void lineSimpleDye(ILayer pLayer) { try { IGeoFeatureLayer pGeoFeatLyr = pLayer as IGeoFeatureLayer; //设置线符号 ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Width = 0; //定义线的宽度 simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSInsideFrame; //定义线的样式 simpleLineSymbol.Color = pColor; //定义线的颜色 ISymbol symbol = simpleLineSymbol as ISymbol; //更改符号样式 ISimpleRenderer pSimpleRenderer = new SimpleRendererClass(); pSimpleRenderer.Symbol = symbol; pGeoFeatLyr.Renderer = pSimpleRenderer as IFeatureRenderer; axMapControl1.Refresh(); axMapControl1.Update(); } catch (Exception ex) { } }
private void ImagePointToolStripMenuItem_Click(object sender, EventArgs e) { IFeatureLayer layer; layer = axMapControl1.get_Layer(0) as IFeatureLayer; //QI到IGeoFeatureLayer IGeoFeatureLayer geoFeatureLayer = layer as IGeoFeatureLayer; //新建SimpleRendererClass对象 SimpleRenderer simpleRender = new SimpleRendererClass(); //指定图片存放的位置 OpenFileDialog pOpenFileDialog = new OpenFileDialog { //Filter = "Image(*.img)|*.img", Title = "打开Image文件" }; pOpenFileDialog.ShowDialog(); string path = pOpenFileDialog.FileName; //string path = Application.StartupPath + @"\symbol\pointPic.BMP"; IPictureMarkerSymbol pPictureMarkerSymbol = new PictureMarkerSymbolClass(); pPictureMarkerSymbol.Size = 40; pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, path); simpleRender.Symbol = pPictureMarkerSymbol as ISymbol; geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer; axMapControl1.Refresh(); axTOCControl1.Update(); }
/// <summary> /// 简单渲染 /// </summary> /// <param name="layerName">图层名字</param> /// <param name="FillStyle">FillStyle</param> /// <param name="pColor">FillColor</param> /// <param name="OutLineColor">OutLineColor</param> /// <param name="RenderLabel">样式名称注释</param> /// <param name="Descripition">描述</param> public void createSimpleFillSymbol(string layerName, esriSimpleFillStyle FillStyle, IColor pColor, IColor OutLineColor, string RenderLabel, string Descripition) { //简单填充符号 ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass(); //可以用符号选择器进行 simpleFillSymbol.Style = FillStyle; simpleFillSymbol.Color = pColor; //创建边线符号 ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Color = OutLineColor; ISymbol symbol = simpleLineSymbol as ISymbol; symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; simpleFillSymbol.Outline = simpleLineSymbol; ISimpleRenderer simpleRender = new SimpleRendererClass(); simpleRender.Symbol = simpleFillSymbol as ISymbol; simpleRender.Label = RenderLabel; simpleRender.Description = Descripition; IGeoFeatureLayer geoFeatureLayer; geoFeatureLayer = getGeoLayer(layerName); if (geoFeatureLayer != null) { geoFeatureLayer.Renderer = simpleRender as IFeatureRenderer; } }
public void ModifyMxd(IFeatureClass outFeatureClass, double[] scales, ISpatialReference spatialReference) { var fi = new FileInfo("animation.mxd"); IMapDocument mapDocument = new MapDocumentClass(); mapDocument.Open(fi.FullName); IMap map = mapDocument.Map[0]; ILayer layerToDelete = null; while ((layerToDelete = map.Layers.Next()) != null) { map.DeleteLayer(layerToDelete); } mapDocument.Save(); mapDocument.Map[0].SpatialReference = spatialReference; mapDocument.Save(); foreach (double scale in scales) { ILayer layer = new FeatureLayerClass(); layer.Name = $"scale{scale}"; layer.SpatialReference = spatialReference; layer.MaximumScale = scale - 1; layer.MinimumScale = scale + 1; ((IFeatureLayer)layer).FeatureClass = outFeatureClass; ISimpleRenderer renderer = new SimpleRendererClass() { Symbol = new SimpleLineSymbolClass() { Color = new RgbColorClass() { Red = 0, Green = 0, Blue = 255 }, } }; ((IGeoFeatureLayer)layer).Renderer = renderer as IFeatureRenderer; mapDocument.Map[0].AddLayer(layer); mapDocument.Save(); } mapDocument.Save(); var mlc = map.LayerCount; var lc = mapDocument.Map[0].LayerCount; ;; //var mlc = map.LayerCount; //var mdmlc = mapDocument.Map[0].LayerCount; //mapDocument.SaveAs($"map{DateTime.Now.ToBinary()}.mxd"); ; }
public override void OnClick() { IFeatureLayer pFeatureLayer = (m_pMapC2 as IMapControl4).CustomProperty as IFeatureLayer; ISimpleRenderer pRenderer = new SimpleRendererClass() { Symbol = AeUtils.GetSymbolBySymbolSelector(pFeatureLayer.FeatureClass.ShapeType) }; (pFeatureLayer as IGeoFeatureLayer).Renderer = pRenderer as IFeatureRenderer; m_pMapC2.Refresh(); AeUtils.UpdateTOCControl(); }
private void showHistoryMapView() { if (m_frmHistoryMapView == null || m_frmHistoryMapView.IsDisposed) { AxMapControl MapMain = _AppHk.ArcGisMapControl; IObjectCopy pOC = new ObjectCopyClass(); IMap pCopy = pOC.Copy(MapMain.Map) as IMap; ILayer pLL = null; for (int i = 0; i < pCopy.LayerCount; i++) { ILayer pLayer = pCopy.get_Layer(i); if (pLayer.Name == "示意图") { pLL = pLayer; ICompositeLayer pCL = pLayer as ICompositeLayer; IGroupLayer pGL = pLayer as IGroupLayer; for (int j = 0; j < pCL.Count; j++) { ILayer pL = pCL.get_Layer(j); if (pL.Name.ToUpper() == "NJTDT.ZONE") { IFeatureRenderer pSR = new SimpleRendererClass(); IGeoFeatureLayer pGEOL = pL as IGeoFeatureLayer; pGEOL.Renderer = pSR; } //else if (pL.Name.ToUpper() == "NJTDT.JFB") //{ // IFeatureClass pFC = (ModData.v_SysDataSet.WorkSpace as IFeatureWorkspace).OpenFeatureClass("JFB"); // if (pFC != null) // (pL as IFeatureLayer).FeatureClass = pFC; //} else { pGL.Delete(pL); } } } } //pCopy.DeleteLayer(pLL); m_frmHistoryMapView = new FrmHistoryMapView(MapMain.Extent, pCopy, _ProjectTree); //m_frmHistoryMapView.clsMain = clsMain; //m_frmHistoryMapView.MainMapExtent = MapMain.Extent; //m_frmHistoryMapView.HistoryMap = pCopy; m_frmHistoryMapView.Show(); ModHistory.SetForegroundWindow(m_frmHistoryMapView.Handle); } else { m_frmHistoryMapView.Visible = true; ModHistory.SetForegroundWindow(m_frmHistoryMapView.Handle); } }
private void MainForm_Load(object sender, EventArgs e) { m_mapControl = (IMapControl3)axMapControl1.Object; //relative file path to the sample data from EXE location string filePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); filePath = System.IO.Path.Combine(filePath, @"ArcGIS\data\USAMajorHighways"); //Add Lakes layer IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactoryClass(); IFeatureWorkspace workspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(filePath, axMapControl1.hWnd); IFeatureLayer featureLayer = new FeatureLayerClass(); featureLayer.Name = "Lakes"; featureLayer.Visible = true; featureLayer.FeatureClass = workspace.OpenFeatureClass("us_lakes"); #region create a SimplerRenderer IRgbColor color = new RgbColorClass(); color.Red = 190; color.Green = 232; color.Blue = 255; ISimpleFillSymbol sym = new SimpleFillSymbolClass(); sym.Color = color; ISimpleRenderer renderer = new SimpleRendererClass(); renderer.Symbol = sym as ISymbol; #endregion ((IGeoFeatureLayer)featureLayer).Renderer = renderer as IFeatureRenderer; axMapControl1.Map.AddLayer((ILayer)featureLayer); //Add Highways layer featureLayer = new FeatureLayerClass(); featureLayer.Name = "Highways"; featureLayer.Visible = true; featureLayer.FeatureClass = workspace.OpenFeatureClass("usa_major_highways"); axMapControl1.Map.AddLayer((ILayer)featureLayer); //******** Important ************* //store a reference to this form (Mainform) using the EditHelper class EditHelper.TheMainForm = this; EditHelper.IsEditorFormOpen = false; //add the EditCmd command to the toolbar axEditorToolbar.AddItem("esriControls.ControlsOpenDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axEditorToolbar.AddItem("esriControls.ControlsSaveAsDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axEditorToolbar.AddItem("esriControls.ControlsAddDataCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axEditorToolbar.AddItem(new EditCmd(), 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); }
/// <summary> /// 设置要素图片显示样式 /// </summary> /// <param name="featureLayer"></param> /// <param name="pictureName"></param> /// <param name="size"></param> public static void SetFeaturePictureSymbol(IFeatureLayer featureLayer, string pictureName, int size) { IGeoFeatureLayer geoLayer = featureLayer as IGeoFeatureLayer; IPictureMarkerSymbol pPicturemksb = CreatePictureSymbol(pictureName, size); ISimpleRenderer simpleRender = geoLayer.Renderer as ISimpleRenderer; if (simpleRender == null) { simpleRender = new SimpleRendererClass(); } simpleRender.Symbol = pPicturemksb as ISymbol; geoLayer.Renderer = simpleRender as IFeatureRenderer; }
public static void PolylineRenderSimply(IFeatureLayer fealyr, IColor lineColor, double lineWidth) { IMarkerLineSymbol pMarkerLine = new MarkerLineSymbolClass(); pMarkerLine.Color = lineColor; pMarkerLine.Width = lineWidth; SimpleRenderer sr = new SimpleRendererClass(); sr.Symbol = pMarkerLine as ISymbol; IGeoFeatureLayer geofealyr = fealyr as IGeoFeatureLayer; geofealyr.Renderer = sr as IFeatureRenderer; }
private void btnSymbolize_Click(object sender, EventArgs e) { if (layer2Symbolize == null) return; ISymbol symbol = GetSymbolByControl(layer2Symbolize.FeatureClass.ShapeType); if (symbol == null) return; ISimpleRenderer pSimpleRenderer = new SimpleRendererClass(); pSimpleRenderer.Symbol = symbol; pSimpleRenderer.Label = "单一符号化"; IGeoFeatureLayer pGeoFeatureL = layer2Symbolize as IGeoFeatureLayer; pGeoFeatureL.Renderer = pSimpleRenderer as IFeatureRenderer; m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_activeView.Extent); m_TOCControl.Update(); }
public SimpleRender(AxMapControl pMapcontrol, IFeatureLayer pFtLayer, String Field) { IGeoFeatureLayer pGeolayer; IActiveView pActiveView; pGeolayer = pFtLayer as IGeoFeatureLayer; pActiveView = pMapcontrol.ActiveView; IFillSymbol pFillSymbol; ILineSymbol pLineSymbol; pFillSymbol = new SimpleFillSymbolClass(); pFillSymbol.Color = GetRGBColor(220, 110, 200); pLineSymbol = new SimpleLineSymbolClass(); pLineSymbol.Color = GetRGBColor(255, 120, 105); pLineSymbol.Width = 2; pFillSymbol.Outline = pLineSymbol; ISimpleRenderer pSimpleRender;//用什么符号渲染 pSimpleRender = new SimpleRendererClass(); pSimpleRender.Symbol = pFillSymbol as ISymbol; pSimpleRender.Description = "China"; pSimpleRender.Label = "SimpleRender"; ITransparencyRenderer pTrans; pTrans = pSimpleRender as ITransparencyRenderer; pTrans.TransparencyField = Field; pGeolayer.Renderer = pTrans as IFeatureRenderer; pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); //地理图层的渲染对象是一个要素渲染对象,而这个对象是由一些相关对象组成的。 //属性也是一个对象,说明大对象是由小对象组成的。 }
private static void SetTysonSymbol() { IFeatureLayer pTysonLayer = Func.GetFeatureLayerByName("tyson"); IFeatureRenderer pRenderer = new SimpleRendererClass() { Symbol = Func.CreateSimpleFillSymbol( Func.CreateRgbColor(0, 0, 0, 0), Func.CreateRgbColor(0, 0, 0), 2 ) as ISymbol, }; (pTysonLayer as IGeoFeatureLayer).Renderer = pRenderer; }
public static void SetLayerColor(IGeoFeatureLayer geolyr, int r, int g, int b) { //ILineSymbol pLineSymbol = new SimpleLineSymbolClass(); //pLineSymbol.Color = CvtRGB(r, g, b); ISimpleFillSymbol pFillSymbol = new SimpleFillSymbolClass(); pFillSymbol.Color = CvtRGB(r, g, b); //pFillSymbol.Outline = pLineSymbol; ISimpleRenderer pSimpleRenderer; pSimpleRenderer = new SimpleRendererClass(); pSimpleRenderer.Symbol = (ISymbol)pFillSymbol; geolyr.Renderer = pSimpleRenderer as IFeatureRenderer; }
public static bool RenderSimply(ILayer layer, IColor color) { IFeatureLayer featureLayer = (IFeatureLayer)layer; esriGeometryType geotype = featureLayer.FeatureClass.ShapeType; ISymbol symbol = GetSymbolFromLayer(layer); switch (geotype) { case esriGeometryType.esriGeometryPoint: { IMarkerSymbol markerSymbol = symbol as IMarkerSymbol; markerSymbol.Color = color; break; } case esriGeometryType.esriGeometryMultipoint: { IMarkerSymbol markerSymbol = symbol as IMarkerSymbol; markerSymbol.Color = color; break; } case esriGeometryType.esriGeometryPolyline: { ISimpleLineSymbol simpleLineSymbol = symbol as ISimpleLineSymbol; simpleLineSymbol.Color = color; break; } case esriGeometryType.esriGeometryPolygon: { IFillSymbol fillSymbol = symbol as IFillSymbol; fillSymbol.Color = color; break; } default: return(false); } ISimpleRenderer simpleRenderer = new SimpleRendererClass(); simpleRenderer.Symbol = symbol; IFeatureRenderer featureRender = simpleRenderer as IFeatureRenderer; if (featureRender == null) { return(false); } IGeoFeatureLayer geoFeatureLayer = featureLayer as IGeoFeatureLayer; geoFeatureLayer.Renderer = featureRender; return(true); }
private void MainForm_Load(object sender, EventArgs e) { m_mapControl = (IMapControl3) axMapControl1.Object; //relative file path to the sample data from EXE location string filePath = @"..\..\..\data\USAMajorHighways"; //Add Lakes layer IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactoryClass(); IFeatureWorkspace workspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(filePath, axMapControl1.hWnd); IFeatureLayer featureLayer = new FeatureLayerClass(); featureLayer.Name = "Lakes"; featureLayer.Visible = true; featureLayer.FeatureClass = workspace.OpenFeatureClass("us_lakes"); #region create a SimplerRenderer IRgbColor color = new RgbColorClass(); color.Red = 190; color.Green = 232; color.Blue = 255; ISimpleFillSymbol sym = new SimpleFillSymbolClass(); sym.Color = color; ISimpleRenderer renderer = new SimpleRendererClass(); renderer.Symbol = sym as ISymbol; #endregion ((IGeoFeatureLayer)featureLayer).Renderer = renderer as IFeatureRenderer; axMapControl1.Map.AddLayer((ILayer)featureLayer); //Add Highways layer featureLayer = new FeatureLayerClass(); featureLayer.Name = "Highways"; featureLayer.Visible = true; featureLayer.FeatureClass = workspace.OpenFeatureClass("usa_major_highways"); axMapControl1.Map.AddLayer((ILayer)featureLayer); //******** Important ************* //store a reference to this form (Mainform) using the EditHelper class EditHelper.TheMainForm = this; EditHelper.IsEditorFormOpen = false; //add the EditCmd command to the toolbar axEditorToolbar.AddItem("esriControls.ControlsOpenDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axEditorToolbar.AddItem("esriControls.ControlsSaveAsDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axEditorToolbar.AddItem("esriControls.ControlsAddDataCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axEditorToolbar.AddItem(new EditCmd(), 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); }
public SimpleRender(AxMapControl pMapcontrol, IFeatureLayer pFtLayer, String Field) { IGeoFeatureLayer pGeolayer; IActiveView pActiveView; pGeolayer = pFtLayer as IGeoFeatureLayer; pActiveView = pMapcontrol.ActiveView; IFillSymbol pFillSymbol; ILineSymbol pLineSymbol; pFillSymbol = new SimpleFillSymbolClass(); pFillSymbol.Color = GetRGBColor(220, 110, 200); pLineSymbol = new SimpleLineSymbolClass(); pLineSymbol.Color = GetRGBColor(255, 120, 105); pLineSymbol.Width = 2; pFillSymbol.Outline = pLineSymbol; ISimpleRenderer pSimpleRender;//��ʲô������Ⱦ pSimpleRender = new SimpleRendererClass(); pSimpleRender.Symbol = pFillSymbol as ISymbol ; pSimpleRender.Description = "China"; pSimpleRender.Label = "SimpleRender"; ITransparencyRenderer pTrans; pTrans = pSimpleRender as ITransparencyRenderer; pTrans.TransparencyField = Field; pGeolayer.Renderer = pTrans as IFeatureRenderer; pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); //����ͼ�����Ⱦ������һ��Ҫ����Ⱦ���������������һЩ��ض�����ɵġ� //����Ҳ��һ������˵�����������С������ɵġ� }
/// <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 axTOCControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ITOCControlEvents_OnMouseDownEvent e) { //Exit if not right mouse button if (e.button != 2) return; IBasicMap map = new MapClass(); ILayer layer = new FeatureLayerClass(); object other = new Object(); object index = new Object(); esriTOCControlItem item = new esriTOCControlItem(); //Determine what kind of item has been clicked on axTOCControl1.HitTest(e.x, e.y, ref item, ref map, ref layer, ref other, ref index); //QI to IFeatureLayer and IGeoFeatuerLayer interface if (layer == null) return; IFeatureLayer featureLayer = layer as IFeatureLayer; if (featureLayer == null) return; IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer) featureLayer; ISimpleRenderer simpleRenderer = (ISimpleRenderer) geoFeatureLayer.Renderer; //Create the form with the SymbologyControl frmSymbol symbolForm = new frmSymbol(); //Get the IStyleGalleryItem IStyleGalleryItem styleGalleryItem = null; //Select SymbologyStyleClass based upon feature type switch (featureLayer.FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassMarkerSymbols, simpleRenderer.Symbol); break; case esriGeometryType.esriGeometryPolyline: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassLineSymbols, simpleRenderer.Symbol); break; case esriGeometryType.esriGeometryPolygon: styleGalleryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassFillSymbols, simpleRenderer.Symbol); break; } //Release the form symbolForm.Dispose(); this.Activate(); if (styleGalleryItem == null) return; //Create a new renderer simpleRenderer = new SimpleRendererClass(); //Set its symbol from the styleGalleryItem simpleRenderer.Symbol = (ISymbol) styleGalleryItem.Item; //Set the renderer into the geoFeatureLayer geoFeatureLayer.Renderer = (IFeatureRenderer) simpleRenderer; //Fire contents changed event that the TOCControl listens to axPageLayoutControl1.ActiveView.ContentsChanged(); //Refresh the display axPageLayoutControl1.Refresh(esriViewDrawPhase.esriViewGeography, null, null); }
private void DataRefesh(DataType dataType) { var list = new List<string>(); var currentPeopleWidth = double.Parse(System.Configuration.ConfigurationManager.AppSettings["PEOPLEWIDTH1"]); switch (dataType) { case DataType.Road: list.Add(RoadName.GetLayer()); break; case DataType.BusLine: list.Add(BusLineName.GetLayer()); list.Add(BusStopName.GetLayer()); break; case DataType.Flow: list.Add(FlowName.GetLayer()); break; case DataType.Parking: list.Add(ParkingName.GetLayer()); break; case DataType.Bike: list.Add(BikeName.GetLayer()); break; case DataType.People: currentPeopleWidth= double.Parse(System.Configuration.ConfigurationManager.AppSettings["PEOPLEWIDTH2"]); break; } var simpleRenderer = new SimpleRendererClass(); simpleRenderer.Symbol = DisplayHelper.GetSimpleLineSymbol(DisplayHelper.GetRGBColor(178, 178, 178), currentPeopleWidth) as ISymbol; var roadBackLayerName = System.Configuration.ConfigurationManager.AppSettings["RoadBackground"]; if (dataType != DataType.Road) { list.Add(roadBackLayerName); } string Ignore = System.Configuration.ConfigurationManager.AppSettings["Ignore"]; short opacity = short.Parse(System.Configuration.ConfigurationManager.AppSettings["OPACITY2"]); var peopleOpacity = short.Parse(System.Configuration.ConfigurationManager.AppSettings["PEOPLEOPACITY"]); var allFeatureLayers = GetAllFeatureLayer(); var flag = false; var name = ""; foreach(var featureLayer in allFeatureLayers) { name = featureLayer.Name; flag = list.Contains(name); featureLayer.Visible = flag; if (flag) { if (name == roadBackLayerName) { var geoFeatureLayer = featureLayer as IGeoFeatureLayer; geoFeatureLayer.Renderer = simpleRenderer as IFeatureRenderer; } ILayerEffects layerEffects = featureLayer as ILayerEffects; layerEffects.Transparency = name == BusStopName.GetLayer() ? opacity : name == BusLineName.GetLayer() ? opacity : dataType == DataType.People && name == roadBackLayerName ? peopleOpacity : (short)0; } } #region //for (var i = 0; i < axMapControl1.Map.LayerCount; i++) //{ // layer = axMapControl1.Map.get_Layer(i); // if (layer.Name == Ignore) // { // continue; // } // if (layer is GroupLayer) // { // ICompositeLayer compositeLayer = layer as ICompositeLayer; // for (var j = 0; j < compositeLayer.Count; j++) // { // featureLayer = compositeLayer.get_Layer(j) as IFeatureLayer; // if (list.Contains(featureLayer.Name)) // { // featureLayer.Visible = true; // ILayerEffects layerEffects = featureLayer as ILayerEffects; // layerEffects.Transparency = featureLayer.Name == BusStopName.GetLayer() ? opacity : featureLayer.Name == BusLineName.GetLayer() ? opacity : (short)0; // } // else // { // featureLayer.Visible = false; // } // } // } // else if (layer is IFeatureLayer) // { // featureLayer = layer as IFeatureLayer; // if (list.Contains(featureLayer.Name)) // { // featureLayer.Visible = true; // ILayerEffects layerEffects = featureLayer as ILayerEffects; // layerEffects.Transparency = featureLayer.Name == BusLineName.GetLayer() ? opacity : featureLayer.Name == BusStopName.GetLayer() ? opacity : (short)0; // } // else // { // featureLayer.Visible = false; // } // } //} #endregion if (ExtentFeature != null) { axMapControl1.Extent = ExtentFeature.Shape.Envelope; } axMapControl1.ActiveView.Refresh(); }
protected void DoClip(IActiveView activeView, IFeatureLayer ifl_active, IGeometry geometry) { try { ESRI.ArcGIS.Carto.IMap map = activeView.FocusMap; ESRI.ArcGIS.Carto.ILayerFile layerFile = new ESRI.ArcGIS.Carto.LayerFileClass(); ISpatialFilter isf = new SpatialFilterClass(); isf.Geometry = geometry; isf.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; gd.Title = "Save clipped feature class"; gd.ObjectFilter = new GxFilterFeatureClassesClass(); //new GxFilterFeatureClassesClass(); if (gd.DoModalSave(ArcMap.Application.hWnd) == false) { return; } while (System.IO.File.Exists(gd.FinalLocation.FullName + "\\" + gd.Name) || gd.ReplacingObject) { if (System.Windows.Forms.MessageBox.Show("You've selected a feature class that already exists. Select a different feature class name.", "Overwrite Feature Class", System.Windows.Forms.MessageBoxButtons.RetryCancel) == System.Windows.Forms.DialogResult.Cancel) { return; } if (gd.DoModalSave(ArcMap.Application.hWnd) == false) { return; } } // Create a new in-memory workspace. This returns a name object. InMemoryWorkspaceFactory wsf = new InMemoryWorkspaceFactoryClass(); IWorkspaceName workspaceName = wsf.Create(null, "MyWorkspace", null, 0); IName name = (IName)workspaceName; IFeatureWorkspace workspace; IWorkspaceEdit iwe; IFields flds; setFeatureSpatialReference(ifl_active, name, out workspace, out iwe, out flds); IFeatureClass ifc_new = workspace.CreateFeatureClass("AAA", flds, null, null, esriFeatureType.esriFTSimple, ifl_active.FeatureClass.ShapeFieldName, ""); IFeatureLayer fl = new FeatureLayerClass(); IGeoFeatureLayer gfl = (IGeoFeatureLayer)fl; IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = 255; rgbColor.Green = 0; rgbColor.Blue = 0; IColor color = rgbColor; // Implicit Cast fl.FeatureClass = ifc_new; fl.Name = "IntersectingShape"; ISimpleFillSymbol sfs = new SimpleFillSymbolClass(); ISimpleLineSymbol sls = new SimpleLineSymbolClass(); sls.Color = color; sls.Width = 4.0; sls.Style = esriSimpleLineStyle.esriSLSSolid; color.NullColor = true; sfs.Color = color; sfs.Outline = sls; ISimpleRenderer isr = new SimpleRendererClass(); isr.Symbol = (ISymbol)sfs; gfl.Renderer = (IFeatureRenderer)isr; IObjectCopy cpy = new ObjectCopyClass(); iwe.StartEditing(true); iwe.StartEditOperation(); IFeatureBuffer fb = ifc_new.CreateFeatureBuffer(); IFeatureCursor csri = ifc_new.Insert(false); fb.Shape = geometry; csri.InsertFeature(fb); csri.Flush(); iwe.StopEditOperation(); iwe.StopEditing(true); map.AddLayer(fl); ESRI.ArcGIS.AnalysisTools.Clip tool = new ESRI.ArcGIS.AnalysisTools.Clip(); tool.clip_features = fl; tool.in_features = ifl_active; tool.out_feature_class = gd.FinalLocation.FullName + "\\" + gd.Name; /*ws.PathName*/ //"In_memory" + "\\NWI_Clip_Result"; gp.AddOutputsToMap = true; gp.OverwriteOutput = true; gp.ToolExecuted += new EventHandler<ToolExecutedEventArgs>(gp_ToolExecuted); gp.ProgressChanged += new EventHandler<ProgressChangedEventArgs>(gp_ProgressChanged); gp.ExecuteAsync(tool); } catch (Exception err) { } finally { SelectArrowToolOnToolbar(); } }
private void resultSymbologyTab() { IGeoFeatureLayer pGeoFeatureLayer = this.pLayer as IGeoFeatureLayer; TreeNode currentNode = this.trvSymbologyShows.SelectedNode; if (currentNode.Text == "单一符号") { if (this.singleSymbol == null) { return; } ISimpleRenderer pSimpleRender = new SimpleRendererClass(); pSimpleRender.Symbol = this.singleSymbol; pSimpleRender.Label = this.txtSingleSymbolLabel.Text; pSimpleRender.Description = this.txtSingleSymbolDescription.Text; pGeoFeatureLayer.Renderer = pSimpleRender as IFeatureRenderer; } else if (currentNode.Text == "唯一值") { if (this.lsvUniqueValue.Items.Count == 0 || this.pUniValueColorRamp == null) { return; } this.pUniValueColorRamp.Size = this.lsvUniqueValue.Items.Count - 1; bool IsColorRampCreatedOK = false; this.pUniValueColorRamp.CreateRamp(out IsColorRampCreatedOK); if (IsColorRampCreatedOK) { IEnumColors pEnumColors = pUniValueColorRamp.Colors; pEnumColors.Reset(); IUniqueValueRenderer pUniqueValueRender = new UniqueValueRendererClass(); pUniqueValueRender.FieldCount = 1; pUniqueValueRender.set_Field(0, this.cbbUniValueField.Text); IColor pColor; if (((IFeatureLayer2)this.pLayer).ShapeType == esriGeometryType.esriGeometryPolygon) { ISimpleFillSymbol pSimpleFillSymbol; for (int i = 0; i < pUniValueColorRamp.Size; i++) { pColor = pEnumColors.Next(); pSimpleFillSymbol = new SimpleFillSymbolClass(); pSimpleFillSymbol.Color = pColor; pUniqueValueRender.AddValue(this.lsvUniqueValue.Items[i + 1].Text, "", (ISymbol)pSimpleFillSymbol); } } else if (((IFeatureLayer2)this.pLayer).ShapeType == esriGeometryType.esriGeometryPolyline) { ISimpleLineSymbol pSimpleLineSymbol; for (int i = 0; i < pUniValueColorRamp.Size; i++) { pColor = pEnumColors.Next(); pSimpleLineSymbol = new SimpleLineSymbolClass(); pSimpleLineSymbol.Color = pColor; pUniqueValueRender.AddValue(this.lsvUniqueValue.Items[i + 1].Text, "", (ISymbol)pSimpleLineSymbol); } } else if (((IFeatureLayer2)this.pLayer).ShapeType == esriGeometryType.esriGeometryPoint) { ISimpleMarkerSymbol pSimpleMarkerSymbol; for (int i = 0; i < pUniValueColorRamp.Size; i++) { pColor = pEnumColors.Next(); pSimpleMarkerSymbol = new SimpleMarkerSymbolClass(); pSimpleMarkerSymbol.Color = pColor; pUniqueValueRender.AddValue(this.lsvUniqueValue.Items[i + 1].Text, "", (ISymbol)pSimpleMarkerSymbol); } } pGeoFeatureLayer.Renderer = (IFeatureRenderer)pUniqueValueRender; } } else if (currentNode.Text == "分级颜色") { if (this.lsvClassBreaksSymbol.Items.Count == 0 || this.pClassBreaksColorRamp == null) { return; } int classCount = int.Parse(this.cbbClassBreaksCount.Text); IClassBreaksRenderer pClassBreaksRenderer = new ClassBreaksRendererClass(); pClassBreaksRenderer.BreakCount = classCount; pClassBreaksRenderer.Field = this.cbbClassBreakField.Text; pClassBreaksRenderer.SortClassesAscending = true; IColorRamp pColorRamp = this.pClassBreaksColorRamp; pColorRamp.Size = classCount; bool ok; pColorRamp.CreateRamp(out ok); if (!ok) { return; } IEnumColors pEnumColors = pColorRamp.Colors; pEnumColors.Reset(); IColor pColor; if (((IFeatureLayer2)this.pLayer).ShapeType == esriGeometryType.esriGeometryPolygon) { for (int i = 0; i < classCount; i++)//为每个值范围设置符号(此处为SimpleFillSymbol) { pColor = pEnumColors.Next(); ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass(); pSimpleFillSymbol.Color = pColor; pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid; pClassBreaksRenderer.set_Break(i, this.classBreaks[i + 1]);//设置临界值,注意下标,关键!!! pClassBreaksRenderer.set_Symbol(i, (ISymbol)pSimpleFillSymbol);//设置Symbol,关键!!! pClassBreaksRenderer.set_Label(i, this.lsvClassBreaksSymbol.Items[i].Text); pClassBreaksRenderer.set_Description(i, this.lsvClassBreaksSymbol.Items[i].Text); } } else if (((IFeatureLayer2)this.pLayer).ShapeType == esriGeometryType.esriGeometryPolyline) { for (int i = 0; i < classCount; i++)//为每个值范围设置符号 { pColor = pEnumColors.Next(); ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass(); pSimpleLineSymbol.Color = pColor; pClassBreaksRenderer.set_Symbol(i, (ISymbol)pSimpleLineSymbol);//设置Symbol,关键!!! pClassBreaksRenderer.set_Label(i, this.lsvClassBreaksSymbol.Items[i].Text); pClassBreaksRenderer.set_Break(i, this.classBreaks[i + 1]);//设置临界值,注意下标,关键!!! } } else if (((IFeatureLayer2)this.pLayer).ShapeType == esriGeometryType.esriGeometryPoint) { for (int i = 0; i < classCount; i++)//为每个值范围设置符号 { pColor = pEnumColors.Next(); ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass(); pSimpleMarkerSymbol.Color = pColor; pClassBreaksRenderer.set_Symbol(i, (ISymbol)pSimpleMarkerSymbol);//设置Symbol,关键!!! pClassBreaksRenderer.set_Label(i, this.lsvClassBreaksSymbol.Items[i].Text); pClassBreaksRenderer.set_Break(i, this.classBreaks[i + 1]);//设置临界值,注意下标,关键!!! } } pGeoFeatureLayer.Renderer = pClassBreaksRenderer as IFeatureRenderer; } }
/// <summary> /// 渲染符号的样式为瓦斯压力点 /// </summary> /// <param name="pfeature"></param> /// <param name="ge"></param> private void RenderfeatureLayer(IFeatureLayer featureLayer, ISymbol layerSymbols) { ISimpleRenderer pRenderer=new SimpleRendererClass(); pRenderer.Symbol=layerSymbols; (featureLayer as IGeoFeatureLayer).Renderer = pRenderer as IFeatureRenderer;//渲染图层; }
/// <summary> /// Loads and symbolizes data used by the application. Selects a city and zooms to it /// </summary> private void SetupMap() { try { //Relative path to the sample data from EXE location string dirPath = @"..\..\..\..\..\data\USZipCodeData"; //Create the cities layer IFeatureClass cities = _gp.Open(dirPath + @"\ZipCode_Boundaries_US_Major_Cities.shp") as IFeatureClass; IFeatureLayer citiesLayer = new FeatureLayerClass(); citiesLayer.FeatureClass = cities; citiesLayer.Name = "Major Cities"; //Create he zip code boundaries layer IFeatureClass zipBndrys = _gp.Open(dirPath + @"\US_ZipCodes.shp") as IFeatureClass; IFeatureLayer zipBndrysLayer = new FeatureLayerClass(); zipBndrysLayer.FeatureClass = zipBndrys; zipBndrysLayer.Name = "Zip Code boundaries"; //Create the highways layer dirPath = @"..\..\..\..\..\data\USAMajorHighways"; IFeatureClass highways = _gp.Open(dirPath + @"\usa_major_highways.shp") as IFeatureClass; IFeatureLayer highwaysLayer = new FeatureLayerClass(); highwaysLayer.FeatureClass = highways; highwaysLayer.Name = "Highways"; //***** Important code ********* //Add the layers to a dictionary. Layers can then easily be returned by their 'key' _layersDict.Add("ZipCodes", zipBndrysLayer); _layersDict.Add("Highways", highwaysLayer); _layersDict.Add("Cities", citiesLayer); #region Symbolize and set additional properties for each layer //Setup and symbolize the cities layer citiesLayer.Selectable = true; citiesLayer.ShowTips = true; ISimpleMarkerSymbol markerSym = CreateSimpleMarkerSymbol(CreateRGBColor(0, 92, 230), esriSimpleMarkerStyle.esriSMSCircle); markerSym.Size = 9; ISimpleRenderer simpleRend = new SimpleRendererClass(); simpleRend.Symbol = (ISymbol)markerSym; ((IGeoFeatureLayer)citiesLayer).Renderer = (IFeatureRenderer)simpleRend; //Setup and symbolize the zip boundaries layer zipBndrysLayer.Selectable = false; ISimpleFillSymbol fillSym = CreateSimpleFillSymbol(CreateRGBColor(0, 0, 0), esriSimpleFillStyle.esriSFSHollow, CreateRGBColor(204, 204, 204), esriSimpleLineStyle.esriSLSSolid, 0.5); ISimpleRenderer simpleRend2 = new SimpleRendererClass(); simpleRend2.Symbol = (ISymbol)fillSym; ((IGeoFeatureLayer)zipBndrysLayer).Renderer = (IFeatureRenderer)simpleRend2; //Setup and symbolize the highways layer highwaysLayer.Selectable = false; ISimpleLineSymbol lineSym = CreateSimpleLineSymbol(CreateRGBColor(250, 52, 17), 3.4, esriSimpleLineStyle.esriSLSSolid); ISimpleRenderer simpleRend3 = new SimpleRendererClass(); simpleRend3.Symbol = (ISymbol)lineSym; ((IGeoFeatureLayer)highwaysLayer).Renderer = (IFeatureRenderer)simpleRend3; #endregion //Add the layers to the Map foreach (IFeatureLayer layer in _layersDict.Values) { axMapControl1.AddLayer((ILayer)layer); } #region select city and set map extent //Select and zoom in on Los Angeles city IQueryFilter qf = new QueryFilterClass(); qf.WhereClause = "NAME='Los Angeles'"; IFeatureSelection citiesLayerSelection = (IFeatureSelection)citiesLayer; citiesLayerSelection.SelectFeatures(qf, esriSelectionResultEnum.esriSelectionResultNew, true); IFeature laFeature = cities.GetFeature(citiesLayerSelection.SelectionSet.IDs.Next()); IEnvelope env = laFeature.Shape.Envelope; env.Expand(0.5, 0.5, false); axMapControl1.Extent = env; axMapControl1.Refresh(); axTOCControl1.Update(); #endregion //Enable GP analysis button btnRunGP.Enabled = true; } catch (Exception ex) { MessageBox.Show("There was an error loading the data used by this sample: " + ex.Message); } }
/// <summary> /// Creates a Temporal Layer using the specified feature class and add it to the map. /// </summary> /// <param name="featureClass">The feature class to use for the temporal layer.</param> /// <param name="eventFieldName">Indicates the feature class column that identifies or groups temporal observations with time series.</param> /// <param name="temporalFieldName">Identifies the temporal field, which must be a field type whose data can be converted to a date value.</param> private void AddTemporalLayer(IFeatureClass featureClass, string eventFieldName, string temporalFieldName) { ITemporalLayer temporalFeatureLayer = new TemporalFeatureLayerClass(); IFeatureLayer2 featureLayer = temporalFeatureLayer as IFeatureLayer2; ILayer layer = temporalFeatureLayer as ILayer; ITemporalRenderer temporalRenderer = new CoTrackSymbologyRendererClass(); ITemporalRenderer2 temporalRenderer2 = (ITemporalRenderer2)temporalRenderer; IFeatureRenderer featureRenderer = temporalRenderer as IFeatureRenderer; ITrackSymbologyRenderer trackRenderer = temporalRenderer as ITrackSymbologyRenderer; if (featureLayer != null) { featureLayer.FeatureClass = featureClass; } if (featureRenderer != null) { temporalRenderer.TemporalObjectColumnName = eventFieldName; temporalRenderer.TemporalFieldName = temporalFieldName; temporalFeatureLayer.Renderer = featureRenderer; } if (trackRenderer != null) { //Create green color value IRgbColor rgbColor = new RgbColorClass(); rgbColor.RGB = 0x00FF00; //Create simple thin green line ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Color = (IColor)rgbColor; simpleLineSymbol.Width = 1.0; //Create simple renderer using line symbol ISimpleRenderer simpleRenderer = new SimpleRendererClass(); simpleRenderer.Symbol = (ISymbol)simpleLineSymbol; //Apply line renderer as track symbol and enable track rendering trackRenderer.TrackSymbologyRenderer = (IFeatureRenderer)simpleRenderer; trackRenderer.ShowTrackSymbologyLegendGroup = true; temporalRenderer2.TrackRendererEnabled = true; } if (layer != null) { ArcMap.Document.FocusMap.AddLayer(layer); } }
/// <summary> /// 显示符号选择器 /// </summary> private void ShowSymbolSelectForm() { ISimpleRenderer currentSimpleRender; IMapControlDefault pMapControl = m_hookHelper.Hook as IMapControlDefault; IGeoFeatureLayer pGeoFeatureLayer = pMapControl.CustomProperty as IGeoFeatureLayer; if (pGeoFeatureLayer == null) { return; } currentSimpleRender = pGeoFeatureLayer.Renderer as ISimpleRenderer; SymbolForm symbolForm = new SymbolForm(currentSimpleRender); IStyleGalleryItem styleGallryItem = null; switch (pGeoFeatureLayer.FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: styleGallryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassMarkerSymbols); break; case esriGeometryType.esriGeometryPolyline: styleGallryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassLineSymbols); break; case esriGeometryType.esriGeometryPolygon: styleGallryItem = symbolForm.GetItem(esriSymbologyStyleClass.esriStyleClassFillSymbols); break; } symbolForm.Dispose(); if (styleGallryItem == null) { return; } ISimpleRenderer simpleRender = new SimpleRendererClass(); simpleRender.Symbol = styleGallryItem.Item as ISymbol; pGeoFeatureLayer.Renderer = simpleRender as IFeatureRenderer; pMapControl.Refresh(esriViewDrawPhase.esriViewGeography, null, null); SymbolChanged(); }
protected override void OnPageApply() { base.OnPageApply(); PropertySheet propSheet = Objects[0] as PropertySheet; IFeatureLayer layer = propSheet.FeatureLayer; if (null == layer) return; if (m_styleGalleryItem == null) return; IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer)layer; //Create a new renderer ISimpleRenderer simpleRenderer = new SimpleRendererClass(); //Set its symbol from the styleGalleryItem simpleRenderer.Symbol = (ISymbol)m_styleGalleryItem.Item; //Set the renderer into the geoFeatureLayer geoFeatureLayer.Renderer = (IFeatureRenderer)simpleRenderer; //Make the PropertyPage class fire an event notifying that the layer's renderer has changed propSheet.FireFeatureLayerRendererChanged(); }
protected override void OnClick() { // Create two points. IPoint fromPoint = new Point(); fromPoint.PutCoords(1300757, 554219); IPoint toPoint = new Point(); toPoint.PutCoords(1300759, 554217); // Note: Spatial Reference = NAD_1983_StatePlane_Washington_North_FIPS_4601_Feet // ****** No Need to go through IPointCollection **** //// Add the points to a point collection //object missing = Type.Missing; //IPointCollection pointCollection = new Multipoint(); //pointCollection.AddPoint(fromPoint, ref missing, ref missing); //pointCollection.AddPoint(toPoint, ref missing, ref missing); // ****** No Need to go through IPointCollection **** // Get a reference to a feature class from ArcMap IMap map = ArcMap.Document.ActiveView as IMap; ILayer layer = map.get_Layer(0); IFeatureLayer featureLayer = layer as FeatureLayer; IFeatureClass featureClass = featureLayer.FeatureClass; IFeature feature = featureClass.CreateFeature(); IPolyline polyline = new PolylineClass(); polyline.FromPoint = fromPoint; polyline.ToPoint = toPoint; //IPolyline polyline = pointCollection as IPolyline; // This leads to a null polyline feature.Shape = polyline as IGeometry; feature.Store(); // ---- Symbolize the polyline with the ArrorMarker at both ends of the line ----------- // See: http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#//0001000008w8000000 ICartographicLineSymbol ipArrowLineSymbol = new CartographicLineSymbol(); // the line color will be red IRgbColor ipRgbRedColor = new RgbColorClass(); ipRgbRedColor.Red = 192; // the arrow will be black IRgbColor ipRgbBlackColor = new RgbColorClass(); ipRgbBlackColor.RGB = 0; // set up the arrow that will be displayed along the line IArrowMarkerSymbol ipArrowMarker = new ArrowMarkerSymbolClass(); ipArrowMarker.Style = esriArrowMarkerStyle.esriAMSPlain; ipArrowMarker.Length = 18; ipArrowMarker.Width = 12; ipArrowMarker.Color = ipRgbBlackColor; // set up the line itself ipArrowLineSymbol.Width = 4; ipArrowLineSymbol.Color = ipRgbRedColor; // decorate the line with the arrow symbol ISimpleLineDecorationElement ipSimpleLineDecorationElement = new SimpleLineDecorationElementClass(); ipSimpleLineDecorationElement.Rotate = true; ipSimpleLineDecorationElement.PositionAsRatio = true; ipSimpleLineDecorationElement.MarkerSymbol = ipArrowMarker; ipSimpleLineDecorationElement.AddPosition(0.0); ipSimpleLineDecorationElement.AddPosition(1.0); ipSimpleLineDecorationElement.FlipFirst = true; ILineDecoration ipLineDecoration = new LineDecorationClass(); ipLineDecoration.AddElement(ipSimpleLineDecorationElement); ((ILineProperties)ipArrowLineSymbol).LineDecoration = ipLineDecoration; // Create renderer and apply it to the layer ISimpleRenderer simpleRenderer = new SimpleRendererClass(); simpleRenderer.Symbol = ipArrowLineSymbol as ISymbol; IGeoFeatureLayer geoFeatureLayer = featureLayer as IGeoFeatureLayer; geoFeatureLayer.Renderer = simpleRenderer as IFeatureRenderer; IMxDocument mxDocument = ArcMap.Application.Document as IMxDocument; mxDocument.ActiveView.Refresh(); mxDocument.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, geoFeatureLayer, mxDocument.ActiveView.Extent); mxDocument.UpdateContents(); // ---- Symbolize the polyline with the ArrorMarker at both ends of the line ----------- ArcMap.Application.CurrentTool = null; }
private void btnSimpleRender_Click(object sender, EventArgs e) { ISimpleFillSymbol pSimpleFillSym = new SimpleFillSymbolClass(); pSimpleFillSym.Color = getRGBColor(255, 0, 0); pSimpleFillSym.Style = esriSimpleFillStyle.esriSFSSolid; ISimpleRenderer pSimpleRender = new SimpleRendererClass(); pSimpleRender.Symbol = pSimpleFillSym as ISymbol; pSimpleRender.Label = "haha"; pSimpleRender.Description = "hoho"; ITransparencyRenderer pTransRenderer = pSimpleRender as ITransparencyRenderer; pTransRenderer.TransparencyField = "GDP_1999(";//透明字段 IGeoFeatureLayer pGeoFeatLyr = this.mainMapControl.get_Layer(0) as IGeoFeatureLayer; pGeoFeatLyr.Renderer = pTransRenderer as IFeatureRenderer; this.mainMapControl.Refresh(esriViewDrawPhase.esriViewBackground, null, null); //this.axTOCControl.SetBuddyControl(this.mainMapControl.Object); this.axTOCControl.Update(); }
private void Form1_Load(object sender, System.EventArgs e) { //Find sample data by navigating two folders up string sFilePath = @"..\..\..\Data\World\Continents.lyr"; //Add sample 'country' shapefile data axMapControl1.AddLayerFromFile(sFilePath); //Set the extent axMapControl1.Extent = axMapControl1.get_Layer(0).AreaOfInterest; //Grab hold of the IgeoFeaturelayer interface on the layer //in the map control in order to symbolize the data IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer) axMapControl1.get_Layer(0); //Create a simple renderer and grab hold of ISimpleRenderer interface ISimpleRenderer simpleRenderer = new SimpleRendererClass(); //Create a fill symbol and grab hold of the ISimpleFillSymbol interface ISimpleFillSymbol fillSymbol = new SimpleFillSymbolClass(); //Create a line symbol and grab hold of the ISimpleLineSymbol interface ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass(); //Assign line symbol and fill symbol properties lineSymbol.Width = 0.1; lineSymbol.Color = GetRGBColor(255, 0, 0); //Red fillSymbol.Outline = lineSymbol; fillSymbol.Color = GetRGBColor(0, 0, 255); //Blue //Set the symbol property of the renderer simpleRenderer.Symbol = (ISymbol) fillSymbol; //Set the renderer property of the geo feature layer geoFeatureLayer.Renderer = (IFeatureRenderer) simpleRenderer; }
/// <summary> /// GetRenderer will return a feature renderer with symbology appropriate to the specified element type /// </summary> private IFeatureRenderer GetRenderer(esriNetworkElementType networkElementType) { ISimpleRenderer simpleRend = new SimpleRendererClass(); IRgbColor color = new RgbColorClass(); switch (networkElementType) { // The junction symbology will be a large yellow circle with a thick black outline case esriNetworkElementType.esriNETJunction: ISimpleMarkerSymbol junctionPointSymbol = new SimpleMarkerSymbolClass(); junctionPointSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; junctionPointSymbol.Size = 10; //yellow color.Red = 255; color.Blue = 0; color.Green = 255; junctionPointSymbol.Color = color; junctionPointSymbol.Outline = true; junctionPointSymbol.OutlineSize = 2; //black color.Red = 0; color.Blue = 0; color.Green = 0; junctionPointSymbol.OutlineColor = color; simpleRend.Label = "TRFC_Junctions"; simpleRend.Symbol = junctionPointSymbol as ISymbol; return simpleRend as IFeatureRenderer; // The turn symbology will be a thick purple line case esriNetworkElementType.esriNETTurn: ISimpleLineSymbol turnLineSymbol = new SimpleLineSymbolClass(); turnLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; turnLineSymbol.Width = 4; //purple color.Red = 125; color.Blue = 125; color.Green = 0; turnLineSymbol.Color = color; simpleRend.Label = "TRFC_Turns"; simpleRend.Symbol = turnLineSymbol as ISymbol; return simpleRend as IFeatureRenderer; // The edge symbology will be a thick blue line case esriNetworkElementType.esriNETEdge: ISimpleLineSymbol edgeLineSymbol = new SimpleLineSymbolClass(); edgeLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; edgeLineSymbol.Width = 4; //blue color.Red = 0; color.Blue = 255; color.Green = 0; edgeLineSymbol.Color = color; simpleRend.Label = "TRFC_Edges"; simpleRend.Symbol = edgeLineSymbol as ISymbol; return simpleRend as IFeatureRenderer; } return null; }
private void SymbolizeData(ILayer layer, double dWidth, IRgbColor colorLine, IRgbColor colorFill) { //Create a line symbol and get the ILineSymbol interface ILineSymbol lineSymbol = new SimpleLineSymbolClass(); //Set the line symbol properties lineSymbol.Width = dWidth; lineSymbol.Color = colorLine; //Create a fill symbol and get the IFillSymbol interface ISimpleFillSymbol fillSymbol = new SimpleFillSymbolClass(); //Set the fill symbol properties fillSymbol.Outline = lineSymbol; fillSymbol.Color = colorFill; //Create a simple renderer and get the ISimpleRenderer interface ISimpleRenderer simpleRenderer = new SimpleRendererClass(); //Set the simple renderer properties simpleRenderer.Symbol = (ISymbol) fillSymbol; //QI for the IGeoFeatureLayer interface from the ILayer2 interface IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer) layer; //Set the GeoFeatureLayer properties geoFeatureLayer.Renderer = (IFeatureRenderer) simpleRenderer; }