Exemplo n.º 1
0
        void infoObservable_HandleNewPokemonLocations(List <DataCollector.PokemonMapData> mapData)
        {
            _pokemonMarks.Clear();
            _pokemonOverlay.Markers.Clear();

            foreach (var pokeData in mapData.Where(x => x.Id != null))
            {
                GMarkerGoogle pokemonMarker;
                Bitmap        pokebitMap = Pokemons.GetPokemonMediumImage(pokeData.PokemonId);
                if (pokebitMap != null)
                {
                    var ImageSize = new System.Drawing.Size(pokebitMap.Width, pokebitMap.Height);
                    pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), pokebitMap)
                    {
                        Offset = new System.Drawing.Point(-ImageSize.Width / 2, -ImageSize.Height / 2)
                    };
                }
                else
                {
                    pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), GMarkerGoogleType.green_small);
                }

                if (pokeData.Type == DataCollector.PokemonMapDataType.Nearby)
                {
                    pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), GMarkerGoogleType.black_small);
                }
                pokemonMarker.ToolTipText  = StringUtils.getPokemonNameByLanguage(null, (PokemonId)pokeData.PokemonId) + ", " + pokeData.ExpiresAt.ToString() + ", " + pokeData.Coordinates.Latitude.Value.ToString() + ", " + pokeData.Coordinates.Longitude.Value.ToString();
                pokemonMarker.ToolTip.Font = new System.Drawing.Font("Arial", 12, System.Drawing.GraphicsUnit.Pixel);
                pokemonMarker.ToolTipMode  = MarkerTooltipMode.OnMouseOver;
                _pokemonMarks.Add(pokeData.Id, pokemonMarker);
                _pokemonOverlay.Markers.Add(pokemonMarker);
            }

            _pokemonOverlay.IsVisibile = cbShowPokemon.Checked;
        }
