/// <summary>
 /// Removes a selection source from the observed sources list.
 /// </summary>
 /// <param name="selectionSource">The selection source.</param>
 public void RemoveSource(ISelectionSource selectionSource)
 {
     if (sources.ContainsKey(selectionSource))
     {
         var handler = sources[selectionSource];
         selectionSource.SelectionChanged -= handler;
         sources.Remove(selectionSource);
     }
 }
 /// <summary>
 /// Removes a selection source from the observed sources list.
 /// </summary>
 /// <param name="selectionSource">The selection source.</param>
 public void RemoveSource(ISelectionSource selectionSource)
 {
     if (sources.ContainsKey(selectionSource))
     {
         var handler = sources[selectionSource];
         selectionSource.SelectionChanged -= handler;
         sources.Remove(selectionSource);
     }
 }
Exemplo n.º 3
0
        public void SetSelectionSource(ISelectionSource selectionSource)
        {
            if (_selectionSource != null)
            {
                _selectionSource.OnSelect -= SelectionHandler;
            }

            _selectionSource           = selectionSource;
            _selectionSource.OnSelect += SelectionHandler;
        }
        /// <summary>
        /// Adds a selection source to the observed sources list.
        /// </summary>
        /// <param name="selectionSource">The selection source.</param>
        public void AddSource(ISelectionSource selectionSource)
        {
            if (sources.ContainsKey(selectionSource)) return;

            EventHandler handler = (s, e) =>
            {
                var source = s as ISelectionSource;
                if (source != null) OnSelectionChanged(source, source.SelectedObject);
            };

            selectionSource.SelectionChanged += handler;
            sources.Add(selectionSource, handler);
        }
        /// <summary>
        /// Adds a selection source to the observed sources list.
        /// </summary>
        /// <param name="selectionSource">The selection source.</param>
        public void AddSource(ISelectionSource selectionSource)
        {
            if (sources.ContainsKey(selectionSource))
            {
                return;
            }

            EventHandler handler = (s, e) =>
            {
                var source = s as ISelectionSource;
                if (source != null)
                {
                    OnSelectionChanged(source, source.SelectedObject);
                }
            };

            selectionSource.SelectionChanged += handler;
            sources.Add(selectionSource, handler);
        }