private async void CanvasAnimatedControl_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { if (SharedMethods.isRunnnig) { ga.NewGenration(); UpdateUI(); count++; SharedMethods.DrawPath(args.DrawingSession, SharedMethods.Locations, ga.BestGenes, Color.FromArgb(85, 255, 255, 255), 4f); SharedMethods.DrawPath(args.DrawingSession, SharedMethods.Locations, ga.Population[elitism].Genes, Color.FromArgb(85, 255, 255, 255), 2f); } else { if (count > 0) { SharedMethods.DrawPath(args.DrawingSession, tourLocations, ga.BestGenes, Color.FromArgb(85, 255, 255, 255), 4f); } await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { startBtn.Visibility = Visibility.Visible; stopBtn.Visibility = Visibility.Collapsed; }); sender.Paused = true; } }
private async void CanvasAnimatedControl_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { if (SharedMethods.isRunnnig) { var curDistance = SharedMethods.RoundTripDistance(tourLocations, tourOrder); bestTourDistance = curDistance; tourOrder = SimulatedAnnealing.PerformSimulatedAnnealing(tourOrder, Temperature, random); Temperature = Temperature * TemperatureRate; UpdateUI(); count++; SharedMethods.DrawPath(args.DrawingSession, tourLocations, tourOrder, Color.FromArgb(85, 255, 255, 255), 2f); } else { if (count > 0) { SharedMethods.DrawPath(args.DrawingSession, tourLocations, tourOrder, Color.FromArgb(85, 255, 255, 255), 4f); } await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { startBtn.Visibility = Visibility.Visible; stopBtn.Visibility = Visibility.Collapsed; }); sender.Paused = true; } }
private async void CanvasAnimatedControl_Draw(Microsoft.Graphics.Canvas.UI.Xaml.ICanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedDrawEventArgs args) { if (SharedMethods.isRunnnig) { var curDistance = SharedMethods.RoundTripDistance(tourLocations, tourOrder); if (curDistance < bestTourDistance) { bestTourDistance = curDistance; tourOrder.CopyTo(bestTourOrder, 0); } currentIteration++; UpdateUI(); tourOrder = LexicographicOrder.Lexicography(tourOrder); if (currentIteration >= totalIterations) { SharedMethods.isRunnnig = false; } else { SharedMethods.DrawPath(args.DrawingSession, tourLocations, tourOrder, Color.FromArgb(85, 255, 255, 255), 2f); SharedMethods.DrawPath(args.DrawingSession, tourLocations, bestTourOrder, Color.FromArgb(85, 255, 255, 255), 4f); } } else { if (currentIteration > 0) { SharedMethods.DrawPath(args.DrawingSession, tourLocations, bestTourOrder, Color.FromArgb(85, 255, 255, 255), 4f); } await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { startBtn.Visibility = Visibility.Visible; stopBtn.Visibility = Visibility.Collapsed; }); sender.Paused = true; } }