Skip to content

Applying a Directional Styling in a WPF Application

This ThinkGeo WPF ApplyDirectionPointStyleForLineStyle functionality for .NET Core will guide you through drawing lineStyles in the form of directional arrows on a map. The direction Point can be an image or a glyph, it not only rotates the icon across the angle of the road, but also provides a way to customize the rotation of the direction point. The arrows highlighted in the red circle in the following screenshot are customized based on the line’s attributes. This sample supports ThinkGeo UI for WPF version 12.0 and higher.

A look at the code

// Set up the line style with white inner pen and black center pen. 
var lineStyle = new LineStyle(new GeoPen(GeoColors.Black, 16) { StartCap = DrawingLineCap.Round, EndCap = DrawingLineCap.Round }, new GeoPen(GeoColors.White, 13) { StartCap = DrawingLineCap.Round, EndCap = DrawingLineCap.Round });

// Set up the required column name for the style. We will customize the line style based on this column value. 
lineStyle.RequiredColumnNames.Add("FENAME");
            
// Set up the style for Direction Point and set up the event for customization. 
lineStyle.DirectionPointStyle = new PointStyle(new GeoImage("AppData\\Arrow.png"));
lineStyle.DrawingDirectionPoint += LineStyle_DrawingPointStyle;
            
private void LineStyle_DrawingPointStyle(object sender, DrawingDirectionPointEventArgs e)
{
    // Customize the direction point for the line feature whose "FENAME" column equals to "Mo-Pac". 
    if (e.Line.ColumnValues["FENAME"] == "Mo-Pac")
    {
        e.RotationAngle = 0;
    }
}

For lots more samples like this, check out ThinkGeo’s GitHub repository, and then start your free 60-day evaluation of ThinkGeo UI to start building your own custom maps.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *