public void SetScenario(Scenario scenario) { this.scenario = scenario; statusLabel.Content = "Scenario initialized"; StartButton.IsEnabled = true; ScenarioComboBox.IsEnabled = true; tourLayer.Shapes.Clear(); orderLayer.Shapes.Clear(); depotLayer.Shapes.Clear(); foreach (var order in scenario.Orders) { var pin = new Ptv.XServer.Controls.Map.Symbols.Cube(); pin.Color = unplannedColor; pin.Width = pin.Height = Math.Sqrt(order.Quantity) * 10; ShapeCanvas.SetLocation(pin, new Point(order.Longitude, order.Latitude)); orderLayer.Shapes.Add(pin); pin.Tag = order; } foreach (var depot in scenario.Depots) { var pin = new Ptv.XServer.Controls.Map.Symbols.Pyramid(); pin.Width = pin.Height = 30; pin.Color = depot.Color; ShapeCanvas.SetLocation(pin, new Point(depot.Longitude, depot.Latitude)); depotLayer.Shapes.Add(pin); } if (firstTime) { firstTime = false; MessageBox.Show(this, "This sample shows some best practices for PTV xTour in a " + ".NET Windows client application. The main techniques demonstrated in this sample:\n" + "* Using xTour at xServer internet\n" + "* Visualizing the tour plan with the xServer .NET control\n" + "* Mapping your application objects from and to xServer objects\n" + "* Invoking PTV xServers from a windows application in a non-blocking way\n" + "* Using the job API to control and display the tour calculation progress", "Info"); } }
public void SetPlannedTours(Scenario scenario) { CancelButton.IsEnabled = false; StartButton.IsEnabled = true; ScenarioComboBox.IsEnabled = true; tourLayer.Shapes.Clear(); foreach (var tour in scenario.Tours) { var pc = new PointCollection(from tp in tour.TourPoints select new System.Windows.Point(tp.Longitude, tp.Latitude)); SetPlainLine(pc, tourLayer, tour.Vehicle.Depot.Color, tour.Vehicle.Id); SetAnimDash(pc, tourLayer); } foreach(Cube cube in this.orderLayer.Shapes) { var order = (Order)cube.Tag; if (order.Tour != null) { cube.Color = order.Tour.Vehicle.Depot.Color; ShapeCanvas.SetZIndex(cube, 1); // bring to front } else { cube.Color = unplannedColor; ShapeCanvas.SetZIndex(cube, 0); // bring to back } } }