Click or drag to resize
Code Example - RoutingWithBarriers

Shows routing and re-routing around user defined point, polyline, and polygon barriers.

Code Example
Routing With Barriers

This section contains selected code files from a Visual Studio project that emphasize specific ArcGIS Runtime SDK (Windows Desktop) features. For example: some code examples may accomplish the bulk of the work as a configuration property in the .xaml file and hence only the .xaml file will be shown in detail below. In other code examples, the .xaml is used to define the configuration of graphical elements for the application but the application logic is performed in the code behind, hence you may see both the .xaml and .cs/.vb files shown in detail below.

XAML
<Window x:Class="RoutingWithBarriers.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
        xmlns:local="clr-namespace:RoutingWithBarriers"
        Height="600" Width="800">

    <Window.CommandBindings>
        <CommandBinding Command="local:NetworkCommands.AddStopCommand" Executed="CommandBinding_AddStopExecuted" />
        <CommandBinding Command="local:NetworkCommands.AddPointBarrierCommand" Executed="CommandBinding_AddPointBarrierExecuted" />
        <CommandBinding Command="local:NetworkCommands.AddPolylineBarrierCommand" Executed="CommandBinding_AddPolylineBarrierExecuted" />
        <CommandBinding Command="local:NetworkCommands.AddPolygonBarrierCommand" Executed="CommandBinding_AddPolygonBarrierExecuted" />
    </Window.CommandBindings>

    <Grid>

        <esri:MapView x:Name="MapView1">
            <esri:Map x:Name="MyMap">
                <esri:ArcGISTiledMapServiceLayer
            ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
            </esri:Map>
        </esri:MapView>

        <Border HorizontalAlignment="Right" VerticalAlignment="Top" Margin="10" Padding="5" Background="White" 
                BorderBrush="Black" BorderThickness="1">
            <Border.Effect>
                <DropShadowEffect />
            </Border.Effect>
            <StackPanel Orientation="Vertical">
                <StackPanel >
                    <TextBlock >Stops:</TextBlock>
                    <Button x:Name="AddStopButton" Command="local:NetworkCommands.AddStopCommand"  
                                ToolTip="Add Stop" Width="32" Height="32" Margin="5,5,5,0" >
                        <Image Source="pack://application:,,,/RoutingWithBarriers;component/Assets/DrawPoint.png" />
                    </Button>
                    <TextBlock >Barriers:</TextBlock>
                    <Button x:Name="AddPointBarrierButton" Command="local:NetworkCommands.AddPointBarrierCommand"  
                            ToolTip="Add Point Barrier" Width="32" Height="32" Margin="5,5,5,0" >
                        <Image Source="pack://application:,,,/RoutingWithBarriers;component/Assets/DrawPoint.png" />
                    </Button>
                    <Button x:Name="AddPolylineBarrierButton" Command="local:NetworkCommands.AddPolylineBarrierCommand"  
                            ToolTip="Add Polyline Barrier" Width="32" Height="32" Margin="5,5,5,0" >
                        <Image Source="pack://application:,,,/RoutingWithBarriers;component/Assets/DrawLineSegment.png" />
                    </Button>
                    <Button x:Name="AddPolygonBarrierButton" Command="local:NetworkCommands.AddPolygonBarrierCommand"  
                            ToolTip="Add Polygon Barrier" Width="32" Height="32" Margin="5,5,5,0" >
                        <Image Source="pack://application:,,,/RoutingWithBarriers;component/Assets/DrawPolygon.png" />
                    </Button>
                </StackPanel>

            </StackPanel>
        </Border>
    </Grid>

</Window>

SPECIAL NOTE: The XAML displayed above comes from a C# project. If you are a VB.NET developer, you will need to modify the text for the x:Class namespace from "RoutingWithBarriers.MainWindow" to be just "MainWindow".

using System.Linq;

// NOTE: This sample demonstrates routing and re-routing around user defined point, polyline, and polygon barriers. Some MVVM styles of
// programming logic are incorporated for control updates within the application. 
// 
// TO USE: 
// (1) When the application loads, click the top button and add an initial staring point for a route on the map. Then click the top button again
// to add another stop on the map to calculate an initial route (this will cause the routing algorithm to determine the optimal routing path 
// between the two points). You could add more routing points by clicking the top button again and then clicking on the map but it is not necessary.
// (2) Click on any of the bottom 3 buttons and then click on the map to add barriers along the route to cause a re-route to occur.  

