예제 #1
0
        private void GeneratePlan_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            Parameters.numberOfTowns = _attractions.Count;
            Parameters.ChosenStart   = Hotel.ActiveHotel.Id;
            Parameters.distances     = DistanceCalculator.GetDistances(Hotel.ActiveHotel, _attractions);
            Parameters.profits       = ProfitCalculator.GetProfits(_attractions);
            Parameters.maxLength     = int.Parse(TBLimit.Text);
            Parameters.daysOfTrip    = int.Parse(TBDays.Text);
            Parameters.Notify        = MockNotify;
            Parameters.Reset();
            var layer = MapInteractivity.GetRouteLineLayer(BingMap);

            layer.Children.Clear();
            PushPinLayer.Children.Clear();
            _dayAttractions.Clear();
            _dayRealRoads.Clear();
            _dayStraightLines.Clear();
            _tripPlan.Clear();
            PlotHotels();
            CBHotels.SelectedItem            = Hotel.ActiveHotel;
            Hotel.ActiveHotel.Pin.Background = new SolidColorBrush(Color.FromRgb(0, 0, 240));
            Hotel.ActiveHotel.Pin.Visibility = Visibility.Visible;
            var    watch = System.Diagnostics.Stopwatch.StartNew();
            Thread t     = new Thread(() => _tripPlanner.GenerateRoutes());

            t.Start();
            t.Join();
            watch.Stop();
            LBAlgorithmExecutionTime.Content = watch.ElapsedMilliseconds / 1000.0 + " s";
            UpdateTripPlan();
            GenerateRouteLines();
            DrawLines();
            watch = System.Diagnostics.Stopwatch.StartNew();
            GenerateRoutes();
            DrawRoutes();
            watch.Stop();

            LBMapLoadingExecutionTime.Content = watch.ElapsedMilliseconds / 1000.0 + " s";
        }