void rsc_QueryRealRoadsCompleted(object sender, QueryRealRoadsCompletedEventArgs e)
        {
            MapLayer layer = (MapLayer)this.ctlMap.FindName("realroads");
            var builder = new StringBuilder();
            if (e.Error==null)
            {
                 Color color = Colors.Blue;
                for (int i = 0; i < e.Result.Count; i++)
                {
                    string[] strArray = e.Result[i].Split(new char[] { ';' });

                    builder.Length = 0;
                    int index = 2;
                    while (index < (strArray.Length - 1))
                    {
                        builder.Append(strArray[index] + ": ");
                        index++;
                    }
                    string[] strArray2 =  strArray[strArray.Length - 1].Split(new char[] { ',' });

                    if ((strArray2.Length == 1) && (strArray2[0].Length > 1))
                    {

                    }
                    else
                    {
                        LocationCollection locations;
                        Location location2;

                        if (strArray2[0].Equals(strArray2[strArray2.Length - 1]))
                        {
                            var polygon = new MapPolygon
                                              {
                                                  Stroke = new SolidColorBrush(color),
                                                  StrokeThickness = 0.5,
                                                  Fill = new SolidColorBrush(color),
                                                  Opacity = 0.75
                                              };
                            locations = new LocationCollection();
                            index = 0;
                            while (index < strArray2.Length)
                            {
                                if (strArray2[index].IndexOf(" ") != -1)
                                {
                                    location2 = new Location(double.Parse(strArray2[index].Split(new char[] {' '})[0]),
                                                             double.Parse(strArray2[index].Split(new char[] {' '})[1]));
                                    locations.Add(location2);
                                }
                                index++;
                            }
                            polygon.Locations = locations;
                            ToolTipService.SetToolTip(polygon, builder.ToString());
                            layer.Children.Add(polygon);
                        }
                        else
                        {
                            var polyline = new MapPolyline {Stroke = new SolidColorBrush(color), StrokeThickness = 6.0};
                            var doubles = new DoubleCollection {3.0, 3.0};
                            polyline.StrokeDashArray = doubles;
                            locations = new LocationCollection();

                            for (index = strArray2.Length - 1; index >= 0; index--)
                            {
                                location2 = new Location(double.Parse(strArray2[index].Split(new char[] {' '})[0]),
                                                         double.Parse(strArray2[index].Split(new char[] {' '})[1]));

                                locations.Add(location2);

                            }

                            polyline.Locations = locations;
                            ToolTipService.SetToolTip(polyline, builder.ToString());

                            layer.Children.Add(polyline);

                        }
                    }
                }
            }
        }
Example #2
0
        void rsc_QueryRealRoadsCompleted(object sender, QueryRealRoadsCompletedEventArgs e)
        {
            MapLayer layer   = (MapLayer)this.ctlMap.FindName("realroads");
            var      builder = new StringBuilder();

            if (e.Error == null)
            {
                Color color = Colors.Blue;
                for (int i = 0; i < e.Result.Count; i++)
                {
                    string[] strArray = e.Result[i].Split(new char[] { ';' });

                    builder.Length = 0;
                    int index = 2;
                    while (index < (strArray.Length - 1))
                    {
                        builder.Append(strArray[index] + ": ");
                        index++;
                    }
                    string[] strArray2 = strArray[strArray.Length - 1].Split(new char[] { ',' });

                    if ((strArray2.Length == 1) && (strArray2[0].Length > 1))
                    {
                    }
                    else
                    {
                        LocationCollection locations;
                        Location           location2;

                        if (strArray2[0].Equals(strArray2[strArray2.Length - 1]))
                        {
                            var polygon = new MapPolygon
                            {
                                Stroke          = new SolidColorBrush(color),
                                StrokeThickness = 0.5,
                                Fill            = new SolidColorBrush(color),
                                Opacity         = 0.75
                            };
                            locations = new LocationCollection();
                            index     = 0;
                            while (index < strArray2.Length)
                            {
                                if (strArray2[index].IndexOf(" ") != -1)
                                {
                                    location2 = new Location(double.Parse(strArray2[index].Split(new char[] { ' ' })[0]),
                                                             double.Parse(strArray2[index].Split(new char[] { ' ' })[1]));
                                    locations.Add(location2);
                                }
                                index++;
                            }
                            polygon.Locations = locations;
                            ToolTipService.SetToolTip(polygon, builder.ToString());
                            layer.Children.Add(polygon);
                        }
                        else
                        {
                            var polyline = new MapPolyline {
                                Stroke = new SolidColorBrush(color), StrokeThickness = 6.0
                            };
                            var doubles = new DoubleCollection {
                                3.0, 3.0
                            };
                            polyline.StrokeDashArray = doubles;
                            locations = new LocationCollection();

                            for (index = strArray2.Length - 1; index >= 0; index--)
                            {
                                location2 = new Location(double.Parse(strArray2[index].Split(new char[] { ' ' })[0]),
                                                         double.Parse(strArray2[index].Split(new char[] { ' ' })[1]));

                                locations.Add(location2);
                            }

                            polyline.Locations = locations;
                            ToolTipService.SetToolTip(polyline, builder.ToString());

                            layer.Children.Add(polyline);
                        }
                    }
                }
            }
        }