private void ButtonSaveBMP_Click(object sender, RoutedEventArgs e) { if (_bestInd != null) { SaveFileDialog dialog = new SaveFileDialog(); var result = dialog.ShowDialog(this); if (result == true) { DrawingCitiesController drawingCities = new DrawingCitiesController(_bestInd.CityModels); var bmp = drawingCities.GenerateBitmap((int)MapGrid.ActualWidth, (int)MapGrid.ActualHeight); try { bmp.Save(dialog.FileName, ImageFormat.Png); } catch (Exception exception) { MessageBox.Show(exception.Message); } } } }
private void loadTspFile_OnLoadingFinishedEvent(List <CityModel> cities) { _geneticAlgorithmController.CityModels = cities; _geneticAlgorithmController.MinimalizeCoords(); var drawingCities = new DrawingCitiesController(_geneticAlgorithmController.CityModels.ToArray()); _progressWindow.Dispatcher.Invoke(() => { _progressWindow.Close(); drawingCities.DrawPoints(MapGrid); }); }
private void OnAlgorithmStateHasChangedEvent(int progress, Individual bestInd, int bestGenNum) { var drawingRoutes = new DrawingCitiesController(bestInd.CityModels); Dispatcher.Invoke(() => { if (!_algorithmCancellationToken.IsCancellationRequested) { _viewModel.ProgressBarValue = progress; } if (bestGenNum != _lastBest) { drawingRoutes.DrawRoutes(MapGrid); _viewModel.BestInfo = new[] { bestInd.OverallDistance.ToString(), bestGenNum.ToString() }; _bestInd = bestInd; } _viewModel.CurrentGeneration = progress; }); }