Beispiel #1
0
        private void pokeMap_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var mousePos = e.GetPosition(pokeMap);
            //Getting real coordinates from mouse click
            var mapPos = pokeMap.FromLocalToLatLng((int)mousePos.X, (int)mousePos.Y);
            var lat    = mapPos.Lat;
            var lng    = mapPos.Lng;

            if (_bot == null)
            {
                return;
            }
            if (_bot.Started)
            {
                if (_bot.ForceMoveMarker == null)
                {
                    _bot.ForceMoveMarker = new GMapMarker(mapPos)
                    {
                        Shape  = Properties.Resources.force_move.ToImage("Force Move To"),
                        Offset = new Point(-24, -48),
                        ZIndex = int.MaxValue
                    };
                    addMarker(_bot.ForceMoveMarker);
                }
                else
                {
                    _bot.ForceMoveMarker.Position = mapPos;
                }
                CurSession.StartForceMove(lat, lng);
            }
            else
            {
                _bot.Lat = _bot._lat = lat;
                _bot.Lng = _bot._lng = lng;
                _bot.GlobalSettings.LocationSettings.DefaultLatitude  = lat;
                _bot.GlobalSettings.LocationSettings.DefaultLongitude = lng;
                DrawPlayerMarker();
                _botSettingsPage.UpdateCoordBoxes();
            }
        }
Beispiel #2
0
        private void pokeMap_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (_bot == null)
            {
                return;
            }
            var mousePos = e.GetPosition(pokeMap);
            //Getting real coordinates from mouse click
            var mapPos = pokeMap.FromLocalToLatLng((int)mousePos.X, (int)mousePos.Y);
            var lat    = mapPos.Lat;
            var lng    = mapPos.Lng;

            //TEST ROUTING
            //var startLat = Math.Round(_bot.Lat, 2);
            //var startLng = Math.Round(_bot.Lng, 2);

            //var top = (startLat + 0.1).ToString(CultureInfo.InvariantCulture);
            //var bot = (startLat - 0.1).ToString(CultureInfo.InvariantCulture);
            //var left = (startLng - 0.1).ToString(CultureInfo.InvariantCulture);
            //var right = (startLng + 0.1).ToString(CultureInfo.InvariantCulture);

            //var routerDb = new RouterDb();
            //Router router = new Router(routerDb);
            //var apiRequest = (HttpWebRequest)WebRequest.Create($"http://overpass.osm.rambler.ru/cgi/xapi_meta?*[bbox={left},{bot},{right},{top}]");
            //apiRequest.Proxy = WebRequest.DefaultWebProxy;
            //apiRequest.Proxy.Credentials = CredentialCache.DefaultCredentials;
            //var res = (HttpWebResponse)apiRequest.GetResponse();
            //using (var urlStream = res.GetResponseStream())
            //{
            //    // create source stream.
            //    var source = new XmlOsmStreamSource(urlStream);

            //    routerDb.LoadOsmData(source, Vehicle.Pedestrian);
            //}
            //// calculate a route.
            //var route = router.Calculate(Vehicle.Pedestrian.Fastest(),
            //    (float)_bot.Lat, (float)_bot.Lng, (float)lat, (float)lng);
            //var geoJson = route.ToGeoJson();



            if (_bot.Started)
            {
                if (_bot.ForceMoveMarker == null)
                {
                    _bot.ForceMoveMarker = new GMapMarker(mapPos)
                    {
                        Shape  = Properties.Resources.force_move.ToImage("Force Move To"),
                        Offset = new Point(-24, -48),
                        ZIndex = int.MaxValue
                    };
                    AddMarker(_bot.ForceMoveMarker);
                }
                else
                {
                    _bot.ForceMoveMarker.Position = mapPos;
                }
                CurSession.StartForceMove(lat, lng);
            }
            else
            {
                _bot.Lat = _bot._lat = lat;
                _bot.Lng = _bot._lng = lng;
                _bot.GlobalSettings.LocationSettings.DefaultLatitude  = lat;
                _bot.GlobalSettings.LocationSettings.DefaultLongitude = lng;
                DrawPlayerMarker();
                _botSettingsPage.UpdateCoordBoxes();
            }
        }