Exemple #1
0
        private void GraphBehavior_EdgesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            // Remove everything deleted from selection
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                break;

            case NotifyCollectionChangedAction.Remove:
            case NotifyCollectionChangedAction.Replace:
                foreach (var oldItem in e.OldItems)
                {
                    SelectedEdges.Remove(oldItem);
                }
                break;

            case NotifyCollectionChangedAction.Move:
                break;

            case NotifyCollectionChangedAction.Reset:
                var edges = (IList)sender;
                for (int index = 0; index < SelectedVertices.Count; index++)
                {
                    if (!edges.Contains(SelectedEdges[index]))
                    {
                        SelectedEdges.RemoveAt(index--);
                    }
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #2
0
        public void UnselectColoredEdges(List <Edge> edgesToPutOff, object color)
        {
            //do not put off all the edges, otherwise it will cause disconnected components in
            //multiple selection
            Set <Rail> railsOfEdge = new Set <Rail>();
            Dictionary <Edge, Boolean> removeEdge = new Dictionary <Edge, Boolean>();

            foreach (Edge e in edgesToPutOff)
            {
                for (int i = _levels.Count - 1; i >= 0; i--)//int i = Levels.Count - 1;
                {
                    if (_levels[i]._railsOfEdges.ContainsKey(e) == false)
                    {
                        continue;                                                   //is it a bug?
                    }
                    railsOfEdge = _levels[i]._railsOfEdges[e];
                    foreach (var r in railsOfEdge)
                    {
                        if (r.Color == null)
                        {
                            continue;
                        }

                        if (r.Color.Count >= 1)
                        {
                            if (!removeEdge.ContainsKey(e))
                            {
                                removeEdge[e] = true;
                            }
                        }
                        r.Color.Remove(color);
                    }
                }
                if (!removeEdge.ContainsKey(e))
                {
                    e.Color = null;
                }
            }

            //foreach (Edge e in removeEdge.Keys)
            //edgesToPutOff.Remove(e);


            var edgesToPutoffSet = new Set <Edge>(edgesToPutOff);

            for (int i = _levels.Count - 1; i >= 0; i--)
            {
                PutOffEdgesOnLevel(i, edgesToPutoffSet);
            }

            foreach (var e in edgesToPutOff)
            {
                SelectedEdges.Remove(e);
            }
        }
Exemple #3
0
        public void UnselectEdges(List <Edge> edgesToPutOff)
        {
            var edgesToPutoffSet = new Set <Edge>(edgesToPutOff);

            for (int i = _levels.Count - 1; i >= 0; i--)
            {
                PutOffEdgesOnLevel(i, edgesToPutoffSet);
            }
            foreach (var e in edgesToPutOff)
            {
                SelectedEdges.Remove(e);
            }
        }
Exemple #4
0
        public void UnselectEdges(List <Edge> edgesToPutOff)
        {
            Set <Rail> railsOfEdge = new Set <Rail>();
            Dictionary <Edge, Boolean> removeEdge = new Dictionary <Edge, Boolean>();

            foreach (Edge e in edgesToPutOff)
            {
                //this for loop seems helping the keypress='end'
                for (int i = _levels.Count - 1; i >= 0; i--)
                //int i = Levels.Count-1;
                {
                    if (_levels[i]._railsOfEdges.ContainsKey(e) == false)
                    {
                        continue;
                    }
                    railsOfEdge = _levels[i]._railsOfEdges[e];
                    foreach (var r in railsOfEdge)
                    {
                        if (r.Color == null || r.Color.Count == 0)
                        {
                            continue;
                        }


                        if (r.Color.Count > 1)
                        {
                            if (!removeEdge.ContainsKey(e))
                            {
                                removeEdge[e] = true;
                            }
                        }
                        r.Color.Remove(e.Color);
                    }
                }
                if (!removeEdge.ContainsKey(e))
                {
                    e.Color = null;
                }
            }
            foreach (Edge e in removeEdge.Keys)
            {
                edgesToPutOff.Remove(e);
            }

            var edgesToPutoffSet = new Set <Edge>(edgesToPutOff);

            for (int i = _levels.Count - 1; i >= 0; i--)
            {
                PutOffEdgesOnLevel(i, edgesToPutoffSet);
            }

            /*
             * foreach (Edge edge in edgesToPutOff)
             * {
             *  for (int i = 0; i <= _levels.Count - 1; i++){
             *      Set<Rail> railsOfEdge;
             *      if (_levels[i]._railsOfEdges.TryGetValue(edge, out railsOfEdge))
             *      {
             *          var PutoffSet = new List<Edge>();
             *          PutoffSet.Add(edge);
             *          PutOffEdgesOnLevel(i, new Set<Edge>(PutoffSet));
             *          break;
             *      }
             *  }
             * }
             */
            foreach (var e in edgesToPutOff)
            {
                SelectedEdges.Remove(e);
            }
        }