Index: trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/General/GraphVisualizationInfoView.cs
===================================================================
--- trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/GraphVisualizationInfoView.cs	(revision 3362)
+++ trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/General/GraphVisualizationInfoView.cs	(revision 3386)
@@ -37,23 +37,23 @@
 using System.Diagnostics;
 using System.Threading;
+using System.Drawing.Drawing2D;
 
 namespace HeuristicLab.Operators.Views.GraphVisualization {
   [View("GraphVisualizationInfo View")]
-  [Content(typeof(GraphVisualizationInfo), false)]
+  [Content(typeof(IGraphVisualizationInfo), true)]
   public partial class GraphVisualizationInfoView : ContentView {
-    private BidirectionalLookup<IOperatorShapeInfo, IShape> shapeInfoShapeMapping;
-    private BidirectionalLookup<IOperatorShapeInfo, INotifyObservableDictionaryItemsChanged<string, IOperatorShapeInfo>> shapeInfoConnectionsMapping;
-    private BidirectionalLookup<IConnection, KeyValuePair<IConnector, IConnector>> connectionConnectorsMapping;
-
-    private bool causedUpdateOfShapeInfo;
+    private BidirectionalLookup<IShapeInfo, IShape> shapeInfoShapeMapping;
+    private BidirectionalLookup<IConnectionInfo, IConnection> connectionInfoConnectionMapping;
+    private LinePenStyle connectionPenStyle;
+
     public GraphVisualizationInfoView() {
       InitializeComponent();
-      this.causedUpdateOfShapeInfo = false;
-      this.shapeInfoShapeMapping = new BidirectionalLookup<IOperatorShapeInfo, IShape>();
-      this.shapeInfoConnectionsMapping = new BidirectionalLookup<IOperatorShapeInfo, INotifyObservableDictionaryItemsChanged<string, IOperatorShapeInfo>>();
-      this.connectionConnectorsMapping = new BidirectionalLookup<IConnection, KeyValuePair<IConnector, IConnector>>();
-    }
-
-    public GraphVisualizationInfoView(GraphVisualizationInfo content)
+      this.shapeInfoShapeMapping = new BidirectionalLookup<IShapeInfo, IShape>();
+      this.connectionInfoConnectionMapping = new BidirectionalLookup<IConnectionInfo, IConnection>();
+      this.connectionPenStyle = new LinePenStyle();
+      this.connectionPenStyle.EndCap = LineCap.ArrowAnchor;
+    }
+
+    public GraphVisualizationInfoView(IGraphVisualizationInfo content)
       : this() {
       this.Content = content;
@@ -64,6 +64,6 @@
     }
 
-    public new GraphVisualizationInfo Content {
-      get { return (GraphVisualizationInfo)base.Content; }
+    public new IGraphVisualizationInfo Content {
+      get { return (IGraphVisualizationInfo)base.Content; }
       set { base.Content = value; }
     }
@@ -78,10 +78,9 @@
       this.SetEnabledStateOfControls();
     }
-
     private void SetEnabledStateOfControls() {
-      DeleteTool deleteTool = (DeleteTool) this.Controller.Tools.Where( t => t.Name == ControllerBase.DeleteToolName).FirstOrDefault();
+      DeleteTool deleteTool = (DeleteTool)this.Controller.Tools.Where(t => t.Name == ControllerBase.DeleteToolName).FirstOrDefault();
       HeuristicLab.Netron.Controller controller = this.Controller as HeuristicLab.Netron.Controller;
       if (Content == null && deleteTool != null && controller != null)
-        controller.RemoveTool(deleteTool); 
+        controller.RemoveTool(deleteTool);
       else {
         if (ReadOnly && deleteTool != null && controller != null)
@@ -93,26 +92,22 @@
 
     private void UpdateContent() {
-      foreach (IOperatorShapeInfo shapeInfo in this.shapeInfoShapeMapping.FirstValues)
+      foreach (IConnectionInfo connectionInfo in this.connectionInfoConnectionMapping.FirstValues)
+        this.RemoveConnectionInfo(connectionInfo);
+      this.connectionInfoConnectionMapping.Clear();
+      foreach (IShapeInfo shapeInfo in this.shapeInfoShapeMapping.FirstValues)
         this.RemoveShapeInfo(shapeInfo);
-
       this.shapeInfoShapeMapping.Clear();
-      this.shapeInfoConnectionsMapping.Clear();
-      this.connectionConnectorsMapping.Clear();
 
       if (Content != null) {
-        foreach (IOperatorShapeInfo shapeInfo in this.Content.OperatorShapeInfos)
-          if (!this.shapeInfoShapeMapping.ContainsFirst(shapeInfo))
-            this.AddShapeInfo(shapeInfo);
-
-        foreach (KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> connection in this.Content.Connections)
-          this.AddConnection(connection.Key.Key, connection.Key.Value, connection.Value);
-
+        foreach (IShapeInfo shapeInfo in this.Content.ShapeInfos)
+          this.AddShapeInfo(shapeInfo);
+        foreach (IConnectionInfo connectionInfo in this.Content.ConnectionInfos)
+          this.AddConnectionInfo(connectionInfo);
         this.UpdateLayoutRoot();
       }
       this.SetEnabledStateOfControls();
     }
-
     private void UpdateLayoutRoot() {
-      IOperatorShapeInfo shapeInfo = this.Content.InitialShape;
+      IShapeInfo shapeInfo = this.Content.InitialShape;
       if (shapeInfo != null)
         this.graphVisualization.Controller.Model.LayoutRoot = this.shapeInfoShapeMapping.GetByFirst(shapeInfo);
@@ -120,5 +115,4 @@
         this.graphVisualization.Controller.Model.LayoutRoot = null;
     }
-
     private void VisualizationInfo_InitialShapeChanged(object sender, EventArgs e) {
       this.UpdateLayoutRoot();
@@ -128,12 +122,12 @@
       base.RegisterContentEvents();
       this.Content.InitialShapeChanged += new EventHandler(VisualizationInfo_InitialShapeChanged);
-      this.Content.ObserveableShapeInfos.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperatorShapeInfo>(ShapeInfos_ItemsAdded);
-      this.Content.ObserveableShapeInfos.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperatorShapeInfo>(ShapeInfos_ItemsRemoved);
-      this.Content.ObserveableShapeInfos.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperatorShapeInfo>(ShapeInfos_CollectionReset);
-
-      this.Content.ObservableConnections.ItemsAdded += new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>>(Connections_ItemsAdded);
-      this.Content.ObservableConnections.ItemsRemoved += new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>>(Connections_ItemsRemoved);
-      this.Content.ObservableConnections.ItemsReplaced += new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>>(Connections_ItemsReplaced);
-      this.Content.ObservableConnections.CollectionReset += new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>>(Connections_CollectionReset);
+
+      this.Content.ObserveableShapeInfos.ItemsAdded += new CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_ItemsAdded);
+      this.Content.ObserveableShapeInfos.ItemsRemoved += new CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_ItemsRemoved);
+      this.Content.ObserveableShapeInfos.CollectionReset += new CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_CollectionReset);
+
+      this.Content.ObservableConnectionInfos.ItemsAdded += new CollectionItemsChangedEventHandler<IConnectionInfo>(ConnectionInfos_ItemsAdded);
+      this.Content.ObservableConnectionInfos.ItemsRemoved += new CollectionItemsChangedEventHandler<IConnectionInfo>(ConnectionInfos_ItemsRemoved);
+      this.Content.ObservableConnectionInfos.CollectionReset += new CollectionItemsChangedEventHandler<IConnectionInfo>(ConnectionInfos_CollectionReset);
     }
 
