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

            }
        }