namespace RoutingWithBarriers
{

    public partial class MainWindow : System.Windows.Window, System.ComponentModel.INotifyPropertyChanged
    {

        // Enable adding the functionality of INotifyPropertyChanged interface into the sample. We will use it for 
        // determining if the Map is ready for adding graphics.

        // Declare the signature of the PropertyChanged Event when various property values change.
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;


        // Global variable for determining if the Map is ready for adding graphics.
        private bool _isMapReady = true;

        // Gets or sets a value indicating whether the Map is initialized. True if the Map is initialized; otherwise, False.
        public bool IsMapReady
        {
            get
            {
                return _isMapReady;
            }
            set
            {
                _isMapReady = !value;

                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs("IsMapReady"));
                }
            }
        }


        // Global variable for the polyline route GraphicsLayer displayed to the user in the Map.
        Esri.ArcGISRuntime.Layers.GraphicsLayer _routeGraphicsLayer;

        // Global variable for the beginning and ending points GraphicsLayer when the user clicks on the Map.
        Esri.ArcGISRuntime.Layers.GraphicsLayer _stopsGraphicsLayer;

        // Global variable for the barrier points GraphicsLayer that will cause re-routing to occur.
        Esri.ArcGISRuntime.Layers.GraphicsLayer _pointBarriersGraphicsLayer;

        // Global variable for the barrier polyline GraphicsLayer that will cause re-routing to occur. 
        Esri.ArcGISRuntime.Layers.GraphicsLayer _polylineBarriersGraphicsLayer;

        // Global variable for the barrier polygon GraphicsLayer that will cause re-routing to occur. 
        Esri.ArcGISRuntime.Layers.GraphicsLayer _polygonBarriersGraphicsLayer;

        // Global variable for the RouteTask. 
        Esri.ArcGISRuntime.Tasks.NetworkAnalyst.RouteTask _routeTask;

        Esri.ArcGISRuntime.Tasks.NetworkAnalyst.RouteParameters _routeParams;

        private async System.Threading.Tasks.Task SetupRouteTask()
        {
            // This function sets up the _routeTask.

            _routeTask = null;
            string _onlineRoutingService = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/NAServer/Route";
            _routeTask = new Esri.ArcGISRuntime.Tasks.NetworkAnalyst.OnlineRouteTask(new System.Uri(_onlineRoutingService));

            if (_routeTask != null)
                _routeParams = await _routeTask.GetDefaultParametersAsync();
        }

        public MainWindow()
        {
            InitializeComponent();

            // Set up the Binding DataContent to this application.
            DataContext = this;

            // Define a SpatialReference for WebMercator.
            Esri.ArcGISRuntime.Geometry.SpatialReference spatialReferenceWebMercator = null;
            spatialReferenceWebMercator = new Esri.ArcGISRuntime.Geometry.SpatialReference(102100);

            // Define an Envelope for the downtown San Diego region using the WebMercator SpatialReference.
            Esri.ArcGISRuntime.Geometry.Envelope myEnvelope = null;
            myEnvelope = new Esri.ArcGISRuntime.Geometry.Envelope(-13044000, 3855000, -13040000, 3858000, spatialReferenceWebMercator);

            // Set the initial extent (via the InitialViewpoint Property) of the Map to the downtown San Diego region.
            MapView1.Map.InitialViewpoint = new Esri.ArcGISRuntime.Controls.Viewpoint(myEnvelope);

            // Call the function to set up the Route Task.
            var _x = SetupRouteTask();

            // Call the function to set up all of the various graphics layers used by the application.
            CreateGraphicsLayers();

            // Call the asynchronous function to ensure all the layers have been loaded so that the user can interact with the Map.
            HandleLayersInitialized();
        }

        private async void HandleLayersInitialized()
        {
            try
            {
                // This next line of code is important. The Task.WhenAll is a Microsoft function that ascertains when a Task has 
                // completed. By using a LINQ query for MapView1.Map.Layers.Select we cycle through all of the Layers to know if we have 
                // a successful layer completion, an error or a cancel.
                await System.Threading.Tasks.Task.WhenAll(MapView1.Map.Layers.Select(layer => layer.InitializeAsync()).ToArray());

                // Once this next line of code executes, the IsMapReady will be called again and this time the _isMapReady global 
                // variable will be set to True and the PropertyChanged Event will be raised allowing the SolveRouteButton to be enabled.
                // This means that the user can now add stops on the map and the route will be calculated.
                IsMapReady = true;
            }
            catch (System.Exception ex)
            {
                // There was a problem, display it to the user.
                System.Windows.MessageBox.Show(ex.Message);
                return;
            }
        }

        public void CreateGraphicsLayers()
        {
            // Create a new GraphicsLayer to hold the polyline route.
            _routeGraphicsLayer = new Esri.ArcGISRuntime.Layers.GraphicsLayer();

            // Create a new renderer to symbolize the polyline and apply it to the GraphicsLayer
            Esri.ArcGISRuntime.Symbology.SimpleLineSymbol myPolylineRouteSymbol = new Esri.ArcGISRuntime.Symbology.SimpleLineSymbol();
            myPolylineRouteSymbol.Color = System.Windows.Media.Colors.Blue;
            myPolylineRouteSymbol.Style = Esri.ArcGISRuntime.Symbology.SimpleLineStyle.Dot;
            myPolylineRouteSymbol.Width = 2;
            Esri.ArcGISRuntime.Symbology.SimpleRenderer myPolylineRouteRenderer = new Esri.ArcGISRuntime.Symbology.SimpleRenderer();
            myPolylineRouteRenderer.Symbol = myPolylineRouteSymbol;
            _routeGraphicsLayer.Renderer = myPolylineRouteRenderer;

            // Add the polyline route GraphicsLayer to the LayerCollection in the Map.
            MapView1.Map.Layers.Add(_routeGraphicsLayer);

            //-----------------------------------------------------------------

            // Create a new GraphicsLayer to hold the start and end point locations of the route.
            _stopsGraphicsLayer = new Esri.ArcGISRuntime.Layers.GraphicsLayer();

            // Create a new renderer to symbolize the start and end points that define the route and apply it to the GraphicsLayer
            Esri.ArcGISRuntime.Symbology.SimpleMarkerSymbol myStopSymbol = new Esri.ArcGISRuntime.Symbology.SimpleMarkerSymbol();
            myStopSymbol.Color = System.Windows.Media.Colors.Green;
            myStopSymbol.Size = 12;
            myStopSymbol.Style = Esri.ArcGISRuntime.Symbology.SimpleMarkerStyle.Circle;
            Esri.ArcGISRuntime.Symbology.SimpleRenderer myStopRenderer = new Esri.ArcGISRuntime.Symbology.SimpleRenderer();
            myStopRenderer.Symbol = myStopSymbol;
            _stopsGraphicsLayer.Renderer = myStopRenderer;

            // Add the start and end points GraphicsLayer to the LayerCollection in the Map.
            MapView1.Map.Layers.Add(_stopsGraphicsLayer);

            //-----------------------------------------------------------------

            // Create a GraphicsLayer to hold point barriers that the routing algorithm will re-route around.
            _pointBarriersGraphicsLayer = new Esri.ArcGISRuntime.Layers.GraphicsLayer();

            // Create a new renderer to symbolize the point barriers 
            Esri.ArcGISRuntime.Symbology.SimpleMarkerSymbol myBarrierPointSymbol = new Esri.ArcGISRuntime.Symbology.SimpleMarkerSymbol();
            myBarrierPointSymbol.Color = System.Windows.Media.Colors.Red;
            myBarrierPointSymbol.Size = 12;
            myBarrierPointSymbol.Style = Esri.ArcGISRuntime.Symbology.SimpleMarkerStyle.Square;
            Esri.ArcGISRuntime.Symbology.SimpleRenderer myBarrierPointRenderer = new Esri.ArcGISRuntime.Symbology.SimpleRenderer();
            myBarrierPointRenderer.Symbol = myBarrierPointSymbol;
            _pointBarriersGraphicsLayer.Renderer = myBarrierPointRenderer;

            // Add the point barriers GraphicsLayer to the LayerCollection in the Map.
            MapView1.Map.Layers.Add(_pointBarriersGraphicsLayer);

            //-----------------------------------------------------------------

            // Create a GraphicsLayer to hold polyline barriers that the routing algorithm will re-route around.
            _polylineBarriersGraphicsLayer = new Esri.ArcGISRuntime.Layers.GraphicsLayer();

            // Create a new renderer to symbolize the polyline barriers 
            Esri.ArcGISRuntime.Symbology.SimpleLineSymbol myBarrierPolylineSymbol = new Esri.ArcGISRuntime.Symbology.SimpleLineSymbol();
            myBarrierPolylineSymbol.Color = System.Windows.Media.Colors.Red;
            myBarrierPolylineSymbol.Width = 3;
            myBarrierPolylineSymbol.Style = Esri.ArcGISRuntime.Symbology.SimpleLineStyle.Solid;
            Esri.ArcGISRuntime.Symbology.SimpleRenderer myBarrierPolylineRenderer = new Esri.ArcGISRuntime.Symbology.SimpleRenderer();
            myBarrierPolylineRenderer.Symbol = myBarrierPolylineSymbol;
            _polylineBarriersGraphicsLayer.Renderer = myBarrierPolylineRenderer;

            // Add the polyline barriers GraphicsLayer to the LayerCollection in the Map.
            MapView1.Map.Layers.Add(_polylineBarriersGraphicsLayer);

            //-----------------------------------------------------------------

            // Create a GraphicsLayer to hold polygon barriers that the routing algorithm will re-route around.
            _polygonBarriersGraphicsLayer = new Esri.ArcGISRuntime.Layers.GraphicsLayer();

            // Create a new renderer to symbolize the polyline barriers 
            Esri.ArcGISRuntime.Symbology.SimpleFillSymbol myBarrierPolygonSymbol = new Esri.ArcGISRuntime.Symbology.SimpleFillSymbol();
            myBarrierPolygonSymbol.Color = System.Windows.Media.Colors.Red;
            myBarrierPolygonSymbol.Style = Esri.ArcGISRuntime.Symbology.SimpleFillStyle.DiagonalCross;
            Esri.ArcGISRuntime.Symbology.SimpleLineSymbol myBarrierPolygonOutlineSymbol = new Esri.ArcGISRuntime.Symbology.SimpleLineSymbol();
            myBarrierPolygonOutlineSymbol.Color = System.Windows.Media.Colors.Red;
            myBarrierPolygonOutlineSymbol.Style = Esri.ArcGISRuntime.Symbology.SimpleLineStyle.Solid;
            myBarrierPolygonOutlineSymbol.Width = 2;
            myBarrierPolygonSymbol.Outline = myBarrierPolygonOutlineSymbol;
            Esri.ArcGISRuntime.Symbology.SimpleRenderer myBarrierPolygonRenderer = new Esri.ArcGISRuntime.Symbology.SimpleRenderer();
            myBarrierPolygonRenderer.Symbol = myBarrierPolygonSymbol;
            _polygonBarriersGraphicsLayer.Renderer = myBarrierPolygonRenderer;

            // Add the polygon barriers GraphicsLayer to the LayerCollection in the Map.
            MapView1.Map.Layers.Add(_polygonBarriersGraphicsLayer);
        }

        public async System.Threading.Tasks.Task SolveRoute()
        {
            if (_stopsGraphicsLayer.Graphics.Count > 1)
            {
                try
                {
                    _routeParams.ReturnPointBarriers = true;
                    _routeParams.ReturnPolylineBarriers = true;
                    _routeParams.ReturnPolygonBarriers = true;
                    _routeParams.ReturnStops = true;
                    _routeParams.ReturnZ = true;

                    _routeParams.SetStops(_stopsGraphicsLayer.Graphics);
                    _routeParams.SetPointBarriers(_pointBarriersGraphicsLayer.Graphics);
                    _routeParams.SetPolylineBarriers(_polylineBarriersGraphicsLayer.Graphics);
                    _routeParams.SetPolygonBarriers(_polygonBarriersGraphicsLayer.Graphics);

                    _routeParams.OutSpatialReference = MapView1.SpatialReference;
                    _routeParams.DirectionsLengthUnit = Esri.ArcGISRuntime.Geometry.LinearUnits.Kilometers;

                    Esri.ArcGISRuntime.Tasks.NetworkAnalyst.RouteResult routeResult = await _routeTask.SolveAsync(_routeParams);
                    if (routeResult.Routes.Count > 0)
                    {
                        _routeGraphicsLayer.Graphics.Clear();
                        Esri.ArcGISRuntime.Layers.Graphic graphic = new Esri.ArcGISRuntime.Layers.Graphic(routeResult.Routes[0].RouteFeature.Geometry);
                        _routeGraphicsLayer.Graphics.Add(graphic);
                    }
                }
                catch (System.AggregateException ex)
                {
                    var innermostExceptions = ex.Flatten().InnerExceptions;
                    if (innermostExceptions != null && innermostExceptions.Count > 0)
                        System.Windows.MessageBox.Show(innermostExceptions[0].Message);
                    else
                        System.Windows.MessageBox.Show(ex.Message);
                }
                catch (System.Exception ex)
                {
                    System.Windows.MessageBox.Show("Error: " + ex.Message);
                }
            }
        }

          private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            foreach (Esri.ArcGISRuntime.Layers.Layer layer in MapView1.Map.Layers)
                if (layer is Esri.ArcGISRuntime.Layers.GraphicsLayer)
                    (layer as Esri.ArcGISRuntime.Layers.GraphicsLayer).Graphics.Clear();
        }

          private async void CommandBinding_AddStopExecuted(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            try
            {
                Esri.ArcGISRuntime.Geometry.MapPoint mapPoint;
                mapPoint = await MapView1.Editor.RequestPointAsync();
                _stopsGraphicsLayer.Graphics.Add(new Esri.ArcGISRuntime.Layers.Graphic(mapPoint));

                await SolveRoute();
            }
            catch (System.Exception exception)
            {
                System.Windows.MessageBox.Show(exception.Message);
            }
        }

          private async void CommandBinding_AddPointBarrierExecuted(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            try
            {
                Esri.ArcGISRuntime.Geometry.MapPoint mapPoint;
                mapPoint = await MapView1.Editor.RequestPointAsync();
                _pointBarriersGraphicsLayer.Graphics.Add(new Esri.ArcGISRuntime.Layers.Graphic(mapPoint));

                await SolveRoute();
            }
            catch (System.Exception exception)
            {
                System.Windows.MessageBox.Show(exception.Message);
            }
        }

          private async void CommandBinding_AddPolylineBarrierExecuted(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            try
            {
                Esri.ArcGISRuntime.Geometry.PolylineBuilder myPolylineBuilder = new Esri.ArcGISRuntime.Geometry.PolylineBuilder(MapView1.SpatialReference);

                // Assign Spatial Reference (no SR conveyed from Coordinates to PolyLine)
                Esri.ArcGISRuntime.Geometry.PointCollection coords = new Esri.ArcGISRuntime.Geometry.PointCollection(MapView1.SpatialReference);

                // 1st Point:
                Esri.ArcGISRuntime.Geometry.MapPoint mapPoint;
                mapPoint = await MapView1.Editor.RequestPointAsync();
                coords.Add(mapPoint);
                Esri.ArcGISRuntime.Layers.Graphic g1 = new Esri.ArcGISRuntime.Layers.Graphic(mapPoint);
                _pointBarriersGraphicsLayer.Graphics.Add(g1);

                // 2nd Point:
                mapPoint = await MapView1.Editor.RequestPointAsync();
                coords.Add(mapPoint);
                Esri.ArcGISRuntime.Layers.Graphic g2 = new Esri.ArcGISRuntime.Layers.Graphic(mapPoint);
                _pointBarriersGraphicsLayer.Graphics.Add(g2); 

                // Return to UI thread to allow 2nd graphic to appear.
                await System.Threading.Tasks.Task.Delay(100);

                Esri.ArcGISRuntime.Geometry.SegmentCollection mySegmentCollection = new Esri.ArcGISRuntime.Geometry.SegmentCollection(coords);

                myPolylineBuilder.Parts.Add(mySegmentCollection);
                _polylineBarriersGraphicsLayer.Graphics.Add(new Esri.ArcGISRuntime.Layers.Graphic(myPolylineBuilder.ToGeometry()));
                _pointBarriersGraphicsLayer.Graphics.Remove(g1);
                _pointBarriersGraphicsLayer.Graphics.Remove(g2);

                await SolveRoute();
            }
            catch (System.Exception exception)
            {
                System.Windows.MessageBox.Show(exception.Message);
            }
        }

        private async void CommandBinding_AddPolygonBarrierExecuted(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
        {
            try
            {
                // Polygon Barrier:
                Esri.ArcGISRuntime.Geometry.PolygonBuilder myPolygonBuilder = new Esri.ArcGISRuntime.Geometry.PolygonBuilder(MapView1.SpatialReference);

                // Assign Spatial Reference (no SR conveyed from Coordinates to PolyLine)
                Esri.ArcGISRuntime.Geometry.PointCollection coords = new Esri.ArcGISRuntime.Geometry.PointCollection(MapView1.SpatialReference);

                // 1st Point:
                Esri.ArcGISRuntime.Geometry.MapPoint mapPoint;
                mapPoint = await MapView1.Editor.RequestPointAsync();
                coords.Add(mapPoint);
                Esri.ArcGISRuntime.Layers.Graphic g1 = new Esri.ArcGISRuntime.Layers.Graphic(mapPoint);
                _pointBarriersGraphicsLayer.Graphics.Add(g1);

                // 2nd Point:
                mapPoint = await MapView1.Editor.RequestPointAsync();
                coords.Add(mapPoint);
                Esri.ArcGISRuntime.Layers.Graphic g2 = new Esri.ArcGISRuntime.Layers.Graphic(mapPoint);
                _pointBarriersGraphicsLayer.Graphics.Add(g2);

                // Return to UI thread to allow 2nd graphic to appear.
                await System.Threading.Tasks.Task.Delay(100);

                // 3rd Point:
                mapPoint = await MapView1.Editor.RequestPointAsync();
                coords.Add(mapPoint);
                Esri.ArcGISRuntime.Layers.Graphic g3 = new Esri.ArcGISRuntime.Layers.Graphic(mapPoint);
                _pointBarriersGraphicsLayer.Graphics.Add(g3);

                // Return to UI thread to allow 2nd graphic to appear.
                await System.Threading.Tasks.Task.Delay(100);

                Esri.ArcGISRuntime.Geometry.SegmentCollection mySegmentCollection = new Esri.ArcGISRuntime.Geometry.SegmentCollection(coords);

                myPolygonBuilder.Parts.Add(mySegmentCollection);
                _polygonBarriersGraphicsLayer.Graphics.Add(new Esri.ArcGISRuntime.Layers.Graphic(myPolygonBuilder.ToGeometry()));
                _pointBarriersGraphicsLayer.Graphics.Remove(g1);
                _pointBarriersGraphicsLayer.Graphics.Remove(g2);
                _pointBarriersGraphicsLayer.Graphics.Remove(g3);

                await SolveRoute();
            }
            catch (System.Exception exception)
            {
                System.Windows.MessageBox.Show(exception.Message);
            }
        }
    }

    public static class NetworkCommands
    {
        public static readonly System.Windows.Input.RoutedUICommand AddStopCommand = new System.Windows.Input.RoutedUICommand("Add Stop", "AddStopCommand", typeof(RoutingWithBarriers.MainWindow));
        public static readonly System.Windows.Input.RoutedUICommand AddPointBarrierCommand = new System.Windows.Input.RoutedUICommand("Add Point Barrier", "AddPointBarrierCommand", typeof(RoutingWithBarriers.MainWindow));
        public static readonly System.Windows.Input.RoutedUICommand AddPolylineBarrierCommand = new System.Windows.Input.RoutedUICommand("Add Polyline Barrier", "AddPolylineBarrierCommand", typeof(RoutingWithBarriers.MainWindow));
        public static readonly System.Windows.Input.RoutedUICommand AddPolygonBarrierCommand = new System.Windows.Input.RoutedUICommand("Add Polygon Barrier", "AddPolygonBarrierCommand", typeof(RoutingWithBarriers.MainWindow));
    }

}