public DirectionsResultView(MapWidget mapWidget, FindCloseFacilityResultView fcfResultView, RouteResult routeResult, FindClosestResourceToolbar fcrToolbar) { InitializeComponent(); base.DataContext = this; // Store a reference to the MapWidget that the toolbar has been installed to. _mapWidget = mapWidget; _closestFaculityResult = fcfResultView; _findClosestFacilityToolbar = fcrToolbar; RouteName = routeResult.Directions.RouteName; Summary = string.Format("{0:F1} {1}, {2}", routeResult.Directions.TotalLength, "miles", FormatTime(routeResult.Directions.TotalTime)); List<Graphic> features = new List<Graphic>(routeResult.Directions.Features); features.RemoveAt(0); List<ManeuverViewModel> directionElements = new List<ManeuverViewModel>(); Graphic previous = null; int i = 1; foreach (var next in features) { ManeuverViewModel maneuver = new ManeuverViewModel(previous, next, i++); maneuver.Graphic.MouseLeftButtonDown += Graphic_MouseLeftButtonDown; directionElements.Add(maneuver); previous = next; } Maneuvers = directionElements; }
public DirectionsResultView(MapWidget mapWidget, FindCloseFacilityResultView fcfResultView, RouteResult routeResult, FindClosestResourceToolbar fcrToolbar) { InitializeComponent(); base.DataContext = this; // Store a reference to the MapWidget that the toolbar has been installed to. _mapWidget = mapWidget; _closestFaculityResult = fcfResultView; _findClosestFacilityToolbar = fcrToolbar; RouteName = routeResult.Directions.RouteName; Summary = string.Format("{0:F1} {1}, {2}", routeResult.Directions.TotalLength, "miles", FormatTime(routeResult.Directions.TotalTime)); List <Graphic> features = new List <Graphic>(routeResult.Directions.Features); features.RemoveAt(0); List <ManeuverViewModel> directionElements = new List <ManeuverViewModel>(); Graphic previous = null; int i = 1; foreach (var next in features) { ManeuverViewModel maneuver = new ManeuverViewModel(previous, next, i++); maneuver.Graphic.MouseLeftButtonDown += Graphic_MouseLeftButtonDown; directionElements.Add(maneuver); previous = next; } Maneuvers = directionElements; }
// *********************************************************************************** // * Add a from location point on the map... closest facility will be found for this location // *********************************************************************************** void SolveClosestFacility_Completed(object sender, RouteEventArgs e) { _routesGraphicsLayer.Graphics.Clear(); _routeLabelsGraphicsLayer.Graphics.Clear(); if (e.RouteResults != null) { int i = 0; Random randomGen = new Random(); foreach (RouteResult route in e.RouteResults) { Graphic routeGraphic = route.Route; Color color = createRandomColor(randomGen); randomGen.Next(255); routeGraphic.Symbol = new SimpleLineSymbol() { Width = 5, Color = new SolidColorBrush(color) }; _routesGraphicsLayer.Graphics.Add(routeGraphic); //Route rank identification symbols... client.Geometry.Polyline pl = (client.Geometry.Polyline)routeGraphic.Geometry; int index = pl.Paths[0].Count / 4; Graphic squareGraphic = new Graphic(); client.Geometry.PointCollection ptColl = pl.Paths[pl.Paths.Count/2]; squareGraphic.Geometry = ptColl[ptColl.Count / 2]; //this is the white outline... SimpleMarkerSymbol sms = new SimpleMarkerSymbol() { Style = SimpleMarkerSymbol.SimpleMarkerStyle.Square, Size = 24, Color = new SolidColorBrush(Color.FromRgb(255, 255, 255)), }; squareGraphic.Symbol = sms; _routeLabelsGraphicsLayer.Graphics.Add(squareGraphic); //purple rectangle behind the rank number Graphic squareGraphic2 = new Graphic(); SimpleMarkerSymbol sms2 = new SimpleMarkerSymbol() { Style = SimpleMarkerSymbol.SimpleMarkerStyle.Square, Size = 20, Color = new SolidColorBrush(Color.FromRgb(0,0,139)) }; squareGraphic2.Symbol = sms2; squareGraphic2.Geometry = ptColl[ptColl.Count / 2]; _routeLabelsGraphicsLayer.Graphics.Add(squareGraphic2); //rank number text symbol Graphic routeRankGraphic = new Graphic(); routeRankGraphic.Geometry = ptColl[ptColl.Count / 2]; TextSymbol routeRankSymbol = new TextSymbol(); routeRankSymbol.FontFamily = new FontFamily("Arial Black"); //Modified offsetx from -4 to 5 routeRankSymbol.OffsetX = 5; routeRankSymbol.OffsetY = 10; routeRankSymbol.Text = e.RouteResults[i].Directions.RouteID.ToString(); routeRankSymbol.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255)); routeRankSymbol.FontSize = 16; routeRankGraphic.Symbol = routeRankSymbol; _routeLabelsGraphicsLayer.Graphics.Add(routeRankGraphic); i++; } //zoom to the map if (chkZoomToMap.IsChecked ?? false) _mapWidget.Map.Extent = _routesGraphicsLayer.FullExtent; //Create and Display Closest Facilities List window... _result = new FindCloseFacilityResultView(this, e.RouteResults, _mapWidget); _mapWidget.SetToolbar(_result); } }
// *********************************************************************************** // * Add a from location point on the map... closest facility will be found for this location // *********************************************************************************** void SolveClosestFacility_Completed(object sender, RouteEventArgs e) { _routesGraphicsLayer.Graphics.Clear(); _routeLabelsGraphicsLayer.Graphics.Clear(); if (e.RouteResults != null) { int i = 0; Random randomGen = new Random(); foreach (RouteResult route in e.RouteResults) { Graphic routeGraphic = route.Route; Color color = createRandomColor(randomGen); randomGen.Next(255); routeGraphic.Symbol = new SimpleLineSymbol() { Width = 5, Color = new SolidColorBrush(color) }; _routesGraphicsLayer.Graphics.Add(routeGraphic); //Route rank identification symbols... client.Geometry.Polyline pl = (client.Geometry.Polyline)routeGraphic.Geometry; int index = pl.Paths[0].Count / 4; Graphic squareGraphic = new Graphic(); client.Geometry.PointCollection ptColl = pl.Paths[pl.Paths.Count / 2]; squareGraphic.Geometry = ptColl[ptColl.Count / 2]; //this is the white outline... SimpleMarkerSymbol sms = new SimpleMarkerSymbol() { Style = SimpleMarkerSymbol.SimpleMarkerStyle.Square, Size = 24, Color = new SolidColorBrush(Color.FromRgb(255, 255, 255)), }; squareGraphic.Symbol = sms; _routeLabelsGraphicsLayer.Graphics.Add(squareGraphic); //purple rectangle behind the rank number Graphic squareGraphic2 = new Graphic(); SimpleMarkerSymbol sms2 = new SimpleMarkerSymbol() { Style = SimpleMarkerSymbol.SimpleMarkerStyle.Square, Size = 20, Color = new SolidColorBrush(Color.FromRgb(0, 0, 139)) }; squareGraphic2.Symbol = sms2; squareGraphic2.Geometry = ptColl[ptColl.Count / 2]; _routeLabelsGraphicsLayer.Graphics.Add(squareGraphic2); //rank number text symbol Graphic routeRankGraphic = new Graphic(); routeRankGraphic.Geometry = ptColl[ptColl.Count / 2]; TextSymbol routeRankSymbol = new TextSymbol(); routeRankSymbol.FontFamily = new FontFamily("Arial Black"); //Modified offsetx from -4 to 5 routeRankSymbol.OffsetX = 5; routeRankSymbol.OffsetY = 10; routeRankSymbol.Text = e.RouteResults[i].Directions.RouteID.ToString(); routeRankSymbol.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255)); routeRankSymbol.FontSize = 16; routeRankGraphic.Symbol = routeRankSymbol; _routeLabelsGraphicsLayer.Graphics.Add(routeRankGraphic); i++; } //zoom to the map if (chkZoomToMap.IsChecked ?? false) { _mapWidget.Map.Extent = _routesGraphicsLayer.FullExtent; } //Create and Display Closest Facilities List window... _result = new FindCloseFacilityResultView(this, e.RouteResults, _mapWidget); _mapWidget.SetToolbar(_result); } }