Inheritance: System.EventArgs
Beispiel #1
0
        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
        }
Beispiel #3
0
 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);
 }
Beispiel #4
0
 private void OnDataChanged(object sender, DataChangedEventArgs e)
 {
     if (DataChanged != null)
     {
         DataChanged(sender, e);
     }
 }
Beispiel #5
0
 private static string GetErrorMessage(DataChangedEventArgs e)
 {
     return (e.Cancelled) ? "Cancelled" : ((e.Error != null) ? e.Error.GetType() + ": " + e.Error.Message : "");
 }
Beispiel #6
0
 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));
     }
 }
Beispiel #7
0
        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);
         }
     }
 }
Beispiel #11
0
 protected void OnDataChanged(DataChangedEventArgs args)
 {
     var handler = DataChanged;
     if (handler != null)
     {
         handler(this, args);
     }
 }
Beispiel #12
0
 private void LayerOnDataChanged(object sender, DataChangedEventArgs dataChangedEventArgs)
 {
     _modified = true;
     if (_buzy) return;
     RestartTimer();
 }
Beispiel #13
0
 void MapDataChanged(object sender, DataChangedEventArgs e)
 {
         //ViewChanged should not be called here. This would cause a loop
     BeginInvoke((Action) (() => DataChanged(sender, e)));
 }
Beispiel #14
0
 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();
     }
 }
Beispiel #15
0
 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();
         }
     }
 }
Beispiel #16
0
 private void AsyncLayerDataChanged(object sender, DataChangedEventArgs e)
 {
     OnDataChanged(sender, e);
 }
Beispiel #17
0
 private void TileFetcherDataChanged(object sender, DataChangedEventArgs e)
 {
     OnDataChanged(e);
 }
Beispiel #18
0
        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();
                }

            }
        }