Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/25/10 17:28:31 (15 years ago)
Author:
mkommend
Message:

finished mapping from OperatorGraph to GraphVisualizationInfo (ticket #867)

Location:
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/Model/IShapeInfo.cs

    r2861 r2868  
    3838    void RemoveConnector(string connectorName);
    3939
    40     IEnumerable<KeyValuePair<string,IShapeInfo>> Connections {get;}
    41     INotifyObservableDictionaryItemsChanged<string, IShapeInfo> ObservableConnections { get; }
    42 
    43     void AddConnection(string fromConnectorName, IShapeInfo toShapeInfo);
    44     void RemoveConnection(string fromConnectorName);
    45     void ChangeConnection(string fromConnector, IShapeInfo toShapeInfo);
    46 
    4740    IShape CreateShape();
    4841    void UpdateShape(IShape shape);
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/Model/OperatorGraphVisualizationInfo.cs

    r2861 r2868  
    4141
    4242      this.shapeInfos = new ObservableSet<IShapeInfo>();
     43      this.connections = new ObservableDictionary<KeyValuePair<IShapeInfo, string>, IShapeInfo>();
    4344    }
    4445
     
    4849      this.operatorGraph.InitialOperatorChanged += new EventHandler(operatorGraph_InitialOperatorChanged);
    4950      foreach (IOperator op in operatorGraph.Operators)
    50         this.AddOperator(op);
     51        if (!this.shapeInfoMapping.ContainsFirst(op))
     52          this.AddOperator(op);
    5153
    5254      operatorGraph.Operators.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsAdded);
     
    8385    }
    8486
     87    private ObservableDictionary<KeyValuePair<IShapeInfo, string>, IShapeInfo> connections;
     88    public INotifyObservableDictionaryItemsChanged<KeyValuePair<IShapeInfo, string>, IShapeInfo> ObservableConnections {
     89      get { return this.connections; }
     90    }
     91    public IEnumerable<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>> Connections {
     92      get { return this.connections; }
     93    }
     94
     95    #region methods to manipulate operatorgraph by the shape info
    8596    internal void AddShapeInfo(IOperator op, IShapeInfo shapeInfo) {
    8697      this.RegisterOperatorEvents(op);
     
    89100      this.shapeInfos.Add(shapeInfo);
    90101
     102      foreach (IParameter param in op.Parameters)
     103        this.AddParameter(op, param);
     104
    91105      this.operatorGraph.Operators.Add(op);
    92106    }
     
    97111    }
    98112
     113    internal void AddConnection(IShapeInfo shapeInfoFrom, string connectorName, IShapeInfo shapeInfoTo) {
     114      IOperator opFrom = this.shapeInfoMapping.GetBySecond(shapeInfoFrom);
     115      IOperator opTo = this.shapeInfoMapping.GetBySecond(shapeInfoTo);
     116
     117      IValueParameter<IOperator> param = (IValueParameter<IOperator>)opFrom.Parameters[connectorName];
     118      param.Value = opTo;
     119    }
     120
     121    internal void ChangeConnection(IShapeInfo shapeInfoFrom, string connectorName, IShapeInfo shapeInfoTo) {
     122      IOperator opFrom = this.shapeInfoMapping.GetBySecond(shapeInfoFrom);
     123      IOperator opTo = this.shapeInfoMapping.GetBySecond(shapeInfoTo);
     124
     125      IValueParameter<IOperator> param = (IValueParameter<IOperator>)opFrom.Parameters[connectorName];
     126      param.Value = opTo;
     127    }
     128
     129    internal void RemoveConnection(IShapeInfo shapeInfoFrom, string connectorName) {
     130      IOperator opFrom = this.shapeInfoMapping.GetBySecond(shapeInfoFrom);
     131      IValueParameter<IOperator> param = (IValueParameter<IOperator>)opFrom.Parameters[connectorName];
     132      param.Value = null;
     133    }
     134    #endregion
     135
    99136    #region operator events
    100137    private void AddOperator(IOperator op) {
    101       if (shapeInfoMapping.ContainsFirst(op))
    102         return;
    103 
    104       this.RegisterOperatorEvents(op);
    105       IShapeInfo shapeInfo = Factory.CreateShapeInfo(op);
    106       this.operatorParameterCollectionMapping.Add(op, op.Parameters);
    107       this.shapeInfoMapping.Add(op, shapeInfo);
    108       foreach (IParameter param in op.Parameters)
    109         this.AddParameter(op, param);
    110 
    111       this.shapeInfos.Add(shapeInfo);
     138      if (!this.shapeInfoMapping.ContainsFirst(op)) {
     139        this.RegisterOperatorEvents(op);
     140        IShapeInfo shapeInfo = Factory.CreateShapeInfo(op);
     141        this.operatorParameterCollectionMapping.Add(op, op.Parameters);
     142        this.shapeInfoMapping.Add(op, shapeInfo);
     143        foreach (IParameter param in op.Parameters)
     144          this.AddParameter(op, param);
     145
     146        this.shapeInfos.Add(shapeInfo);
     147      }
    112148    }
    113149
     
    166202          if (!this.shapeInfoMapping.ContainsFirst(opParam.Value))
    167203            this.AddOperator(opParam.Value);
    168           shapeInfo.AddConnection(param.Name, this.shapeInfoMapping.GetByFirst(opParam.Value));
     204          this.connections.Add(new KeyValuePair<IShapeInfo, string>(shapeInfo, param.Name), this.shapeInfoMapping.GetByFirst(opParam.Value));
    169205        }
    170206      }
    171207    }
     208
    172209    private void RemoveParameter(IOperator op, IParameter param) {
    173210      IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>;
     
    176213        this.parameterOperatorMapping.Remove(opParam);
    177214        IShapeInfo shapeInfo = this.shapeInfoMapping.GetByFirst(op);
     215
     216        this.connections.Remove(new KeyValuePair<IShapeInfo, string>(shapeInfo, param.Name));
    178217        shapeInfo.RemoveConnector(param.Name);
    179218      }
     
    185224        IOperator op = this.parameterOperatorMapping[opParam];
    186225        IShapeInfo shapeInfo = this.shapeInfoMapping.GetByFirst(op);
     226        KeyValuePair<IShapeInfo, string> connectionFrom = new KeyValuePair<IShapeInfo, string>(shapeInfo, opParam.Name);
    187227
    188228        if (opParam.Value == null)
    189           shapeInfo.RemoveConnection(opParam.Name);
     229          this.connections.Remove(connectionFrom);
    190230        else
    191           shapeInfo.ChangeConnection(opParam.Name, this.shapeInfoMapping.GetByFirst(opParam.Value));
     231          this.connections[connectionFrom] = this.shapeInfoMapping.GetByFirst(opParam.Value);
    192232      }
    193233    }
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/Model/OperatorShape.cs

    r2861 r2868  
    5151
    5252    private IConnector CreateConnector(string connectorName, Point location) {
    53       Connector connector = new Connector(location);
     53      Connector connector = new Connector(location, this.Model);
    5454      connector.ConnectorStyle = ConnectorStyle.Square;
    5555      connector.Parent = this;
     
    6969
    7070    public void RemoveConnector(string connectorName) {
    71       IConnector connector = this.additionalConnectors.Where(c => c.Name ==connectorName).FirstOrDefault();
     71      IConnector connector = this.additionalConnectors.Where(c => c.Name == connectorName).FirstOrDefault();
    7272      if (connector != null) {
    7373        this.additionalConnectors.Remove(connector);
     
    7878
    7979    private void UpdateConnectorLocation() {
    80       int spacing = this.Rectangle.Width / this.additionalConnectors.Count + 1;
     80      if (this.additionalConnectors.Count == 0)
     81        return;
     82
     83      int spacing = this.Rectangle.Width / this.additionalConnectors.Count;
    8184      int margin = spacing / 2;
    8285      int posX = margin + this.Rectangle.X;
     
    98101      Connectors.Add(predecessor);
    99102
    100       successor = this.CreateConnector("Successor",(new Point(Rectangle.Right, Center.Y)));
     103      successor = this.CreateConnector("Successor", (new Point(Rectangle.Right, Center.Y)));
    101104      Connectors.Add(successor);
    102105      #endregion
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/Model/OperatorShapeInfo.cs

    r2861 r2868  
    5454      if (this.connectorNames.Contains(connectorName)) {
    5555        this.connectorNames.Remove(connectorName);
    56         if (this.connections.ContainsKey(connectorName))
    57           this.connections.Remove(connectorName);
    5856        this.OnChanged();
    5957      }
    60     }
    61 
    62     public override void AddConnection(string fromConnectorName, IShapeInfo toShapeInfo) {
    63       this.connections.Add(fromConnectorName, toShapeInfo);
    64     }
    65 
    66     public override void RemoveConnection(string fromConnectorName) {
    67       if (this.connections.ContainsKey(fromConnectorName))
    68         this.connections.Remove(fromConnectorName);
    69     }
    70 
    71     public override void ChangeConnection(string fromConnectorName, IShapeInfo toShapeInfo) {
    72       this.connections[fromConnectorName] = toShapeInfo;
    7358    }
    7459
     
    137122        }
    138123        //remove old connectors
    139         for (; j < oldConnectorNames.Count; i++)
     124        for (; j < oldConnectorNames.Count; j++)
    140125          operatorShape.RemoveConnector(oldConnectorNames[j]);
    141126
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/Model/ShapeInfo.cs

    r2861 r2868  
    3535        throw new ArgumentException("The passed shape type " + shapeType + " must be derived from IShape.");
    3636      this.shapeType = shapeType;
    37       this.connections = new ObservableDictionary<string, IShapeInfo>();
    3837    }
    3938
     
    6564    }
    6665
    67     protected ObservableDictionary<string, IShapeInfo> connections;
    68     public IEnumerable<KeyValuePair<string, IShapeInfo>> Connections {
    69       get { return this.connections; }
    70     }
    71     public INotifyObservableDictionaryItemsChanged<string, IShapeInfo> ObservableConnections {
    72       get { return this.connections; }
    73     }
    74 
    7566    public abstract void AddConnector(string connectorName);
    7667    public abstract void RemoveConnector(string connectorName);
    77     public abstract void AddConnection(string fromConnectorName, IShapeInfo toShapeInfo);
    78     public abstract void RemoveConnection(string fromConnectorName);
    79     public abstract void ChangeConnection(string fromConnectorName, IShapeInfo toShapeInfo);
    80 
    8168
    8269    public virtual IShape CreateShape() {
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphView.cs

    r2862 r2868  
    4242    private BidirectionalLookup<IShapeInfo, IShape> shapeInfoShapeMapping;
    4343    private BidirectionalLookup<IShapeInfo, INotifyObservableDictionaryItemsChanged<string, IShapeInfo>> shapeInfoConnectionsMapping;
    44     private Dictionary<IConnector, IShape> connectorShapeMapping;
    4544    private BidirectionalLookup<IConnection, KeyValuePair<IConnector, IConnector>> connectionConnectorsMapping;
    4645
     
    5352      this.shapeInfoConnectionsMapping = new BidirectionalLookup<IShapeInfo, INotifyObservableDictionaryItemsChanged<string, IShapeInfo>>();
    5453      this.connectionConnectorsMapping = new BidirectionalLookup<IConnection, KeyValuePair<IConnector, IConnector>>();
    55       this.connectorShapeMapping = new Dictionary<IConnector, IShape>();
    5654    }
    5755
     
    8381      this.shapeInfoShapeMapping.Clear();
    8482      this.shapeInfoConnectionsMapping.Clear();
    85       this.connectorShapeMapping.Clear();
    8683      this.connectionConnectorsMapping.Clear();
    8784
     
    8986        if (!this.shapeInfoShapeMapping.ContainsFirst(shapeInfo))
    9087          this.AddShapeInfo(shapeInfo);
     88
     89      foreach (KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo> connection in this.VisualizationInfo.Connections)
     90        this.AddConnection(connection.Key.Key, connection.Key.Value, connection.Value);
    9191
    9292      this.UpdateLayoutRoot();
     
    111111      this.VisualizationInfo.ObserveableShapeInfos.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_ItemsRemoved);
    112112      this.VisualizationInfo.ObserveableShapeInfos.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_CollectionReset);
     113
     114      this.VisualizationInfo.ObservableConnections.ItemsAdded += new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>>(Connections_ItemsAdded);
     115      this.VisualizationInfo.ObservableConnections.ItemsRemoved += new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>>(Connections_ItemsRemoved);
     116      this.VisualizationInfo.ObservableConnections.ItemsReplaced += new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>>(Connections_ItemsReplaced);
     117      this.VisualizationInfo.ObservableConnections.CollectionReset += new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>>(Connections_CollectionReset);
    113118    }
    114119
     
    119124      this.VisualizationInfo.ObserveableShapeInfos.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_ItemsRemoved);
    120125      this.VisualizationInfo.ObserveableShapeInfos.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_CollectionReset);
     126
     127      this.VisualizationInfo.ObservableConnections.ItemsAdded -= new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>>(Connections_ItemsAdded);
     128      this.VisualizationInfo.ObservableConnections.ItemsRemoved -= new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>>(Connections_ItemsRemoved);
     129      this.VisualizationInfo.ObservableConnections.ItemsReplaced -= new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>>(Connections_ItemsReplaced);
     130      this.VisualizationInfo.ObservableConnections.CollectionReset -= new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>>(Connections_CollectionReset);
    121131    }
    122132
     
    144154      shape.OnEntityChange += new EventHandler<EntityEventArgs>(shape_OnEntityChange);
    145155      this.shapeInfoShapeMapping.Add(shapeInfo, shape);
    146       this.shapeInfoConnectionsMapping.Add(shapeInfo, shapeInfo.ObservableConnections);
    147 
    148       foreach (IConnector connector in shape.Connectors)
    149         this.connectorShapeMapping.Add(connector, shape);
    150156
    151157      this.graphVisualization.Controller.Model.AddShape(shape);
    152 
    153       foreach (KeyValuePair<string, IShapeInfo> pair in shapeInfo.Connections) {
    154         if (!this.shapeInfoShapeMapping.ContainsFirst(pair.Value))
    155           this.AddShapeInfo(pair.Value);
    156         this.AddConnection(shapeInfo, pair.Key, pair.Value);
    157       }
    158158    }
    159159
     
    180180    private void RegisterShapeInfoEvents(IShapeInfo shapeInfo) {
    181181      shapeInfo.Changed += new ChangedEventHandler(shapeInfo_Changed);
    182       shapeInfo.ObservableConnections.ItemsAdded += new CollectionItemsChangedEventHandler<KeyValuePair<string, IShapeInfo>>(Connections_ItemsAdded);
    183       shapeInfo.ObservableConnections.ItemsRemoved += new CollectionItemsChangedEventHandler<KeyValuePair<string, IShapeInfo>>(Connections_ItemsRemoved);
    184       shapeInfo.ObservableConnections.ItemsReplaced += new CollectionItemsChangedEventHandler<KeyValuePair<string, IShapeInfo>>(Connections_ItemsReplaced);
    185       shapeInfo.ObservableConnections.CollectionReset += new CollectionItemsChangedEventHandler<KeyValuePair<string, IShapeInfo>>(Connections_CollectionReset);
    186182    }
    187183
    188184    private void DeregisterShapeInfoEvents(IShapeInfo shapeInfo) {
    189185      shapeInfo.Changed -= new ChangedEventHandler(shapeInfo_Changed);
    190       shapeInfo.ObservableConnections.ItemsAdded -= new CollectionItemsChangedEventHandler<KeyValuePair<string, IShapeInfo>>(Connections_ItemsAdded);
    191       shapeInfo.ObservableConnections.ItemsRemoved -= new CollectionItemsChangedEventHandler<KeyValuePair<string, IShapeInfo>>(Connections_ItemsRemoved);
    192       shapeInfo.ObservableConnections.ItemsReplaced -= new CollectionItemsChangedEventHandler<KeyValuePair<string, IShapeInfo>>(Connections_ItemsReplaced);
    193       shapeInfo.ObservableConnections.CollectionReset -= new CollectionItemsChangedEventHandler<KeyValuePair<string, IShapeInfo>>(Connections_CollectionReset);
    194     }
    195 
    196     private void Connections_CollectionReset(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IShapeInfo>> e) {
    197       IShapeInfo shapeInfo = this.shapeInfoConnectionsMapping.GetBySecond((INotifyObservableDictionaryItemsChanged<string, IShapeInfo>)sender);
     186    }
     187
     188    private void Connections_CollectionReset(object sender, CollectionItemsChangedEventArgs<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>> e) {
    198189      IConnection connection;
    199       foreach (KeyValuePair<string, IShapeInfo> pair in e.Items) {
    200         connection = this.GetConnection(shapeInfo, pair.Key);
     190      foreach (KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo> pair in e.Items) {
     191        connection = this.GetConnection(pair.Key.Key, pair.Key.Value);
    201192        this.RemoveConnection(connection);
    202193      }
    203       foreach (KeyValuePair<string, IShapeInfo> pair in e.Items)
    204         this.AddConnection(shapeInfo, pair.Key, pair.Value);
    205     }
    206 
    207     private void Connections_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IShapeInfo>> e) {
    208       IShapeInfo shapeInfo = this.shapeInfoConnectionsMapping.GetBySecond((INotifyObservableDictionaryItemsChanged<string, IShapeInfo>)sender);
     194      foreach (KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo> pair in e.Items)
     195        this.AddConnection(pair.Key.Key, pair.Key.Value, pair.Value);
     196    }
     197
     198    private void Connections_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>> e) {
    209199      IConnection connection;
    210       foreach (KeyValuePair<string, IShapeInfo> pair in e.Items) {
    211         connection = this.GetConnection(shapeInfo, pair.Key);
     200      foreach (KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo> pair in e.Items) {
     201        connection = this.GetConnection(pair.Key.Key, pair.Key.Value);
    212202        this.RemoveConnection(connection);
    213203      }
    214       foreach (KeyValuePair<string, IShapeInfo> pair in e.Items)
    215         this.AddConnection(shapeInfo, pair.Key, pair.Value);
    216     }
    217 
    218     private void Connections_ItemsAdded(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IShapeInfo>> e) {
    219       IShapeInfo shapeInfo = this.shapeInfoConnectionsMapping.GetBySecond((INotifyObservableDictionaryItemsChanged<string, IShapeInfo>)sender);
    220       foreach (KeyValuePair<string, IShapeInfo> pair in e.Items)
    221         this.AddConnection(shapeInfo, pair.Key, pair.Value);
    222     }
    223 
    224     private void Connections_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IShapeInfo>> e) {
    225       IShapeInfo shapeInfo = this.shapeInfoConnectionsMapping.GetBySecond((INotifyObservableDictionaryItemsChanged<string, IShapeInfo>)sender);
     204      foreach (KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo> pair in e.Items)
     205        this.AddConnection(pair.Key.Key, pair.Key.Value, pair.Value);
     206    }
     207
     208    private void Connections_ItemsAdded(object sender, CollectionItemsChangedEventArgs<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>> e) {
     209      foreach (KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo> pair in e.Items)
     210        this.AddConnection(pair.Key.Key, pair.Key.Value, pair.Value);
     211    }
     212
     213    private void Connections_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>> e) {
    226214      IConnection connection;
    227       foreach (KeyValuePair<string, IShapeInfo> pair in e.Items) {
    228         connection = this.GetConnection(shapeInfo, pair.Key);
     215      foreach (KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo> pair in e.Items) {
     216        connection = this.GetConnection(pair.Key.Key, pair.Key.Value);
    229217        this.RemoveConnection(connection);
    230218      }
     
    237225      IConnector connectorFrom = shapeFrom.Connectors.Where(c => c.Name == connectorName).First();
    238226      IConnector connectorTo = shapeTo.Connectors.Where(c => c.Name == "Predecessor").FirstOrDefault();
    239 
    240       IConnection connection = Factory.CreateConnection(connectorFrom, connectorTo);
    241       this.connectionConnectorsMapping.Add(connection, new KeyValuePair<IConnector, IConnector>(connectorFrom, connectorTo));
    242       this.graphVisualization.Controller.Model.AddConnection(connection);
    243       this.graphVisualization.Invalidate();
     227      KeyValuePair<IConnector, IConnector> connectorPair = new KeyValuePair<IConnector, IConnector>(connectorFrom, connectorTo);
     228      if (!this.connectionConnectorsMapping.ContainsSecond(connectorPair)) {
     229        IConnection connection = Factory.CreateConnection(connectorFrom, connectorTo);
     230        this.connectionConnectorsMapping.Add(connection, connectorPair);
     231        this.graphVisualization.Controller.Model.AddConnection(connection);
     232        this.graphVisualization.Invalidate();
     233      }
    244234    }
    245235
     
    258248      IConnection connection = this.GetConnection(shapeInfoFrom, connectorName);
    259249      IShape shapeTo = this.shapeInfoShapeMapping.GetByFirst(shapeInfoFrom);
    260       IConnector connectorTo = shapeTo.Connectors.Where(c => c.Name == "Predecessor").FirstOrDefault();
     250      IConnector connectorTo = shapeTo.Connectors.Where(c => c.Name == "Predecessor").First();
    261251
    262252      connection.To.DetachFromParent();
     
    307297      IConnection connection = e.Entity as IConnection;
    308298      if (connection != null && !this.connectionConnectorsMapping.ContainsFirst(connection)) {
    309         if (connection.From.AttachedTo == null || connection.To.AttachedTo == null)
    310           this.RemoveConnection(connection);
     299        IConnector connectorFrom = connection.From.AttachedTo;
     300        IConnector connectorTo = connection.To.AttachedTo;
     301        this.RemoveConnection(connection); //is added again by the model events
     302
     303        if (connectorFrom != null && connectorTo != null) {
     304          IShape shapeFrom = (IShape)connectorFrom.Parent;
     305          IShape shapeTo = (IShape)connectorTo.Parent;
     306          IShapeInfo shapeInfoFrom = this.shapeInfoShapeMapping.GetBySecond(shapeFrom);
     307          IShapeInfo shapeInfoTo = this.shapeInfoShapeMapping.GetBySecond(shapeTo);
     308          string connectorName = connectorFrom.Name;
     309
     310          this.VisualizationInfo.AddConnection(shapeInfoFrom, connectorName, shapeInfoTo);
     311        }
    311312      }
    312313    }
     
    321322      IConnection connection = e.Entity as IConnection;
    322323      if (connection != null && this.connectionConnectorsMapping.ContainsFirst(connection)) {
    323         IShape parentShape = this.connectorShapeMapping[connection.From.AttachedTo];
     324        IShape parentShape = (IShape)connection.From.AttachedTo.Parent;
    324325        IShapeInfo shapeInfo = this.shapeInfoShapeMapping.GetBySecond(parentShape);
    325         string parameterName = connection.From.AttachedTo.Name;
    326 
    327         shapeInfo.RemoveConnection(parameterName);
     326        string connectorName = connection.From.AttachedTo.Name;
     327
     328        this.VisualizationInfo.RemoveConnection(shapeInfo, connectorName);
    328329      }
    329330    }
Note: See TracChangeset for help on using the changeset viewer.