private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var x1 = float.Parse(Corner1X.Text);
            var y1 = float.Parse(Corner1Y.Text);

            _corner1 = new Navigation.Point(x1, y1);
            var x2 = float.Parse(Corner2X.Text);
            var y2 = float.Parse(Corner2Y.Text);

            _corner2 = new Navigation.Point(x2, y2);
            _map     = new Map(_corner1, _corner2, 0.4f);

            _visitedNodes.Clear();

            var destX = float.Parse(DestX.Text);
            var destY = float.Parse(DestY.Text);

            _target = new Navigation.Point(destX, destY);

            DrawMap(_map);

            var bot = new DuckieBot(RoverAdress.Text, RoverId.Text);

            bot.RouteCalculated   += Bot_RouteCalculated;
            bot.ObstaclesDetected += Bot_ObstaclesDetected;
            await bot.MoveOnMap(_map, _target, new CancellationToken());
        }
        private void Bot_RouteCalculated(object sender, RouteArgs args)
        {
            var rover = (DuckieBot)sender;

            _visitedNodes.Add(new Navigation.Point(rover.CurrentX, rover.CurrentY));
            _plannedRoute = args.Route;
            _plannedNext  = args.NextPoint;
            Application.Current.Dispatcher.Invoke(() => {
                DrawMap(_map);
            });
        }
        private void Bot_ObstaclesDetected(object sender, ObstaclesDetectedArgs args)
        {
            _obstacles          = args.Obstacles;
            _currentPosition    = args.CurrentPosition;
            _currentOrientation = args.CurrentOrientation;
            var rover = (DuckieBot)sender;

            Application.Current.Dispatcher.Invoke(() => {
                DrawMap(_map);
            });
        }
        public System.Windows.Point Transform(Navigation.Point point)
        {
            float minX = _corner1.X;
            float minY = _corner1.Y;
            float maxX = _corner2.X;
            float maxY = _corner2.Y;

            var transform = new TranslateTransform(0 - minX, 0 - minY);
            var scale     = new ScaleTransform((_actualWidth - 10) / Math.Abs(maxX - minX), (_actualHeight - 50) / Math.Abs(maxY - minY));

            return(scale.Transform(transform.Transform(
                                       new System.Windows.Point(point.X, -1 * point.Y))));
        }