Exemplo n.º 1
0
 //只留当前屏幕显示的几个瓦片,其余全部释放
 public void Deactive()
 {
     if (!_isActive)
     {
         return;
     }
     try
     {
         TileIdentify[] visibleTiles;
         LevelDef       suitableLevel;
         _tilesLocator.Compute(_canvas, out suitableLevel, out visibleTiles);
         if (visibleTiles == null)
         {
             return;
         }
         foreach (TileIdentify tile in visibleTiles)
         {
             TileBitmap tb = _tileCacheManager.Get(suitableLevel.LevelNo, tile.Row, tile.Col);
             if (tb != null)
             {
                 _sleepTileCacheManager.Put(tb);
                 _tileCacheManager.Remove(tb);
             }
         }
     }
     finally
     {
         SetToSleep();
         _isActive = false;
     }
 }
Exemplo n.º 2
0
 public void Active()
 {
     if (_isActive)
     {
         return;
     }
     try
     {
         CreateTileLoadWorker();
         if (_sleepTileCacheManager.Count > 0)
         {
             foreach (TileBitmap tb in _sleepTileCacheManager.TileBitmaps.ToArray())
             {
                 _tileCacheManager.Put(tb);
                 _sleepTileCacheManager.Remove(tb);
             }
         }
         ReLoadTileBitmapsBySync(_levels);
     }
     finally
     {
         _isActive = true;
     }
 }