This example demonstrates how to create custom line patterns. Here is a screenshot with the results of the code execution.

using AxMapWinGIS;
using MapWinGIS;
namespace Examples
public partial class MapExamples
// <summary>
// Creates and displayes custom line patterns
// </summary>
public void LinePattern(AxMap axMap1, string iconPath)
axMap1.Projection = tkMapProjection.PROJECTION_NONE;
var sf = this.CreateLines();
axMap1.AddLayer(sf, true);
var utils = new Utils();
// railroad pattern
LinePattern pattern = new LinePattern();
pattern.AddLine(utils.ColorByName(tkMapColor.Black), 6.0f, tkDashStyle.dsSolid);
pattern.AddLine(utils.ColorByName(tkMapColor.White), 5.0f, tkDashStyle.dsDot);
ShapefileCategory ct = sf.Categories.Add("Railroad");
sf.set_ShapeCategory(0, 0);
// river pattern
pattern = new LinePattern();
pattern.AddLine(utils.ColorByName(tkMapColor.DarkBlue), 6.0f, tkDashStyle.dsSolid);
pattern.AddLine(utils.ColorByName(tkMapColor.LightBlue), 4.0f, tkDashStyle.dsSolid);
ct = sf.Categories.Add("River");
sf.set_ShapeCategory(1, 1);
// road with direction
pattern = new LinePattern();
pattern.AddLine(utils.ColorByName(tkMapColor.Gray), 8.0f, tkDashStyle.dsSolid);
pattern.AddLine(utils.ColorByName(tkMapColor.Yellow), 7.0f, tkDashStyle.dsSolid);
LineSegment segm = pattern.AddMarker(tkDefaultPointSymbol.dpsArrowRight);
segm.Color = utils.ColorByName(tkMapColor.Orange);
segm.MarkerSize = 10;
segm.MarkerInterval = 32;
ct = sf.Categories.Add("Direction");
sf.set_ShapeCategory(2, 2);
// <summary>
// This function creates a number of parallel polylines (segments)
// </summary>
private Shapefile CreateLines()
Shapefile sf = new Shapefile();
sf.CreateNew("", ShpfileType.SHP_POLYLINE);
int width = 500;
int step = 50;
for (int i = 0; i < 3; i++)
Shape shp = new Shape();
Point pnt = new Point();
pnt.x = 0;
pnt.y = i * step;
int index = shp.numPoints;
shp.InsertPoint(pnt, ref index);
pnt = new Point();
pnt.x = width;
pnt.y = i * step;
index = shp.numPoints;
shp.InsertPoint(pnt, ref index);
index = sf.NumShapes;
sf.EditInsertShape(shp, ref index);
return sf;
A list of named constants for some of the well-known colors.
Definition: Enumerations.cs:951
The available style of lines. Can be used for drawing polylines and outlines of the polygons.
Definition: Enumerations.cs:442
The type of the shapefile.
Definition: Enumerations.cs:169
The set of available point symbols. They represent macros for modification of several properties of t...
Definition: Enumerations.cs:460
Commonly used map projections to be set in Form Designer (see AxMap.Projection property).
Definition: Enumerations.cs:1741
Map component for visualization of vector, raster or grid data.
Definition: AxMap.cs:56
Provides means for defining custom pattern from lines and point symbols for rendering polyline layers...
Definition: LinePattern.cs:46
LineSegment AddMarker(tkDefaultPointSymbol Marker)
Adds a segment represented by point symbol (marker).
Definition: LinePattern.cs:64
void AddLine(uint Color, float Width, tkDashStyle style)
Adds a line segment to the pattern.
Definition: LinePattern.cs:54
Holds information about a single line or marker in the line pattern represented by LinePattern class.
Definition: LineSegment.cs:39
uint Color
Gets or sets the color of the line or marker.
Definition: LineSegment.cs:45
float MarkerSize
Gets or sets the size of marker in pixels.
Definition: LineSegment.cs:214
float MarkerInterval
Gets or sets the interval between markers.
Definition: LineSegment.cs:142
A point object represents a point with x, y, Z, and M values. Shapes created by adding point objects ...
Definition: PointClass.cs:38
double y
Gets or sets the y value of the point.
Definition: PointClass.cs:122
double x
Gets or sets the x value of the point.
Definition: PointClass.cs:113
LinePattern LinePattern
Gets or sets line pattern for rendering polyline shapefile.
Definition: ShapeDrawingOptions.cs:586
bool UseLinePattern
Gets or set the value which indicates whether line pattern will be used to render polyline shapefile.
Definition: ShapeDrawingOptions.cs:790
A shape object represents a geometric shape which can be added to a shapefile which is displayed in t...
Definition: Shape.cs:41
bool Create(ShpfileType shpType)
Creates a new shape of the specified type.
Definition: Shape.cs:154
bool InsertPoint(Point newPoint, ref int pointIndex)
Inserts the specified point object into the shape using the desired point index if possible.
Definition: Shape.cs:372
Represents a set of visualization options for shapefile layer.
Definition: ShapefileCategory.cs:47
ShapeDrawingOptions DrawingOptions
Gets or sets visualization options associated with the category.
Definition: ShapefileCategory.cs:52
Provides a functionality for accessing and editing ESRI shapefiles.
Definition: Shapefile.cs:72
int NumShapes
Gets the number of shapes in the shapefile.
Definition: Shapefile.cs:254
A utils object provides access to a set of utility functions to perform a variety of tasks on other o...
Definition: Utils.cs:20
tkMapProjection Projection
Sets projection of the map. It providers 2 most commonly used coordinate system/projections to be eas...
Definition: AxMap.cs:2709
int AddLayer(object Object, bool visible)
Adds a layer to the map.
Definition: AxMap.cs:1342
bool EditInsertShape(Shape shape, ref int shapeIndex)
Inserts a new shape in the shapefile.
Definition: Shapefile.cs:819
bool CreateNew(string shapefileName, ShpfileType shapefileType)
Initializes in-memory shapefile of the specified type.
Definition: Shapefile.cs:1401