private void menu_Click(object sender, EventArgs e) { FormContour Frm = new FormContour(); Frm.layers = App.Map.GetRasterLayers(); if (Frm.layers.GetLength(0) <= 0) { MessageBox.Show("No raster layer found!"); return; } if (Frm.ShowDialog() == DialogResult.OK) { IMapFeatureLayer fl = App.Map.Layers.Add(Frm.Contours); fl.LegendText = Frm.LayerName + " - Contours"; int numlevs = Frm.lev.GetLength(0); switch (Frm.contourtype) { case (Contour.ContourType.Line): { LineScheme ls = new LineScheme(); ls.Categories.Clear(); for (int i = 0; i < Frm.color.GetLength(0); i++) { LineCategory lc = new LineCategory(Frm.color[i], 2.0); lc.FilterExpression = "[Value] = " + Frm.lev[i].ToString(); lc.LegendText = Frm.lev[i].ToString(); ls.AddCategory(lc); } fl.Symbology = ls; } break; case (Contour.ContourType.Polygon): { PolygonScheme ps = new PolygonScheme(); ps.Categories.Clear(); for (int i = 0; i < Frm.color.GetLength(0); i++) { PolygonCategory pc = new PolygonCategory(Frm.color[i], Color.Transparent, 0); pc.FilterExpression = "[Lev] = " + i.ToString(); pc.LegendText = Frm.lev[i].ToString() + " - " + Frm.lev[i + 1].ToString(); ps.AddCategory(pc); } fl.Symbology = ps; } break; } } }
/// <summary> /// Retrieve the info from an existing transline from the component LineController. /// </summary> /// <param name="controller"></param> public void PrepareLineForEdit(LineController controller) { ResetEditingInfo(); editingLine = controller; foreach (var station in controller.stations) { editingLineStations.Add(station); } foreach (var time in controller.travelingTimes) { travelTimes.Add(time); } editLineName = controller.lineName; lineCategory = controller.category; }
public void MessageReceived(Core.Result.Events.ResultLayerSelected theEvent) { if (theEvent.ResultSet == null) { this.resultsGroup.Layers.Remove(this.resultsLayer); this.resultsLayer = null; return; } if (this.curResultsSet != theEvent.ResultSet) { SetupResultsMapGroup(theEvent.ResultSet); } if (this.resultsLayer == null) { return; } var layers = theEvent.SelectedLayers; IFeatureScheme scheme = this.resultsLayer.Symbology.Clone() as IFeatureScheme; this.resultsLayer.Symbology.SuspendEvents(); scheme.ClearCategories(); for (int i = 0; i < layers.Count; i++) { var cat = new LineCategory(this.colorList[i % this.colorList.Count], 1); string filter = "[LayerName] = '" + layers[i] + "'"; cat.FilterExpression = filter; cat.LegendText = layers[i]; scheme.AddCategory(cat); } BeginInvoke(new MethodInvoker(delegate { this.resultsLayer.Symbology.CopyProperties(scheme); this.resultsLayer.Symbology.ResumeEvents(); })); }
public void SetLineCategory(LineCategory category) { this.category = category; var spawner = GetComponent <SpawnerLineController>(); if (spawner == null) { Debug.LogError("No spawner found!"); } switch (category) { case LineCategory.Bus: lineColor = Color.red; spawner.enabled = false; break; case LineCategory.Tram: lineColor = Color.blue; spawner.enabled = true; break; case LineCategory.Metro: lineColor = Color.cyan; spawner.enabled = true; break; case LineCategory.Train: lineColor = Color.magenta; spawner.enabled = true; break; default: lineColor = Color.white; spawner.enabled = false; break; } UpdateGameObjectName(); }
public void Add(LineCategory cat, string line) { switch (cat) { case LineCategory.Header: Header.Add(line); break; case LineCategory.Seat: Seat.Add(line); break; case LineCategory.Action: Action.Add(line); break; case LineCategory.Showdown: Showdown.Add(line); break; case LineCategory.Summary: Summary.Add(line); break; case LineCategory.Other: Other.Add(line); break; case LineCategory.Ignore: Ignore.Add(line); break; default: throw new ArgumentException("Unknown category: " + cat); } }
/// <summary> /// Translates the given style as line style and adds it to the given line scheme. /// </summary> /// <param name="scheme">The scheme the style gets added to.</param> /// <param name="style">The style that gets translated.</param> private static void TranslateLineStyle(LineScheme scheme, string style) { if (string.IsNullOrWhiteSpace(style)) { return; } var mystyle = style; int index = mystyle.IndexOf("(", StringComparison.Ordinal); if (index < 1) { return; } var toolname = mystyle.Substring(0, index); mystyle = mystyle.Substring(index + 1); Color col = Color.Black; double width = 1; DashStyle dashStyle = DashStyle.Solid; float[] pattern = null; bool invisible = true; switch (toolname) { case "PEN": col = GetColor(ref mystyle, Parameters.Color); width = GetWidth(ref mystyle); pattern = GetPattern(ref mystyle); dashStyle = GetDashStyle(ref mystyle, out invisible); break; } if (pattern != null) { dashStyle = DashStyle.Custom; } if (invisible) { col = Color.Transparent; } var stroke = new CartographicStroke(col) { Width = width, DashStyle = dashStyle }; if (pattern != null) { stroke.DashPattern = pattern; } var symb = new LineSymbolizer { ScaleMode = ScaleMode.Simple, Smoothing = false, Strokes = { [0] = stroke } }; var cat = new LineCategory { FilterExpression = $"[style] = '{style}'", LegendText = style, Symbolizer = symb }; scheme.AddCategory(cat); }
/// <summary> /// Translates the style strings from the list to DotSpatial style categories and adds them to the given layer. /// </summary> /// <param name="layer">The layer the styles get added to.</param> /// <param name="styles">The style strings that should get translated.</param> public static void TranslateStyles(IMapFeatureLayer layer, IList <string> styles) { var featureType = layer.DataSet.FeatureType; switch (featureType) { case FeatureType.MultiPoint: case FeatureType.Point: { // create the scheme var scheme = new PointScheme(); scheme.Categories.Clear(); scheme.EditorSettings.ClassificationType = ClassificationType.UniqueValues; scheme.EditorSettings.FieldName = "style"; scheme.LegendText = "Point"; // add the default category var cat = new PointCategory(Color.Black, Symbology.PointShape.Rectangle, 5) { LegendText = "default", Symbolizer = { ScaleMode = ScaleMode.Simple, Smoothing = false } }; scheme.AddCategory(cat); var labelLayer = new MapLabelLayer(); labelLayer.Symbology.Categories.Clear(); bool needsLabels = styles.Any(_ => !string.IsNullOrWhiteSpace(_) && _.StartsWith("LABEL")); foreach (var style in styles) { TranslatePointStyle(scheme, labelLayer.Symbology, style); } // assign the scheme layer.Symbology = scheme; // assign the label layer if needed if (needsLabels) { layer.LabelLayer = labelLayer; layer.ShowLabels = true; layer.LabelLayer.CreateLabels(); } layer.DataSet.UpdateExtent(); layer.DataSet.InitializeVertices(); layer.AssignFastDrawnStates(); break; } case FeatureType.Line: { // create the scheme var scheme = new LineScheme(); scheme.Categories.Clear(); scheme.EditorSettings.ClassificationType = ClassificationType.UniqueValues; scheme.EditorSettings.FieldName = "style"; scheme.LegendText = "Line"; // add the default category var cat = new LineCategory(Color.Black, 1) { LegendText = "default", Symbolizer = { ScaleMode = ScaleMode.Simple, Smoothing = false } }; scheme.AddCategory(cat); // add the categories from the file foreach (var style in styles) { TranslateLineStyle(scheme, style); } // assign the scheme layer.Symbology = scheme; layer.DataSet.UpdateExtent(); layer.DataSet.InitializeVertices(); layer.AssignFastDrawnStates(); break; } case FeatureType.Polygon: { // create the scheme var scheme = new PolygonScheme(); scheme.Categories.Clear(); scheme.EditorSettings.ClassificationType = ClassificationType.UniqueValues; scheme.EditorSettings.FieldName = "style"; scheme.LegendText = "Polygon"; // add the default category var cat = new PolygonCategory(Color.GhostWhite, Color.Black, 1) { LegendText = "default", Symbolizer = { ScaleMode = ScaleMode.Simple, Smoothing = false } }; scheme.AddCategory(cat); // add the categories from the file foreach (var style in styles) { TranslatePolygonStyle(scheme, style); } // assign the scheme layer.Symbology = scheme; layer.DataSet.UpdateExtent(); layer.DataSet.InitializeVertices(); layer.AssignFastDrawnStates(); break; } default: throw new ArgumentOutOfRangeException(nameof(featureType), featureType, null); } }
public void setSymbolizer() { double baseWidth = 20.0; double baseOutlineWidth = 10.0; double adjWidth = baseWidth; double adjOutlineWidth = baseOutlineWidth; LineScheme rdScheme = new LineScheme(); LineSymbolizer catSelSym = new LineSymbolizer(); catSelSym.ScaleMode = ScaleMode.Geographic; catSelSym.SetWidth(adjWidth); catSelSym.SetOutline(Color.Blue, adjOutlineWidth); catSelSym.SetFillColor(Color.White); LineSymbolizer symDef = new LineSymbolizer(); symDef.ScaleMode = ScaleMode.Geographic; symDef.SetWidth(adjWidth); symDef.SetOutline(Color.Black, adjOutlineWidth); symDef.SetFillColor(Color.Gray); LineCategory catDef = new LineCategory(); catDef.LegendText = "No RSL Info"; catDef.SelectionSymbolizer = catSelSym; catDef.Symbolizer = symDef; rdScheme.AddCategory(catDef); int[] r = new int[30]; int[] g = new int[30]; int[] b = new int[30]; if (Project.settings.GetValue("road_colors").Contains("t")) { if (moduleRoads.roadColors == "RSL") { for (int rsl = 0; rsl <= 20; rsl++) { // create a category LineCategory colorCat = new LineCategory(); colorCat.FilterExpression = "[TAMSROADRSL] = '" + rsl.ToString() + "'"; LineSymbolizer colorSym = new LineSymbolizer(); colorSym.ScaleMode = ScaleMode.Geographic; colorSym.SetWidth(adjWidth); colorSym.SetOutline(Color.DarkGray, adjOutlineWidth); Color fillColor = Color.Gray; if (rsl == 20 || rsl == 19) { fillColor = Color.Blue; } if (rsl <= 18 && rsl >= 16) { fillColor = Color.DeepSkyBlue; } if (rsl <= 15 && rsl >= 13) { fillColor = Color.Green; } if (rsl <= 12 && rsl >= 10) { fillColor = Color.LimeGreen; } if (rsl <= 9 && rsl >= 7) { fillColor = Color.Yellow; } if (rsl <= 6 && rsl >= 4) { fillColor = Color.Orange; } if (rsl <= 3 && rsl >= 1) { fillColor = Color.Red; } if (rsl == 0) { fillColor = Color.DarkRed; } if (selectedColors[fillColor]) { colorSym.SetFillColor(fillColor); } else { continue; } colorCat.Symbolizer = colorSym; // assign (default) selection symbolizer colorCat.SelectionSymbolizer = catSelSym; // done rdScheme.AddCategory(colorCat); } } if (moduleRoads.roadColors == "Treatment") { DataTable nameToTreatment = Database.GetDataByQuery(Project.conn, "SELECT name, category FROM treatments;"); string[] treatments = new string[30]; int j = 0; foreach (DataRow row in nameToTreatment.Rows) { treatments[j] = row["name"].ToString(); if (row["category"].ToString() == "routine") { r[j] = 0; } g[j] = 0; b[j] = 255; if (row["category"].ToString() == "patch") { r[j] = 50; } g[j] = 205; b[j] = 50; if (row["category"].ToString() == "preventative") { r[j] = 255; } g[j] = 255; b[j] = 0; if (row["category"].ToString() == "rehabilitation") { r[j] = 255; } g[j] = 0; b[j] = 0; if (row["category"].ToString() == "reconstruction") { r[j] = 139; } g[j] = 0; b[j] = 0; j++; } treatments[24] = "Routine"; r[24] = 0; g[24] = 0; b[24] = 255; treatments[25] = "Patching"; r[25] = 50; g[25] = 205; b[25] = 50; treatments[26] = "Preventative"; r[26] = 255; g[26] = 255; b[26] = 0; treatments[27] = "Preventative with Patching"; r[27] = 255; g[27] = 165; b[27] = 0; treatments[28] = "Rehabilitation"; r[28] = 255; g[28] = 0; b[28] = 0; treatments[29] = "Reconstruction"; r[29] = 139; g[29] = 0; b[29] = 0; for (int i = 0; i < treatments.Length; i++) { // TODO: Get this to work Color fillColor = Color.Gray; if (r[i] == 0 && g[i] == 0 && b[i] == 255) { fillColor = Color.Blue; } if (r[i] == 50 && g[i] == 205 && b[i] == 50) { fillColor = Color.LimeGreen; } if (r[i] == 255 && g[i] == 255 && b[i] == 0) { fillColor = Color.Yellow; } if (r[i] == 255 && g[i] == 165 && b[i] == 0) { fillColor = Color.Orange; } if (r[i] == 255 && g[i] == 0 && b[i] == 0) { fillColor = Color.Red; } if (r[i] == 139 && g[i] == 0 && b[i] == 0) { fillColor = Color.DarkRed; } if (!selectedColors[fillColor]) { continue; } LineCategory colorCat = new LineCategory(); colorCat.FilterExpression = "[TAMSTREATMENT] = '" + treatments[i] + "'"; LineSymbolizer colorSym = new LineSymbolizer(); colorSym.ScaleMode = ScaleMode.Geographic; colorSym.SetWidth(adjWidth); colorSym.SetOutline(Color.DarkGray, adjOutlineWidth); colorSym.SetFillColor(Color.FromArgb(r[i], g[i], b[i])); colorCat.Symbolizer = colorSym; // assign (default) selection symbolizer colorCat.SelectionSymbolizer = catSelSym; // done rdScheme.AddCategory(colorCat); } } } ((MapLineLayer)moduleRoads.Layer).ShowLabels = false; FeatureLayer roadFeatures = moduleRoads.Layer as FeatureLayer; if (!string.IsNullOrEmpty(Project.settings.GetValue("road_labels"))) { string streetnames = "[" + Project.settings.GetValue(ModuleName + "_f_streetname") + "]"; roadFeatures.AddLabels(streetnames, new Font("Tahoma", (float)8.0), moduleRoads.labelColor); roadFeatures.ShowLabels = Project.settings.GetValue("road_labels").Contains("true"); } ((MapLineLayer)moduleRoads.Layer).Symbology = rdScheme; ((MapLineLayer)moduleRoads.Layer).ApplyScheme(rdScheme); }
private void MenuClick(object sender, EventArgs e) { using (FormContour frm = new FormContour()) { frm.Layers = App.Map.GetRasterLayers(); if (frm.Layers.GetLength(0) <= 0) { MessageBox.Show(Resources.NoRasterLayerFound); return; } if (frm.ShowDialog() != DialogResult.OK) { return; } IMapFeatureLayer fl = App.Map.Layers.Add(frm.Contours); fl.LegendText = frm.LayerName + " - Contours"; int numlevs = frm.Lev.GetLength(0); switch (frm.Contourtype) { case Contour.ContourType.Line: { LineScheme ls = new LineScheme(); ls.Categories.Clear(); for (int i = 0; i < frm.Color.GetLength(0); i++) { LineCategory lc = new LineCategory(frm.Color[i], 2.0) { FilterExpression = "[Value] = " + frm.Lev[i], LegendText = frm.Lev[i].ToString(CultureInfo.InvariantCulture) }; ls.AddCategory(lc); } fl.Symbology = ls; } break; case Contour.ContourType.Polygon: { PolygonScheme ps = new PolygonScheme(); ps.Categories.Clear(); for (int i = 0; i < frm.Color.GetLength(0); i++) { PolygonCategory pc = new PolygonCategory(frm.Color[i], Color.Transparent, 0) { FilterExpression = "[Lev] = " + i, LegendText = frm.Lev[i] + " - " + frm.Lev[i + 1] }; ps.AddCategory(pc); } fl.Symbology = ps; } break; } } }
private void SymbolizerLines(IMapFeatureLayer aLayer) { //Method 1. simple symbolizer aLayer.Symbolizer = new LineSymbolizer(Color.Brown, 1); //Method 2. Combined symbolizer LineSymbolizer road = new LineSymbolizer(Color.Yellow, 5); road.SetOutline(Color.Black, 1); aLayer.Symbolizer = road; /* Method 3. Symbology by unique values: * HueSatLight = true, then the ramp is created by adjusting the * hue, saturation and lightness between the start and end colors. * HueSatLight = false, then the red, blue and green values are ramped instead. * * In both cases, alpha (transparency) is ramped the same way. */ LineScheme lScheme = new LineScheme(); lScheme.EditorSettings.ClassificationType = ClassificationType.UniqueValues; lScheme.EditorSettings.FieldName = "CARTO"; lScheme.CreateCategories(aLayer.DataSet.DataTable); aLayer.Symbology = lScheme; //Method 4. Collapsible field name in legend via 'AppearsInLegend' LineScheme lScheme1 = new LineScheme(); lScheme1.Categories.Clear(); //redundant??? LineCategory lowCat = new LineCategory(Color.Blue, 2); lowCat.FilterExpression = "[CARTO] = 3"; lowCat.LegendText = "Low"; LineCategory highCat = new LineCategory( Color.Red, Color.Black, 6, DashStyle.Solid, LineCap.Triangle);; highCat.FilterExpression = "[CARTO] = 2"; highCat.LegendText = "High"; lScheme1.AppearsInLegend = true; lScheme1.LegendText = "CARTO"; lScheme1.Categories.Add(lowCat); aLayer.Symbology = lScheme1; lScheme1.Categories.Add(highCat); /*Method 5. Lines with multiple strokes * Each individual LineSymbolizer is made up of at least one, * but potentially several strokes overlapping each other */ LineSymbolizer multiStrokeSym = new LineSymbolizer(); multiStrokeSym.Strokes.Clear(); //redundant??? CartographicStroke ties = new CartographicStroke(Color.Brown); ties.DashPattern = new float[] { 1 / 6f, 2 / 6f }; ties.Width = 6; ties.EndCap = LineCap.Flat; ties.StartCap = LineCap.Flat; CartographicStroke rails = new CartographicStroke(Color.DarkGray); rails.CompoundArray = new float[] { .15f, .3f, .6f, .75f }; rails.Width = 6; rails.EndCap = LineCap.Flat; rails.StartCap = LineCap.Flat; multiStrokeSym.Strokes.Add(ties); multiStrokeSym.Strokes.Add(rails); aLayer.Symbolizer = multiStrokeSym; }