Changeset 3422
- Timestamp:
- 04/19/10 22:07:24 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorGraphVisualizationInfo.cs
r3393 r3422 81 81 foreach (IOperator oper in this.operatorShapeInfoMapping.FirstValues) { 82 82 foreach (IParameter param in oper.Parameters) { 83 IValueParameter opParam = param as IValueParameter; 83 84 this.parameterOperatorMapping.Add(param, oper); 84 IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>; 85 if (opParam != null) 85 if (opParam != null && typeof(IOperator).IsAssignableFrom(param.DataType)) 86 86 this.RegisterOperatorParameterEvents(opParam); 87 87 else … … 125 125 foreach (IParameter param in oper.Parameters) { 126 126 clone.parameterOperatorMapping.Add(param, oper); 127 IValueParameter <IOperator> opParam = param as IValueParameter<IOperator>;128 if (opParam != null )127 IValueParameter opParam = param as IValueParameter; 128 if (opParam != null && typeof(IOperator).IsAssignableFrom(param.DataType)) 129 129 clone.RegisterOperatorParameterEvents(opParam); 130 130 else … … 230 230 IOperatorShapeInfo shapeInfo = (IOperatorShapeInfo)connectionInfo.From; 231 231 IOperator op = this.operatorShapeInfoMapping.GetBySecond(shapeInfo); 232 IValueParameter <IOperator> param = (IValueParameter<IOperator>)op.Parameters[connectionInfo.ConnectorFrom];232 IValueParameter param = (IValueParameter)op.Parameters[connectionInfo.ConnectorFrom]; 233 233 param.Value = null; 234 } 235 236 public override void AddConnectionInfo(IConnectionInfo connectionInfo) { 237 IOperatorShapeInfo shapeInfo = (IOperatorShapeInfo)connectionInfo.From; 238 IOperator op = this.operatorShapeInfoMapping.GetBySecond(shapeInfo); 239 IValueParameter param = (IValueParameter)op.Parameters.Where(p => p.Name == connectionInfo.ConnectorFrom).Single(); 240 IOperatorShapeInfo shapeInfoTo = (IOperatorShapeInfo)connectionInfo.To; 241 IOperator opTo = this.operatorShapeInfoMapping.GetBySecond(shapeInfoTo); 242 param.Value = opTo; 234 243 } 235 244 #endregion … … 321 330 private void AddParameter(IOperator op, IParameter param) { 322 331 this.parameterOperatorMapping.Add(param, op); 323 IValueParameter <IOperator> opParam = param as IValueParameter<IOperator>;324 if (opParam != null ) {332 IValueParameter opParam = param as IValueParameter; 333 if (opParam != null && typeof(IOperator).IsAssignableFrom(param.DataType)) { 325 334 this.RegisterOperatorParameterEvents(opParam); 326 335 IOperatorShapeInfo shapeInfoFrom = this.operatorShapeInfoMapping.GetByFirst(op); … … 328 337 329 338 if (opParam.Value != null) { 330 if (!this.operatorShapeInfoMapping.ContainsFirst( opParam.Value))331 this.AddOperator( opParam.Value);332 IOperatorShapeInfo shapeInfoTo = this.operatorShapeInfoMapping.GetByFirst( opParam.Value);339 if (!this.operatorShapeInfoMapping.ContainsFirst((IOperator)opParam.Value)) 340 this.AddOperator((IOperator)opParam.Value); 341 IOperatorShapeInfo shapeInfoTo = this.operatorShapeInfoMapping.GetByFirst((IOperator)opParam.Value); 333 342 this.connectionInfos.Add(new ConnectionInfo(shapeInfoFrom, param.Name, shapeInfoTo, OperatorShapeInfoFactory.PredecessorConnector)); 334 343 } … … 338 347 339 348 private void RemoveParameter(IOperator op, IParameter param) { 340 IValueParameter <IOperator> opParam = param as IValueParameter<IOperator>;341 if (opParam != null ) {349 IValueParameter opParam = param as IValueParameter; 350 if (opParam != null && typeof(IOperator).IsAssignableFrom(param.DataType)) { 342 351 this.DeregisterOperatorParameterEvents(opParam); 343 352 IOperatorShapeInfo shapeInfo = this.operatorShapeInfoMapping.GetByFirst(op); … … 352 361 353 362 private void opParam_ValueChanged(object sender, EventArgs e) { 354 IValueParameter <IOperator> opParam = (IValueParameter<IOperator>)sender;363 IValueParameter opParam = (IValueParameter)sender; 355 364 IOperator op = this.parameterOperatorMapping[opParam]; 356 365 IOperatorShapeInfo shapeInfoFrom = this.operatorShapeInfoMapping.GetByFirst(op); … … 359 368 this.connectionInfos.RemoveWhere(c => c.From == shapeInfoFrom && c.ConnectorFrom == opParam.Name); 360 369 if (opParam.Value != null) { 361 if (!this.operatorShapeInfoMapping.ContainsFirst( opParam.Value))362 this.AddOperator( opParam.Value);363 I ShapeInfo shapeInfoTo = this.operatorShapeInfoMapping.GetByFirst(opParam.Value);364 this.AddConnectionInfo(new ConnectionInfo(shapeInfoFrom, opParam.Name, shapeInfoTo, OperatorShapeInfoFactory.PredecessorConnector));370 if (!this.operatorShapeInfoMapping.ContainsFirst((IOperator)opParam.Value)) 371 this.AddOperator((IOperator)opParam.Value); 372 IOperatorShapeInfo shapeInfoTo = this.operatorShapeInfoMapping.GetByFirst((IOperator)opParam.Value); 373 base.AddConnectionInfo(new ConnectionInfo(shapeInfoFrom, opParam.Name, shapeInfoTo, OperatorShapeInfoFactory.PredecessorConnector)); 365 374 } 366 375 } … … 399 408 } 400 409 401 private void RegisterOperatorParameterEvents(IValueParameter <IOperator>opParam) {410 private void RegisterOperatorParameterEvents(IValueParameter opParam) { 402 411 opParam.ValueChanged += new EventHandler(opParam_ValueChanged); 403 412 } 404 private void DeregisterOperatorParameterEvents(IValueParameter <IOperator>opParam) {413 private void DeregisterOperatorParameterEvents(IValueParameter opParam) { 405 414 opParam.ValueChanged -= new EventHandler(opParam_ValueChanged); 406 415 } … … 426 435 427 436 private void UpdateParameterLabels(IOperator op) { 428 IEnumerable<IParameter> parameters = op.Parameters.Where(p => !(p is IValueParameter <IOperator>));437 IEnumerable<IParameter> parameters = op.Parameters.Where(p => !(p is IValueParameter && typeof(IOperator).IsAssignableFrom(p.DataType))); 429 438 IOperatorShapeInfo operatorShapeInfo = this.operatorShapeInfoMapping.GetByFirst(op); 430 439 if (parameters.Count() > 0) -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShape.cs
r3386 r3422 206 206 this.Children.Add(expandIconMaterial); 207 207 208 this.predecessor = this.CreateConnector( "Predecessor", new Point(Rectangle.Left, Center.Y));208 this.predecessor = this.CreateConnector(OperatorShapeInfoFactory.PredecessorConnector, new Point(Rectangle.Left, Center.Y)); 209 209 this.Connectors.Add(predecessor); 210 210 211 this.successor = this.CreateConnector( "Successor", (new Point(Rectangle.Right, Center.Y)));211 this.successor = this.CreateConnector(OperatorShapeInfoFactory.SuccessorConnector, (new Point(Rectangle.Right, Center.Y))); 212 212 this.Connectors.Add(successor); 213 213 } -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfo.cs
r3386 r3422 160 160 shape.Collapsed = this.Collapsed; 161 161 foreach (string connectorName in this.connectorNames) 162 shape.AddConnector(connectorName); 162 if (connectorName != OperatorShapeInfoFactory.SuccessorConnector && connectorName != OperatorShapeInfoFactory.PredecessorConnector) 163 shape.AddConnector(connectorName); 163 164 164 165 shape.UpdateLabels(this.labels); … … 191 192 operatorShape.RemoveConnector(oldConnectorNames[j]); 192 193 193 //add new connectors 194 //add new connectors except successor and connector 194 195 for (; i < this.connectorNames.Count; i++) 196 if (this.connectorNames[i] != OperatorShapeInfoFactory.SuccessorConnector && this.connectorNames[i] != OperatorShapeInfoFactory.PredecessorConnector) 195 197 operatorShape.AddConnector(this.connectorNames[i]); 196 198 -
trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphVisualization/OperatorShapeInfoFactory.cs
r3386 r3422 32 32 internal static class OperatorShapeInfoFactory { 33 33 public const string PredecessorConnector = "Predecessor"; 34 public const string SuccessorConnector = "Successor"; 34 35 public static IOperatorShapeInfo CreateOperatorShapeInfo(IOperator op) { 35 IEnumerable<string> operatorParameterNames = op.Parameters.Where(p => p is IValueParameter <IOperator>).Select(p => p.Name);36 IEnumerable<string> paramaterNameValues = op.Parameters.Where(p => !(p is IValueParameter <IOperator>)).Select(p => p.ToString());36 IEnumerable<string> operatorParameterNames = op.Parameters.Where(p => p is IValueParameter && typeof(IOperator).IsAssignableFrom(p.DataType)).Select(p => p.Name); 37 IEnumerable<string> paramaterNameValues = op.Parameters.Where(p => !(p is IValueParameter && typeof(IOperator).IsAssignableFrom(p.DataType))).Select(p => p.ToString()); 37 38 38 39 OperatorShapeInfo operatorShapeInfo = new OperatorShapeInfo(operatorParameterNames, paramaterNameValues);
Note: See TracChangeset
for help on using the changeset viewer.