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; } }
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()); } }
private static void MapUsingClassbreaksRenderer() { string layerName = CboLayers.GetSelectedLayer(); ILayer layer = GetLayerByName(layerName); IFeatureLayer2 fLayer = layer as IFeatureLayer2; string fieldName = CboFields.GetSelectedField(); // Get the number of classes string selectedClass = CboClasses.GetSelectedClass(); int numberOfClasses = Convert.ToInt32(selectedClass); ITableHistogram tableHistogram = new TableHistogramClass(); tableHistogram.Table = fLayer.FeatureClass as ITable; tableHistogram.Field = fieldName; IHistogram histo = tableHistogram as IHistogram; object datavalues, datafrequencies; histo.GetHistogram(out datavalues, out datafrequencies); IClassify classify = new QuantileClass(); classify.SetHistogramData(datavalues, datafrequencies); classify.Classify(ref numberOfClasses); if (numberOfClasses <= 1) { return; } double[] classBreaks = (double[])classify.ClassBreaks; IClassBreaksRenderer render = new ClassBreaksRenderer(); render.Field = fieldName; render.BreakCount = numberOfClasses; render.MinimumBreak = classBreaks[0]; // Get the colors ICmykColor[] colors = ColorbrewerExtension.GetCmykColors(); IFillSymbol fill = null; // Iterate through the colors for (int i = 0; i < numberOfClasses; i++) { fill = new SimpleFillSymbol(); fill.Color = colors[i]; fill.Outline.Width = 0.5; render.Symbol[i] = fill as ISymbol; render.Break[i] = classBreaks[i + 1]; render.Label[i] = string.Format("{0} to {1}", classBreaks[i] , classBreaks[i + 1]); } IGeoFeatureLayer gFLayer = layer as IGeoFeatureLayer; gFLayer.Renderer = render as IFeatureRenderer; IMxDocument mxDoc = ArcMap.Application.Document as IMxDocument; mxDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, gFLayer , mxDoc.ActiveView.Extent); mxDoc.UpdateContents(); }
public CboClasses() { s_CboClasses = this; }