Ejemplo n.º 1
0
 //this runs in its own thread, looks up the locations in the
 //path location list, invokes registered methods when done
 private void getLocations()
 {
     _processingLocations = true;
     for (int i = 0; i < _path.GeocodeLocations.Count; i++)
     {
         if (i % 20 == 0)
         {
             _exceeded_query_limit = false;
         }
         //hit the cache first
         Address tempAddress = _cache.lookup(_path.GeocodeLocations[i]);
         if (_cache.CacheHit)
         {
             _addresses.Add(tempAddress);
         }
         else
         {
             _addresses.Add(getAddress(_path.GeocodeLocations[i]));
             _cache.addToCache(_addresses[_addresses.Count - 1]);
             Thread.Sleep(20);
         }
         _processingLocations = false;
         if (processedLocation != null)
         {
             processedLocation.Invoke();
         }
     }
     //sanatize input
     for (int i = 0; i < _addresses.Count; i++)
     {
         if (_addresses[i].StreetName == "")
         {
             _addresses.RemoveAt(i); i--;
         }
         ;
     }
     //generate directions
     if (_addresses.Count > 0)
     {
         _pois       = new List <PointOfInterest>();
         _turns      = DirectionsGenerator.generateDirections(_addresses);
         _turnImages = new List <Image>(_turns.Count);
         for (int i = 0; i < _turns.Count; i++)
         {
             _turnImages.Add(null);
         }
     }
     if (finishedProcessing != null)
     {
         finishedProcessing.Invoke();
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// removes the turn at index _currentTurn from the turns array
 /// </summary>
 public void deleteCurrentTurn()
 {
     if (_turns != null && _turns.Count != 0)
     {
         for (int i = 0; i < _pois.Count; i++)
         {
             if (_pois[i].Notes == _turns[_currentTurn].Notes)
             {
                 _pois.RemoveAt(i);
             }
         }
         _turns.RemoveAt(_currentTurn);
         _turnImages.RemoveAt(_currentTurn);
         DirectionsGenerator.computeTurnDistances(_turns);
         if (_currentTurn > _turns.Count - 1)
         {
             _currentTurn = 0;
         }
     }
 }