Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2942


Ignore:
Timestamp:
03/05/10 16:37:53 (15 years ago)
Author:
mkommend
Message:

saving and loading of GraphVisualizationInfo (ticket #867)

File:
1 edited

Legend:

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

    r2935 r2942  
    3737      get { return this.operatorShapeInfoMapping; }
    3838      set {
    39         foreach (KeyValuePair<IOperator, IOperatorShapeInfo> pair in value.FirstEnumerable)
    40           this.AddShapeInfo(pair.Key, pair.Value);
     39        IOperator op;
     40        IOperatorShapeInfo shapeInfo;
     41        foreach (KeyValuePair<IOperator, IOperatorShapeInfo> pair in value.FirstEnumerable) {
     42          op = pair.Key;
     43          shapeInfo = pair.Value;
     44          this.RegisterOperatorEvents(op);
     45          this.operatorParameterCollectionMapping.Add(op, pair.Key.Parameters);
     46          this.operatorShapeInfoMapping.Add(op, shapeInfo);
     47          this.shapeInfos.Add(shapeInfo);
     48        }
     49
     50        foreach(IOperator oper in value.FirstValues) {
     51          foreach (IParameter param in oper.Parameters) {
     52            this.parameterOperatorMapping.Add(param, oper);
     53            IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>;
     54            if (opParam != null) {
     55              this.RegisterOperatorParameterEvents(opParam);
     56              shapeInfo = this.operatorShapeInfoMapping.GetByFirst(oper);
     57              if (opParam.Value != null) {
     58                this.connections.Add(new KeyValuePair<IOperatorShapeInfo, string>(shapeInfo, param.Name), this.operatorShapeInfoMapping.GetByFirst(opParam.Value));
     59              }
     60            } else
     61              this.RegisterParameterEvents(param);
     62          }
     63        }
    4164      }
    4265    }
     
    5679    public GraphVisualizationInfo(OperatorGraph operatorGraph)
    5780      : this() {
    58       this.operatorGraph = operatorGraph;
    59       this.operatorGraph.InitialOperatorChanged += new EventHandler(operatorGraph_InitialOperatorChanged);
    60       operatorGraph.Operators.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsAdded);
    61       operatorGraph.Operators.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsRemoved);
    62       operatorGraph.Operators.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperator>(Operators_CollectionReset);
     81      this.OperatorGraph = operatorGraph;
    6382
    6483      foreach (IOperator op in operatorGraph.Operators)
     
    109128    }
    110129
     130   
     131    private OperatorGraph operatorGraph;
    111132    [Storable]
    112     private OperatorGraph operatorGraph;
    113133    public OperatorGraph OperatorGraph {
    114134      get { return this.operatorGraph; }
     135      private set {
     136        if (this.operatorGraph != null || value == null)
     137          throw new InvalidOperationException("Could not set OperatorGraph");
     138
     139        this.operatorGraph = value;
     140        this.operatorGraph.InitialOperatorChanged += new EventHandler(operatorGraph_InitialOperatorChanged);
     141        this.operatorGraph.Operators.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsAdded);
     142        this.operatorGraph.Operators.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsRemoved);
     143        this.operatorGraph.Operators.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperator>(Operators_CollectionReset);
     144      }
    115145    }
    116146
     
    126156    }
    127157
    128     [Storable]
    129158    private ObservableDictionary<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> connections;
    130159    public INotifyObservableDictionaryItemsChanged<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> ObservableConnections {
     
    145174        this.AddParameter(op, param);
    146175
    147       if (!this.operatorGraph.Operators.Contains(op))
    148         this.operatorGraph.Operators.Add(op);
     176      this.operatorGraph.Operators.Add(op);
    149177    }
    150178
     
    184212        this.operatorParameterCollectionMapping.Add(op, op.Parameters);
    185213        this.operatorShapeInfoMapping.Add(op, shapeInfo);
     214        this.shapeInfos.Add(shapeInfo);
    186215        foreach (IParameter param in op.Parameters)
    187216          this.AddParameter(op, param);
    188 
    189         this.shapeInfos.Add(shapeInfo);
    190217      }
    191218    }
Note: See TracChangeset for help on using the changeset viewer.