Changeset 11431
- Timestamp:
- 10/09/14 03:10:16 (10 years ago)
- Location:
- branches/OptimizationNetworks
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/InputPortView.cs
r11423 r11431 39 39 } 40 40 41 private void UpdateOutputPortTextBoxText() { 42 if ((Content == null) || (Content.OutputPort == null)) { 43 outputPortTextBox.Text = string.Empty; 44 } else { 45 outputPortTextBox.Text = Content.OutputPort.Path + "." + Content.OutputPort.ToString(); 46 } 47 } 48 41 49 protected override void DeregisterContentEvents() { 42 50 Content.OutputPortChanged -= Content_OutputPortChanged; 43 51 base.DeregisterContentEvents(); 44 52 } 45 46 53 protected override void RegisterContentEvents() { 47 54 base.RegisterContentEvents(); … … 51 58 protected override void OnContentChanged() { 52 59 base.OnContentChanged(); 53 outputPortTextBox.Text = ((Content == null) || (Content.OutputPort == null)) ? string.Empty : Content.OutputPort.ToString();60 UpdateOutputPortTextBoxText(); 54 61 } 55 62 … … 58 65 outputPortTextBox.Enabled = Content != null && !ReadOnly; 59 66 } 67 60 68 protected virtual void Content_OutputPortChanged(object sender, EventArgs e) { 61 69 if (InvokeRequired) 62 70 Invoke(new EventHandler(Content_OutputPortChanged), sender, e); 63 71 else { 64 outputPortTextBox.Text = Content.OutputPort == null ? string.Empty : Content.OutputPort.ToString();72 UpdateOutputPortTextBoxText(); 65 73 } 66 74 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/NodeCollectionView.cs
r11409 r11431 47 47 if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { 48 48 try { 49 return (INode)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 49 var n = (INode)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 50 n.Name = GetUniqueName(n.Name); 51 return n; 50 52 } 51 53 catch (Exception ex) { -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks.Views/3.3/PortCollectionView.cs
r11409 r11431 47 47 if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { 48 48 try { 49 return (IPort)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 49 var p = (IPort)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 50 p.Name = GetUniqueName(p.Name); 51 return p; 50 52 } 51 53 catch (Exception ex) { -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/IPort.cs
r11423 r11431 21 21 22 22 using HeuristicLab.Core; 23 using System; 23 24 24 25 namespace HeuristicLab.Optimization.Networks { 25 26 public interface IPort : INamedItem { 26 27 INode Parent { get; set; } 28 string Path { get; } 29 30 event EventHandler PathChanged; 27 31 } 28 32 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputOutputPort.cs
r11421 r11431 92 92 } 93 93 protected void OutputInputPort_ValueSent(object sender, OutputInputPortEventArgs<TIn, TOut> e) { 94 var value = (TIn)e.Value.Clone(); 94 var value = e.Value; 95 if (value != null) 96 value = (TIn)value.Clone(); 95 97 Value = value; 96 98 e.Result = OnValueReceived(value); -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/InputPort.cs
r11423 r11431 88 88 if (outputPort != null) { 89 89 outputPort.ValueChanged += OutputPort_ValueChanged; 90 outputPort. ToStringChanged += OutputPort_ToStringChanged;90 outputPort.PathChanged += OutputPort_PathChanged; 91 91 } 92 92 } … … 94 94 if (outputPort != null) { 95 95 outputPort.ValueChanged -= OutputPort_ValueChanged; 96 outputPort. ToStringChanged -= OutputPort_ToStringChanged;96 outputPort.PathChanged -= OutputPort_PathChanged; 97 97 } 98 98 } 99 99 protected void OutputPort_ValueChanged(object sender, EventArgs e) { 100 Value = (T)OutputPort.Value.Clone(); 100 var value = OutputPort.Value; 101 if (value != null) 102 value = (T)value.Clone(); 103 Value = value; 101 104 //DISCUSS: clone value? 102 105 //DISCUSS: switch threads to decouple value propagation and to make communication asynchronous -> should be done in Node? 103 106 } 104 protected void OutputPort_ ToStringChanged(object sender, EventArgs e) {107 protected void OutputPort_PathChanged(object sender, EventArgs e) { 105 108 OnOutputPortChanged(); 106 109 } -
branches/OptimizationNetworks/HeuristicLab.Optimization.Networks/3.3/Port.cs
r11423 r11431 38 38 get { return parent; } 39 39 set { 40 // NOTE: never call setter directly as the Parent property is set by the node which contains the port 40 41 if (value != parent) { 41 // NOTE: never call setter directly as the Parent property is set by the node which contains the port42 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 42 DeregisterParentEvents(); 47 43 parent = value; 48 44 RegisterParentEvents(); 49 On ToStringChanged();45 OnPathChanged(); 50 46 } 47 } 48 } 49 public string Path { 50 get { 51 return parent != null ? parent.Name : string.Empty; 51 52 } 52 53 } … … 59 60 protected Port(string name, string description) : base(name, description) { } 60 61 61 public override string ToString() { 62 if (parent != null) { 63 return string.Concat(parent.ToString(), " -> ", base.ToString()); 64 } 65 return base.ToString(); 62 public event EventHandler PathChanged; 63 protected virtual void OnPathChanged() { 64 var handler = PathChanged; 65 if (handler != null) handler(this, EventArgs.Empty); 66 66 } 67 67 … … 69 69 protected virtual void RegisterParentEvents() { 70 70 if (parent != null) { 71 parent. ToStringChanged += Parent_ToStringChanged;71 parent.NameChanged += Parent_NameChanged; 72 72 } 73 73 } 74 74 protected virtual void DeregisterParentEvents() { 75 75 if (parent != null) { 76 parent. ToStringChanged -= Parent_ToStringChanged;76 parent.NameChanged -= Parent_NameChanged; 77 77 } 78 78 } 79 void Parent_ ToStringChanged(object sender, EventArgs e) {80 On ToStringChanged();79 void Parent_NameChanged(object sender, EventArgs e) { 80 OnPathChanged(); 81 81 } 82 82 #endregion
Note: See TracChangeset
for help on using the changeset viewer.