public void OnNewData(NewNodesEvent e) {
            
            // avoid flickering of the MapIcons by Remove or Add only the Elements which are needed

            // collection of all mapElemements which should be removed
            ICollection<MapElement> elementToRemove = new List<MapElement>(mapControl.MapElements);
            ICollection<Model.Node> dirtyElements = new List<Model.Node>();

            foreach (Model.Node n in e.nodes) {
                // check if node already exists on the map
                if (nodeElementMap.Contains(n)) {

                    if (n.NodeTag ==  Model.NodeTag.RETRIEVED) {
                        // this element should not be removed
                        elementToRemove.Remove(nodeElementMap.Get(n));
                    } else {
                        dirtyElements.Add(n);
                    }

                } else {
                    // create new element
                    AddNewMapIcons(n);
                }
                
            }

            // remove all outdated mapelements
            foreach (MapElement element in elementToRemove) {
                mapControl.MapElements.Remove(element);
                nodeElementMap.Remove(element);
            }
            elementToRemove.Clear();
            
            foreach (Model.Node n in dirtyElements) {
                AddNewMapIcons(n);
            }

            /*
            // remove all MapIcons
            nodeElementMap.Clear();
            mapControl.MapElements.Clear();
            // refresh all
            foreach (Model.Node n in e.nodes) {
                AddNewMapIcons(n);
            }
            */
        }
        public void OnNewData(NewNodesEvent e) {

            if (Filter != null) {
                SetData(Filter.FilterNodes(DataHolder.Instance.Nodes));
            } else {
                SetData(e?.nodes);
            }
            
        }
Esempio n. 3
0
        public void RefreshFilter() {
            _FilterdNodes = Filter.FilterNodes(_Nodes);

            var filterChangedEvent = new FilterChangedEvent {
                Filter = Filter
            };
            BusProvider.DefaultInstance.Post(filterChangedEvent);

            var e = new NewNodesEvent() {
                nodes = _FilterdNodes,
                RefreshAll = false
            };
            Prefs.Filter = Filter;
            BusProvider.DefaultInstance.Post(e);
            
        }