@@ -141,38 +135,34 @@
       base.DeregisterContentEvents();
       this.Content.InitialShapeChanged -= new EventHandler(VisualizationInfo_InitialShapeChanged);
-      this.Content.ObserveableShapeInfos.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperatorShapeInfo>(ShapeInfos_ItemsAdded);
-      this.Content.ObserveableShapeInfos.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperatorShapeInfo>(ShapeInfos_ItemsRemoved);
-      this.Content.ObserveableShapeInfos.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperatorShapeInfo>(ShapeInfos_CollectionReset);
-
-      this.Content.ObservableConnections.ItemsAdded -= new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>>(Connections_ItemsAdded);
-      this.Content.ObservableConnections.ItemsRemoved -= new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>>(Connections_ItemsRemoved);
-      this.Content.ObservableConnections.ItemsReplaced -= new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>>(Connections_ItemsReplaced);
-      this.Content.ObservableConnections.CollectionReset -= new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>>(Connections_CollectionReset);
-    }
-
-    private void ShapeInfos_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IOperatorShapeInfo> e) {
-      foreach (IOperatorShapeInfo shapeInfo in e.OldItems)
+
+      this.Content.ObserveableShapeInfos.ItemsAdded -= new CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_ItemsAdded);
+      this.Content.ObserveableShapeInfos.ItemsRemoved -= new CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_ItemsRemoved);
+      this.Content.ObserveableShapeInfos.CollectionReset -= new CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_CollectionReset);
+
+      this.Content.ObservableConnectionInfos.ItemsAdded -= new CollectionItemsChangedEventHandler<IConnectionInfo>(ConnectionInfos_ItemsAdded);
+      this.Content.ObservableConnectionInfos.ItemsRemoved -= new CollectionItemsChangedEventHandler<IConnectionInfo>(ConnectionInfos_ItemsRemoved);
+      this.Content.ObservableConnectionInfos.CollectionReset -= new CollectionItemsChangedEventHandler<IConnectionInfo>(ConnectionInfos_CollectionReset);
+    }
+
+    #region ShapeInfos
+    private void ShapeInfos_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IShapeInfo> e) {
+      foreach (IShapeInfo shapeInfo in e.OldItems)
         this.RemoveShapeInfo(shapeInfo);
-      foreach (IOperatorShapeInfo shapeInfo in e.Items)
+      foreach (IShapeInfo shapeInfo in e.Items)
         this.AddShapeInfo(shapeInfo);
     }
