Esempio n. 1
0
 void OnShapeSourcesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         AddSources(e.NewItems.Cast <ShapeSource>().ToList());
     }
     else if (e.Action == NotifyCollectionChangedAction.Remove)
     {
         RemoveSources(e.OldItems.Cast <ShapeSource>().ToList());
     }
     else if (e.Action == NotifyCollectionChangedAction.Reset)
     {
         var sources = map.Sources;
         foreach (var s in sources)
         {
             if (s.Id.HasPrefix())
             {
                 map.RemoveSource(s);
             }
         }
     }
     else if (e.Action == NotifyCollectionChangedAction.Replace)
     {
         RemoveSources(e.OldItems.Cast <ShapeSource>().ToList());
         AddSources(e.NewItems.Cast <ShapeSource>().ToList());
     }
 }
        void OnShapeSourcesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                AddSources(e.NewItems.Cast <MapSource>().ToList());
                break;

            case NotifyCollectionChangedAction.Remove:
                RemoveSources(e.OldItems.Cast <MapSource>().ToList());
                break;

            case NotifyCollectionChangedAction.Reset:
                var sources = map.Sources;
                foreach (var source in sources)
                {
                    if (source.Id.HasPrefix())
                    {
                        map.RemoveSource(source);
                    }
                }
                break;

            case NotifyCollectionChangedAction.Replace:
                RemoveSources(e.OldItems.Cast <MapSource>().ToList());
                AddSources(e.NewItems.Cast <MapSource>().ToList());
                break;
            }
        }
Esempio n. 3
0
 void RemoveSources(List <ShapeSource> sources)
 {
     if (sources == null)
     {
         return;
     }
     foreach (ShapeSource source in sources)
     {
         if (source.Id != null)
         {
             map.RemoveSource(source.Id.Prefix());
         }
     }
 }