Changeset 11409
- Timestamp:
- 10/02/14 03:30:30 (10 years ago)
- Location:
- branches/OptimizationNetworks
- Files:
-
- 12 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/HeuristicLab.Optimization.Networks.Views-3.3.csproj
r11069 r11409 40 40 <Reference Include="System" /> 41 41 <Reference Include="System.Core" /> 42 <Reference Include="System.Drawing" /> 43 <Reference Include="System.Windows.Forms" /> 42 44 <Reference Include="System.Xml.Linq" /> 43 45 <Reference Include="System.Data.DataSetExtensions" /> … … 47 49 </ItemGroup> 48 50 <ItemGroup> 51 <Compile Include="AlgorithmNodeView.cs"> 52 <SubType>UserControl</SubType> 53 </Compile> 54 <Compile Include="AlgorithmNodeView.Designer.cs"> 55 <DependentUpon>AlgorithmNodeView.cs</DependentUpon> 56 </Compile> 57 <Compile Include="PortView.cs"> 58 <SubType>UserControl</SubType> 59 </Compile> 60 <Compile Include="PortView.Designer.cs"> 61 <DependentUpon>PortView.cs</DependentUpon> 62 </Compile> 63 <Compile Include="NodeView.cs"> 64 <SubType>UserControl</SubType> 65 </Compile> 66 <Compile Include="NodeView.Designer.cs"> 67 <DependentUpon>NodeView.cs</DependentUpon> 68 </Compile> 69 <Compile Include="PortCollectionView.cs"> 70 <SubType>UserControl</SubType> 71 </Compile> 72 <Compile Include="PortCollectionView.Designer.cs"> 73 <DependentUpon>PortCollectionView.cs</DependentUpon> 74 </Compile> 49 75 <Compile Include="Plugin.cs" /> 50 76 <Compile Include="Properties\AssemblyInfo.cs" /> 77 <Compile Include="NetworkView.cs"> 78 <SubType>UserControl</SubType> 79 </Compile> 80 <Compile Include="NetworkView.Designer.cs"> 81 <DependentUpon>NetworkView.cs</DependentUpon> 82 </Compile> 83 <Compile Include="NodeCollectionView.cs"> 84 <SubType>UserControl</SubType> 85 </Compile> 86 <Compile Include="NodeCollectionView.Designer.cs"> 87 <DependentUpon>NodeCollectionView.cs</DependentUpon> 88 </Compile> 51 89 </ItemGroup> 52 90 <ItemGroup> … … 56 94 </ItemGroup> 57 95 <ItemGroup> 96 <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj"> 97 <Project>{958b43bc-cc5c-4fa2-8628-2b3b01d890b6}</Project> 98 <Name>HeuristicLab.Collections-3.3</Name> 99 </ProjectReference> 100 <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj"> 101 <Project>{0e27a536-1c4a-4624-a65e-dc4f4f23e3e1}</Project> 102 <Name>HeuristicLab.Common.Resources-3.3</Name> 103 </ProjectReference> 104 <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj"> 105 <Project>{a9ad58b9-3ef9-4cc1-97e5-8d909039ff5c}</Project> 106 <Name>HeuristicLab.Common-3.3</Name> 107 </ProjectReference> 108 <ProjectReference Include="..\..\HeuristicLab.Core.Views\3.3\HeuristicLab.Core.Views-3.3.csproj"> 109 <Project>{e226881d-315f-423d-b419-a766fe0d8685}</Project> 110 <Name>HeuristicLab.Core.Views-3.3</Name> 111 </ProjectReference> 112 <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj"> 113 <Project>{c36bd924-a541-4a00-afa8-41701378ddc5}</Project> 114 <Name>HeuristicLab.Core-3.3</Name> 115 </ProjectReference> 116 <ProjectReference Include="..\..\HeuristicLab.MainForm.WindowsForms\3.3\HeuristicLab.MainForm.WindowsForms-3.3.csproj"> 117 <Project>{ab687bbe-1bfe-476b-906d-44237135431d}</Project> 118 <Name>HeuristicLab.MainForm.WindowsForms-3.3</Name> 119 </ProjectReference> 120 <ProjectReference Include="..\..\HeuristicLab.MainForm\3.3\HeuristicLab.MainForm-3.3.csproj"> 121 <Project>{3bd61258-31da-4b09-89c0-4f71fef5f05a}</Project> 122 <Name>HeuristicLab.MainForm-3.3</Name> 123 </ProjectReference> 124 <ProjectReference Include="..\..\HeuristicLab.Optimization.Networks\3.3\HeuristicLab.Optimization.Networks-3.3.csproj"> 125 <Project>{7cf51332-0e37-447c-8017-82a258c59ef2}</Project> 126 <Name>HeuristicLab.Optimization.Networks-3.3</Name> 127 </ProjectReference> 128 <ProjectReference Include="..\..\HeuristicLab.Optimization\3.3\HeuristicLab.Optimization-3.3.csproj"> 129 <Project>{14ab8d24-25bc-400c-a846-4627aa945192}</Project> 130 <Name>HeuristicLab.Optimization-3.3</Name> 131 </ProjectReference> 58 132 <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj"> 59 133 <Project>{94186a6a-5176-4402-ae83-886557b53cca}</Project> -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/Plugin.cs.frame
r11401 r11409 28 28 [Plugin("HeuristicLab.Optimization.Networks.Views", "3.3.11.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Optimization.Networks.Views-3.3.dll", PluginFileType.Assembly)] 30 // [PluginDependency("HeuristicLab.Collections", "3.3")] 31 // [PluginDependency("HeuristicLab.Common", "3.3")] 32 // [PluginDependency("HeuristicLab.Common.Resources", "3.3")] 33 // [PluginDependency("HeuristicLab.Core", "3.3")] 34 // [PluginDependency("HeuristicLab.Data", "3.3")] 35 // [PluginDependency("HeuristicLab.Parameters", "3.3")] 36 // [PluginDependency("HeuristicLab.Persistence", "3.3")] 30 [PluginDependency("HeuristicLab.Collections", "3.3")] 31 [PluginDependency("HeuristicLab.Common", "3.3")] 32 [PluginDependency("HeuristicLab.Common.Resources", "3.3")] 33 [PluginDependency("HeuristicLab.Core", "3.3")] 34 [PluginDependency("HeuristicLab.Core.Views", "3.3")] 35 [PluginDependency("HeuristicLab.MainForm", "3.3")] 36 [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")] 37 [PluginDependency("HeuristicLab.Optimization", "3.3")] 38 [PluginDependency("HeuristicLab.Optimization.Networks", "3.3")] 37 39 public class HeuristicLabOptimizationNetworksViewsPlugin : PluginBase { 38 40 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/AlgorithmNode.cs
r11406 r11409 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Drawing;25 22 using HeuristicLab.Common; 26 23 using HeuristicLab.Core; 27 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 using System; 28 26 29 27 namespace HeuristicLab.Optimization.Networks { 30 28 [Item("AlgorithmNode", "A node of an optimization network which contains a HeuristicLab algorithm.")] 31 29 [StorableClass] 32 public class AlgorithmNode : Node { 30 public class AlgorithmNode : Node, IAlgorithmNode { 31 new public PortCollection Ports { 32 get { return base.Ports; } 33 } 34 33 35 [Storable] 34 36 private IAlgorithm algorithm; … … 54 56 } 55 57 public AlgorithmNode() 56 : base(" Node") {58 : base("AlgorithmNode") { 57 59 RegisterPortsEvents(); 58 60 } … … 69 71 private void AfterDeserialization() { 70 72 RegisterPortsEvents(); 73 RegisterAlgorithmEvents(); 71 74 } 72 75 … … 77 80 private void UpdateParameter(IInputPort port) { 78 81 if (algorithm != null) { 79 foreach (var param in algorithm.Parameters) { 82 IParameter param = null; 83 if (algorithm.Parameters.TryGetValue(port.Name, out param)) { 80 84 IValueParameter p = param as IValueParameter; 81 if ( (p != null) && (p.Name == port.Name)) {85 if (p != null) { 82 86 p.Value = (IItem)port.Value; 83 87 } … … 86 90 } 87 91 private void UpdateOutputPort(IResult result) { 88 foreach (var port in Ports) { 92 IPort port = null; 93 if (Ports.TryGetValue(result.Name, out port)) { 89 94 IOutputPort p = port as IOutputPort; 90 if ( (p != null) && (p.Name == result.Name)) {95 if (p != null) { 91 96 p.Value = result.Value; 97 } 98 } 99 } 100 private void UpdateOutputPort(IOutputPort port) { 101 if ((algorithm != null) && (algorithm.Results != null)) { 102 IResult result = null; 103 if (algorithm.Results.TryGetValue(port.Name, out result)) { 104 port.Value = result != null ? result.Value : null; 105 } else { 106 port.Value = null; 92 107 } 93 108 } … … 106 121 Ports.ItemsReplaced += Ports_ItemsReplaced; 107 122 Ports.CollectionReset += Ports_CollectionReset; 123 foreach (var p in Ports) 124 RegisterPortEvents(p); 108 125 } 109 126 void Ports_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<IPort> e) { … … 131 148 #region Port Events 132 149 private void RegisterPortEvents(IPort port) { 133 IInputPort p = port as IInputPort; 134 if (p != null) { 135 p.ValueChanged += InputPort_ValueChanged; 150 IInputPort i = port as IInputPort; 151 if (i != null) { 152 i.NameChanged += InputPort_NameChanged; 153 i.ValueChanged += InputPort_ValueChanged; 154 UpdateParameter(i); 155 } 156 IOutputPort o = port as IOutputPort; 157 if (o != null) { 158 o.NameChanged += OutputPort_NameChanged; 159 UpdateOutputPort(o); 136 160 } 137 161 } 138 162 private void DeregisterPortEvents(IPort port) { 139 IInputPort p = port as IInputPort; 140 if (p != null) { 141 p.ValueChanged -= InputPort_ValueChanged; 142 } 163 IInputPort i = port as IInputPort; 164 if (i != null) { 165 i.NameChanged -= InputPort_NameChanged; 166 i.ValueChanged -= InputPort_ValueChanged; 167 } 168 IOutputPort o = port as IOutputPort; 169 if (o != null) { 170 o.NameChanged -= OutputPort_NameChanged; 171 } 172 } 173 private void InputPort_NameChanged(object sender, EventArgs e) { 174 UpdateParameter((IInputPort)sender); 143 175 } 144 176 private void InputPort_ValueChanged(object sender, EventArgs e) { 145 177 UpdateParameter((IInputPort)sender); 178 } 179 private void OutputPort_NameChanged(object sender, EventArgs e) { 180 UpdateOutputPort((IOutputPort)sender); 146 181 } 147 182 #endregion … … 150 185 private void RegisterAlgorithmEvents() { 151 186 if (algorithm != null) { 187 algorithm.Prepared += Algorithm_Prepared; 188 RegisterResultsEvents(); 189 } 190 } 191 192 private void DeregisterAlgorithmEvents() { 193 if (algorithm != null) { 194 algorithm.Prepared -= Algorithm_Prepared; 195 DeregisterResultsEvents(); 196 } 197 } 198 private void Algorithm_Prepared(object sender, EventArgs e) { 199 RegisterResultsEvents(); 200 } 201 #endregion 202 203 #region Results Events 204 private void RegisterResultsEvents() { 205 if ((algorithm != null) && (algorithm.Results != null)) { 152 206 algorithm.Results.ItemsAdded += Results_ItemsAdded; 153 207 algorithm.Results.ItemsRemoved += Results_ItemsRemoved; 154 208 algorithm.Results.ItemsReplaced += Results_ItemsReplaced; 155 209 algorithm.Results.CollectionReset += Results_CollectionReset; 156 } 157 } 158 private void DeregisterAlgorithmEvents() { 159 if (algorithm != null) { 210 foreach (var r in algorithm.Results) 211 RegisterResultEvents(r); 212 } 213 } 214 private void DeregisterResultsEvents() { 215 if ((algorithm != null) && (algorithm.Results != null)) { 160 216 algorithm.Results.ItemsAdded -= Results_ItemsAdded; 161 217 algorithm.Results.ItemsRemoved -= Results_ItemsRemoved; 162 218 algorithm.Results.ItemsReplaced -= Results_ItemsReplaced; 163 219 algorithm.Results.CollectionReset -= Results_CollectionReset; 220 foreach (var r in algorithm.Results) 221 DeregisterResultEvents(r); 164 222 } 165 223 } … … 190 248 if (result != null) { 191 249 result.ValueChanged += Result_ValueChanged; 250 result.ToStringChanged += Result_ToStringChanged; 251 UpdateOutputPort(result); 192 252 } 193 253 } … … 195 255 if (result != null) { 196 256 result.ValueChanged -= Result_ValueChanged; 257 result.ToStringChanged += Result_ToStringChanged; 197 258 } 198 259 } … … 200 261 UpdateOutputPort((IResult)sender); 201 262 } 263 private void Result_ToStringChanged(object sender, EventArgs e) { 264 UpdateOutputPort((IResult)sender); 265 } 202 266 #endregion 203 267 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IAlgorithmNode.cs
r11406 r11409 24 24 namespace HeuristicLab.Optimization.Networks { 25 25 public interface IAlgorithmNode : INode { 26 new PortCollection Ports { get; } 27 26 28 IAlgorithm Algorithm { get; set; } 27 29 event EventHandler AlgorithmChanged; -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IPort.cs
r11401 r11409 25 25 namespace HeuristicLab.Optimization.Networks { 26 26 public interface IPort : INamedItem { 27 //DISCUSS: Should there be a reference to the node of this port? 28 27 29 object Value { get; } 28 30 -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputPort.cs
r11406 r11409 24 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 25 using System; 26 using System.Drawing; 26 27 27 28 namespace HeuristicLab.Optimization.Networks { … … 29 30 [StorableClass] 30 31 public class InputPort<T> : Port<T>, IInputPort<T> where T : class, IItem { 32 public static new Image StaticItemImage { 33 get { return HeuristicLab.Common.Resources.VSImageLibrary.ArrowDown; } 34 } 35 31 36 [Storable] 32 37 private IOutputPort<T> outputPort; -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Network.cs
r11401 r11409 29 29 [Creatable("Optimization Networks")] 30 30 [StorableClass] 31 public class Network : Node, INetwork { 31 public class Network : Node, INetwork, IStorableContent { 32 public string Filename { get; set; } 33 32 34 public static new Image StaticItemImage { 33 35 get { return HeuristicLab.Common.Resources.VSImageLibrary.Module; } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/OutputPort.cs
r11401 r11409 24 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 25 using System; 26 using System.Drawing; 26 27 27 28 namespace HeuristicLab.Optimization.Networks { … … 29 30 [StorableClass] 30 31 public class OutputPort<T> : Port<T>, IOutputPort<T> where T : class, IItem { 32 public static new Image StaticItemImage { 33 get { return HeuristicLab.Common.Resources.VSImageLibrary.ArrowUp; } 34 } 35 31 36 new public T Value { 32 37 get { return base.Value; } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Plugin.cs.frame
r11406 r11409 32 32 [PluginDependency("HeuristicLab.Common.Resources", "3.3")] 33 33 [PluginDependency("HeuristicLab.Core", "3.3")] 34 // [PluginDependency("HeuristicLab.Data", "3.3")]35 // [PluginDependency("HeuristicLab.Parameters", "3.3")]36 34 [PluginDependency("HeuristicLab.Optimization", "3.3")] 37 35 [PluginDependency("HeuristicLab.Persistence", "3.3")]
Note: See TracChangeset
for help on using the changeset viewer.