internal static void Render() { if (CboLayers.GetSelectedLayer() == null || CboFields.GetSelectedField() == null || s_selectedRenderer == null || CboColors.GetSelectedColor() == null || CboClasses.GetSelectedClass() == null) { return; } switch (s_selectedRenderer) { case "Simple Marker Renderer": MapUsingSimpleMarkerRenderer(); break; case "Proportional Symbol Renderer": MapUsingProportionalSymbolRenderer(); break; case "Simple Fill Renderer": MapUsingSimpleFillRenderer(); break; case "Classbreaks Renderer": MapUsingClassbreaksRenderer(); break; } }
private static void MapUsingSimpleMarkerRenderer() { string layerName = CboLayers.GetSelectedLayer(); ILayer layer = GetLayerByName(layerName); string colorName = CboColors.GetSelectedColor(); ICmykColor markerColor = ColorbrewerExtension.GetSingleCMYKColor(); ISimpleMarkerSymbol marker = new SimpleMarkerSymbol(); marker.Style = esriSimpleMarkerStyle.esriSMSCircle; marker.Color = markerColor; marker.Size = 5; ISimpleRenderer renderer = new SimpleRenderer(); renderer.Symbol = marker as ISymbol; renderer.Label = layer.Name; IGeoFeatureLayer gFLayer = layer as IGeoFeatureLayer; gFLayer.Renderer = renderer as IFeatureRenderer; IMxDocument mxDoc = ArcMap.Application.Document as IMxDocument; IMap map = mxDoc.FocusMap; mxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, gFLayer, mxDoc.ActiveView.Extent); mxDoc.UpdateContents(); }
private static void MapUsingSimpleFillRenderer() { string layerName = CboLayers.GetSelectedLayer(); ILayer layer = GetLayerByName(layerName); string colorName = CboColors.GetSelectedColor(); ICmykColor fillColor = ColorbrewerExtension.GetSingleCMYKColor(); ISimpleFillSymbol fill = new SimpleFillSymbol(); fill.Style = esriSimpleFillStyle.esriSFSSolid; fill.Color = fillColor; ISimpleRenderer simpleRenderer = new SimpleRenderer(); simpleRenderer.Symbol = fill as ISymbol; simpleRenderer.Label = layer.Name; IGeoFeatureLayer gFLayer = layer as IGeoFeatureLayer; gFLayer.Renderer = simpleRenderer as IFeatureRenderer; IMxDocument mxDoc = ArcMap.Application.Document as IMxDocument; IMap map = mxDoc.FocusMap; mxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography , gFLayer, mxDoc.ActiveView.Extent); }
internal void PopulateCboColors() { try { List <string> colors = new List <string>(); System.IO.StreamReader file = new System.IO.StreamReader(filepath); string line; while ((line = file.ReadLine()) != null) { string name = line.Split(',')[0]; if (!(name == "" || name == "ColorName" || colors.Contains(name))) { colors.Add(name); } } foreach (string color in colors) { CboColors.AddItem(color); } } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.ToString()); LocateCBfile(); PopulateCboColors(); } }
internal static void UpdateCboClasses() { try { CboClasses.ClearAllItems(); string selectedColor = CboColors.GetSelectedColor(); /* FILEPATH needs to be modified whenever the cb.csv file is moved aka during installation */ System.IO.StreamReader file = new System.IO.StreamReader(filepath); string line; string currentColor = ""; List <string> values = new List <string>(); while ((line = file.ReadLine()) != null) { string[] words = line.Split(','); string value = ""; if (words[0] != "") { currentColor = words[0]; } if (currentColor.Equals(selectedColor)) { switch (CboRenderers.GetSelectedRenderer()) { case "Simple Marker Renderer": case "Simple Fill Renderer": case "Proportional Symbol Renderer": value = words[5]; break; case "Classbreaks Renderer": value = words[1]; break; } if (!values.Contains(value) && !value.Equals("")) { values.Add(value); } } } foreach (string value in values) { CboClasses.AddItem(value); } } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.ToString()); LocateCBfile(); UpdateCboClasses(); } }
internal static ICmykColor[] GetCmykColors() { try { string selectedClass = CboClasses.GetSelectedClass(); ICmykColor[] colors = new ICmykColor[Convert.ToInt32(selectedClass)]; int currentIndex = 0; string selectedColor = CboColors.GetSelectedColor(); System.IO.StreamReader file = new System.IO.StreamReader(filepath); string line; string currentColor = ""; string currentClass = ""; while ((line = file.ReadLine()) != null) { if (currentIndex == colors.Length) { break; } string[] words = line.Split(','); if (words[0] != "") { currentColor = words[0]; } if (words[1] != "") { currentClass = words[1]; } if (currentColor.Equals(selectedColor) && currentClass.Equals(selectedClass)) { ICmykColor color = new CmykColorClass(); color.Cyan = Convert.ToInt32(words[6]); color.Magenta = Convert.ToInt32(words[7]); color.Yellow = Convert.ToInt32(words[8]); color.Black = Convert.ToInt32(words[9]); colors[currentIndex] = color; currentIndex++; } } return(colors); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.ToString()); LocateCBfile(); return(GetCmykColors()); } }
internal static ICmykColor GetSingleCMYKColor() { try { ICmykColor color = new CmykColorClass(); string selectedColor = CboColors.GetSelectedColor(); string selectedClass = CboClasses.GetSelectedClass(); /* FILEPATH needs to be modified whenever the cb.csv file is moved aka during installation */ System.IO.StreamReader file = new System.IO.StreamReader(filepath); string line; string currentColor = ""; string currentClass = ""; while ((line = file.ReadLine()) != null) { string[] words = line.Split(','); if (words[0] != "") { currentColor = words[0]; } currentClass = words[5]; if (currentColor.Equals(selectedColor) && currentClass.Equals(selectedClass)) { color.Cyan = Convert.ToInt32(words[6]); color.Magenta = Convert.ToInt32(words[7]); color.Yellow = Convert.ToInt32(words[8]); color.Black = Convert.ToInt32(words[9]); return(color); } } return(color); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.ToString()); LocateCBfile(); return(GetSingleCMYKColor()); } }
public CboColors() { s_CboColors = this; }