Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11423


Ignore:
Timestamp:
10/08/14 03:27:24 (10 years ago)
Author:
swagner
Message:

#2205: Worked on optimization networks

Location:
branches/OptimizationNetworks
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • branches/OptimizationNetworks/HeuristicLab 3.3.sln

    r11069 r11423  
    11
    22Microsoft Visual Studio Solution File, Format Version 12.00
    3 # Visual Studio 2012
     3# Visual Studio 2013
     4VisualStudioVersion = 12.0.21005.1
     5MinimumVisualStudioVersion = 10.0.40219.1
    46Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{96396439-A764-4022-A8D2-BE021449B8D1}"
    57  ProjectSection(SolutionItems) = preProject
     
    19421944    {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
    19431945    {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
    1944     {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Debug|x64.ActiveCfg = Debug|Any CPU
    1945     {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Debug|x86.ActiveCfg = Debug|Any CPU
     1946    {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Debug|x64.ActiveCfg = Debug|x64
     1947    {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Debug|x64.Build.0 = Debug|x64
     1948    {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Debug|x86.ActiveCfg = Debug|x86
     1949    {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Debug|x86.Build.0 = Debug|x86
    19461950    {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
    19471951    {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Release|Any CPU.Build.0 = Release|Any CPU
    1948     {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Release|x64.ActiveCfg = Release|Any CPU
    1949     {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Release|x86.ActiveCfg = Release|Any CPU
     1952    {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Release|x64.ActiveCfg = Release|x64
     1953    {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Release|x64.Build.0 = Release|x64
     1954    {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Release|x86.ActiveCfg = Release|x86
     1955    {37B08E61-93B1-4184-AE21-F2B5DE8A40F8}.Release|x86.Build.0 = Release|x86
    19501956    {7CF51332-0E37-447C-8017-82A258C59EF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
    19511957    {7CF51332-0E37-447C-8017-82A258C59EF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
    1952     {7CF51332-0E37-447C-8017-82A258C59EF2}.Debug|x64.ActiveCfg = Debug|Any CPU
    1953     {7CF51332-0E37-447C-8017-82A258C59EF2}.Debug|x86.ActiveCfg = Debug|Any CPU
     1958    {7CF51332-0E37-447C-8017-82A258C59EF2}.Debug|x64.ActiveCfg = Debug|x64
     1959    {7CF51332-0E37-447C-8017-82A258C59EF2}.Debug|x64.Build.0 = Debug|x64
     1960    {7CF51332-0E37-447C-8017-82A258C59EF2}.Debug|x86.ActiveCfg = Debug|x86
     1961    {7CF51332-0E37-447C-8017-82A258C59EF2}.Debug|x86.Build.0 = Debug|x86
    19541962    {7CF51332-0E37-447C-8017-82A258C59EF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
    19551963    {7CF51332-0E37-447C-8017-82A258C59EF2}.Release|Any CPU.Build.0 = Release|Any CPU
    1956     {7CF51332-0E37-447C-8017-82A258C59EF2}.Release|x64.ActiveCfg = Release|Any CPU
    1957     {7CF51332-0E37-447C-8017-82A258C59EF2}.Release|x86.ActiveCfg = Release|Any CPU
     1964    {7CF51332-0E37-447C-8017-82A258C59EF2}.Release|x64.ActiveCfg = Release|x64
     1965    {7CF51332-0E37-447C-8017-82A258C59EF2}.Release|x64.Build.0 = Release|x64
     1966    {7CF51332-0E37-447C-8017-82A258C59EF2}.Release|x86.ActiveCfg = Release|x86
     1967    {7CF51332-0E37-447C-8017-82A258C59EF2}.Release|x86.Build.0 = Release|x86
    19581968    {792B263D-92BA-453A-BFDF-261511C2F63B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
    19591969    {792B263D-92BA-453A-BFDF-261511C2F63B}.Debug|Any CPU.Build.0 = Debug|Any CPU
    1960     {792B263D-92BA-453A-BFDF-261511C2F63B}.Debug|x64.ActiveCfg = Debug|Any CPU
    1961     {792B263D-92BA-453A-BFDF-261511C2F63B}.Debug|x86.ActiveCfg = Debug|Any CPU
     1970    {792B263D-92BA-453A-BFDF-261511C2F63B}.Debug|x64.ActiveCfg = Debug|x64
     1971    {792B263D-92BA-453A-BFDF-261511C2F63B}.Debug|x64.Build.0 = Debug|x64
     1972    {792B263D-92BA-453A-BFDF-261511C2F63B}.Debug|x86.ActiveCfg = Debug|x86
     1973    {792B263D-92BA-453A-BFDF-261511C2F63B}.Debug|x86.Build.0 = Debug|x86
    19621974    {792B263D-92BA-453A-BFDF-261511C2F63B}.Release|Any CPU.ActiveCfg = Release|Any CPU
    19631975    {792B263D-92BA-453A-BFDF-261511C2F63B}.Release|Any CPU.Build.0 = Release|Any CPU
    1964     {792B263D-92BA-453A-BFDF-261511C2F63B}.Release|x64.ActiveCfg = Release|Any CPU
    1965     {792B263D-92BA-453A-BFDF-261511C2F63B}.Release|x86.ActiveCfg = Release|Any CPU
     1976    {792B263D-92BA-453A-BFDF-261511C2F63B}.Release|x64.ActiveCfg = Release|x64
     1977    {792B263D-92BA-453A-BFDF-261511C2F63B}.Release|x64.Build.0 = Release|x64
     1978    {792B263D-92BA-453A-BFDF-261511C2F63B}.Release|x86.ActiveCfg = Release|x86
     1979    {792B263D-92BA-453A-BFDF-261511C2F63B}.Release|x86.Build.0 = Release|x86
    19661980  EndGlobalSection
    19671981  GlobalSection(SolutionProperties) = preSolution
  • branches/OptimizationNetworks/HeuristicLab.Modeler/3.3/HeuristicLab.Modeler-3.3.csproj

    r11063 r11423  
    3636  <PropertyGroup>
    3737    <AssemblyOriginatorKeyFile>HeuristicLab.snk</AssemblyOriginatorKeyFile>
     38  </PropertyGroup>
     39  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
     40    <DebugSymbols>true</DebugSymbols>
     41    <OutputPath>bin\x64\Debug\</OutputPath>
     42    <DefineConstants>DEBUG;TRACE</DefineConstants>
     43    <DebugType>full</DebugType>
     44    <PlatformTarget>x64</PlatformTarget>
     45    <ErrorReport>prompt</ErrorReport>
     46    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
     47  </PropertyGroup>
     48  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
     49    <OutputPath>bin\x64\Release\</OutputPath>
     50    <DefineConstants>TRACE</DefineConstants>
     51    <Optimize>true</Optimize>
     52    <DebugType>pdbonly</DebugType>
     53    <PlatformTarget>x64</PlatformTarget>
     54    <ErrorReport>prompt</ErrorReport>
     55    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
     56  </PropertyGroup>
     57  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
     58    <DebugSymbols>true</DebugSymbols>
     59    <OutputPath>bin\x86\Debug\</OutputPath>
     60    <DefineConstants>DEBUG;TRACE</DefineConstants>
     61    <DebugType>full</DebugType>
     62    <PlatformTarget>x86</PlatformTarget>
     63    <ErrorReport>prompt</ErrorReport>
     64    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
     65  </PropertyGroup>
     66  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
     67    <OutputPath>bin\x86\Release\</OutputPath>
     68    <DefineConstants>TRACE</DefineConstants>
     69    <Optimize>true</Optimize>
     70    <DebugType>pdbonly</DebugType>
     71    <PlatformTarget>x86</PlatformTarget>
     72    <ErrorReport>prompt</ErrorReport>
     73    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    3874  </PropertyGroup>
    3975  <ItemGroup>
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/HeuristicLab.Optimization.Networks.Views-3.3.csproj

    r11421 r11423  
    3737    <AssemblyOriginatorKeyFile>HeuristicLab.snk</AssemblyOriginatorKeyFile>
    3838  </PropertyGroup>
     39  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
     40    <DebugSymbols>true</DebugSymbols>
     41    <OutputPath>bin\x64\Debug\</OutputPath>
     42    <DefineConstants>DEBUG;TRACE</DefineConstants>
     43    <DebugType>full</DebugType>
     44    <PlatformTarget>x64</PlatformTarget>
     45    <ErrorReport>prompt</ErrorReport>
     46    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
     47  </PropertyGroup>
     48  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
     49    <OutputPath>bin\x64\Release\</OutputPath>
     50    <DefineConstants>TRACE</DefineConstants>
     51    <Optimize>true</Optimize>
     52    <DebugType>pdbonly</DebugType>
     53    <PlatformTarget>x64</PlatformTarget>
     54    <ErrorReport>prompt</ErrorReport>
     55    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
     56  </PropertyGroup>
     57  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
     58    <DebugSymbols>true</DebugSymbols>
     59    <OutputPath>bin\x86\Debug\</OutputPath>
     60    <DefineConstants>DEBUG;TRACE</DefineConstants>
     61    <DebugType>full</DebugType>
     62    <PlatformTarget>x86</PlatformTarget>
     63    <ErrorReport>prompt</ErrorReport>
     64    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
     65  </PropertyGroup>
     66  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
     67    <OutputPath>bin\x86\Release\</OutputPath>
     68    <DefineConstants>TRACE</DefineConstants>
     69    <Optimize>true</Optimize>
     70    <DebugType>pdbonly</DebugType>
     71    <PlatformTarget>x86</PlatformTarget>
     72    <ErrorReport>prompt</ErrorReport>
     73    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
     74  </PropertyGroup>
    3975  <ItemGroup>
    4076    <Reference Include="System" />
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/InputPortView.cs

    r11421 r11423  
    5151    protected override void OnContentChanged() {
    5252      base.OnContentChanged();
    53       outputPortTextBox.Text = ((Content == null) || (Content.OutputPort == null)) ? string.Empty : Content.OutputPort.Name;
     53      outputPortTextBox.Text = ((Content == null) || (Content.OutputPort == null)) ? string.Empty : Content.OutputPort.ToString();
    5454    }
    5555
     
    6262        Invoke(new EventHandler(Content_OutputPortChanged), sender, e);
    6363      else {
    64         outputPortTextBox.Text = Content.OutputPort == null ? string.Empty : Content.OutputPort.Name;
     64        outputPortTextBox.Text = Content.OutputPort == null ? string.Empty : Content.OutputPort.ToString();
    6565      }
    6666    }
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/AlgorithmNode.cs

    r11412 r11423  
    116116
    117117    #region Ports Events
    118     private void RegisterPortsEvents() {
    119       Ports.ItemsAdded += Ports_ItemsAdded;
    120       Ports.ItemsRemoved += Ports_ItemsRemoved;
    121       Ports.ItemsReplaced += Ports_ItemsReplaced;
    122       Ports.CollectionReset += Ports_CollectionReset;
     118    protected override void RegisterPortsEvents() {
     119      base.RegisterPortsEvents();
    123120      foreach (var p in Ports)
    124121        RegisterPortEvents(p);
    125122    }
    126     void Ports_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
    127       foreach (var p in e.Items)
    128         RegisterPortEvents(p);
    129     }
    130     void Ports_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     123    protected override void Ports_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     124      base.Ports_ItemsAdded(sender, e);
     125      foreach (var p in e.Items)
     126        RegisterPortEvents(p);
     127    }
     128    protected override void Ports_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     129      base.Ports_ItemsRemoved(sender, e);
    131130      foreach (var p in e.Items)
    132131        DeregisterPortEvents(p);
    133132    }
    134     void Ports_ItemsReplaced(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     133    protected override void Ports_ItemsReplaced(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     134      base.Ports_ItemsReplaced(sender, e);
    135135      foreach (var p in e.OldItems)
    136136        DeregisterPortEvents(p);
     
    138138        RegisterPortEvents(p);
    139139    }
    140     void Ports_CollectionReset(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     140    protected override void Ports_CollectionReset(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     141      base.Ports_CollectionReset(sender, e);
    141142      foreach (var p in e.OldItems)
    142143        DeregisterPortEvents(p);
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/HeuristicLab.Optimization.Networks-3.3.csproj

    r11421 r11423  
    3636  <PropertyGroup>
    3737    <AssemblyOriginatorKeyFile>HeuristicLab.snk</AssemblyOriginatorKeyFile>
     38  </PropertyGroup>
     39  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
     40    <DebugSymbols>true</DebugSymbols>
     41    <OutputPath>bin\x64\Debug\</OutputPath>
     42    <DefineConstants>DEBUG;TRACE</DefineConstants>
     43    <DebugType>full</DebugType>
     44    <PlatformTarget>x64</PlatformTarget>
     45    <ErrorReport>prompt</ErrorReport>
     46    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
     47  </PropertyGroup>
     48  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
     49    <OutputPath>bin\x64\Release\</OutputPath>
     50    <DefineConstants>TRACE</DefineConstants>
     51    <Optimize>true</Optimize>
     52    <DebugType>pdbonly</DebugType>
     53    <PlatformTarget>x64</PlatformTarget>
     54    <ErrorReport>prompt</ErrorReport>
     55    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
     56  </PropertyGroup>
     57  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
     58    <DebugSymbols>true</DebugSymbols>
     59    <OutputPath>bin\x86\Debug\</OutputPath>
     60    <DefineConstants>DEBUG;TRACE</DefineConstants>
     61    <DebugType>full</DebugType>
     62    <PlatformTarget>x86</PlatformTarget>
     63    <ErrorReport>prompt</ErrorReport>
     64    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
     65  </PropertyGroup>
     66  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
     67    <OutputPath>bin\x86\Release\</OutputPath>
     68    <DefineConstants>TRACE</DefineConstants>
     69    <Optimize>true</Optimize>
     70    <DebugType>pdbonly</DebugType>
     71    <PlatformTarget>x86</PlatformTarget>
     72    <ErrorReport>prompt</ErrorReport>
     73    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
    3874  </PropertyGroup>
    3975  <ItemGroup>
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IPort.cs

    r11421 r11423  
    2424namespace HeuristicLab.Optimization.Networks {
    2525  public interface IPort : INamedItem {
    26     INode Node { get; set; }
     26    INode Parent { get; set; }
    2727  }
    2828}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputPort.cs

    r11421 r11423  
    8888      if (outputPort != null) {
    8989        outputPort.ValueChanged += OutputPort_ValueChanged;
     90        outputPort.ToStringChanged += OutputPort_ToStringChanged;
    9091      }
    9192    }
     
    9394      if (outputPort != null) {
    9495        outputPort.ValueChanged -= OutputPort_ValueChanged;
     96        outputPort.ToStringChanged -= OutputPort_ToStringChanged;
    9597      }
    9698    }
     
    100102      //DISCUSS: switch threads to decouple value propagation and to make communication asynchronous -> should be done in Node?
    101103    }
     104    protected void OutputPort_ToStringChanged(object sender, EventArgs e) {
     105      OnOutputPortChanged();
     106    }
    102107  }
    103108}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Node.cs

    r11421 r11423  
    5252      : base(original, cloner) {
    5353      ports = cloner.Clone(original.ports);
     54      foreach (var p in Ports)
     55        p.Parent = this;
    5456      readOnlyPorts = null;
     57      RegisterPortsEvents();
    5558    }
    5659    public Node()
    5760      : base("Node") {
    58       ports = new PortCollection(this);
     61      ports = new PortCollection();
    5962      readOnlyPorts = null;
     63      RegisterPortsEvents();
    6064    }
    6165    public Node(string name)
    6266      : base(name) {
    63       ports = new PortCollection(this);
     67      ports = new PortCollection();
    6468      readOnlyPorts = null;
     69      RegisterPortsEvents();
    6570    }
    6671    public Node(string name, string description)
    6772      : base(name, description) {
    68       ports = new PortCollection(this);
     73      ports = new PortCollection();
    6974      readOnlyPorts = null;
     75      RegisterPortsEvents();
     76    }
     77
     78    [StorableHook(HookType.AfterDeserialization)]
     79    private void AfterDeserialization() {
     80      foreach (var p in Ports)
     81        p.Parent = this;
     82      RegisterPortsEvents();
    7083    }
    7184
     
    7386      return new Node(this, cloner);
    7487    }
     88
     89    #region Ports Events
     90    protected virtual void RegisterPortsEvents() {
     91      ports.ItemsAdded += Ports_ItemsAdded;
     92      ports.ItemsRemoved += Ports_ItemsRemoved;
     93      ports.ItemsReplaced += Ports_ItemsReplaced;
     94      ports.CollectionReset += Ports_CollectionReset;
     95    }
     96    protected virtual void Ports_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     97      foreach (var p in e.Items)
     98        p.Parent = this;
     99    }
     100    protected virtual void Ports_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     101      foreach (var p in e.Items)
     102        p.Parent = null;
     103    }
     104    protected virtual void Ports_ItemsReplaced(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     105      foreach (var p in e.OldItems)
     106        p.Parent = null;
     107      foreach (var p in e.Items)
     108        p.Parent = this;
     109    }
     110    protected virtual void Ports_CollectionReset(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     111      foreach (var p in e.OldItems)
     112        p.Parent = null;
     113      foreach (var p in e.Items)
     114        p.Parent = this;
     115    }
     116    #endregion
    75117  }
    76118}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Port.cs

    r11421 r11423  
    3434    }
    3535
    36     [Storable]
    37     private INode node;
    38     public INode Node {
    39       get { return node; }
     36    private INode parent;
     37    public INode Parent {
     38      get { return parent; }
    4039      set {
    41         if ((value != null) && !value.Ports.Contains(this))
    42           throw new InvalidOperationException("Port is not contained in port collection of node.");
    43         if ((value == null) && node.Ports.Contains(this))
    44           throw new InvalidOperationException("Port is still contained in port collection of node.");
    45         node = value;
     40        if (value != parent) {
     41          // NOTE: never call setter directly as the Parent property is set by the node which contains the port
     42          if ((value != null) && !value.Ports.Contains(this))
     43            throw new InvalidOperationException("Port is not contained in port collection of node.");
     44          if ((value == null) && parent.Ports.Contains(this))
     45            throw new InvalidOperationException("Port is still contained in port collection of node.");
     46          DeregisterParentEvents();
     47          parent = value;
     48          RegisterParentEvents();
     49          OnToStringChanged();
     50        }
    4651      }
    4752    }
     
    4954    [StorableConstructor]
    5055    protected Port(bool deserializing) : base(deserializing) { }
    51     protected Port(Port original, Cloner cloner)
    52       : base(original, cloner) {
    53       node = (INode)cloner.GetClone(original.node);  // NOTE: original node is NOT automatically cloned
    54     }
     56    protected Port(Port original, Cloner cloner) : base(original, cloner) { }
    5557    protected Port() : base("Port") { }
    5658    protected Port(string name) : base(name) { }
    5759    protected Port(string name, string description) : base(name, description) { }
     60
     61    public override string ToString() {
     62      if (parent != null) {
     63        return string.Concat(parent.ToString(), " -> ", base.ToString());
     64      }
     65      return base.ToString();
     66    }
     67
     68    #region Parent Events
     69    protected virtual void RegisterParentEvents() {
     70      if (parent != null) {
     71        parent.ToStringChanged += Parent_ToStringChanged;
     72      }
     73    }
     74    protected virtual void DeregisterParentEvents() {
     75      if (parent != null) {
     76        parent.ToStringChanged -= Parent_ToStringChanged;
     77      }
     78    }
     79    void Parent_ToStringChanged(object sender, EventArgs e) {
     80      OnToStringChanged();
     81    }
     82    #endregion
    5883  }
    5984}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/PortCollection.cs

    r11421 r11423  
    3030  [Item("PortCollection", "Represents a collection of ports in an optimization network node.")]
    3131  public class PortCollection : NamedItemCollection<IPort> {
    32     [Storable]
    33     private INode node;
    34     public INode Node {
    35       get { return node; }
    36     }
    37 
    3832    [StorableConstructor]
    3933    protected PortCollection(bool deserializing) : base(deserializing) { }
    40     protected PortCollection(PortCollection original, Cloner cloner)
    41       : base(original, cloner) {
    42       if (!cloner.ClonedObjectRegistered(original.node))
    43         // NOTE: cannot clone port collection alone if referenced node is not cloned
    44         throw new InvalidOperationException("Node of port collection is not cloned.");
    45       node = cloner.Clone(original.node);
    46     }
    47     public PortCollection(INode node)
    48       : base() {
    49       this.node = node;
    50     }
    51     public PortCollection(INode node, int capacity)
    52       : base(capacity) {
    53       this.node = node;
    54     }
    55     public PortCollection(INode node, IEnumerable<IPort> collection)
    56       : base(collection) {
    57       this.node = node;
    58     }
     34    protected PortCollection(PortCollection original, Cloner cloner) : base(original, cloner) { }
     35    public PortCollection() : base() { }
     36    public PortCollection(INode node, int capacity) : base(capacity) { }
     37    public PortCollection(INode node, IEnumerable<IPort> collection) : base(collection) { }
    5938
    6039    public override IDeepCloneable Clone(Cloner cloner) { return new PortCollection(this, cloner); }
    61 
    62     protected override void OnItemsAdded(IEnumerable<IPort> items) {
    63       foreach (var p in items)
    64         p.Node = node;
    65       base.OnItemsAdded(items);
    66     }
    67     protected override void OnItemsRemoved(IEnumerable<IPort> items) {
    68       foreach (var p in items)
    69         p.Node = null;
    70       base.OnItemsRemoved(items);
    71     }
    72     protected override void OnItemsReplaced(IEnumerable<IPort> items, IEnumerable<IPort> oldItems) {
    73       foreach (var p in oldItems)
    74         p.Node = null;
    75       foreach (var p in items)
    76         p.Node = node;
    77       base.OnItemsReplaced(items, oldItems);
    78     }
    79     protected override void OnCollectionReset(IEnumerable<IPort> items, IEnumerable<IPort> oldItems) {
    80       foreach (var p in oldItems)
    81         p.Node = null;
    82       foreach (var p in items)
    83         p.Node = node;
    84       base.OnCollectionReset(items, oldItems);
    85     }
    8640  }
    8741}
  • branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/VariablesNode.cs

    r11412 r11423  
    101101
    102102    #region Ports Events
    103     private void RegisterPortsEvents() {
    104       Ports.ItemsAdded += Ports_ItemsAdded;
    105       Ports.ItemsRemoved += Ports_ItemsRemoved;
    106       Ports.ItemsReplaced += Ports_ItemsReplaced;
    107       Ports.CollectionReset += Ports_CollectionReset;
     103    protected override void RegisterPortsEvents() {
     104      base.RegisterPortsEvents();
    108105      foreach (var p in Ports)
    109106        RegisterPortEvents(p);
    110107    }
    111     void Ports_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
    112       foreach (var p in e.Items)
    113         RegisterPortEvents(p);
    114     }
    115     void Ports_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     108    protected override void Ports_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     109      base.Ports_ItemsAdded(sender, e);
     110      foreach (var p in e.Items)
     111        RegisterPortEvents(p);
     112    }
     113    protected override void Ports_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     114      base.Ports_ItemsRemoved(sender, e);
    116115      foreach (var p in e.Items)
    117116        DeregisterPortEvents(p);
    118117    }
    119     void Ports_ItemsReplaced(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     118    protected override void Ports_ItemsReplaced(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     119      base.Ports_ItemsReplaced(sender, e);
    120120      foreach (var p in e.OldItems)
    121121        DeregisterPortEvents(p);
     
    123123        RegisterPortEvents(p);
    124124    }
    125     void Ports_CollectionReset(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     125    protected override void Ports_CollectionReset(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) {
     126      base.Ports_CollectionReset(sender, e);
    126127      foreach (var p in e.OldItems)
    127128        DeregisterPortEvents(p);
Note: See TracChangeset for help on using the changeset viewer.