SuperMap.WindowsPhone.Mapping.Map.Layers_CollectionChanged C# (CSharp) Method

Layers_CollectionChanged() private method

private Layers_CollectionChanged ( object sender, NotifyCollectionChangedEventArgs e ) : void
sender object
e NotifyCollectionChangedEventArgs
return void
        private void Layers_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            IList oldItems = e.OldItems;
            if (e.Action == NotifyCollectionChangedAction.Reset)
            {

                oldItems = this.layers;
                ResetMapStatus();
                //但从 road 到 aerial 会怎么样呢? 请用Replace
            }
            //if (e.Action == NotifyCollectionChangedAction.Replace)
            //{
            //    origin = Point2D.Empty;
            //    cacheViewBounds = Rectangle2D.Empty;
            //}//如果仅仅替换图层,其他已有图层的坐标也不对,所以不会发生该种情况
            layers = new List<Layer>(this.Layers);
            if (oldItems != null)
            {
                foreach (object obj2 in oldItems)
                {
                    Layer layer = obj2 as Layer;
                    if (layer != null)
                    {
                        RemoveMapLayers(layer);
                    }
                }
            }
            if (e.NewItems != null)
            {
                foreach (object obj4 in e.NewItems)
                {
                    Layer layer2 = obj4 as Layer;
                    if (layer2 != null)
                    {
                        Map map = layer2.GetValue(MapProperty) as Map;
                        if ((map != null) && (map != this))
                        {
                            throw new ArgumentException(ExceptionStrings.LayerToMap);
                        }
                        if (map == null)
                        {
                            layer2.SetValue(MapProperty, this);
                        }
                        layer2.LayerChanged += new Layer.LayerChangedHandler(this.layer_OnLayerChanged);
                        layer2.Initialized += new EventHandler<EventArgs>(this.layer_Initialized);
                        if (!layer2.IsInitialized && (this.panHelper != null))
                        {
                            layer2.Initialize();
                        }
                    }
                }
            }
            bool flag = true;
            foreach (Layer layer3 in this.Layers)
            {
                if (!layer3.IsInitialized)
                {
                    flag = false;
                    break;
                }
            }
            if (flag)
            {
                this.Layers_LayersInitialized(sender, null);
            }
        }