private void TileLayerDataChanged(object sender, DataChangedEventArgs e) { if (Schema == null) return; var tiles = new List<MemoryStream>(); foreach (var tileLayer in Layers) { if (!tileLayer.Enabled) continue; var tile = tileLayer.MemoryCache.Find(e.TileInfo.Index); if (tile != null) tiles.Add(((IRaster) tile.Geometry).Data); } if (tiles.Count == 0) return; if (tiles.Count == 1) { AddBitmapToCache(e, tiles.First()); // If there is 1 tile then omit the rasterization to gain performance. } else { var tileWidth = Schema.GetTileWidth(e.TileInfo.Index.Level); var tileHeight = Schema.GetTileHeight(e.TileInfo.Index.Level); #if SILVERLIGHT RunOnUIThread(() => AddBitmapToCache(e, CombineBitmaps(tiles, tileWidth, tileHeight))); #else AddBitmapToCache(e, CombineBitmaps(tiles, tileWidth, tileHeight)); #endif } }
private void TileLayerDataChanged(object sender, DataChangedEventArgs e) { if (Schema == null) return; var tiles = new List<MemoryStream>(); foreach (var tileLayer in Layers) { if (!tileLayer.Enabled) continue; var tile = tileLayer.MemoryCache.Find(e.TileInfo.Index); if (tile != null) tiles.Add(((IRaster)tile.Geometry).Data); } #if SILVERLIGHT System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { #endif var bitmap = CombineBitmaps(tiles, Schema.Width, Schema.Height); if (bitmap != null) MemoryCache.Add(e.TileInfo.Index, new Feature { Geometry = new Raster(bitmap, e.TileInfo.Extent.ToBoundingBox()), Styles = new List<IStyle> { new VectorStyle()} }); if (DataChanged != null) DataChanged(sender, e); #if SILVERLIGHT }); #endif }
private void AddBitmapToCache(DataChangedEventArgs e, MemoryStream bitmap) { if (bitmap != null) MemoryCache.Add(e.TileInfo.Index, new Feature { Geometry = new Raster(bitmap, e.TileInfo.Extent.ToBoundingBox()), Styles = new List<IStyle> {new VectorStyle()} }); OnDataChanged(e); }
private void OnDataChanged(object sender, DataChangedEventArgs e) { if (DataChanged != null) { DataChanged(sender, e); } }
private static string GetErrorMessage(DataChangedEventArgs e) { return (e.Cancelled) ? "Cancelled" : ((e.Error != null) ? e.Error.GetType() + ": " + e.Error.Message : ""); }
public void MapDataChanged(object sender, DataChangedEventArgs e) { if (e.Cancelled || e.Error != null) { //todo test code below: //((Activity)Context).RunOnUiThread(new Runnable(Toast.MakeText(Context, GetErrorMessage(e), ToastLength.Short).Show)); } else // no problems { ((Activity)Context).RunOnUiThread(new Runnable(RefreshGraphics)); } }
public void MapDataChanged(object sender, DataChangedEventArgs e) { string errorMessage; DispatchQueue.MainQueue.DispatchAsync((Action)delegate { if (e == null) { errorMessage = "MapDataChanged Unexpected error: DataChangedEventArgs can not be null"; Console.WriteLine(errorMessage); } else if (e.Cancelled) { errorMessage = "MapDataChanged: Cancelled"; System.Diagnostics.Debug.WriteLine(errorMessage); } else if (e.Error is System.Net.WebException) { errorMessage = "MapDataChanged WebException: " + e.Error.Message; Console.WriteLine(errorMessage); } else if (e.Error != null) { errorMessage = "MapDataChanged errorMessage: " + e.Error.GetType() + ": " + e.Error.Message; Console.WriteLine(errorMessage); } RefreshGraphics(); }); }
private void OnDataChanged(DataChangedEventArgs e) { if (DataChanged != null) DataChanged(this, e); }
private void LayerOnDataChanged(object sender, DataChangedEventArgs dataChangedEventArgs) { StartTimerToTriggerRasterize(); }
public void map_DataChanged(object sender, DataChangedEventArgs e) { if (!Dispatcher.CheckAccess()) { Dispatcher.BeginInvoke(new DataChangedEventHandler(map_DataChanged), new object[] { sender, e }); } else { if (e.Error == null && e.Cancelled == false) { Redraw(); } else if (e.Cancelled) { errorMessage = "Cancelled"; OnErrorMessageChanged(EventArgs.Empty); } else if (e.Error is System.Net.WebException) { errorMessage = "WebException: " + e.Error.Message; OnErrorMessageChanged(EventArgs.Empty); } else { errorMessage = e.Error.GetType() + ": " + e.Error.Message; OnErrorMessageChanged(EventArgs.Empty); } } }
protected void OnDataChanged(DataChangedEventArgs args) { var handler = DataChanged; if (handler != null) { handler(this, args); } }
private void LayerOnDataChanged(object sender, DataChangedEventArgs dataChangedEventArgs) { _modified = true; if (_buzy) return; RestartTimer(); }
void MapDataChanged(object sender, DataChangedEventArgs e) { //ViewChanged should not be called here. This would cause a loop BeginInvoke((Action) (() => DataChanged(sender, e))); }
private void DataChanged(object sender, DataChangedEventArgs e) { if (e.Error == null && e.Cancelled == false) { Invalidate(); } else if (e.Cancelled) { _errorMessage = "Cancelled"; OnErrorMessageChanged(); } else if (e.Error is System.Net.WebException) { _errorMessage = "WebException: " + e.Error.Message; OnErrorMessageChanged(); } else if (e.Error == null) { _errorMessage = "Unknown Exception"; OnErrorMessageChanged(); } else { _errorMessage = "Exception: " + e.Error.Message; OnErrorMessageChanged(); } }
public void MapDataChanged(object sender, DataChangedEventArgs e) { if (!Dispatcher.HasThreadAccess) { Task.Run(() => Dispatcher.RunAsync( CoreDispatcherPriority.Normal, () => MapDataChanged(sender, e))) .ConfigureAwait(false); } else { if (e.Cancelled) { ErrorMessage = "Cancelled"; OnErrorMessageChanged(EventArgs.Empty); } else if (e.Error is WebException) { ErrorMessage = "WebException: " + e.Error.Message; OnErrorMessageChanged(EventArgs.Empty); } else if (e.Error != null) { ErrorMessage = e.Error.GetType() + ": " + e.Error.Message; OnErrorMessageChanged(EventArgs.Empty); } else // no problems { RefreshGraphics(); } } }
private void AsyncLayerDataChanged(object sender, DataChangedEventArgs e) { OnDataChanged(sender, e); }
private void TileFetcherDataChanged(object sender, DataChangedEventArgs e) { OnDataChanged(e); }
public void MapDataChanged(object sender, DataChangedEventArgs e) { if (!Dispatcher.CheckAccess()) { Dispatcher.BeginInvoke(new DataChangedEventHandler(MapDataChanged), new[] { sender, e }); } else { if (e.Cancelled) { errorMessage = "Cancelled"; OnErrorMessageChanged(EventArgs.Empty); } else if (e.Error is System.Net.WebException) { errorMessage = "WebException: " + e.Error.Message; OnErrorMessageChanged(EventArgs.Empty); } else if (e.Error != null) { errorMessage = e.Error.GetType() + ": " + e.Error.Message; OnErrorMessageChanged(EventArgs.Empty); } else // no problems { RefreshGraphics(); } } }