Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/General/ConnectionInfo.cs @ 4684

Last change on this file since 4684 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 2.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Linq;
24using HeuristicLab.Common;
25using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
26
27namespace HeuristicLab.Operators.Views.GraphVisualization {
28  [StorableClass]
29  public class ConnectionInfo : DeepCloneable, IConnectionInfo {
30    private ConnectionInfo() {
31    }
32    public ConnectionInfo(IShapeInfo from, string connectorFrom, IShapeInfo to, string connectorTo)
33      : this() {
34      if (from == to)
35        throw new ArgumentException("Could not create connections between the same shape info.");
36      if (!from.Connectors.Contains(connectorFrom) || !to.Connectors.Contains(connectorTo))
37        throw new ArgumentException("Could not create connection between not existent connectors.");
38
39      this.from = from;
40      this.connectorFrom = connectorFrom;
41      this.to = to;
42      this.connectorTo = connectorTo;
43    }
44
45    [Storable]
46    private IShapeInfo from;
47    public IShapeInfo From {
48      get { return from; }
49    }
50
51    [Storable]
52    private string connectorFrom;
53    public string ConnectorFrom {
54      get { return this.connectorFrom; }
55    }
56
57    [Storable]
58    private IShapeInfo to;
59    public IShapeInfo To {
60      get { return this.to; }
61    }
62
63    [Storable]
64    private string connectorTo;
65    public string ConnectorTo {
66      get { return this.connectorTo; }
67    }
68
69    public event EventHandler Changed;
70    protected virtual void OnChanged() {
71      EventHandler handler = this.Changed;
72      if (handler != null)
73        this.Changed(this, EventArgs.Empty);
74    }
75
76    public override IDeepCloneable Clone(Cloner cloner) {
77      ConnectionInfo clone = (ConnectionInfo)base.Clone(cloner);
78      clone.from = (IShapeInfo)cloner.Clone(this.from);
79      clone.connectorFrom = this.ConnectorFrom;
80      clone.to = (IShapeInfo)cloner.Clone(this.To);
81      clone.connectorTo = this.ConnectorTo;
82      return clone;
83    }
84  }
85}
Note: See TracBrowser for help on using the repository browser.