Changeset 11238 for branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/DirectedGraph/DirectedGraph.cs
- Timestamp:
- 07/30/14 13:06:52 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/DirectedGraph/DirectedGraph.cs
r11234 r11238 56 56 vertex.ArcAdded += OnArcAdded; 57 57 vertex.ArcRemoved += OnArcRemoved; 58 vertex.Changed += OnVertexChanged;59 58 } 60 59 … … 64 63 source.AddArc(arc); 65 64 target.AddArc(arc); 66 arc.Changed += OnArcChanged;67 65 } 68 66 } … … 91 89 vertices.Add(vertex); 92 90 // register event handlers 93 vertex.Changed += OnVertexChanged;94 91 vertex.ArcAdded += OnArcAdded; 95 92 vertex.ArcRemoved += OnArcRemoved; … … 99 96 vertices.Remove(vertex); 100 97 // remove connections to/from the removed vertex 101 var arcList = vertex.InArcs.Concat(vertex.OutArcs).ToList(); 98 var arcList = vertex.InArcs.Concat(vertex.OutArcs).ToList(); // avoid invalid operation exception: "collection was modified" below 102 99 foreach (var arc in arcList) 103 100 RemoveArc(arc); … … 105 102 vertex.ArcAdded -= OnArcAdded; 106 103 vertex.ArcRemoved -= OnArcRemoved; 107 vertex.Changed -= OnVertexChanged;108 104 } 109 105 … … 130 126 } 131 127 132 protected virtual void OnVertexChanged(object sender, EventArgs args) { }133 134 128 protected virtual void OnArcAdded(object sender, EventArgs<IArc> args) { 135 129 var arc = args.Value; … … 139 133 if (arcs.Contains(arc)) return; 140 134 arcs.Add(arc); 141 arc.Changed += OnArcChanged;142 135 } 143 136 … … 146 139 if (!arcs.Contains(arc)) return; // the same rationale as above 147 140 arcs.Remove(arc); 148 arc.Changed -= OnArcChanged;149 141 } 150 151 protected virtual void OnArcChanged(object sender, EventArgs args) { }152 142 153 143 public override Image ItemImage { 154 144 get { return Common.Resources.VSImageLibrary.Graph; } 155 145 } 146 147 // events 148 public event EventHandler VertexAdded; 149 public event EventHandler VertexRemoved; 150 public event EventHandler ArcAdded; 151 public event EventHandler ArcRemoved; 156 152 } 157 153 }
Note: See TracChangeset
for help on using the changeset viewer.