ArcGISWindowsPhoneSDK.RoutingDirections.routeTask_SolveCompleted C# (CSharp) Method

routeTask_SolveCompleted() private method

private routeTask_SolveCompleted ( object sender, RouteEventArgs e ) : void
sender object
e RouteEventArgs
return void
        private void routeTask_SolveCompleted(object sender, RouteEventArgs e)
        {
            GraphicsLayer graphicsLayer = MyMap.Layers["MyRouteGraphicsLayer"] as GraphicsLayer;
            RouteResult routeResult = e.RouteResults[0];
            _directionsFeatureSet = routeResult.Directions;

            graphicsLayer.Graphics.Add(new Graphic() { Geometry = _directionsFeatureSet.MergedGeometry, Symbol = LayoutRoot.Resources["RouteSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol });
            TotalDistanceTextBlock.Text = string.Format("Total Distance: {0}", FormatDistance(_directionsFeatureSet.TotalLength, "miles"));
            TotalTimeTextBlock.Text = string.Format("Total Time: {0}", FormatTime(_directionsFeatureSet.TotalTime));

            int i = 1;
            foreach (Graphic graphic in _directionsFeatureSet.Features)
            {
                System.Text.StringBuilder text = new System.Text.StringBuilder();
                text.AppendFormat("{0}. {1}", i, graphic.Attributes["text"]);
                if (i > 1 && i < _directionsFeatureSet.Features.Count)
                {
                    string distance = FormatDistance(Convert.ToDouble(graphic.Attributes["length"]), "miles");
                    string time = null;
                    if (graphic.Attributes.ContainsKey("time"))
                    {
                        time = FormatTime(Convert.ToDouble(graphic.Attributes["time"]));
                    }
                    if (!string.IsNullOrEmpty(distance) || !string.IsNullOrEmpty(time))
                        text.Append(" (");
                    text.Append(distance);
                    if (!string.IsNullOrEmpty(distance) && !string.IsNullOrEmpty(time))
                        text.Append(", ");
                    text.Append(time);
                    if (!string.IsNullOrEmpty(distance) || !string.IsNullOrEmpty(time))
                        text.Append(")");
                }
                TextBlock textBlock = new TextBlock() { Text = text.ToString(), Tag = graphic, Margin = new Thickness(4), Cursor = Cursors.Hand, TextWrapping = TextWrapping.Wrap };
                textBlock.MouseLeftButtonDown += new MouseButtonEventHandler(directionsSegment_MouseLeftButtonDown);
                DirectionsStackPanel.Children.Add(textBlock);
                i++;
            }
            MyMap.ZoomTo(Expand(_directionsFeatureSet.Extent));
        }