void WriteSQLite(object o) { OneTile oneTile = (OneTile)o; //SaveTile(e.Level, e.Row, e.Column, StreamToBytes(e.ImageStream)); SaveTile(oneTile.level, oneTile.row, oneTile.col, StreamToBytes(oneTile.e)); }
private void OfflineableTileLayer_TileLoaded(object sender, TiledLayer.TileLoadEventArgs e) { //This event is only fired if _isConnected==true if (EnableOffline && SaveOfflineTiles) { string key = string.Format("{0}/{1}/{2}", e.Level, e.Row, e.Column); if (SaveTilesMode == Mode.SaveOnly && _tilesNeedToSave.Contains(key) && !_tilesAlreadySaved.Contains(key) && e.ImageStream != null) { byte[] bytes = LoadTile(e.Level, e.Row, e.Column); if (bytes == null) { //LPY 2014-12-28 10:46:56 修改 先将瓦片图写到内存中,再处理 OneTile oneTile = new OneTile(e.Level, e.Row, e.Column, e.ImageStream); try { dic.TryAdd(key, oneTile); } catch (Exception) { } //SaveTile(e.Level, e.Row, e.Column, StreamToBytes(e.ImageStream)); //mark this tile already saved, avoid to save it repeatly when LoadOfflineTileFirst=false. _tilesAlreadySaved.Add(key); //Debug.WriteLine(key + " tile saved."); _tilesNeedToSave.Remove(key); } } else if (SaveTilesMode == Mode.SaveOrUpdate && e.ImageStream != null) { SaveOrReplaceTile(e.Level, e.Row, e.Column, StreamToBytes(e.ImageStream)); // Debug.WriteLine(key + " tile saved or replaced."); } } }