public static IFeatureRenderer HideSymbolOfLayer(IGeoFeatureLayer pGeoFeatureLayer) { IFeatureRenderer pFeatureRenderer = pGeoFeatureLayer.Renderer; ISymbol pSymbol = null; if (pFeatureRenderer is ISimpleRenderer) { ISimpleRenderer pSimpleRender = pFeatureRenderer as ISimpleRenderer; pSimpleRender.Symbol = null; //pSymbol = pSimpleRender.Symbol; //SetSymbolNoColor(pGeoFeatureLayer, ref pSymbol); //pSimpleRender.Symbol = pSymbol; return(pSimpleRender as IFeatureRenderer); } else if (pFeatureRenderer is IUniqueValueRenderer) { IUniqueValueRenderer pUniqueRender = pFeatureRenderer as IUniqueValueRenderer; for (int i = 0; i < pUniqueRender.ValueCount; i++) { string sValue = pUniqueRender.get_Value(i); pUniqueRender.set_Symbol(sValue, null); //pSymbol = pUniqueRender.get_Symbol(sValue); //SetSymbolNoColor(pGeoFeatureLayer, ref pSymbol); //pUniqueRender.set_Symbol(sValue, pSymbol); } return(pUniqueRender as IFeatureRenderer); } else if (pFeatureRenderer is IClassBreaksRenderer) { IClassBreaksRenderer pClassRenderer = pFeatureRenderer as IClassBreaksRenderer; for (int i = 0; i < pClassRenderer.BreakCount; i++) { pClassRenderer.set_Symbol(i, null); } pClassRenderer.BackgroundSymbol = null; return(pClassRenderer as IFeatureRenderer); } else if (pFeatureRenderer is IProportionalSymbolRenderer) { } else if (pFeatureRenderer is IChartRenderer) { IChartRenderer pChartRenderer = pFeatureRenderer as IChartRenderer; pChartRenderer.BaseSymbol = null; pChartRenderer.ChartSymbol = null; } return(null); }
//目前只支持简单符号和质地填充符号 public static IFeatureRenderer SetColorOfRenderer(IGeoFeatureLayer pGeoFeatureLayer, IRgbColor pFillRgbColor, IRgbColor pBorderColor, double PointSize, double LineWidth) { IFeatureRenderer pFeatureRenderer = pGeoFeatureLayer.Renderer; ISymbol pSymbol = null; if (pFeatureRenderer is ISimpleRenderer) { ISimpleRenderer pSimpleRender = pFeatureRenderer as ISimpleRenderer; pSymbol = pSimpleRender.Symbol; SetSymbolColor(pGeoFeatureLayer, ref pSymbol, pFillRgbColor, pBorderColor, PointSize, LineWidth); pSimpleRender.Symbol = pSymbol; return(pSimpleRender as IFeatureRenderer); } else if (pFeatureRenderer is IUniqueValueRenderer) { IUniqueValueRenderer pUniqueRender = pFeatureRenderer as IUniqueValueRenderer; for (int i = 0; i < pUniqueRender.ValueCount; i++) { string sValue = pUniqueRender.get_Value(i); pSymbol = pUniqueRender.get_Symbol(sValue); SetSymbolColor(pGeoFeatureLayer, ref pSymbol, pFillRgbColor, pBorderColor, PointSize, LineWidth); pUniqueRender.set_Symbol(sValue, pSymbol); } return(pUniqueRender as IFeatureRenderer); } else if (pFeatureRenderer is IClassBreaksRenderer) { } else if (pFeatureRenderer is IProportionalSymbolRenderer) { } else if (pFeatureRenderer is IChartRenderer) { } return(null); }
private void btnok_Click(object sender, EventArgs e) { if (treeshow.SelectedIndex == 0) { if (treeadd.SelectedNode == null) { MessageBox.Show("请选择要添加的值", "提示", MessageBoxButtons.OK); } else { string strnode = ""; strnode = treeadd.SelectedNode.Text; if (pFClass.ShapeType == esriGeometryType.esriGeometryPolygon) { IClone pSourceClone = pSimpleFillSymbol as IClone; ISimpleFillSymbol pSimpleFillSymb = pSourceClone.Clone() as ISimpleFillSymbol; pUniquerender.AddValue(strnode, "唯一值渲染", (ISymbol)pSimpleFillSymb); ISimpleFillSymbol pNextSymbol = pUniquerender.get_Symbol(strnode) as ISimpleFillSymbol; pNextSymbol.Color = coloru[treeadd.SelectedIndex]; pUniquerender.set_Symbol(strnode, (ISymbol)pNextSymbol); DataRow rowu = dtable2.NewRow(); rowu[1] = strnode; rowu[2] = strnode; rowu[3] = cuntu[treeadd.SelectedIndex]; dtable2.Rows.Add(rowu); gridviewu.Rows[gridviewu.Rows.Count - 2].Cells[0].Style.BackColor = ClsGDBDataCommon.IColorToColor(pNextSymbol.Color); } else if (pFClass.ShapeType == esriGeometryType.esriGeometryLine || pFClass.ShapeType == esriGeometryType.esriGeometryPolyline) { IClone pSourceClone = pLineSymbol as IClone; ISimpleLineSymbol pSimpleFillSymb = pSourceClone.Clone() as ISimpleLineSymbol; pUniquerender.AddValue(strnode, "唯一值渲染", (ISymbol)pSimpleFillSymb); ISimpleLineSymbol pNextSymbol = pUniquerender.get_Symbol(strnode) as ISimpleLineSymbol; pNextSymbol.Color = coloru[treeadd.SelectedIndex]; pUniquerender.set_Symbol(strnode, (ISymbol)pNextSymbol); DataRow rowu = dtable2.NewRow(); rowu[1] = strnode; rowu[2] = strnode; rowu[3] = cuntu[treeadd.SelectedIndex]; dtable2.Rows.Add(rowu); gridviewu.Rows[gridviewu.Rows.Count - 2].Cells[0].Style.BackColor = ClsGDBDataCommon.IColorToColor(pNextSymbol.Color); } else { IClone pSourceClone = pPointSymbol as IClone; ISimpleMarkerSymbol pSimpleFillSymb = pSourceClone.Clone() as ISimpleMarkerSymbol; pUniquerender.AddValue(strnode, "唯一值渲染", (ISymbol)pSimpleFillSymb); ISimpleMarkerSymbol pNextSymbol = pUniquerender.get_Symbol(strnode) as ISimpleMarkerSymbol; pNextSymbol.Color = coloru[treeadd.SelectedIndex]; pUniquerender.set_Symbol(strnode, (ISymbol)pNextSymbol); DataRow rowu = dtable2.NewRow(); rowu[1] = strnode; rowu[2] = strnode; rowu[3] = cuntu[treeadd.SelectedIndex]; dtable2.Rows.Add(rowu); gridviewu.Rows[gridviewu.Rows.Count - 2].Cells[0].Style.BackColor = ClsGDBDataCommon.IColorToColor(pNextSymbol.Color); } addvx.Remove(addvx[treeadd.SelectedIndex]); coloru.Remove(coloru[treeadd.SelectedIndex]); countu.Add(cuntu[treeadd.SelectedIndex]); cuntu.Remove(cuntu[treeadd.SelectedIndex]); treeadd.Nodes[treeadd.SelectedIndex].Remove(); treeadd.SelectedNode = null; gridviewu.CurrentCell = null; } } else { if (treeadd.SelectedNode == null) { MessageBox.Show("请选择要添加的值", "提示", MessageBoxButtons.OK); } else { string strnode = ""; strnode = treeadd.SelectedNode.Text; if (pFClass.ShapeType == esriGeometryType.esriGeometryPolygon) { IClone pSourceClone = pSimpleFillSymbol as IClone; ISimpleFillSymbol pSimpleFillSymb = pSourceClone.Clone() as ISimpleFillSymbol; pUniquerendermu.AddValue(strnode, "唯一值渲染", (ISymbol)pSimpleFillSymb); ISimpleFillSymbol pNextSymbol = pUniquerendermu.get_Symbol(strnode) as ISimpleFillSymbol; pNextSymbol.Color = colorumu[treeadd.SelectedIndex]; pUniquerendermu.set_Symbol(strnode, (ISymbol)pNextSymbol); DataRow rowu = dtable3.NewRow(); rowu[1] = strnode; rowu[2] = strnode; rowu[3] = cuntumu[treeadd.SelectedIndex]; dtable3.Rows.Add(rowu); gridviewmu.Rows[gridviewmu.Rows.Count - 2].Cells[0].Style.BackColor = ClsGDBDataCommon.IColorToColor(pNextSymbol.Color); } else if (pFClass.ShapeType == esriGeometryType.esriGeometryLine || pFClass.ShapeType == esriGeometryType.esriGeometryPolyline) { IClone pSourceClone = pLineSymbol as IClone; ISimpleLineSymbol pSimpleFillSymb = pSourceClone.Clone() as ISimpleLineSymbol; pUniquerendermu.AddValue(strnode, "唯一值渲染", (ISymbol)pSimpleFillSymb); ISimpleLineSymbol pNextSymbol = pUniquerendermu.get_Symbol(strnode) as ISimpleLineSymbol; pNextSymbol.Color = colorumu[treeadd.SelectedIndex]; pUniquerendermu.set_Symbol(strnode, (ISymbol)pNextSymbol); DataRow rowu = dtable3.NewRow(); rowu[1] = strnode; rowu[2] = strnode; rowu[3] = cuntumu[treeadd.SelectedIndex]; dtable3.Rows.Add(rowu); gridviewmu.Rows[gridviewmu.Rows.Count - 2].Cells[0].Style.BackColor = ClsGDBDataCommon.IColorToColor(pNextSymbol.Color); } else { IClone pSourceClone = pPointSymbol as IClone; ISimpleMarkerSymbol pSimpleFillSymb = pSourceClone.Clone() as ISimpleMarkerSymbol; pUniquerendermu.AddValue(strnode, "唯一值渲染", (ISymbol)pSimpleFillSymb); ISimpleMarkerSymbol pNextSymbol = pUniquerendermu.get_Symbol(strnode) as ISimpleMarkerSymbol; pNextSymbol.Color = colorumu[treeadd.SelectedIndex]; pUniquerendermu.set_Symbol(strnode, (ISymbol)pNextSymbol); DataRow rowu = dtable3.NewRow(); rowu[1] = strnode; rowu[2] = strnode; rowu[3] = cuntumu[treeadd.SelectedIndex]; dtable3.Rows.Add(rowu); gridviewmu.Rows[gridviewmu.Rows.Count - 2].Cells[0].Style.BackColor = ClsGDBDataCommon.IColorToColor(pNextSymbol.Color); } addvxmu.Remove(addvxmu[treeadd.SelectedIndex]); colorumu.Remove(colorumu[treeadd.SelectedIndex]); countumu.Add(cuntumu[treeadd.SelectedIndex]); cuntumu.Remove(cuntumu[treeadd.SelectedIndex]); treeadd.Nodes[treeadd.SelectedIndex].Remove(); treeadd.SelectedNode = null; gridviewmu.CurrentCell = null; } } }