SuperMap.Connector.Control.Forms.MapControl.item_LineCollectionChanged C# (CSharp) Method

item_LineCollectionChanged() public method

public item_LineCollectionChanged ( object sender, System e ) : void
sender object
e System
return void
        void item_LineCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            GraphicsLayer graphicsLayer = sender as GraphicsLayer;
            if (graphicsLayer != null && _layerMapOverlay.ContainsKey(graphicsLayer.ID))
            {
                GMapOverlay overlay = _layerMapOverlay[graphicsLayer.ID].GMapOverlay;
                if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add && e.NewItems != null)
                {
                    List<Line> lines = new List<Line>();
                    foreach (Line lineItem in e.NewItems)
                    {
                        lines.Add(lineItem);
                    }
                    this.AddLine(graphicsLayer, overlay, lines);
                }
                else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove && e.OldItems != null)
                {
                    foreach (Line lineItem in e.OldItems)
                    {
                        if (lineItem != null)
                        {
                            overlay.Routes.Remove(_lineMapGMapRoute[graphicsLayer.ID][lineItem.ID].GMapRoute);
                            _lineMapGMapRoute[graphicsLayer.ID].Remove(lineItem.ID);
                        }
                    }
                }
                else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset)
                {
                    overlay.Routes.Clear();
                    if (_lineMapGMapRoute.ContainsKey(graphicsLayer.ID))
                    {
                        _lineMapGMapRoute[graphicsLayer.ID].Clear();
                    }
                }
            }
        }