private void AttachLayersHandler(IEnumerable <Layer> layers) { if (layers != null) { // Subscribe to Layers Collection changes var layersINotifyCollectionChanged = layers as INotifyCollectionChanged; if (layersINotifyCollectionChanged != null) { Debug.Assert(_layersWeakEventListener == null); _layersWeakEventListener = new WeakEventListener <TemplatePicker, object, NotifyCollectionChangedEventArgs>(this) { OnEventAction = (instance, source, eventArgs) => instance.OnLayerCollectionChanged(source, eventArgs), OnDetachAction = weakEventListener => layersINotifyCollectionChanged.CollectionChanged -= weakEventListener.OnEvent }; layersINotifyCollectionChanged.CollectionChanged += _layersWeakEventListener.OnEvent; } // Subscribe to FeatureLayers Property Changes Debug.Assert(_featureLayerPropertyChangedListeners == null); _featureLayerPropertyChangedListeners = new DependencyPropertyChangedListeners <TemplatePicker>(this) { OnEventAction = (instance, source, eventArgs) => instance.OnLayerPropertyChanged(source, eventArgs) }; foreach (var layer in layers.OfType <FeatureLayer>()) { AttachLayerHandler(layer); } } }
/// <summary> /// Initializes a new instance of the <see cref="TemplatePicker"/> class. /// </summary> public TemplatePicker() { DefaultStyleKey = typeof(TemplatePicker); _featureLayerPropertyChangedListeners = new DependencyPropertyChangedListeners<TemplatePicker>(this) { OnEventAction = (instance, source, eventArgs) => instance.OnLayerPropertyChanged(source, eventArgs) }; }
/// <summary> /// Initializes a new instance of the <see cref="TemplatePicker"/> class. /// </summary> public TemplatePicker() { DefaultStyleKey = typeof(TemplatePicker); _featureLayerPropertyChangedListeners = new DependencyPropertyChangedListeners <TemplatePicker>(this) { OnEventAction = (instance, source, eventArgs) => instance.OnLayerPropertyChanged(source, eventArgs) }; }
/// <summary> /// Initializes a new instance of the <see cref="Attribution"/> class. /// </summary> public Attribution() { #if NETFX_CORE DefaultStyleKey = typeof(Attribution); #endif _layerPropertyChangedListeners = new DependencyPropertyChangedListeners <Attribution>(this) { OnEventAction = (instance, source, eventArgs) => instance.Layer_PropertyChanged(source, eventArgs) }; }
public LegendTree() { LayerItemsOptions = new LayerItemsOpts(returnMapLayerItems: false, returnGroupLayerItems: false, returnLegendItems: false, showOnlyVisibleLayers: true, reverseLayersOrder: false); Attach(this); _layerPropertyChangedListeners = new DependencyPropertyChangedListeners <LegendTree>(this) { OnEventAction = (instance, source, eventArgs) => instance.Layer_PropertyChanged(source, eventArgs) }; }
/// <summary> /// Initializes a new instance of the <see cref="Attribution"/> class. /// </summary> public Attribution() { #if NETFX_CORE DefaultStyleKey = typeof(Attribution); #endif _layerPropertyChangedListeners = new DependencyPropertyChangedListeners<Attribution>(this) { OnEventAction = (instance, source, eventArgs) => instance.Layer_PropertyChanged(source, eventArgs) }; }
public LegendTree() { LayerItemsOptions = new LayerItemsOpts(returnMapLayerItems: false, returnGroupLayerItems: false, returnLegendItems: false, showOnlyVisibleLayers: true, reverseLayersOrder: false); Attach(this); _layerPropertyChangedListeners = new DependencyPropertyChangedListeners<LegendTree>(this) { OnEventAction = (instance, source, eventArgs) => instance.Layer_PropertyChanged(source, eventArgs) }; }
private void DetachLayersHandler() { if (_layersWeakEventListener != null) { _layersWeakEventListener.Detach(); _layersWeakEventListener = null; } if (_featureLayerPropertyChangedListeners != null) { _featureLayerPropertyChangedListeners.DetachAll(); _featureLayerPropertyChangedListeners = null; } }
private void AttachLayersHandler(IEnumerable<Layer> layers) { if (layers != null) { // Subscribe to Layers Collection changes var layersINotifyCollectionChanged = layers as INotifyCollectionChanged; if (layersINotifyCollectionChanged != null) { Debug.Assert(_layersWeakEventListener == null); _layersWeakEventListener = new WeakEventListener<TemplatePicker, object, NotifyCollectionChangedEventArgs>(this) { OnEventAction = (instance, source, eventArgs) => instance.OnLayerCollectionChanged(source, eventArgs), OnDetachAction = weakEventListener => layersINotifyCollectionChanged.CollectionChanged -= weakEventListener.OnEvent }; layersINotifyCollectionChanged.CollectionChanged += _layersWeakEventListener.OnEvent; } // Subscribe to FeatureLayers Property Changes Debug.Assert(_featureLayerPropertyChangedListeners == null); _featureLayerPropertyChangedListeners = new DependencyPropertyChangedListeners<TemplatePicker>(this) { OnEventAction = (instance, source, eventArgs) => instance.OnLayerPropertyChanged(source, eventArgs) }; foreach (var layer in layers.OfType<FeatureLayer>()) AttachLayerHandler(layer); } }
private void DetachLayersHandler() { if (_layersWeakEventListener != null) { _layersWeakEventListener.Detach(); _layersWeakEventListener = null; } if (_featureLayerPropertyChangedListeners != null) { _featureLayerPropertyChangedListeners.DetachAll(); _featureLayerPropertyChangedListeners = null; } }