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; } }
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; } }