-
-    private void ShapeInfos_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IOperatorShapeInfo> e) {
-      foreach (IOperatorShapeInfo shapeInfo in e.Items)
+    private void ShapeInfos_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IShapeInfo> e) {
+      foreach (IShapeInfo shapeInfo in e.Items)
         this.AddShapeInfo(shapeInfo);
     }
-
-    private void ShapeInfos_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IOperatorShapeInfo> e) {
-      foreach (IOperatorShapeInfo shapeInfo in e.Items)
+    private void ShapeInfos_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IShapeInfo> e) {
+      foreach (IShapeInfo shapeInfo in e.Items)
         this.RemoveShapeInfo(shapeInfo);
     }
 
-    private void AddShapeInfo(IOperatorShapeInfo shapeInfo) {
+    private void AddShapeInfo(IShapeInfo shapeInfo) {
       this.RegisterShapeInfoEvents(shapeInfo);
-
       IShape shape = shapeInfo.CreateShape();
-      shape.OnEntityChange += new EventHandler<EntityEventArgs>(shape_OnEntityChange);
-      shape.OnMouseEnter += new EventHandler<EntityMouseEventArgs>(shape_OnMouseEnter);
-      shape.OnMouseLeave += new EventHandler<EntityMouseEventArgs>(shape_OnMouseLeave);
+      this.RegisterShapeEvents(shape);
       this.shapeInfoShapeMapping.Add(shapeInfo, shape);
 
@@ -180,25 +170,14 @@
       this.graphVisualization.Invalidate();
     }
-
-    private void RemoveShapeInfo(IOperatorShapeInfo shapeInfo) {
-      this.DeregisterShapeInfoEvents(shapeInfo);
-      IShape shape = this.shapeInfoShapeMapping.GetByFirst(shapeInfo);
-      shape.OnEntityChange -= new EventHandler<EntityEventArgs>(shape_OnEntityChange);
-      shape.OnMouseEnter -= new EventHandler<EntityMouseEventArgs>(shape_OnMouseEnter);
-      shape.OnMouseLeave -= new EventHandler<EntityMouseEventArgs>(shape_OnMouseLeave);
-
-      IConnection connection;
-      foreach (IConnector connector in shape.Connectors) {
-        connection = this.GetConnection(shapeInfo, connector.Name);
-        this.RemoveConnection(connection);
-      }
-
-      this.shapeInfoShapeMapping.RemoveByFirst(shapeInfo);
-      this.shapeInfoConnectionsMapping.RemoveByFirst(shapeInfo);
-
-      if (this.graphVisualization.Controller.Model.Shapes.Contains(shape)) {
-        this.graphVisualization.Controller.Model.RemoveShape(shape);
-      }
-      this.graphVisualization.Invalidate();
+    private void RemoveShapeInfo(IShapeInfo shapeInfo) {
+        this.DeregisterShapeInfoEvents(shapeInfo);
+        IShape shape = this.shapeInfoShapeMapping.GetByFirst(shapeInfo);
+        this.DeregisterShapeEvents(shape);
+        this.shapeInfoShapeMapping.RemoveByFirst(shapeInfo);
+
+        if (this.graphVisualization.Controller.Model.Shapes.Contains(shape)) {
+          this.graphVisualization.Controller.Model.RemoveShape(shape);
+          this.graphVisualization.Invalidate();
+        }
     }
 
@@ -206,52 +185,49 @@
       shapeInfo.Changed += new EventHandler(shapeInfo_Changed);
     }
-
     private void DeregisterShapeInfoEvents(IShapeInfo shapeInfo) {
       shapeInfo.Changed -= new EventHandler(shapeInfo_Changed);
     }
 
-    private void Connections_CollectionReset(object sender, CollectionItemsChangedEventArgs<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>> e) {
-      IConnection connection;
-      foreach (KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> pair in e.Items) {
-        connection = this.GetConnection(pair.Key.Key, pair.Key.Value);
-        this.RemoveConnection(connection);
-      }
-      foreach (KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> pair in e.Items)
-        this.AddConnection(pair.Key.Key, pair.Key.Value, pair.Value);
-    }
-
-    private void Connections_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>> e) {
-      IConnection connection;
-      foreach (KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> pair in e.Items) {
-        connection = this.GetConnection(pair.Key.Key, pair.Key.Value);
-        this.RemoveConnection(connection);
-      }
-      foreach (KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> pair in e.Items)
-        this.AddConnection(pair.Key.Key, pair.Key.Value, pair.Value);
-    }
-
-    private void Connections_ItemsAdded(object sender, CollectionItemsChangedEventArgs<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>> e) {
-      foreach (KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> pair in e.Items)
-        this.AddConnection(pair.Key.Key, pair.Key.Value, pair.Value);
-    }
-
-    private void Connections_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>> e) {
-      IConnection connection;
-      foreach (KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> pair in e.Items) {
-        connection = this.GetConnection(pair.Key.Key, pair.Key.Value);
-        this.RemoveConnection(connection);
-      }
-    }
-
-    private void AddConnection(IOperatorShapeInfo shapeInfoFrom, string connectorName, IOperatorShapeInfo shapeInfoTo) {
-      IShape shapeFrom = this.shapeInfoShapeMapping.GetByFirst(shapeInfoFrom);
-      IShape shapeTo = this.shapeInfoShapeMapping.GetByFirst(shapeInfoTo);
-
-      IConnector connectorFrom = shapeFrom.Connectors.Where(c => c.Name == connectorName).First();
-      IConnector connectorTo = shapeTo.Connectors.Where(c => c.Name == "Predecessor").FirstOrDefault();
-      KeyValuePair<IConnector, IConnector> connectorPair = new KeyValuePair<IConnector, IConnector>(connectorFrom, connectorTo);
-      if (!this.connectionConnectorsMapping.ContainsSecond(connectorPair)) {
-        IConnection connection = Factory.CreateConnection(connectorFrom, connectorTo);
-        this.connectionConnectorsMapping.Add(connection, connectorPair);
+    private void shapeInfo_Changed(object sender, EventArgs e) {
+      IShapeInfo shapeInfo = (IShapeInfo)sender;
+      IShape shape = this.shapeInfoShapeMapping.GetByFirst(shapeInfo);
+      this.DeregisterShapeEvents(shape);
+      shapeInfo.UpdateShape(shape);
+      shape.Invalidate();
+      this.RegisterShapeEvents(shape);
+    }
+    #endregion
+
+    #region ConnectionInfos
+    private void ConnectionInfos_CollectionReset(object sender, CollectionItemsChangedEventArgs<IConnectionInfo> e) {
+      foreach (IConnectionInfo connectionInfo in e.Items)
+        this.RemoveConnectionInfo(connectionInfo);
+      foreach (IConnectionInfo connectionInfo in e.Items)
+        this.AddConnectionInfo(connectionInfo);
+    }
+    private void ConnectionInfos_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IConnectionInfo> e) {
+      foreach (IConnectionInfo connectionInfo in e.Items)
+        this.AddConnectionInfo(connectionInfo);
+    }
+    private void ConnectionInfos_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IConnectionInfo> e) {
+      foreach (IConnectionInfo connectionInfo in e.Items)
+        this.RemoveConnectionInfo(connectionInfo);
+    }
+
+    private void AddConnectionInfo(IConnectionInfo connectionInfo) {
+      this.RegisterConnectionInfoEvents(connectionInfo);
+      IShape shapeFrom = this.shapeInfoShapeMapping.GetByFirst(connectionInfo.From);
+      IShape shapeTo = this.shapeInfoShapeMapping.GetByFirst(connectionInfo.To);
+
+      IConnector connectorFrom = shapeFrom.Connectors.Where(c => c.Name == connectionInfo.ConnectorFrom).FirstOrDefault();
+      IConnector connectorTo = shapeTo.Connectors.Where(c => c.Name == connectionInfo.ConnectorTo).FirstOrDefault();
+      if (connectorFrom != null && connectorTo != null) {
+        Connection connection = new Connection(connectorFrom.Point, connectorTo.Point);
+        connection.From.AllowMove = false;
+        connection.To.AllowMove = false;
+        connectorFrom.AttachConnector(connection.From);
+        connectorTo.AttachConnector(connection.To);
+        connection.PenStyle = this.connectionPenStyle;
+        this.connectionInfoConnectionMapping.Add(connectionInfo, connection);
         this.graphVisualization.Controller.Model.AddConnection(connection);
         this.graphVisualization.Invalidate();
@@ -259,52 +235,47 @@
     }
 
-    private IConnection GetConnection(IOperatorShapeInfo shapeInfoFrom, string connectorName) {
-      IShape shape = this.shapeInfoShapeMapping.GetByFirst(shapeInfoFrom);
-      IConnector connector = shape.Connectors.Where(c => c.Name == connectorName).First();
-
-      if (!this.connectionConnectorsMapping.SecondValues.Any(p => p.Key == connector))
-        return null;
-
-      KeyValuePair<IConnector, IConnector> connectorPair = this.connectionConnectorsMapping.SecondValues.Where(p => p.Key == connector).FirstOrDefault();
-      return this.connectionConnectorsMapping.GetBySecond(connectorPair);
-    }
-
-    private void ChangeConnection(IOperatorShapeInfo shapeInfoFrom, string connectorName, IOperatorShapeInfo shapeInfoTo) {
-      IConnection connection = this.GetConnection(shapeInfoFrom, connectorName);
-      IShape shapeTo = this.shapeInfoShapeMapping.GetByFirst(shapeInfoFrom);
-      IConnector connectorTo = shapeTo.Connectors.Where(c => c.Name == "Predecessor").First();
-
-      connection.To.DetachFromParent();
-      connection.To.AttachTo(connectorTo);
-      this.graphVisualization.Invalidate();
-    }
-
+    private void RemoveConnectionInfo(IConnectionInfo connectionInfo) {
+      DeregisterConnectionInfoEvents(connectionInfo);
+      IConnection connection = this.connectionInfoConnectionMapping.GetByFirst(connectionInfo);
+      this.connectionInfoConnectionMapping.RemoveByFirst(connectionInfo);
+      this.RemoveConnection(connection);
+      
+    }
     private void RemoveConnection(IConnection connection) {
-      if (connection == null)
-        return;
-
       if (connection.From.AttachedTo != null)
         connection.From.DetachFromParent();
       if (connection.To.AttachedTo != null)
         connection.To.DetachFromParent();
-
-      if (this.connectionConnectorsMapping.ContainsFirst(connection))
-        this.connectionConnectorsMapping.RemoveByFirst(connection);
-      if (this.graphVisualization.Controller.Model.Connections.Contains(connection))
+      if (this.Controller.Model.Connections.Contains(connection)) {
         this.graphVisualization.Controller.Model.Remove(connection);
-      this.graphVisualization.Invalidate();
-    }
-
-
-    private void shapeInfo_Changed(object sender, EventArgs e) {
-      if (this.causedUpdateOfShapeInfo)
-        return;
-
-      this.causedUpdateOfShapeInfo = true;
-      IOperatorShapeInfo shapeInfo = (IOperatorShapeInfo)sender;
-      IShape shape = this.shapeInfoShapeMapping.GetByFirst(shapeInfo);
-      shapeInfo.UpdateShape(shape);
-      shape.Invalidate();
-      this.causedUpdateOfShapeInfo = false;
+        this.graphVisualization.Invalidate();
+      }
+    }
+
+    private void RegisterConnectionInfoEvents(IConnectionInfo connectionInfo) {
+      connectionInfo.Changed += new EventHandler(connectionInfo_Changed);
+    }
+    private void DeregisterConnectionInfoEvents(IConnectionInfo connectionInfo) {
+      connectionInfo.Changed -= new EventHandler(connectionInfo_Changed);
+    }
+    private void connectionInfo_Changed(object sender, EventArgs e) {
+      IConnectionInfo connectionInfo = (IConnectionInfo)sender;
+      IConnection connection = this.connectionInfoConnectionMapping.GetByFirst(connectionInfo);
+      this.RemoveConnectionInfo(connectionInfo);
+      this.AddConnectionInfo(connectionInfo);
+    }
+    #endregion
+
+    #region netron events - shapes, graphvisualization
+    private void RegisterShapeEvents(IShape shape) {
+      shape.OnEntityChange += new EventHandler<EntityEventArgs>(shape_OnEntityChange);
+      shape.OnMouseEnter += new EventHandler<EntityMouseEventArgs>(shape_OnMouseEnter);
+      shape.OnMouseLeave += new EventHandler<EntityMouseEventArgs>(shape_OnMouseLeave);
+    }
+
+    private void DeregisterShapeEvents(IShape shape) {
+      shape.OnEntityChange -= new EventHandler<EntityEventArgs>(shape_OnEntityChange);
+      shape.OnMouseEnter -= new EventHandler<EntityMouseEventArgs>(shape_OnMouseEnter);
+      shape.OnMouseLeave -= new EventHandler<EntityMouseEventArgs>(shape_OnMouseLeave);
     }
 
@@ -321,36 +292,30 @@
 
     private void shape_OnEntityChange(object sender, EntityEventArgs e) {
-      if (this.causedUpdateOfShapeInfo)
-        return;
-
-      this.causedUpdateOfShapeInfo = true;
       IShape shape = e.Entity as IShape;
-      IOperatorShapeInfo shapeInfo = this.shapeInfoShapeMapping.GetBySecond(shape);
-      shapeInfo.Location = shape.Location;
-
-      OperatorShape operatorShape = shape as OperatorShape;
-      if (operatorShape != null)
-        shapeInfo.Collapsed = operatorShape.Collapsed;
-
+      IShapeInfo shapeInfo = this.shapeInfoShapeMapping.GetBySecond(shape);
+      this.DeregisterShapeInfoEvents(shapeInfo);
+      shapeInfo.UpdateShapeInfo(shape);
+      this.RegisterShapeInfoEvents(shapeInfo);
       this.graphVisualization.Invalidate();
-      this.causedUpdateOfShapeInfo = false;
-    }
+    }
+
 
     private void graphVisualization_OnEntityAdded(object sender, EntityEventArgs e) {
       IConnection connection = e.Entity as IConnection;
-      if (connection != null && !this.connectionConnectorsMapping.ContainsFirst(connection)) {
+      if (connection != null && !this.connectionInfoConnectionMapping.ContainsSecond(connection)) {
         IConnector connectorFrom = connection.From.AttachedTo;
         IConnector connectorTo = connection.To.AttachedTo;
         this.RemoveConnection(connection); //is added again by the model events
 
-        if (connectorFrom != null && connectorTo != null && connectorFrom.Name != "Predecessor") {
+        if (connectorFrom != null && connectorTo != null) {
           IShape shapeFrom = (IShape)connectorFrom.Parent;
           IShape shapeTo = (IShape)connectorTo.Parent;
-          IOperatorShapeInfo shapeInfoFrom = this.shapeInfoShapeMapping.GetBySecond(shapeFrom);
-          IOperatorShapeInfo shapeInfoTo = this.shapeInfoShapeMapping.GetBySecond(shapeTo);
-          string connectorName = connectorFrom.Name;
-
-          if (shapeFrom != shapeTo) //avoid self references
-            this.Content.AddConnection(shapeInfoFrom, connectorName, shapeInfoTo);
+          IShapeInfo shapeInfoFrom = this.shapeInfoShapeMapping.GetBySecond(shapeFrom);
+          IShapeInfo shapeInfoTo = this.shapeInfoShapeMapping.GetBySecond(shapeTo);
+          string connectorFromName = connectorFrom.Name;
+          string connectorToName = connectorTo.Name;
+
+          if (shapeInfoFrom != shapeInfoTo) //avoid self references
+            this.Content.AddConnectionInfo(new ConnectionInfo(shapeInfoFrom, connectorFromName, shapeInfoTo, connectorToName));
         }
       }
@@ -360,21 +325,19 @@
       IShape shape = e.Entity as IShape;
       if (shape != null && this.shapeInfoShapeMapping.ContainsSecond(shape)) {
-        IOperatorShapeInfo shapeInfo = this.shapeInfoShapeMapping.GetBySecond(shape);
+        IShapeInfo shapeInfo = this.shapeInfoShapeMapping.GetBySecond(shape);
         this.Content.RemoveShapeInfo(shapeInfo);
       }
 
       IConnection connection = e.Entity as IConnection;
-      if (connection != null && this.connectionConnectorsMapping.ContainsFirst(connection)) {
-        IShape parentShape = (IShape)connection.From.AttachedTo.Parent;
-        IOperatorShapeInfo shapeInfo = this.shapeInfoShapeMapping.GetBySecond(parentShape);
-        string connectorName = connection.From.AttachedTo.Name;
-
-        this.Content.RemoveConnection(shapeInfo, connectorName);
-      }
-    }
-
-    internal void RelayoutGraph() {
+      if (connection != null && this.connectionInfoConnectionMapping.ContainsSecond(connection)) {
+        IConnectionInfo connectionInfo = connectionInfoConnectionMapping.GetBySecond(connection);
+        this.Content.RemoveConnectionInfo(connectionInfo);
+      }
+    }
+    #endregion
+
+    public void RelayoutGraph() {
       if (this.shapeInfoShapeMapping.Count > 0
-        && this.connectionConnectorsMapping.Count > 0
+        && this.connectionInfoConnectionMapping.Count > 0
         && this.Content.InitialShape != null) { //otherwise the layout does not work
         string layoutName = "Standard TreeLayout";
