/// <summary> /// 获取唯一值渲染方式中指定序号中符号对应的值 /// </summary> /// <param name="Renderer"></param> /// <param name="Index"></param> /// <returns></returns> public static IList <string> getUVFieldValues(IUniqueValueRenderer Renderer, int Index) { IList <string> Fieldvalues = new List <string>(); int iFieldCount = 0; int Index2 = 0; iFieldCount = Renderer.FieldCount; if (iFieldCount > 0) { string Label = string.Empty; string Label2 = string.Empty; ISymbol objSymbol = default(ISymbol); int iNumberOfSymbols = Renderer.ValueCount; Label = Renderer.Label[Renderer.Value[Index]]; Fieldvalues.Add(Renderer.Value[Index]); Index2 = Index + 1; while (Index2 < iNumberOfSymbols) { objSymbol = Renderer.Symbol[Renderer.Value[Index2]]; Label2 = Renderer.Label[Renderer.Value[Index2]]; if (objSymbol == null && Label == Label2) { Fieldvalues.Add(Renderer.Value[Index2]); } else { break; } Index2++; } } return(Fieldvalues); }
protected override void OnClick() { // Clear all layers from the TOC ArcMap.Document.FocusMap.ClearLayers(); // Open the data included with the sample IFeatureLayer packageLayer = OpenLayerPackage(LPK); packageLayer.Name = "Initial Layer"; // Add the original layer to the map document ArcMap.Document.FocusMap.AddLayer(packageLayer); IFeatureLayer updatedLayer = OpenLayerPackage(LPK); updatedLayer.Name = "Updated Layer"; // Add the updated layer to the map ArcMap.Document.FocusMap.AddLayer(updatedLayer); // Refresh the display ArcMap.Document.ActiveView.Refresh(); ArcMap.Document.ActiveView.ContentsChanged(); // Generate the unique value renderer using DataStatistics IUniqueValueRenderer uvRenderer = GenerateUniqueValueRenderer(packageLayer); // Update the layers symbology ((IGeoFeatureLayer)ArcMap.Document.FocusMap.Layer[0]).Renderer = (IFeatureRenderer)uvRenderer; // Force refresh of the TOC ArcMap.Document.ActiveView.ContentsChanged(); }
//地图渲染 private void btnRender_Click(object sender, EventArgs e) { IGeoFeatureLayer PGeoFeatureLayer = (IGeoFeatureLayer)axMapControl1.get_Layer(0); IUniqueValueRenderer pUniqueValueRenderer = CreateTrackUniqueValueRenderer(PGeoFeatureLayer.FeatureClass, "TYPE"); PGeoFeatureLayer.Renderer = (IFeatureRenderer)pUniqueValueRenderer; axMapControl1.ActiveView.Refresh(); axTOCControl1.SetActiveView(axTOCControl1.ActiveView); }
private void method_0() { if (this.ilayer_0 == null) { this.iuniqueValueRenderer_0 = null; } else { IAttributeTable table = this.ilayer_0 as IAttributeTable; if (table == null) { this.int_0 = 50; } else { int num = table.AttributeTable.RowCount(null); if (num > 100) { this.int_0 = 100; } else { this.int_0 = (int)num; } } if (this.ilayer_0 is IGeoFeatureLayer) { IUniqueValueRenderer pInObject = (this.ilayer_0 as IGeoFeatureLayer).Renderer as IUniqueValueRenderer; if (pInObject == null) { if (this.iuniqueValueRenderer_0 == null) { this.iuniqueValueRenderer_0 = new UniqueValueRendererClass(); this.iuniqueValueRenderer_0.FieldCount = 1; this.iuniqueValueRenderer_0.DefaultLabel = "默认符号"; this.iuniqueValueRenderer_0.DefaultSymbol = this.method_6((this.ilayer_0 as IGeoFeatureLayer).FeatureClass.ShapeType); this.iuniqueValueRenderer_0.UseDefaultSymbol = true; this.iuniqueValueRenderer_0.FieldDelimiter = ","; } } else { IObjectCopy copy = new ObjectCopyClass(); this.iuniqueValueRenderer_0 = copy.Copy(pInObject) as IUniqueValueRenderer; if (this.iuniqueValueRenderer_0.FieldDelimiter == "") { this.iuniqueValueRenderer_0.FieldDelimiter = ","; } } } } }
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); }
/// <summary> /// 获取指定图层的所有标志值 /// </summary> /// <param name="pfLayer">图层</param> /// <param name="sArrValues">所有标志值</param> /// <returns>是否存在分层字段</returns> public static bool GetUniqueValues(IFeatureLayer pfLayer, out string[] sArrValues) { IGeoFeatureLayer pGeoFLayer = pfLayer as IGeoFeatureLayer; IFeatureRenderer pfRenderer = pGeoFLayer.Renderer; if (pfRenderer is IUniqueValueRenderer) { IUniqueValueRenderer pUVRenderer = pfRenderer as IUniqueValueRenderer; int nValueCount = pUVRenderer.ValueCount; sArrValues = new string[nValueCount]; for (int i = 0; i < nValueCount; i++) { sArrValues[i] = pUVRenderer.get_Value(i); // 如 "1,1" "0|1" } return(true); } sArrValues = null; return(false); }
/// <summary> /// 获取图层对应的所有标志字段 /// </summary> /// <param name="pfLayer">图层</param> /// <param name="sArrFields">所有标志字段</param> /// <returns>是否存在分层字段</returns> public static bool GetUniqueFields(IFeatureLayer pfLayer, out string[] sArrFields) { IGeoFeatureLayer pGeoFLayer = pfLayer as IGeoFeatureLayer; IFeatureRenderer pfRenderer = pGeoFLayer.Renderer; if (pfRenderer is IUniqueValueRenderer) { IUniqueValueRenderer pUVRenderer = pfRenderer as IUniqueValueRenderer; int nFieldCount = pUVRenderer.FieldCount; sArrFields = new string[nFieldCount]; // 一般nFieldCount为1,在特殊情况下为多个域,此时value的值由分割符',' 或'|'等分割 for (int i = 0; i < nFieldCount; i++) { sArrFields[i] = pUVRenderer.get_Field(i); } return(true); } sArrFields = null; return(false); }
/// <summary> /// 根据指定的标志名称,获取图层中对应的标志值 /// </summary> /// <param name="pfLayer">图层</param> /// <param name="sLabel">标志名称</param> /// <returns>标志值</returns> public static string GetUniqueValue(IFeatureLayer pfLayer, string sLabel) { IGeoFeatureLayer pGeoFLayer = pfLayer as IGeoFeatureLayer; IFeatureRenderer pfRenderer = pGeoFLayer.Renderer; if (pfRenderer is IUniqueValueRenderer) { IUniqueValueRenderer pUVRenderer = pfRenderer as IUniqueValueRenderer; int nValueCount = pUVRenderer.ValueCount; string sValue = null; for (int i = 0; i < nValueCount; i++) { sValue = pUVRenderer.get_Value(i); // 如 "1,1" "0|1" if (sLabel == pUVRenderer.get_Label(sValue)) { return(sValue); } } } return(""); }
private void Renderer() { IGeoFeatureLayer pGeoFeatureL = (IGeoFeatureLayer)layer2Symbolize; //选中的图层 IFeatureClass featureClass = pGeoFeatureL.FeatureClass; int lfieldNumber = featureClass.FindField(strRendererField);//找出rendererField在字段中的编号 if (lfieldNumber == -1) { MessageBox.Show("Can't find field called " + strRendererField); return; } IUniqueValueRenderer pUniqueValueR = CreateRenderer(featureClass); //符号化 if (pUniqueValueR == null) { return; } pGeoFeatureL.Renderer = (IFeatureRenderer)pUniqueValueR; m_activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_activeView.Extent); }
private void cmbInlayer_SelectedIndexChanged(object sender, EventArgs e) { cmbfield1.Items.Clear(); ILayer playermap = ClsGDBDataCommon.GetLayerFromName(pMapControl.Map, cmbInlayer.Text); if (playermap is IFeatureLayer) { IFeatureLayer pfeaturelayer = (IFeatureLayer)playermap; IGeoFeatureLayer pGeofeaturelayer = (IGeoFeatureLayer)pfeaturelayer; if (pGeofeaturelayer.Renderer is IUniqueValueRenderer) { pInLayer = playermap; pInFLayer = (IFeatureLayer)pInLayer; pInGeoFLayer = (IGeoFeatureLayer)pInFLayer; pUniquerend = pInGeoFLayer.Renderer as IUniqueValueRenderer; } } if (pUniquerend.FieldCount == 1) { cmbfield2.Enabled = false; cmbfield3.Enabled = false; ITable pTbale = pLayer as ITable; IFields pFields = pTbale.Fields; for (int i = 2; i < pFields.FieldCount; i++) { cmbfield1.Items.Add(pFields.get_Field(i).Name); } string uniquefield = pUniquerend.get_Field(0); if (cmbfield1.Items.Contains(uniquefield)) { cmbfield1.Text = uniquefield; } else { MessageBox.Show("当前图层中不包含导入符号图层的独立值字段", "提示", MessageBoxButtons.OK); //this.Close(); } } }
private ITemporalRenderer setRenderer(IFeatureClass featureClass, string temporalField, string eventName) { CoTrackSymbologyRenderer trackingRenderer = new CoTrackSymbologyRendererClass(); ITemporalRenderer temporalRenderer = (ITemporalRenderer)trackingRenderer; temporalRenderer.TemporalFieldName = temporalField; temporalRenderer.TemporalObjectColumnName = eventName; temporalRenderer.TimeSymbologyMethod = enumTemporalSymbolizationMethod.enumColor; //this is a desktop only code which requires assemblies CartoUI and Framework //IRendererPropertyPage rendererPropPage = new UniqueValuePropertyPageClass(); //enable the most current renderer IUniqueValueRenderer uniqueValrenderer = CreateUniqueValueRenderer(featureClass, eventName); if (null != uniqueValrenderer) { ((ITemporalRenderer2)temporalRenderer).MostCurrentRenderer = (IFeatureRenderer)uniqueValrenderer; ((ITemporalRenderer2)temporalRenderer).MostCurrentRendererEnabled = true; //this is a desktop only code which requires assemblies CartoUI and Framework //((ITemporalRenderer2)temporalRenderer).PropPageMostCurrentRenderer = rendererPropPage.ClassID; } //set the track renderer uniqueValrenderer = CreateTrackUniqueValueRenderer(featureClass, eventName); if (null != uniqueValrenderer) { ITrackSymbologyRenderer trackSymbolenderer = trackingRenderer as ITrackSymbologyRenderer; trackSymbolenderer.TrackSymbologyRenderer = (IFeatureRenderer)uniqueValrenderer; ((ITemporalRenderer2)temporalRenderer).TrackRendererEnabled = true; ((ITemporalRenderer2)temporalRenderer).SmoothTracks = true; //this is a desktop only code which requires assemblies CartoUI and Framework //((ITemporalRenderer2)temporalRenderer).PropPageTrackRenderer = rendererPropPage.ClassID; } return(temporalRenderer); }
/// <summary> /// 获取指定图层,指定类型的符号 /// </summary> /// <param name="pfLayer">图层</param> /// <param name="subtype">类型</param> /// <returns></returns> public static ISymbol GetLayerSymbol(IFeatureLayer pfLayer, string subtype) { IGeoFeatureLayer pGeoFLayer = pfLayer as IGeoFeatureLayer; IFeatureRenderer pfRenderer = pGeoFLayer.Renderer; if (subtype == "") { ISimpleRenderer pSimpleRenderer = pfRenderer as ISimpleRenderer; if (pSimpleRenderer != null) { return(pSimpleRenderer.Symbol); } } IUniqueValueRenderer pUniqueRenderer = pfRenderer as IUniqueValueRenderer; if (pUniqueRenderer != null) { return(pUniqueRenderer.get_Symbol(subtype)); } 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 static IGeoFeatureLayer VisibilityColorsRender(IFeatureLayer layer, IObjectFactory objFactory) { const string fieldName = "IS_VISIBLE"; string[] uniqueValues = new string[2]; int fieldIndex = layer.FeatureClass.Fields.FindField(fieldName); uniqueValues[0] = "0"; uniqueValues[1] = "1"; Type renderType = typeof(UniqueValueRendererClass); string typeRenderID = renderType.GUID.ToString("B"); IUniqueValueRenderer uVRenderer = (IUniqueValueRenderer)objFactory.Create(typeRenderID); uVRenderer.FieldCount = 1; uVRenderer.Field[0] = fieldName; var invisibleSymbol = GetSymbol(layer.FeatureClass.ShapeType, new RgbColor() { Red = 255, Blue = 0, Green = 0 }); var visibleSymbol = GetSymbol(layer.FeatureClass.ShapeType, new RgbColor() { Red = 0, Blue = 0, Green = 255 }); uVRenderer.AddValue(uniqueValues[0], "Visibility", invisibleSymbol); uVRenderer.AddValue(uniqueValues[1], "Visibility", visibleSymbol); IGeoFeatureLayer geoFL = layer as IGeoFeatureLayer; geoFL.Renderer = uVRenderer as IFeatureRenderer; return(geoFL); }
public FrmAddUValue(IUniqueValueRenderer ure, IUniqueValueRenderer uremu, IFeatureClass fc, List <IColor> cu, List <IColor> cumu , DevComponents.DotNetBar.Controls.DataGridViewX grid, DevComponents.DotNetBar.Controls.DataGridViewX gridmu , DevComponents.AdvTree.AdvTree tree, DataTable dt, DataTable dtmu, ArrayList avx, ArrayList avxmu , List <long> couu, List <long> couumu, List <long> conuu, List <long> conuumu) { InitializeComponent(); this.EnableGlass = false; pUniquerender = ure; pUniquerendermu = uremu; coloru = cu; colorumu = cumu; treeshow = tree; addvx = avx; addvxmu = avxmu; pFClass = fc; gridviewu = grid; gridviewmu = gridmu; dtable2 = dt; dtable3 = dtmu; cuntu = couu; cuntumu = couumu; countu = conuu; countumu = conuumu; }
public void Apply() { this.iuniqueValueRenderer_0.RemoveAllValues(); for (int i = 0; i < this.listView1.Items.Count; i++) { ListViewItemEx ex = this.listView1.Items[i] as ListViewItemEx; if (ex != null) { string[] strArray = ex.SubItems[1].Text.Split(new char[] { ';' }); this.iuniqueValueRenderer_0.AddValue(strArray[0], null, ex.Style as ISymbol); this.iuniqueValueRenderer_0.set_Label(strArray[0], ex.SubItems[2].Text); for (int j = 1; j < strArray.Length; j++) { this.iuniqueValueRenderer_0.AddValue(strArray[j], null, ex.Style as ISymbol); this.iuniqueValueRenderer_0.set_Label(strArray[j], ex.SubItems[2].Text); this.iuniqueValueRenderer_0.AddReferenceValue(strArray[j], strArray[0]); } } } IObjectCopy copy = new ObjectCopyClass(); IUniqueValueRenderer renderer = copy.Copy(this.iuniqueValueRenderer_0) as IUniqueValueRenderer; (this.ilayer_0 as IGeoFeatureLayer).Renderer = renderer as IFeatureRenderer; }
public static List <YTEditTemplate> Create(IFeatureLayer ifeatureLayer_0) { YTEditTemplate jLKEditTemplate; int i; string field; List <YTEditTemplate> jLKEditTemplates; List <YTEditTemplate> jLKEditTemplates1 = new List <YTEditTemplate>(); if (ifeatureLayer_0 is IGeoFeatureLayer) { IGeoFeatureLayer ifeatureLayer0 = ifeatureLayer_0 as IGeoFeatureLayer; if (ifeatureLayer0.Renderer is ISimpleRenderer) { ISimpleRenderer renderer = ifeatureLayer0.Renderer as ISimpleRenderer; jLKEditTemplate = new YTEditTemplate(); jLKEditTemplate.Init(ifeatureLayer_0); jLKEditTemplate.Symbol = (renderer.Symbol as IClone).Clone() as ISymbol; jLKEditTemplate.InitBitmap(); jLKEditTemplates1.Add(jLKEditTemplate); } else if (!(ifeatureLayer0.Renderer is IUniqueValueRenderer)) { jLKEditTemplate = new YTEditTemplate(); jLKEditTemplate.Init(ifeatureLayer_0); jLKEditTemplate.InitBitmap(); jLKEditTemplates1.Add(jLKEditTemplate); } else { EditTemplateSchems editTemplateSchem = new EditTemplateSchems(); IUniqueValueRenderer uniqueValueRenderer = ifeatureLayer0.Renderer as IUniqueValueRenderer; for (i = 0; i < uniqueValueRenderer.FieldCount; i++) { field = uniqueValueRenderer.Field[i]; editTemplateSchem.AddField(field); } EditTemplateSchem symbol = new EditTemplateSchem(); for (int j = 0; j < uniqueValueRenderer.ValueCount; j++) { symbol = new EditTemplateSchem(); string value = uniqueValueRenderer.Value[j]; jLKEditTemplate = new YTEditTemplate(); jLKEditTemplate.Init(ifeatureLayer_0); jLKEditTemplate.Symbol = (uniqueValueRenderer.Symbol[value] as IClone).Clone() as ISymbol; jLKEditTemplate.Name = uniqueValueRenderer.Heading[value]; symbol.Symbol = jLKEditTemplate.Symbol; symbol.Value = value; symbol.Label = uniqueValueRenderer.Label[value]; symbol.Description = uniqueValueRenderer.Description[value]; if (uniqueValueRenderer.FieldCount != 1) { string[] strArrays = value.Split(uniqueValueRenderer.FieldDelimiter.ToCharArray()); for (i = 0; i < uniqueValueRenderer.FieldCount; i++) { field = uniqueValueRenderer.Field[i]; string str = strArrays[i].Trim(); if (str.Length > 0) { jLKEditTemplate.SetFieldValue(field, str); } symbol.Add(field, str); } } else { string field1 = uniqueValueRenderer.Value[0]; jLKEditTemplate.SetFieldValue(field1, value); symbol.Add(field1, value); } editTemplateSchem.Add(symbol); jLKEditTemplate.InitBitmap(); jLKEditTemplate.EditTemplateSchems = editTemplateSchem; jLKEditTemplates1.Add(jLKEditTemplate); } } } else if (ifeatureLayer_0.FeatureClass.FeatureType == esriFeatureType.esriFTAnnotation) { IAnnoClass extension = ifeatureLayer_0.FeatureClass.Extension as IAnnoClass; ISymbolCollection symbolCollection = extension.SymbolCollection; IAnnotateLayerPropertiesCollection2 annoProperties = extension.AnnoProperties as IAnnotateLayerPropertiesCollection2; symbolCollection.Reset(); for (ISymbolIdentifier k = symbolCollection.Next(); k != null; k = symbolCollection.Next()) { jLKEditTemplate = new YTEditTemplate(); jLKEditTemplate.Init(ifeatureLayer_0); jLKEditTemplate.Symbol = (k.Symbol as IClone).Clone() as ISymbol; jLKEditTemplate.Name = annoProperties.Properties[k.ID].Class; jLKEditTemplate.SetFieldValue("SymbolID", k.ID.ToString()); jLKEditTemplate.InitBitmap(); jLKEditTemplates1.Add(jLKEditTemplate); } } if (jLKEditTemplates1.Count <= 0) { jLKEditTemplates = null; } else { jLKEditTemplates = jLKEditTemplates1; } return(jLKEditTemplates); }
private IFeatureRenderer method_6(ITopology itopology_0, esriTopologyRenderer esriTopologyRenderer_0) { IUniqueValueRenderer renderer = null; IList list; IFillSymbol symbol; ILineSymbol symbol2; bool flag; IEnumColors colors; IFillSymbol symbol3; int num; ITopologyRule rule; int topologyRuleType; ILineSymbol symbol4; ISimpleMarkerSymbol symbol5; ISimpleMarkerSymbol symbol6; IRandomColorRamp ramp = new RandomColorRampClass { StartHue = 40, EndHue = 120, MinValue = 65, MaxValue = 90, MinSaturation = 25, MaxSaturation = 45, Size = 5, Seed = 23 }; switch (esriTopologyRenderer_0) { case esriTopologyRenderer.esriTRAreaErrors: renderer = new UniqueValueRendererClass(); list = this.method_4(itopology_0); symbol = new SimpleFillSymbolClass { Color = ColorManage.CreatColor(255, 128, 128) }; symbol2 = new SimpleLineSymbolClass { Width = 2.5, Color = ColorManage.CreatColor(255, 0, 0) }; symbol.Outline = symbol2; renderer.DefaultSymbol = (symbol as IClone).Clone() as ISymbol; ramp.Size = list.Count + 2; ramp.CreateRamp(out flag); colors = ramp.Colors; colors.Reset(); symbol3 = (symbol as IClone).Clone() as IFillSymbol; symbol3.Color = colors.Next(); renderer.AddValue("0", "必须大于集束容限值", symbol3 as ISymbol); renderer.set_Label("0", "必须大于集束容限值"); for (num = 0; num < list.Count; num++) { rule = list[num] as ITopologyRule; symbol3 = (symbol as IClone).Clone() as IFillSymbol; symbol3.Color = colors.Next(); topologyRuleType = (int)rule.TopologyRuleType; renderer.AddValue(topologyRuleType.ToString(), this.method_5(rule.TopologyRuleType), symbol3 as ISymbol); renderer.set_Label(topologyRuleType.ToString(), this.method_5(rule.TopologyRuleType)); } break; case esriTopologyRenderer.esriTRLineErrors: renderer = new UniqueValueRendererClass(); list = this.method_3(itopology_0); symbol2 = new SimpleLineSymbolClass { Width = 2.5, Color = ColorManage.CreatColor(255, 128, 128) }; renderer.DefaultSymbol = (symbol2 as IClone).Clone() as ISymbol; ramp.Size = list.Count + 2; ramp.CreateRamp(out flag); colors = ramp.Colors; colors.Reset(); symbol4 = (symbol2 as IClone).Clone() as ILineSymbol; symbol4.Color = colors.Next(); renderer.AddValue("0", "必须大于集束容限值", symbol4 as ISymbol); renderer.set_Label("0", "必须大于集束容限值"); for (num = 0; num < list.Count; num++) { rule = list[num] as ITopologyRule; symbol4 = (symbol2 as IClone).Clone() as ILineSymbol; symbol4.Color = colors.Next(); topologyRuleType = (int)rule.TopologyRuleType; renderer.AddValue(topologyRuleType.ToString(), this.method_5(rule.TopologyRuleType), symbol4 as ISymbol); renderer.set_Label(topologyRuleType.ToString(), this.method_5(rule.TopologyRuleType)); } break; case esriTopologyRenderer.esriTRPointErrors: renderer = new UniqueValueRendererClass(); list = this.method_2(itopology_0); symbol5 = new SimpleMarkerSymbolClass { Size = 6.0, Style = esriSimpleMarkerStyle.esriSMSSquare, Color = ColorManage.CreatColor(255, 128, 128) }; renderer.DefaultSymbol = (symbol5 as IClone).Clone() as ISymbol; if (list.Count > 0) { ramp.Size = list.Count + 1; ramp.CreateRamp(out flag); colors = ramp.Colors; colors.Reset(); symbol6 = null; for (num = 0; num < list.Count; num++) { rule = list[num] as ITopologyRule; symbol6 = (symbol5 as IClone).Clone() as ISimpleMarkerSymbol; symbol6.Color = colors.Next(); topologyRuleType = (int)rule.TopologyRuleType; renderer.AddValue(topologyRuleType.ToString(), this.method_5(rule.TopologyRuleType), symbol6 as ISymbol); renderer.set_Label(topologyRuleType.ToString(), this.method_5(rule.TopologyRuleType)); } } break; case esriTopologyRenderer.esriTRAreaExceptions: renderer = new UniqueValueRendererClass(); list = this.method_4(itopology_0); symbol = new SimpleFillSymbolClass { Color = ColorManage.CreatColor(255, 255, 255) }; symbol2 = new SimpleLineSymbolClass { Width = 1.0, Color = ColorManage.CreatColor(128, 255, 128) }; symbol.Outline = symbol2; renderer.DefaultSymbol = (symbol as IClone).Clone() as ISymbol; ramp.Size = list.Count + 2; ramp.CreateRamp(out flag); colors = ramp.Colors; colors.Reset(); symbol3 = (symbol as IClone).Clone() as IFillSymbol; symbol3.Color = colors.Next(); renderer.AddValue("0", "必须大于集束容限值", symbol3 as ISymbol); renderer.set_Label("0", "必须大于集束容限值"); for (num = 0; num < list.Count; num++) { rule = list[num] as ITopologyRule; symbol3 = (symbol as IClone).Clone() as IFillSymbol; symbol3.Color = colors.Next(); topologyRuleType = (int)rule.TopologyRuleType; renderer.AddValue(topologyRuleType.ToString(), this.method_5(rule.TopologyRuleType), symbol3 as ISymbol); renderer.set_Label(topologyRuleType.ToString(), this.method_5(rule.TopologyRuleType)); } break; case esriTopologyRenderer.esriTRLineExceptions: renderer = new UniqueValueRendererClass(); list = this.method_3(itopology_0); symbol2 = new SimpleLineSymbolClass { Width = 1.0, Color = ColorManage.CreatColor(128, 255, 128) }; renderer.DefaultSymbol = (symbol2 as IClone).Clone() as ISymbol; ramp.Size = list.Count + 2; ramp.CreateRamp(out flag); colors = ramp.Colors; colors.Reset(); symbol4 = (symbol2 as IClone).Clone() as ILineSymbol; symbol4.Color = colors.Next(); renderer.AddValue("0", "必须大于集束容限值", symbol4 as ISymbol); renderer.set_Label("0", "必须大于集束容限值"); for (num = 0; num < list.Count; num++) { rule = list[num] as ITopologyRule; symbol4 = (symbol2 as IClone).Clone() as ILineSymbol; symbol4.Color = colors.Next(); topologyRuleType = (int)rule.TopologyRuleType; renderer.AddValue(topologyRuleType.ToString(), this.method_5(rule.TopologyRuleType), symbol4 as ISymbol); renderer.set_Label(topologyRuleType.ToString(), this.method_5(rule.TopologyRuleType)); } break; case esriTopologyRenderer.esriTRPointExceptions: renderer = new UniqueValueRendererClass(); list = this.method_2(itopology_0); symbol5 = new SimpleMarkerSymbolClass { Size = 5.0, Style = esriSimpleMarkerStyle.esriSMSSquare, Color = ColorManage.CreatColor(128, 255, 128) }; renderer.DefaultSymbol = (symbol5 as IClone).Clone() as ISymbol; if (list.Count > 0) { ramp.Size = list.Count + 1; ramp.CreateRamp(out flag); colors = ramp.Colors; colors.Reset(); symbol6 = null; for (num = 0; num < list.Count; num++) { rule = list[num] as ITopologyRule; symbol6 = (symbol5 as IClone).Clone() as ISimpleMarkerSymbol; symbol6.Color = colors.Next(); topologyRuleType = (int)rule.TopologyRuleType; renderer.AddValue(topologyRuleType.ToString(), this.method_5(rule.TopologyRuleType), symbol6 as ISymbol); renderer.set_Label(topologyRuleType.ToString(), this.method_5(rule.TopologyRuleType)); } } break; } return(renderer as IFeatureRenderer); }
public void processFeatureLayer(ILayer lyr) { type = "Vektor"; fillLayerProps(lyr); fillDatalayerProps(lyr); IFeatureLayer flyr = lyr as IFeatureLayer; fillDefQueryProps(flyr); processJoins(flyr); processRelates(flyr); IGeoFeatureLayer gflyr = flyr as IGeoFeatureLayer; if (gflyr.DisplayAnnotation == true) { IAnnotateLayerPropertiesCollection labelPropsColl = gflyr.AnnotationProperties; for (int collIndex = 0; collIndex < labelPropsColl.Count; collIndex++) { IAnnotateLayerProperties annoLayerProps; IElementCollection elCol1; IElementCollection elCol2; labelPropsColl.QueryItem(collIndex, out annoLayerProps, out elCol1, out elCol2); string sql = annoLayerProps.WhereClause; ILabelEngineLayerProperties2 labelEngineProps = (ILabelEngineLayerProperties2)annoLayerProps; string expr = labelEngineProps.Expression; this.label = this.label + sql + "?" + expr + "/"; } } this.label = this.label.TrimEnd('/'); IFeatureRenderer rend = gflyr.Renderer; if (rend is IUniqueValueRenderer) { string felder = ""; IUniqueValueRenderer u = rend as IUniqueValueRenderer; for (int i = 0; i < u.FieldCount; i++) { felder = felder + u.get_Field(i) + "/"; } symbfields = felder.TrimEnd('/') + " (UniqueValueRenderer)"; } else if (rend is IProportionalSymbolRenderer) { IProportionalSymbolRenderer prop = rend as IProportionalSymbolRenderer; symbfields = prop.Field + " (ProportionalSymbolRenderer)"; } else if (rend is IClassBreaksRenderer) { IClassBreaksRenderer cl = rend as IClassBreaksRenderer; symbfields = cl.Field + " (ClassBreaksRenderer)";; } else if (rend is ISimpleRenderer) { symbfields = "kein Feld (SimpleRenderer)"; } else { symbfields = "unbekannter Renderer"; } }
public string[] getQueryValueOptions_withSuffix(string queryType, string fileSuffix) { ESRI.ArcGIS.Carto.ILayerFile layerFile = new LayerFileClass(); //layerFile.Open("\\\\tornado\\Research3\\Tony\\Wetlands\\wetlands10.1\\10.0\\" + queryType + "_Poly.lyr"); layerFile.Open(GetAssemblyPath() + "\\Symbology\\LLWWW_" + queryType + "_Polygon" + fileSuffix + ".lyr"); IGeoFeatureLayer igfl_lyr = (IGeoFeatureLayer)layerFile.Layer; iuvr = (IUniqueValueRenderer)igfl_lyr.Renderer; string[] s = new string[iuvr.ValueCount]; for (int j = 0; j < iuvr.ValueCount; j++) { s[j] = iuvr.Label[iuvr.Value[j]] + " (" + iuvr.Value[j] + ")"; } return s; }
private static void RandomizeMarkerColor(IUniqueValueRenderer renderer) { IMarkerSymbol symbol; IRgbColor color = RandomColor(); for (int i = 0; i < renderer.ValueCount; i++) { symbol = renderer.Symbol[renderer.Value[i]] as IMarkerSymbol; if (symbol != null) symbol.Color = color; } }
private static void AddSymbolNode(TreeNodeComLayer tnComLayer, object renderer) { int index; LogicBaseTree logicBT = new LogicBaseTree(); ImageCollection treeImages = logicBT.TreeList.StateImageList as ImageCollection; if (renderer is SimpleRenderer) { ISimpleRenderer simpleRenderer = (ISimpleRenderer)renderer; ISymbol symbol = simpleRenderer.Symbol; Image img = ConvertSymbolToImage.Convert(symbol, 16, 16); index = treeImages.Images.Add(img); //img.Save("d:\\" + index + ".JPG"); string label = simpleRenderer.Label; TreeNodeSymbol tnSymbol = new TreeNodeSymbol() { Name = label, CustomValue = symbol }; tnSymbol.ImageIndex = index; tnComLayer.Add(tnSymbol); } else if (renderer is UniqueValueRenderer) { string renderLabel = ""; IUniqueValueRenderer uniqueValueRenderer = renderer as IUniqueValueRenderer; for (int i = 0; i < uniqueValueRenderer.FieldCount - 1; i++) { renderLabel += uniqueValueRenderer.get_Field(i) + " /"; } renderLabel += uniqueValueRenderer.get_Field(uniqueValueRenderer.FieldCount - 1);//FieldCount为地物分类数 //getImage(esriGeometryType.esriGeometryPolygon, Color.White).Save("D:\\111.jpg"); index = treeImages.Images.Add(getImage(esriGeometryType.esriGeometryPolygon, Color.White)); TreeNodeSymbol tnChartNode = new TreeNodeSymbol() { Name = renderLabel, CustomValue = uniqueValueRenderer }; tnChartNode.ImageIndex = index; tnComLayer.Add(tnChartNode); for (int i = 0; i < uniqueValueRenderer.ValueCount; i++)//ValueCount为地物分类下的设施种类数 { ISymbol symbol = uniqueValueRenderer.get_Symbol(uniqueValueRenderer.get_Value(i)); Image img = ConvertSymbolToImage.Convert(symbol, 16, 16); //img.Save("D:\\121121.jpg"); index = treeImages.Images.Add(img); TreeNodeSymbol tnSymbol = new TreeNodeSymbol() { Name = uniqueValueRenderer.get_Label(uniqueValueRenderer.get_Value(i)), CustomValue = symbol }; tnSymbol.ImageIndex = index; tnComLayer.Add(tnSymbol); } if (uniqueValueRenderer.UseDefaultSymbol) { ISymbol symbol = uniqueValueRenderer.DefaultSymbol; Image img = ConvertSymbolToImage.Convert(symbol, 16, 16); index = treeImages.Images.Add(img); TreeNodeSymbol tnSymbol = new TreeNodeSymbol() { Name = uniqueValueRenderer.DefaultLabel, CustomValue = symbol }; tnSymbol.ImageIndex = index; tnComLayer.Add(tnSymbol); } } else if (renderer is IChartRenderer) { IChartRenderer chartRenderer = renderer as IChartRenderer; IRendererFields pFields = chartRenderer as IRendererFields; string renderLabel = ""; for (int i = 0; i < pFields.FieldCount - 1; i++) { renderLabel += pFields.get_FieldAlias(i) + " /"; } renderLabel += pFields.get_FieldAlias(pFields.FieldCount - 1); index = treeImages.Images.Add(getImage(esriGeometryType.esriGeometryPolygon, Color.White)); TreeNodeSymbol tnChartNode = new TreeNodeSymbol() { Name = renderLabel, CustomValue = chartRenderer }; tnChartNode.ImageIndex = index; tnComLayer.Add(tnChartNode); ISymbolArray symArray = chartRenderer.ChartSymbol as ISymbolArray; for (int i = 0; i < symArray.SymbolCount; i++) { ISymbol symbol = symArray.get_Symbol(i); Image img = ConvertSymbolToImage.Convert(symbol, 16, 16); index = treeImages.Images.Add(img); TreeNodeSymbol tnSymbol = new TreeNodeSymbol() { Name = pFields.get_FieldAlias(i), CustomValue = symbol }; tnSymbol.ImageIndex = index; tnComLayer.Add(tnSymbol); } } else if (renderer is IClassBreaksRenderer) { IClassBreaksRenderer classRenderer = renderer as IClassBreaksRenderer; index = treeImages.Images.Add(getImage(esriGeometryType.esriGeometryPolygon, Color.White)); TreeNodeSymbol tnChartNode = new TreeNodeSymbol() { Name = classRenderer.Field, CustomValue = classRenderer }; tnChartNode.ImageIndex = index; tnComLayer.Add(tnChartNode); for (int i = 0; i < classRenderer.BreakCount; i++) { ISymbol symbol = classRenderer.get_Symbol(i); Image img = ConvertSymbolToImage.Convert(symbol, 16, 16); index = treeImages.Images.Add(img); TreeNodeSymbol tnSymbol = new TreeNodeSymbol() { Name = classRenderer.get_Label(i), CustomValue = symbol }; tnSymbol.ImageIndex = index; tnComLayer.Add(tnSymbol); } } else if (renderer is IRasterRenderer) { if (renderer is IRasterClassifyColorRampRenderer) { //MessageBox.Show("IRasterClassifyColorRampRenderer"); } else if (renderer is IRasterUniqueValueRenderer) { //MessageBox.Show("IRasterUniqueValueRenderer"); } else if (renderer is IRasterStretchColorRampRenderer) { ////MessageBox.Show("IRasterStretchColorRampRenderer"); IRasterStretchColorRampRenderer pRSCRR = renderer as IRasterStretchColorRampRenderer; index = treeImages.Images.Add(getImage(esriGeometryType.esriGeometryPolygon, Color.White)); TreeNodeSymbol tnChartNode = new TreeNodeSymbol() { Name = "<Value>", CustomValue = pRSCRR }; tnChartNode.ImageIndex = index; tnComLayer.Add(tnChartNode); if (pRSCRR.ColorRamp.Size >= 3) { IEnumColors colors = pRSCRR.ColorRamp.Colors; colors.Reset(); IColor c = colors.Next(); Color[] cArray = new Color[3]; int count = 0; while (c != null) { count++; if (count == 1) { cArray[0] = Color.FromArgb(c.RGB); } else if (count == pRSCRR.ColorRamp.Size / 2) { cArray[1] = Color.FromArgb(c.RGB); } else if (count == pRSCRR.ColorRamp.Size) { cArray[2] = Color.FromArgb(c.RGB); } c = colors.Next(); } for (int i = 0; i < 3; i++) { Image img = getImage(esriGeometryType.esriGeometryPolygon, cArray[i]); index = treeImages.Images.Add(img); string label = ""; if (i == 0) { label = pRSCRR.LabelLow; } else if (i == 1) { label = pRSCRR.LabelMedium; } else if (i == 2) { label = pRSCRR.LabelHigh; } TreeNodeSymbol tnSymbol = new TreeNodeSymbol() { Name = label, CustomValue = cArray[i] }; tnSymbol.ImageIndex = index; tnComLayer.Add(tnSymbol); } } } else if (renderer is IRasterRGBRenderer) { //MessageBox.Show("IRasterRGBRenderer"); } else if (renderer is IRasterColormap) { //MessageBox.Show("IRasterColormap"); } else { //MessageBox.Show("未处理的IRasterRenderer类型: " + renderer.GetType().FullName); } } else if (renderer is ITinRenderer) { if (renderer is ITinColorRampRenderer) { ////MessageBox.Show("ITinColorRampRenderer"); ITinColorRampRenderer pTCRR = renderer as ITinColorRampRenderer; index = treeImages.Images.Add(getImage(esriGeometryType.esriGeometryPolygon, Color.White)); TreeNodeSymbol tnChartNode = new TreeNodeSymbol() { Name = "Elevation", CustomValue = pTCRR }; tnChartNode.ImageIndex = index; tnComLayer.Add(tnChartNode); for (int i = 0; i < pTCRR.BreakCount; i++) { ISymbol symbol = pTCRR.get_Symbol(i); Image img = ConvertSymbolToImage.Convert(symbol, 16, 16); index = treeImages.Images.Add(img); TreeNodeSymbol tnSymbol = new TreeNodeSymbol() { Name = pTCRR.get_Label(i), CustomValue = symbol }; tnSymbol.ImageIndex = index; tnComLayer.Add(tnSymbol); } } else if (renderer is ITinUniqueValueRenderer) { ////MessageBox.Show("ITinUniqueValueRenderer"); ITinUniqueValueRenderer pTUVR = renderer as ITinUniqueValueRenderer; index = treeImages.Images.Add(getImage(esriGeometryType.esriGeometryPolygon, Color.White)); TreeNodeSymbol tnChartNode = new TreeNodeSymbol() { Name = "Elevation", CustomValue = pTUVR }; tnChartNode.ImageIndex = index; tnComLayer.Add(tnChartNode); for (int i = 0; i < pTUVR.ValueCount; i++) { string val = pTUVR.get_Value(i); ISymbol symbol = pTUVR.get_Symbol(val); Image img = ConvertSymbolToImage.Convert(symbol, 16, 16); index = treeImages.Images.Add(img); TreeNodeSymbol tnSymbol = new TreeNodeSymbol() { Name = pTUVR.get_Label(val), CustomValue = symbol }; tnSymbol.ImageIndex = index; tnComLayer.Add(tnSymbol); } if (pTUVR.UseDefaultSymbol) { ISymbol symbol = pTUVR.DefaultSymbol; Image img = ConvertSymbolToImage.Convert(symbol, 16, 16); index = treeImages.Images.Add(img); TreeNodeSymbol tnSymbol = new TreeNodeSymbol() { Name = pTUVR.DefaultLabel, CustomValue = symbol }; tnSymbol.ImageIndex = index; tnComLayer.Add(tnSymbol); } } else if (renderer is ITinSingleSymbolRenderer) { ////MessageBox.Show("ITinSingleSymbolRenderer"); ITinSingleSymbolRenderer pTSSR = renderer as ITinSingleSymbolRenderer; ISymbol symbol = pTSSR.Symbol; Image img = ConvertSymbolToImage.Convert(symbol, 16, 16); index = treeImages.Images.Add(img); TreeNodeSymbol tnSymbol = new TreeNodeSymbol() { Name = pTSSR.Label, CustomValue = symbol }; tnSymbol.ImageIndex = index; tnComLayer.Add(tnSymbol); } else { //MessageBox.Show("未处理的ITinRenderer类型: " + renderer.GetType().FullName); } } else { //MessageBox.Show("未处理的Renderer类型: " + renderer.GetType().FullName); } }