Ejemplo n.º 1
0
        public void RecordRemoved(IDataRecord record)
        {
            if (record == GraphData)
            {
                return;
            }
            List <GraphItemViewModel> removeList = new List <GraphItemViewModel>();
            var filterItem = record as FilterItem;

            if (filterItem != null)
            {
                var node = filterItem.Node;
                if (node != null)
                {
                    foreach (var item in GraphItems)
                    {
                        if (item.DataObject == node)
                        {
                            removeList.Add(item);
                            removeList.AddRange(item.Connectors.OfType <GraphItemViewModel>());
                        }
                    }
                }
                if (FilterItems.ContainsKey(filterItem.NodeId))
                {
                    FilterItems.Remove(filterItem.NodeId);
                }
            }
            else
            {
                for (int index = 0; index < GraphItems.Count; index++)
                {
                    var item = GraphItems[index];
                    if (item.DataObject == record)
                    {
                        removeList.Add(item);
                        removeList.AddRange(item.Connectors.OfType <GraphItemViewModel>());
                    }
                    item.RecordRemoved(record);
                }
            }
            foreach (var remove in removeList)
            {
                GraphItems.Remove(remove);
            }
            if (removeList.Count > 0)
            {
                RefreshConnectors();
            }
        }