Exemplo n.º 2
0
        void infoObservable_HandleNewPokemonLocations(List <DataCollector.PokemonMapData> mapData)
        {
            try
            {
                if (pokemonLock.WaitOne(5000))
                {
                    if (mapData.Count > 0)
                    {
                        _pokemonMarks.Clear();
                        _pokemonOverlay.Markers.Clear();

                        int prevCount = mapData.Count;
                        mapData.Where(x => x.Id == null && x.PokemonId != null && x.Coordinates.Latitude.HasValue && x.Coordinates.Longitude.HasValue).ToList().ForEach(x => x.Id = x.PokemonId.ToString() + x.Coordinates.Longitude.Value + +x.Coordinates.Latitude.Value);
                        mapData = mapData.Where(x => x.Id != null).ToList();

                        Logger.ColoredConsoleWrite(ConsoleColor.White, string.Format("Got new Pokemon Count: {0}, unfiltered: {1}", mapData.Count, prevCount));
                        foreach (var pokeData in mapData)
                        {
                            GMarkerGoogle pokemonMarker;
                            Bitmap        pokebitMap = Pokemons.GetPokemonMediumImage(pokeData.PokemonId);
                            if (pokebitMap != null)
                            {
                                var ImageSize = new System.Drawing.Size(pokebitMap.Width, pokebitMap.Height);
                                pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), pokebitMap)
                                {
                                    Offset = new System.Drawing.Point(-ImageSize.Width / 2, -ImageSize.Height / 2)
                                };
                            }
                            else
                            {
                                pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), GMarkerGoogleType.green_small);
                            }

                            if (pokeData.Type == DataCollector.PokemonMapDataType.Nearby)
                            {
                                pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), GMarkerGoogleType.black_small);
                            }
                            pokemonMarker.ToolTipText  = string.Format("{0}, {1}, {2}, {3}", StringUtils.getPokemonNameByLanguage(null, pokeData.PokemonId), pokeData.ExpiresAt.ToString(), pokeData.Coordinates.Latitude.Value.ToString(), pokeData.Coordinates.Longitude.Value.ToString());
                            pokemonMarker.ToolTip.Font = new System.Drawing.Font("Arial", 12, System.Drawing.GraphicsUnit.Pixel);
                            pokemonMarker.ToolTipMode  = MarkerTooltipMode.OnMouseOver;
                            _pokemonMarks.Add(pokeData.Id, pokemonMarker);
                            _pokemonOverlay.Markers.Add(pokemonMarker);
                        }
                    }
                    _pokemonOverlay.IsVisibile = cbShowPokemon.Checked;
                }
            }
            catch (Exception e)
            {
                Logger.ColoredConsoleWrite(ConsoleColor.DarkRed, string.Format("Ignore this: Error in HandleNewPokemonLocations: {0}", e.ToString()));
            }
        }
        void infoObservable_HandleNewPokemonLocations(List <DataCollector.PokemonMapData> mapData)
        {
            Invoke(new MethodInvoker(() =>
            {
                try
                {
                    //if (pokemonLock.WaitOne(5000))
                    //{
                    if (mapData.Count > 0)
                    {
                        //_pokemonOverlay = new GMapOverlay("Pokemon");
                        _pokemonMarks.Clear();
                        _pokemonOverlay.Markers.Clear();
                        _pokemonOverlay.IsVisibile = false;

                        int prevCount = mapData.Count;
                        //mapData.Where(x => x.Id == null && x.Coordinates.Latitude.HasValue && x.Coordinates.Longitude.HasValue).ToList().ForEach(x => x.Id = x.PokemonId.ToString() + x.Coordinates.Longitude.Value + +x.Coordinates.Latitude.Value);
                        mapData = mapData.Where(x => x.Id != null).ToList();

                        //Logger.ColoredConsoleWrite(ConsoleColor.White, string.Format("Got new Pokemon Count: {0}, unfiltered: {1}", mapData.Count, prevCount));

                        for (int i = mapData.Count - 1; i >= 0; i--)
                        {
                            var pokeData = mapData[i];
                            GMarkerGoogle pokemonMarker;
                            if (pokeData.Type == DataCollector.PokemonMapDataType.Nearby)
                            {
                                pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), GMarkerGoogleType.black_small);
                            }
                            else
                            {
                                Bitmap pokebitMap = Pokemons.GetPokemonMediumImage(pokeData.PokemonId);
                                if (pokebitMap != null)
                                {
                                    var ImageSize = new System.Drawing.Size(pokebitMap.Width, pokebitMap.Height);
                                    pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), pokebitMap)
                                    {
                                        Offset = new System.Drawing.Point(-ImageSize.Width / 2, -ImageSize.Height / 2)
                                    };
                                }
                                else
                                {
                                    pokemonMarker = new GMarkerGoogle(new PointLatLng(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), GMarkerGoogleType.green_small);
                                }
                            }
                            pokemonMarker.ToolTipText  = string.Format("{0}\nExpires at:{1}\n{2}\n{3},{4}", StringUtils.getPokemonNameByLanguage(null, pokeData.PokemonId), pokeData.ExpiresAt.ToString(), FindAddress(pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value), pokeData.Coordinates.Latitude.Value, pokeData.Coordinates.Longitude.Value);
                            pokemonMarker.ToolTip.Font = new System.Drawing.Font("Arial", 12, System.Drawing.GraphicsUnit.Pixel);
                            pokemonMarker.ToolTipMode  = MarkerTooltipMode.OnMouseOver;
                            _pokemonMarks.Add(pokeData.Id, pokemonMarker);
                            _pokemonOverlay.Markers.Add(pokemonMarker);
                        }
                    }
                    if (!map.Overlays.Contains(_pokemonOverlay))
                    {
                        map.Overlays.Add(_pokemonOverlay);
                    }
                    _pokemonOverlay.IsVisibile = true;    //cbShowPokemon.Checked;
                    //}
                }
                catch (Exception e)
                {
                    Logger.ColoredConsoleWrite(ConsoleColor.DarkRed, "Ignore this: sending exception information to log file.");
                    Logger.AddLog(string.Format("Error in HandleNewPokemonLocations: {0}", e.ToString()));
                }
            }));
        }