Changeset 11421 for branches/OptimizationNetworks
- Timestamp:
- 10/07/14 08:32:58 (10 years ago)
- Location:
- branches/OptimizationNetworks
- Files:
-
- 4 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/HeuristicLab.Optimization.Networks.Views-3.3.csproj
r11412 r11421 49 49 </ItemGroup> 50 50 <ItemGroup> 51 <Compile Include="PortView.cs"> 52 <SubType>UserControl</SubType> 53 </Compile> 54 <Compile Include="PortView.Designer.cs"> 55 <DependentUpon>PortView.cs</DependentUpon> 56 </Compile> 51 57 <Compile Include="VariablesNodeView.cs"> 52 58 <SubType>UserControl</SubType> … … 67 73 <DependentUpon>InputPortView.cs</DependentUpon> 68 74 </Compile> 69 <Compile Include=" PortView.cs">75 <Compile Include="ValuePortView.cs"> 70 76 <SubType>UserControl</SubType> 71 77 </Compile> 72 <Compile Include=" PortView.Designer.cs">73 <DependentUpon> PortView.cs</DependentUpon>78 <Compile Include="ValuePortView.Designer.cs"> 79 <DependentUpon>ValuePortView.cs</DependentUpon> 74 80 </Compile> 75 81 <Compile Include="NodeView.cs"> -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/InputPortView.cs
r11412 r11421 29 29 [Content(typeof(IInputPort<>), false)] 30 30 [Content(typeof(IInputPort), false)] 31 public partial class InputPortView : PortView {31 public partial class InputPortView : ValuePortView { 32 32 public new IInputPort Content { 33 33 get { return (IInputPort)base.Content; } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/PortView.Designer.cs
r11412 r11421 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.valueGroupBox = new System.Windows.Forms.GroupBox();48 this.valuePanel = new System.Windows.Forms.Panel();49 this.valueViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();50 47 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 51 this.valueGroupBox.SuspendLayout();52 this.valuePanel.SuspendLayout();53 48 this.SuspendLayout(); 54 49 // … … 64 59 this.infoLabel.Location = new System.Drawing.Point(626, 3); 65 60 // 66 // valueGroupBox67 //68 this.valueGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)69 | System.Windows.Forms.AnchorStyles.Left)70 | System.Windows.Forms.AnchorStyles.Right)));71 this.valueGroupBox.Controls.Add(this.valuePanel);72 this.valueGroupBox.Location = new System.Drawing.Point(0, 26);73 this.valueGroupBox.Name = "valueGroupBox";74 this.valueGroupBox.Size = new System.Drawing.Size(645, 491);75 this.valueGroupBox.TabIndex = 3;76 this.valueGroupBox.TabStop = false;77 this.valueGroupBox.Text = "Value";78 //79 // valuePanel80 //81 this.valuePanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)82 | System.Windows.Forms.AnchorStyles.Left)83 | System.Windows.Forms.AnchorStyles.Right)));84 this.valuePanel.Controls.Add(this.valueViewHost);85 this.valuePanel.Location = new System.Drawing.Point(6, 19);86 this.valuePanel.Name = "valuePanel";87 this.valuePanel.Size = new System.Drawing.Size(633, 466);88 this.valuePanel.TabIndex = 0;89 //90 // valueViewHost91 //92 this.valueViewHost.Caption = "View";93 this.valueViewHost.Content = null;94 this.valueViewHost.Dock = System.Windows.Forms.DockStyle.Fill;95 this.valueViewHost.Enabled = false;96 this.valueViewHost.Location = new System.Drawing.Point(0, 0);97 this.valueViewHost.Name = "valueViewHost";98 this.valueViewHost.ReadOnly = false;99 this.valueViewHost.Size = new System.Drawing.Size(633, 466);100 this.valueViewHost.TabIndex = 0;101 this.valueViewHost.ViewsLabelVisible = true;102 this.valueViewHost.ViewType = null;103 //104 61 // PortView 105 62 // 106 63 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 107 this.Controls.Add(this.valueGroupBox);108 64 this.Name = "PortView"; 109 65 this.Size = new System.Drawing.Size(645, 517); … … 111 67 this.Controls.SetChildIndex(this.nameTextBox, 0); 112 68 this.Controls.SetChildIndex(this.infoLabel, 0); 113 this.Controls.SetChildIndex(this.valueGroupBox, 0);114 69 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 115 this.valueGroupBox.ResumeLayout(false);116 this.valuePanel.ResumeLayout(false);117 70 this.ResumeLayout(false); 118 71 this.PerformLayout(); … … 122 75 #endregion 123 76 124 protected System.Windows.Forms.GroupBox valueGroupBox;125 protected System.Windows.Forms.Panel valuePanel;126 protected MainForm.WindowsForms.ViewHost valueViewHost;127 128 129 130 77 131 78 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/PortView.cs
r11412 r11421 28 28 namespace HeuristicLab.Optimization.Networks.Views { 29 29 [View("Port View")] 30 [Content(typeof(Port<>), true)] 31 [Content(typeof(IPort<>), false)] 30 [Content(typeof(Port), true)] 32 31 [Content(typeof(IPort), false)] 33 32 public partial class PortView : NamedItemView { … … 40 39 InitializeComponent(); 41 40 } 42 43 protected override void DeregisterContentEvents() {44 Content.ValueChanged -= Content_ValueChanged;45 base.DeregisterContentEvents();46 }47 48 protected override void RegisterContentEvents() {49 base.RegisterContentEvents();50 Content.ValueChanged += Content_ValueChanged;51 }52 53 protected override void OnContentChanged() {54 base.OnContentChanged();55 if (Content == null) {56 valueViewHost.Content = null;57 } else {58 valueViewHost.ViewType = null;59 valueViewHost.Content = Content.Value as IContent;60 }61 }62 63 protected override void SetEnabledStateOfControls() {64 base.SetEnabledStateOfControls();65 valueGroupBox.Enabled = (Content as IContent) != null;66 }67 protected virtual void Content_ValueChanged(object sender, System.EventArgs e) {68 if (InvokeRequired)69 Invoke(new EventHandler(Content_ValueChanged), sender, e);70 else {71 valueViewHost.ViewType = null;72 valueViewHost.Content = Content.Value as IContent;73 74 }75 }76 41 } 77 42 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/HeuristicLab.Optimization.Networks-3.3.csproj
r11412 r11421 48 48 </ItemGroup> 49 49 <ItemGroup> 50 <Compile Include="IPort.cs" /> 50 51 <Compile Include="IVariablesNode.cs" /> 52 <Compile Include="Port.cs" /> 51 53 <Compile Include="VariablesNode.cs" /> 52 54 <Compile Include="EventArgs.cs" /> … … 61 63 <Compile Include="INetwork.cs" /> 62 64 <Compile Include="IInputPort.cs" /> 63 <Compile Include="I Port.cs" />65 <Compile Include="IValuePort.cs" /> 64 66 <Compile Include="INode.cs" /> 65 67 <Compile Include="Network.cs" /> … … 67 69 <Compile Include="NodeCollection.cs" /> 68 70 <Compile Include="PortCollection.cs" /> 69 <Compile Include=" Port.cs" />71 <Compile Include="ValuePort.cs" /> 70 72 <Compile Include="Plugin.cs" /> 71 73 <Compile Include="Properties\AssemblyInfo.cs" /> -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IInputOutputPort.cs
r11412 r11421 24 24 25 25 namespace HeuristicLab.Optimization.Networks { 26 public interface IInputOutputPort : I Port {26 public interface IInputOutputPort : IValuePort { 27 27 IOutputInputPort OutputInputPort { get; } 28 28 … … 30 30 } 31 31 32 public interface IInputOutputPort<TIn, TOut> : IInputOutputPort, I Port<TIn>32 public interface IInputOutputPort<TIn, TOut> : IInputOutputPort, IValuePort<TIn> 33 33 where TIn : class, IItem 34 34 where TOut : class, IItem { -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IInputPort.cs
r11412 r11421 24 24 25 25 namespace HeuristicLab.Optimization.Networks { 26 public interface IInputPort : I Port {26 public interface IInputPort : IValuePort { 27 27 IOutputPort OutputPort { get; set; } 28 28 … … 30 30 } 31 31 32 public interface IInputPort<T> : IInputPort, I Port<T> where T : class, IItem {32 public interface IInputPort<T> : IInputPort, IValuePort<T> where T : class, IItem { 33 33 new IOutputPort<T> OutputPort { get; set; } 34 34 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IOutputInputPort.cs
r11406 r11421 24 24 25 25 namespace HeuristicLab.Optimization.Networks { 26 public interface IOutputInputPort : I Port {26 public interface IOutputInputPort : IValuePort { 27 27 object SendValue(object value); 28 28 } 29 29 30 public interface IOutputInputPort<TOut, TIn> : IOutputInputPort, I Port<TOut>30 public interface IOutputInputPort<TOut, TIn> : IOutputInputPort, IValuePort<TOut> 31 31 where TOut : class, IItem 32 32 where TIn : class, IItem { -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IOutputPort.cs
r11401 r11421 23 23 24 24 namespace HeuristicLab.Optimization.Networks { 25 public interface IOutputPort : I Port {25 public interface IOutputPort : IValuePort { 26 26 new object Value { get; set; } 27 27 } 28 28 29 public interface IOutputPort<T> : IOutputPort, I Port<T> where T : class, IItem {29 public interface IOutputPort<T> : IOutputPort, IValuePort<T> where T : class, IItem { 30 30 new T Value { get; set; } 31 31 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IPort.cs
r11409 r11421 21 21 22 22 using HeuristicLab.Core; 23 using System;24 23 25 24 namespace HeuristicLab.Optimization.Networks { 26 25 public interface IPort : INamedItem { 27 //DISCUSS: Should there be a reference to the node of this port? 28 29 object Value { get; } 30 31 event EventHandler ValueChanged; 32 } 33 34 public interface IPort<T> : IPort where T : class, IItem { 35 new T Value { get; } 26 INode Node { get; set; } 36 27 } 37 28 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputOutputPort.cs
r11412 r11421 28 28 [Item("InputOutputPort", "A synchronous input/output port of an optimization network node.")] 29 29 [StorableClass] 30 public class InputOutputPort<TIn, TOut> : Port<TIn>, IInputOutputPort<TIn, TOut>30 public class InputOutputPort<TIn, TOut> : ValuePort<TIn>, IInputOutputPort<TIn, TOut> 31 31 where TIn : class, IItem 32 32 where TOut : class, IItem { -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputPort.cs
r11412 r11421 29 29 [Item("InputPort", "An asynchronous input port of an optimization network node.")] 30 30 [StorableClass] 31 public class InputPort<T> : Port<T>, IInputPort<T> where T : class, IItem {31 public class InputPort<T> : ValuePort<T>, IInputPort<T> where T : class, IItem { 32 32 public static new Image StaticItemImage { 33 33 get { return HeuristicLab.Common.Resources.VSImageLibrary.ArrowDown; } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Node.cs
r11401 r11421 56 56 public Node() 57 57 : base("Node") { 58 ports = new PortCollection( );58 ports = new PortCollection(this); 59 59 readOnlyPorts = null; 60 60 } 61 61 public Node(string name) 62 62 : base(name) { 63 ports = new PortCollection( );63 ports = new PortCollection(this); 64 64 readOnlyPorts = null; 65 65 } 66 66 public Node(string name, string description) 67 67 : base(name, description) { 68 ports = new PortCollection( );68 ports = new PortCollection(this); 69 69 readOnlyPorts = null; 70 70 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/OutputInputPort.cs
r11406 r11421 28 28 [Item("OutputInputPort", "A synchronous output/input port of an optimization network node.")] 29 29 [StorableClass] 30 public class OutputInputPort<TOut, TIn> : Port<TOut>, IOutputInputPort<TOut, TIn>30 public class OutputInputPort<TOut, TIn> : ValuePort<TOut>, IOutputInputPort<TOut, TIn> 31 31 where TOut : class, IItem 32 32 where TIn : class, IItem { -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/OutputPort.cs
r11409 r11421 29 29 [Item("OutputPort", "An asynchronous output port of an optimization network node.")] 30 30 [StorableClass] 31 public class OutputPort<T> : Port<T>, IOutputPort<T> where T : class, IItem {31 public class OutputPort<T> : ValuePort<T>, IOutputPort<T> where T : class, IItem { 32 32 public static new Image StaticItemImage { 33 33 get { return HeuristicLab.Common.Resources.VSImageLibrary.ArrowUp; } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Port.cs
r11406 r11421 29 29 [Item("Port", "Abstract base class for ports of an optimization network node.")] 30 30 [StorableClass] 31 public abstract class Port <T> : NamedItem, IPort<T> where T : class, IItem{31 public abstract class Port : NamedItem, IPort { 32 32 public static new Image StaticItemImage { 33 33 get { return HeuristicLab.Common.Resources.VSImageLibrary.Field; } … … 35 35 36 36 [Storable] 37 protected T value; 38 public virtual T Value { 39 get { return value; } 40 protected set { 41 DeregisterValueEvents(); 42 this.value = value; 43 RegisterValueEvents(); 44 OnValueChanged(); 37 private INode node; 38 public INode Node { 39 get { return node; } 40 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; 45 46 } 46 }47 object IPort.Value {48 get { return Value; }49 47 } 50 48 51 49 [StorableConstructor] 52 50 protected Port(bool deserializing) : base(deserializing) { } 53 protected Port(Port <T>original, Cloner cloner)51 protected Port(Port original, Cloner cloner) 54 52 : base(original, cloner) { 55 value = cloner.Clone(original.value); 56 RegisterValueEvents(); 53 node = (INode)cloner.GetClone(original.node); // NOTE: original node is NOT automatically cloned 57 54 } 58 55 protected Port() : base("Port") { } 59 56 protected Port(string name) : base(name) { } 60 57 protected Port(string name, string description) : base(name, description) { } 61 62 [StorableHook(HookType.AfterDeserialization)]63 private void AfterDeserialization() {64 RegisterValueEvents();65 }66 67 public override string ToString() {68 return Name + ": " + (Value != null ? Value.ToString() : "null");69 }70 71 public event EventHandler ValueChanged;72 protected virtual void OnValueChanged() {73 var handler = ValueChanged;74 if (handler != null) handler(this, EventArgs.Empty);75 OnToStringChanged();76 }77 78 protected virtual void RegisterValueEvents() {79 if (value != null) {80 value.ToStringChanged += new EventHandler(Value_ToStringChanged);81 }82 }83 protected virtual void DeregisterValueEvents() {84 if (value != null) {85 value.ToStringChanged -= new EventHandler(Value_ToStringChanged);86 }87 }88 private void Value_ToStringChanged(object sender, EventArgs e) {89 OnToStringChanged();90 }91 58 } 92 59 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/PortCollection.cs
r11401 r11421 20 20 #endregion 21 21 22 using System.Collections.Generic;23 22 using HeuristicLab.Common; 24 23 using HeuristicLab.Core; 25 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 using System; 26 using System.Collections.Generic; 26 27 27 28 namespace HeuristicLab.Optimization.Networks { 28 29 [StorableClass] 29 [Item("PortCollection", "Represents a collection of ports .")]30 [Item("PortCollection", "Represents a collection of ports in an optimization network node.")] 30 31 public class PortCollection : NamedItemCollection<IPort> { 32 [Storable] 33 private INode node; 34 public INode Node { 35 get { return node; } 36 } 37 31 38 [StorableConstructor] 32 39 protected PortCollection(bool deserializing) : base(deserializing) { } 33 protected PortCollection(PortCollection original, Cloner cloner) : base(original, cloner) { } 34 public PortCollection() : base() { } 35 public PortCollection(int capacity) : base(capacity) { } 36 public PortCollection(IEnumerable<IPort> collection) : base(collection) { } 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 } 37 59 38 60 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 } 39 86 } 40 87 }
Note: See TracChangeset
for help on using the changeset viewer.