Tools

From Maria GDK Wiki
Jump to navigation Jump to search

Distance Tool

With the DistanceTool the user can create one or more measuring lines with multiple positions. A measuring line can be edited, e.g. add, insert, remove or move positions.

Tool Properties

Here is a list of the properties of the tool.

Name Description
IsPannningEnabled Set if map can be panned when not adding or editing a distance line. When true the IsAddInstanceEnabled property must be set to true before a new distance line can be drawn.
IsInsertPointEnabled Enable or disable if inserting a vertex is allowed.
IsAddPointEnabled Enable or disable if adding a vertex at start or end is allowed.
IsMultiLine Set if tool supports multiple lines.
Positions Returns a list of all the positions defined by the distance tool legs. Can also be used to set the positions of the measuring line.
SelectedInstance The selected measuring line instance.
SelectedIndex The selected vertex/position of the active measuring line instance.
SnapsToPoint When set the tool snaps to track or draw object points.
SnapsToPointDistance The distance in pixels when the tool snaps to a point.
CalculationPath Set how the measure line is calculated: Geodesics or Loxodrome.
OverrideVertexRenderer Renderer for overriding how distance line vertices are rendered.

Tool Style Properties

Here is a list of the properties used to style the appearance of the tool.

Name Description
LineThickness The line thickness.
LineColor The line color.
LineDashStyle The line dash style.
SelectedLineColor The selected line color.
OutlineThickness The outline thickness of the line.
OutlineColor The outline color of the line.
OutlineDashStyle The outline dash style of the line.
VertexLineThickness The vertex line thickness.
VertexLineColor The vertex line color.
VertexOutlineThickness The vertex outline thickness.
VertexOutlineColor The vertex outline color.
VertexFillColor The vertex fill color.
VertexSize The vertex radius.
HighlightColor The highlight distance vertex color.
SelectedVertexLineColor The selected vertex line color.
InsertVertexLineColor The insert vertex line color.
InsertVertexOutlineColor The insert vertex outline color.
InsertVertexFillColor The insert vertex fill color.
AreaFillColor The area fill color.
ForegroundColor The text foreground color.
BackgroundColor The text background color.
OutlineFontColor The outline font color.
FontTypeface The text typeface.
FontSize The text size.

Overriding The Vertex Rendering

To override how the vertices are rendered, create a class that implements the IDistanceToolOverrideRenderer interface and assign an instance of the class to the OverrideVertexRenderer property.

 /// <summary>
 /// Interface for renderer for overriding how distance line vertices are rendered.
 /// </summary>
 public interface IDistanceToolOverrideRenderer
 {
     /// <summary>
     /// Render vertex.
     /// </summary>
     /// <param name="dc">The drawing context instance.</param>
     /// <param name="p">The vertex point.</param>
     /// <param name="isSelected">The selected state of the point.</param>
     void RenderVertex(DrawingContext dc, Point p, bool isSelected);

     /// <summary>
     /// Render snap to vertex.
     /// </summary>
     /// <param name="dc">The drawing context instance.</param>
     /// <param name="p">The vertex point.</param>
     void RenderSnapToVertex(DrawingContext dc, Point p);

     /// <summary>
     /// Render insert vertex.
     /// </summary>
     /// <param name="dc">The drawing context instance.</param>
     /// <param name="p">The vertex point.</param>
     void RenderInsertVertex(DrawingContext dc, Point p);

     /// <summary>
     /// Render add start or end vertex.
     /// </summary>
     /// <param name="dc">The drawing context instance.</param>
     /// <param name="p">The vertex point.</param>
     void RenderAddVertex(DrawingContext dc, Point p);

     /// <summary>
     /// Render highlight distance vertex.
     /// </summary>
     /// <param name="dc">The drawing context instance.</param>
     /// <param name="p">The vertex point.</param>
     void RenderHighlightDistance(DrawingContext dc, Point p);
 }

Set Initial Positions of The Tool

To set initial positions of the tool when it is activated, set the Positions and SelectedIndex properties after the tool is activated.

var geoPos1 = new GeoPos(lat1,lon1);
var geoPos2 = new GeoPos(lat2,lon2);
 
tool.Positions = new List<GeoPos>() { geoPos1 geoPos2 };
tool.SelectedIndex = tool.Positions.Count - 1;